Introduction to Hugging Face
What is Hugging Face?
Hugging Face is both a community and an open-source stack. Two pieces matter most:
- Hub: a collaboration platform for models, datasets, and Spaces (hosted demos), with 1M+ public checkpoints.
- Transformers: the model-definition framework for text, vision, audio, video, and multimodal models—inference and training. One definition can plug into PyTorch loops, Accelerate, and engines such as vLLM / TGI.
This course centers on Transformers + Hub, and introduces datasets, evaluate, accelerate, and peft.
Ecosystem
Three core classes
Officially a checkpoint is three objects, assembled with AutoClass + from_pretrained:
device_map="auto" shards layers across GPU/CPU; dtype="auto" picks the checkpoint’s float type. You do not need to write attention from scratch.
Three official paths
vs training from scratch and vs Ollama
This site’s PyTorch course teaches tensors, nn.Module, and handwritten loops—building networks from scratch. Transformers is load a pretrained checkpoint, then infer or fine-tune. They complement each other: if loss.backward() is unclear, go back to PyTorch; if you need BERT or Qwen from the Hub, stay here.
Pick: chat only → Ollama; fine-tune, eval, publish, vision/audio → Transformers.
Coding agents (Cursor, Claude Code, …) can use Hugging Face Skills to run hf or TRL jobs. That is optional, not the main path of this tutorial.
Good fit / caveats
Good fit: text classification / NER, generation and chat, ASR, image classification, reproducing Hub paper checkpoints, LoRA on domain data.
Watch out: full-finetuning a 7B on a laptop GPU; shipping weights without reading the card; gated Llama-style repos you never accepted; committing tokens.
Readers who need strong Chinese support can prefer Qwen and DeepSeek (often ungated). Generation examples use distilgpt2 and Qwen/Qwen2.5-0.5B-Instruct.