Free — no signup required

Adapters: LoRA and QLoRA

3 min read

The Post-it Note Approach

Instead of rewriting the entire textbook (full fine-tuning), what if you just added sticky notes in the margins?

Adapters are small, trainable modules added to a frozen base model. The base model's weights are locked — they never change. Only the adapter's weights are updated during training. When you run inference, the adapter's outputs are combined with the base model's outputs, effectively steering the model's behavior toward your custom task.

This is the key insight: you don't need to update all 70 billion parameters to change how the model behaves. You only need to update the parameters that matter for your specific task.

LoRA: Low-Rank Adaptation

LoRA (Low-Rank Adaptation) is the most widely adopted adapter technique. It works by injecting pairs of small matrices into the model's attention layers.

Here's the intuition: the weight matrices in a transformer are very large (e.g., 4096 × 4096 = 16 million values). LoRA hypothesizes that the change needed to adapt the model to a new task has a much lower "rank" — meaning it can be approximated by two much smaller matrices multiplied together (e.g., 4096×8 and 8×4096 = only 65,536 values total).

During training, only these small matrices are updated. The result:

  • Adapter file size: ~50–200 MB instead of 140 GB.
  • Training time: Hours instead of days.
  • Deployment flexibility: One base model loaded in memory; swap adapter files on the fly for different tasks.
  • No catastrophic forgetting: The base model is untouched.

A single A100 GPU can serve one base model with multiple LoRA adapters loaded simultaneously, switching between them per-request with negligible overhead.

QLoRA: Fine-Tuning on Consumer Hardware

QLoRA (Quantized LoRA) combines two techniques: it first quantizes the base model to 4-bit precision (dramatically reducing its VRAM footprint), then attaches a LoRA adapter for training.

The quantized base model is frozen and uses minimal VRAM. The LoRA adapter is trained in higher precision (BF16) on top of the quantized base. The gradients flow through the quantized weights during backpropagation, but only the adapter weights are actually updated.

The practical impact: QLoRA makes it possible to fine-tune a 70B model on a single consumer GPU with 24 GB of VRAM (like an NVIDIA RTX 4090), a task that would otherwise require a cluster of 8× A100s. This democratized custom LLM development, making it accessible to individual researchers and small teams.

Interview Tip

Interviewers sometimes ask: "When would you choose RAG over fine-tuning?" The answer hinges on what you're trying to change. RAG is better for grounding the model in specific, frequently-updated facts (documents, databases). Fine-tuning (via LoRA) is better for changing the model's behavior — its output format, tone, reasoning style, or domain-specific vocabulary. In practice, the best systems use both: LoRA to tune behavior, RAG to inject current facts.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free