Stage 5 track
Track C: Deep Learning & Fine-tuning
Goal: Adapt pretrained models to your data — and know when prompting or a baseline beats fine-tuning. Builds on: Stage 3 (PyTorch, transfer concepts).
What you learn
- Transfer learning — feature extraction (frozen body, new head) vs full fine-tuning; always against a from-scratch baseline, because transfer is not automatic (see the measured example below).
- The Hugging Face ecosystem —
transformers,datasetsand the model hub: thousands of pretrained models behind one API. - Fine-tuning a text classifier — a small pretrained transformer on your labels; the Part 10/11 training loop with a pretrained start.
- Parameter-efficient fine-tuning — LoRA and adapters: train a sliver of parameters, keep the base frozen (the measured 1.56% below).
- Fine-tune vs prompt — fine-tuning costs data, compute and maintenance per task; prompting costs tokens per call. Volume, latency and task-specificity decide.
- Evaluating fine-tuned models — held-out sets, error analysis by slice, and the same baseline discipline as Stage 2.
Executed examples
Both ran in this repo; outputs are from those runs.
Transfer learning is not automatic (examples-track-c/01) — pretrain on digits 0–4, adapt to 5–9 with only 50 labels:
from scratch : 0.936
fine-tune all layers : 0.852
frozen body, new head : 0.638
Here the source features don't suit the target, and scratch wins. Transfer pays off when the source task is large and related — ImageNet to your photos — which is why the baseline row is non-negotiable.
The idea behind LoRA (examples-track-c/02) — a rank-8 update on one 1024×1024 matrix:
full fine-tune parameters: 1048576
LoRA parameters (r=8): 16384
fraction trained: 0.0156
output unchanged at start: True
Train 1.6% of the weights; B starting at zero means the model is exactly the base model until training moves it.
Capstone: Ticket Classifier Shoot-out
- Core — a TF-IDF baseline and a prompted Claude classifier on the same labelled tickets.
- Stretch — fine-tune a small pretrained transformer and add it to the comparison.
- Production — report accuracy, cost per 1,000 tickets and latency for all three, and recommend one with reasons.
Read more: PyTorch tutorials