Skip to content

Share your work on the Hub

This lesson closes Phase 1 by turning your work outward: you publish a model on the Hugging Face Hub so anyone (including future you) can load it with the same from_pretrained call you have used on other people’s models all track. The source curriculum is the Hugging Face LLM Course, Chapter 4, freely available and Apache-2.0 licensed at huggingface.co/learn/llm-course/chapter4.

You will authenticate with notebook_login(); push a model and tokenizer with the push_to_hub API (during training via TrainingArguments, or directly on the objects); compare that to the two lower-level routes (the huggingface_hub library and the git/git-lfs workflow); see what a usable model repo contains and why weights are tracked by git-lfs; and write a model card, the README.md that documents intended use, training data, and limitations and is the real deliverable.

This is lesson 4 of 12, the close of Phase 1 (the Transformers library). It completes the run-adapt-share arc: lesson 2 ran models, lesson 3 adapted one, and this lesson shares it. It connects directly back to lesson 3 (you publish what you fine-tuned) and forward to Phase 2, which turns to the data and tokenizers that everything so far has quietly depended on.

Prerequisites: lesson 3 of this track (fine-tuning with the Trainer), since the most natural thing to share is the model you trained there, and push_to_hub=True in TrainingArguments is the bridge. You will need a free Hugging Face account (create one at huggingface.co/join) to actually upload. Install with pip install transformers huggingface_hub.

None, and almost no new modeling. This is a workflow lesson: authentication, uploading, and documentation. The code is short calls (notebook_login(), push_to_hub(...)) rather than computation, and the one conceptual idea (git-lfs for large files) is explained, not derived.

The single capability this lesson builds: push a fine-tuned model and its tokenizer to the Hub with a model card, and explain why sharing matters. Concretely, you will be able to:

  • Authenticate to the Hub with notebook_login() (or hf auth login)
  • Push a model and tokenizer with the push_to_hub API (and via TrainingArguments)
  • Compare the three upload routes (push_to_hub, the huggingface_hub library, git/git-lfs)
  • Identify what a usable model repo contains and why git-lfs is used for weights
  • Write a model card that documents intended use, training data, and limitations
  • Read time: about 10 minutes
  • Practice time: about 10 minutes (push a real model and tokenizer, write a minimal model card, plus flashcards)
  • Difficulty: standard (a workflow lesson; short calls, but you do need a free Hub account)