Fine-tuning with LoRA/PEFT
When to fine-tune vs prompt vs RAG, LoRA on a 7-8B open model, dataset curation, catastrophic forgetting. The "should you fine-tune?" question is a favorite senior screen.
The mental model
Prompting is handing the model instructions every single time; fine-tuning is training a habit into it once. The analogy: a prompt is a laminated checklist you tape to a contractor's toolbox before every job — it works, but you pay to re-read it on every request and it can only steer behavior so far. Fine-tuning is an apprenticeship: after a few hundred worked examples, the behavior becomes reflex — no checklist needed, faster, cheaper per job, but changing the habit later requires another apprenticeship.
LoRA (Low-Rank Adaptation) is the trick that makes this affordable. Instead of updating all 7–8 billion weights of the base model (which needs the memory to hold weights, gradients, and optimizer states — roughly 16x the parameter bytes with Adam in mixed precision), LoRA freezes the base model entirely and learns tiny low-rank correction matrices alongside selected weight matrices (the current default is all attention and MLP projections). You train well under 1% of the parameters, on one GPU, and the output is a small adapter file (tens of MB) rather than a new 15GB model.
Why this exists: without parameter-efficient fine-tuning, adapting an open model meant multi-GPU clusters and full-model checkpoints per task — economically absurd for the common case of "make this 8B model reliably produce our report format." What breaks without the discipline around it: teams fine-tune when a prompt would do, on scraped low-quality data, and produce a model that aces the training format while forgetting how to follow general instructions — catastrophic forgetting, discovered in production.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision