Hands-On Practice
From the course Hugging Face & Transformers
Put what you have learned in this course into practice with the structured exercise below. Working through it end-to-end is the single best way to consolidate the concepts.
Exercise: Hugging Face Transformers in the Real World
Pick one realistic scenario from your own work, study, or curiosity and apply the techniques covered in earlier lessons. Aim for a small, completable artifact — a notebook, a working script, a written design, or a side-by-side comparison.
Suggested Workflow
- Frame the goal: write a one-sentence problem statement that the techniques in this course can address.
- Pick the right tool: revisit the lessons above and choose the specific method, model, or pattern that best fits.
- Build an MVP: produce the simplest version that proves the approach works. Keep it small.
- Evaluate: how did it perform? What surprised you? What broke?
- Iterate: refine one decision (prompt, parameter, tool) and re-evaluate.
Self-Check Questions
- Could you explain the chosen approach to a teammate in under two minutes?
- Where might this break in production? What guardrails would you add?
- What is the next thing you would try if you had another day?
Stretch Goal
Document your run as a short write-up. Compare against alternative approaches and note the trade-offs.
This practice loop converts passive reading into durable skill — the exact transfer-of-learning step most learners skip.
Concrete Starter Project: Fine-Tune a Sentiment Classifier for Product Reviews
Goal: Fine-tune DistilBERT on an e-commerce review dataset to classify sentiment as positive, neutral, or negative.
Steps:
- Load the Amazon product reviews dataset from Hugging Face Datasets:
load_dataset("McAuley-Lab/Amazon-Reviews-2023", "raw_review_All_Beauty"). - Map star ratings to sentiment labels (1–2 stars = negative, 3 = neutral, 4–5 = positive).
- Tokenize with
AutoTokenizer.from_pretrained("distilbert-base-uncased"), max_length 256. - Fine-tune with
AutoModelForSequenceClassificationusing the Trainer API for 3 epochs. - Evaluate on the test split and report per-class F1 scores.
Extend it:
- Apply LoRA via the PEFT library and compare training time and accuracy against full fine-tuning.
- Export the model to ONNX and compare inference latency.
- Push the final model to the Hugging Face Hub with a model card describing the task and dataset.
What you will learn: The complete Hugging Face fine-tuning lifecycle — from dataset loading and tokenization through training, evaluation, and Hub deployment.
Key Takeaways
- •Hands-on application converts course concepts into real skill
- •Start small with an MVP before optimising
- •Self-check questions catch gaps in understanding before they ship to production
Progress is kept in this browser only.