Fine-Tuning & LoRA
AI Engineer path · lesson 98 of 124Adapt foundation models to your task without retraining billions of parameters — explore the LoRA rank decomposition, compare full fine-tuning vs. PEFT strategies, and know exactly when to fine-tune vs. prompt or RAG.
Key insight
Fine-tuning adapts a pretrained model to your task. The challenge: updating all parameters of a 70B model costs millions of dollars and weeks of GPU time. Parameter-efficient methods like LoRA solve this by updating only a tiny fraction of weights.
The LoRA decomposition
Complete the update applied to a frozen weight matrix.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
+
Test your knowledge
LoRA stands for…
The short version
Full fine-tuning is repainting a house — every surface, massive cost. LoRA is installing removable wallpaper in the key rooms: a thin low-rank "diff" stored separately, snapped on top of the frozen original. Same look, a fraction of the cost, and you can swap rooms (tasks) without repainting.
In more depth
Fine-Tuning & LoRA
Fine-tuning adapts a pretrained model to a target task by updating its weights on task-specific data. But updating all parameters of a 70B model is prohibitively expensive.
LoRA: Low-Rank Adaptation
LoRA freezes the original weight matrix W ∈ ℝ^{d×k} and injects a trainable low-rank update:
W' = W + ΔW = W + BA
where B ∈ ℝ^{d×r} and A ∈ ℝ^{r×k}, with rank r ≪ min(d, k).
Trainable params per layer: 2·r·d (vs. d² for full FT).
For d=4096, r=8: 65,536 vs. 16,777,216 — 256× fewer.
At inference, merge: W' = W + BA → zero latency overhead.
QLoRA
QLoRA (Dettmers et al. 2023) combines LoRA with 4-bit NormalFloat quantization of the base model, enabling 65B fine-tuning on a single 48GB GPU.
When to fine-tune?
Interview Questions
References & Further Reading
Related topics
Love this visualization?
Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.
100% free • No credit card required