Explain transfer learning — when to freeze vs fine-tune, and common failure modes
Written by the mlprep team · Updated
Explain transfer learning. When do you freeze pretrained layers vs fine-tune them? What are common failure modes?
Why transfer learning works#
Pretrained models encode general representations: edges and textures in early CNN layers, semantic structures in later layers. LLMs encode language syntax, factual knowledge, and reasoning patterns in attention layers and MLPs.
These representations transfer because many tasks share low-level structure. A ResNet pretrained on ImageNet has learned filters useful for radiology, satellite imagery, and manufacturing defect detection — even though none of those were in training data.
Feature extraction (full freeze)#
Freeze all pretrained weights. Add a new head (linear layer, small MLP) and train only the head.
When to use:
- Very small target dataset (fewer than a few hundred samples) — fine-tuning risks overfitting
- Task distribution is similar to pretraining distribution
- Pretrained representations are known to be strong (CLIP, ViT-large)
- Fast iteration needed — training a linear probe is cheap
Fine-tuning (partial or full unfreeze)#
Unfreeze some or all pretrained layers and train end-to-end on the target task.
Layer selection heuristic for CNNs: early layers (edges, textures) are universal — freeze. Late layers (semantic concepts) are more task-specific — fine-tune. Common: freeze first N blocks, fine-tune last M blocks + head.
For LLMs: most practical fine-tuning updates all layers with a very small LR (1e-5 to 5e-5) using AdamW.
When to use full fine-tuning:
- Target domain significantly different from pretraining
- Large enough target dataset (thousands+ examples)
- Task requires adapting high-level representations, not just adding a head
Learning rate strategy for fine-tuning#
Use a much smaller LR than pretraining (10×–100× smaller). Pretrained weights are already near a good solution — large updates destroy useful representations.
Discriminative fine-tuning / gradual unfreezing (ULMFiT): assign different LRs to different layers. Lower LR for early (general) layers, higher LR for late (task-specific) layers. Unfreeze layers from top to bottom progressively. This was a key insight before the transformer era.
For transformers: linear warmup + linear decay with LR ≈ 2e-5 is the standard BERT fine-tuning recipe.
Catastrophic forgetting#
Fine-tuning on a new task degrades performance on old tasks — the model "forgets" original pretraining knowledge. Mitigation:
- Very small LR (minimal weight change)
- Elastic weight consolidation (EWC): penalize changes to weights that were important for original task
- LoRA / parameter-efficient fine-tuning: don't touch original weights
Parameter-efficient fine-tuning (PEFT)#
For large LLMs, full fine-tuning is expensive. PEFT methods update a tiny fraction of parameters:
LoRA (Low-Rank Adaptation): instead of updating W, add a low-rank decomposition ΔW = BA where B∈ℝ^(d×r) and A∈ℝ^(r×k) with r much smaller than min(d,k). Train only A and B, freeze W. At inference: W' = W + BA. Typically r=4-64. Updates under 1% of total params. Quality approaches full fine-tuning for most tasks.
Prompt tuning / prefix tuning: prepend learnable "soft tokens" to the input or key-value pairs. Train only these tokens.
Failure modes#
- Overfitting: fine-tuning too many parameters on too little data. Fix: freeze more, add dropout, use LoRA.
- Catastrophic forgetting: wiping out pretrained representations. Fix: smaller LR, EWC, LoRA.
- Distribution mismatch: target domain is so different that pretraining helps little. Fix: intermediate fine-tuning on a domain-adjacent task first.
- Task mismatch: pretraining objective incompatible with target task. Fix: choose better pretrained model (CLIP for vision+text, code model for coding tasks).
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
Feature extraction (freeze all) when data is small or domains match. Fine-tune when data is sufficient and domains differ. Use 10-100× smaller LR for fine-tuning than pretraining; add warmup. Catastrophic forgetting is real — small LR and LoRA help. LoRA (low-rank adaptation) is the practical standard for LLM fine-tuning: under 1% parameter updates, near full fine-tune quality. Discriminative LRs (lower for early layers) improve fine-tuning in practice.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- How does LoRA's rank r affect the trade-off between expressiveness and compute/memory?
- What is the difference between task-specific fine-tuning and instruction tuning for LLMs?
- You fine-tuned a BERT model and it performs well in offline evaluation but degrades after deployment. What could cause this?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions
Walk me through how modern object detection works
Walk me through two-tower models for retrieval — architecture, tradeoffs, and limits
How does multi-task learning work for ranking — and what are the failure modes?
How do you serve hundreds of fine-tuned LoRA adapters on one base model efficiently?