What does LoRA do, and why is it popular for fine-tuning?
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.
Detailed answer & concept explanation~6 min readEverything 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. 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.
- OpenAI's fine-tuning API for GPT-4o-mini uses LoRA-style adapters under the hood, exposing only the high-level training endpoint.
- Together.ai serves dozens of customer LoRA adapters on the same Llama 3.1 base via per-request adapter routing.
- Anthropic Workbench supports LoRA fine-tuning on Claude Haiku for enterprise customers with custom datasets.
- Modal Labs and Anyscale publish reference QLoRA pipelines for Llama 3.1 8B and 70B at single-GPU and multi-GPU scale.
- Hugging Face PEFT is the standard open-source library, used in nearly every academic and indie LoRA recipe since 2023.
What an interviewer would ask next. Try answering before peeking at the approach.
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
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.
Same topic, related formats. Practice these next.