What does LoRA do, and why is it popular for fine-tuning?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
LoRA freezes the base weights and trains tiny rank-r matrices that act as a low-rank delta. Same quality at 1/100 to 1/1000 the trainable parameters.
Imagine a huge textbook you cannot edit. You want to teach it a new chapter without rewriting the book. Instead of editing every page, you stick a thin pack of sticky notes (the LoRA adapter) on certain pages. The book never changes, the new ideas live on the sticky notes, and when you read a page you read the original plus whatever is on the sticky. Training is fast because there are only a few thousand sticky notes, not a million pages. Whenever you want a different specialty, you swap in a different sticky-note pack on the same book.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: BA factorisation + zero-init B + target modules + memory math + QLoRA layering + production serving with adapter routing.
from peft import LoraConfig, get_peft_model
from transformers import AutoModelForCausalLM
base = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-4-8B")
config = LoraConfig(
r=16, # rank
lora_alpha=32, # scaling factor
target_modules=["q_proj", "k_proj", "v_proj", "o_proj",
"gate_proj", "up_proj", "down_proj"],
lora_dropout=0.05,
bias="none",
task_type="CAUSAL_LM",
)
model = get_peft_model(base, config)
model.print_trainable_parameters()
# trainable params: 41M || all params: 8.04B || trainable: 0.51%Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Confusing LoRA with quantization or distillation. LoRA does not shrink the model, it adds a small trainable delta on top of frozen base weights.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.