Summary: Share your work on the Hub
Sharing closes Phase 1 by turning your work outward: you push a model to the Hugging Face Hub so anyone can load it with the same from_pretrained call you have used on other people’s models all track. You authenticate once (notebook_login()), then upload by the easiest of three routes: the push_to_hub API (set push_to_hub=True in TrainingArguments, or call model.push_to_hub(...) and tokenizer.push_to_hub(...) directly), the huggingface_hub library (create_repo, upload_file), or git plus git-lfs underneath. A usable repo holds the config, the weights (a large file tracked by git-lfs), and the tokenizer files, exactly what from_pretrained expects. The most important file you write is the model card (README.md), which tells others what the model does and where it fails. This is the scan version; the lesson pushes a real model.
Core ideas
Section titled “Core ideas”- Sharing is
from_pretrainedin reverse. You upload under a name; anyone loads it with one line. Almost every model you used got there this way. - Authenticate once.
notebook_login()(orhf auth login) caches a token so later uploads know who you are. - Prefer the
push_to_hubAPI.push_to_hub=TrueinTrainingArgumentsuploads during training;trainer.push_to_hub()finalizes and generates a starter model card; the method also lives on model and tokenizer objects directly. - Always push the tokenizer with the model. A model without its matching tokenizer cannot be run, because the next person needs your exact text-to-numbers conversion.
- Under the hood it is git plus git-lfs. Large weight files are tracked by git-lfs; small config and tokenizer files use plain git. The
huggingface_hublibrary andpush_to_hubare conveniences over that. - The model card is the real deliverable. The
README.mddocumenting intended use, training data, and limitations is what turns a pile of weights into something others adopt and trust.
What changes for you
Section titled “What changes for you”This lesson moves you from consumer to contributor, and the shift is more than symbolic. A model on the Hub is versioned, loadable from anywhere, and trivially shareable with a teammate or a deployment system: one string instead of a folder of files passed around by hand. The discipline that carries forward is the model card. The honesty you learned to demand of models in lesson 1 (biases in, biases out; know the limits) is exactly what you now owe the next person when you publish. Naming the training data and the failure modes is what makes your work trustworthy, and trust is the currency the whole Hub runs on. With this, Phase 1 is complete: you can run a model, adapt it to your data, and share the result. Phase 2 turns to the data and tokenizers that feed all of it.
A model you keep is a result; a model you share, with an honest card, is a tool other people can build on. That is the whole point of the Hub.