Let the model be a composition:
y^=hϕ(fθ(x))
where fθ is the pretrained backbone (params θ) and hϕ is the head (params ϕ). Loss L(y^,y).
Gradient update for any parameter set w:
w←w−η∂w∂L
Why this step? Gradient descent only moves parameters that receive a nonzero, applied gradient.
Feature extraction sets θ as constants (requires_grad=False):
∂ϕ∂Lused;∂θ∂Ldiscarded (or never computed)
So only ϕ updates. The features fθ(x) are fixed vectors — you can even precompute them once and cache them.
Full fine-tuning applies both:
θ←θ−η∂θ∂L,ϕ←ϕ−η∂ϕ∂L
By the chain rule the backbone gradient is
∂θ∂L=∂y^∂L∂fθ∂hϕ∂θ∂fθWhy this step? This chain must be evaluated in full fine-tuning, which is why it needs a full backward pass through the (huge) backbone — the source of its cost.
What is frozen in feature extraction? ⟶ the entire backbone; only the head trains.
Why can you cache embeddings in feature extraction but not in full FT? ⟶ frozen backbone gives constant fθ(x); full FT keeps changing θ.
Why use a small LR in full FT? ⟶ avoid catastrophic forgetting of pretrained features.
Which strategy suits tiny datasets and why? ⟶ feature extraction; few trainable params → less overfitting.
Recall Feynman: explain to a 12-year-old
Imagine you hired a chef who already knows how to cook thousands of dishes (the pretrained model). You want them to make your family's special dish.
Feature extraction: you don't retrain the chef at all. You just tell them, "use everything you already know, and I'll add one final instruction at the end." Cheap, safe, but limited.
Full fine-tuning: you let the chef relearn their whole style for your recipe — powerful, but if you only give them 2 practice tries, they might forget their old skills and mess it up. So you teach them slowly (small learning rate) and only when you have lots of practice dishes (data).
Dekho, ek pretrained model already bahut kuch seekh chuka hota hai — uske andar achhe features (representations) bane hote hain. Ab jab tumhe apne chhote task pe kaam karna ho, tumhare paas do main options hain. Pehla: feature extraction — matlab backbone ko freeze kar do (uske weights fix), aur sirf ek chhota naya head train karo. Yahan model ke internal features change nahi hote, tum unko as-is use karte ho. Isliye ye sasta hai, fast hai, aur chhote data pe overfit nahi hota.
Doosra option: full fine-tuning — poore model ke saare weights ko train hone do, lekin chhoti learning rate ke saath. Isse model apne features ko tumhare domain ke hisaab se adjust kar leta hai. Ye powerful hai, par mehnga hai (Adam ke moment states, gradients sab store karne padte hain) aur agar LR bada rakh diya to model apni purani knowledge bhool sakta hai — isko catastrophic forgetting kehte hain.
Toh choose kaise karein? Simple bias-variance soch: agar data kam hai ya task pretraining domain ke close hai → feature extraction, kyunki kam trainable params matlab kam overfitting. Agar data zyada hai aur domain kaafi alag (jaise legal ya medical text) → full fine-tuning, kyunki frozen features tumhare domain ke liye galat honge, unhe adapt karna zaroori hai. Beech ka rasta bhi hai: sirf upar ke kuch layers unfreeze karo (deeper layers zyada task-specific hote hain), ya LoRA/PEFT use karo.
Yaad rakhne ka trick: "Freeze the Features, Fine-tune the Full." Feature extraction = frozen backbone, Full FT = sab free. Aur haan, feature extraction karte time frozen backbone ko eval() mode me rakhna, warna BatchNorm/dropout ke stats hil jayenge.