SDE & MLE Prep

Fine-Tuning: SFT, LoRA & PEFT

Q: How does LoRA work and when would you fine-tune vs prompt?

  • LoRA: freeze W, learn a low-rank update ΔW = B·A (A: r×d, B: d×r, r ≈ 8–64) on attention/MLP matrices. Trains ~0.1–1% of params; adapters are tiny and swappable; can merge into W for zero inference overhead. QLoRA = LoRA on a 4-bit quantized base.
  • Choose: prompting / few-shot first (cheap, flexible) → RAG if the model lacks knowledge → fine-tuning for format/style/behaviour consistency, domain language, latency/cost reduction (smaller tuned model), or tasks prompting can't reach.
  • Data quality beats quantity: a few thousand clean examples often suffice for SFT.