↰ Learning hub  ·  ← Back to "Embeddings"
Beginner deep dive · guide 4 of the set

Fine-tuning & LoRA

How you take a general model and make it yours — specialized for your task, your tone, your domain — without needing a data center. And why the clever shortcut called LoRA changed everything.

0. Why fine-tune at all?

A base model like Llama or Gemma is a generalist — it knows a bit about everything but nothing about your specifics: your product's support style, your legal templates, your company's tone of voice. Fine-tuning is how you specialize a general model by training it a little more on examples of what you want.

The result is a model that reliably answers in the right format, uses your terminology, and behaves consistently — without you having to explain it all in every prompt.

1. Three ways to steer a model

Before fine-tuning, know it's one of three tools — and often the last one you should reach for. They stack from cheapest to most involved:

Promptingjust ask well RAGgive it your docs Fine-tuningchange the model cheapest / fastest →→→ most powerful / most effort
Try prompting first, RAG for knowledge, fine-tuning for behavior. They combine well too.

Prompting = just wording your request well (and giving examples in the prompt). RAG (from the embeddings guide) = feeding the model the right documents so it has the knowledge. Fine-tuning = actually changing the model's weights so it learns a skill or style. We'll compare when to use which in section 7.

2. What fine-tuning actually does

Remember the weights — the billions of numbers that are the model's knowledge. Training set them in the first place. Fine-tuning continues that training, but gently, on a small set of your own examples (say, hundreds or thousands of ideal question-and-answer pairs).

The model nudges its weights just enough to absorb the pattern in your examples, while keeping everything it already knew.

general modelknows a bit of everything + your examples100s–1000s of pairs specialized modelyour tone, format, skill
Fine-tuning gently continues training on your examples, turning a generalist into your specialist.
Analogy: Hiring an experienced generalist, then giving them a week of on-the-job training in your specific workflow. You're not re-teaching them to read — just adapting a capable person to your way of doing things.

3. The problem: full fine-tuning is expensive

Full fine-tuning means updating all of the model's weights. For a multi-billion-parameter model that's brutal:

This put fine-tuning out of reach for most people — until a shortcut arrived.

4. LoRA: train a tiny add-on instead

The key idea

LoRA (Low-Rank Adaptation) is a wonderfully simple insight: don't touch the giant model at all. Freeze every original weight. Instead, add a tiny set of new weights alongside it, and train only those.

Those add-on weights (called an adapter) are typically well under 1% of the model's size. You get most of the benefit of full fine-tuning for a fraction of the memory, storage, and cost.

Full fine-tuning ALL weightsretrained · huge LoRA frozen modelunchanged adapter
LoRA leaves the big model untouched and trains only a small green adapter beside it.

5. How LoRA works, simply

A model's big weight blocks are grids of numbers (matrices). Fully retraining one means changing every cell. LoRA's trick: instead of learning a big grid of changes, it learns two much skinnier grids that multiply together to approximate that change.

A "1000 × 1000" change would be a million numbers. But two skinny grids of "1000 × 8" and "8 × 1000" are only about 16,000 numbers — yet multiplied together they cover the same shape. That "8" is the rank: small rank = tiny adapter, slightly less expressive; larger rank = bigger adapter, more capacity.

frozenbig W + A × B = adaptedbehavior only A & Bare trained
Two skinny trainable matrices (A, B) add a small correction to the frozen weight W.
Analogy: Instead of rewriting a 500-page manual, you clip in a few sticky-note corrections. Tiny, cheap to make, easy to swap out — and the original book is untouched.

Two lovely side-effects: an adapter is a small file (a few megabytes), and because the base model is untouched, you can keep many adapters and swap them in and out — one for legal tone, one for coding, one for customer support — all sharing the same base model.

6. QLoRA: LoRA meets quantization

Remember quantization from the first guide (storing weights in 4 bits to shrink them)? QLoRA combines the two ideas: quantize the frozen base model down to 4 bits and train a LoRA adapter on top.

Now even the frozen base barely uses memory, so you can fine-tune surprisingly large models on a single ordinary GPU. Quantization shrinks the base; LoRA shrinks the training. Together they made custom models genuinely accessible.

base model → 4-bitfrozen · tiny memory + LoRA adapter = QLoRAfine-tune big models, 1 GPU quantization (guide 1) LoRA (this guide)
QLoRA = the quantization trick stacked on the LoRA trick — two shrink-tricks combined.
Connects two guides: QLoRA is literally the quantization trick (guide 1) plus the LoRA trick (this guide), stacked. A nice example of how these ideas compose.

7. When to prompt, RAG, or fine-tune

A quick decision guide — these are complements, not rivals, and you'll often combine them:

ApproachBest forWatch out
PromptingQuick tasks; trying things out; when a clear instruction or a few examples is enough.Long prompts get costly; behavior can be inconsistent.
RAGGiving the model knowledge — private, large, or frequently-changing facts and documents.Doesn't change the model's style or skills; needs a retrieval setup.
Fine-tuning / LoRATeaching a skill, format, or tone you need reliably and repeatedly.Needs good example data; not the way to add fast-changing facts (use RAG for those).
Rule of thumb: need facts? Reach for RAG. Need a consistent behavior or style? Fine-tune. Just experimenting? Prompt. Many real systems use all three at once.

8. Swappable adapters on the edge

LoRA is a natural fit for edge devices. Because adapters are tiny and the base model is shared, a phone can keep one base model in memory and swap small adapters to change its personality or specialty — cheaply, instantly, and offline.

EdgeLM tie-in: this pairs perfectly with the shared-model idea from guide 1 — one base model mapped once in RAM, with a handful of small adapters giving different apps their own specialized behavior, no extra full models needed.

9. Test yourself

Pick an answer and it'll explain why. Score updates as you go.

1. What does fine-tuning do to a model?

Specializes it. Fine-tuning nudges the weights to learn your task, style, or format.

2. Why is full fine-tuning expensive?

All the weights. Each fine-tuned copy is a full-size model, and training needs lots of memory.

3. What is LoRA's core trick?

Freeze + tiny adapter. The big model is untouched; only a small set of new weights is trained.

4. Roughly how big is a LoRA adapter compared to the model?

Under 1%. That's why adapters are small files you can store and swap easily.

5. What does QLoRA add to LoRA?

Quantized base + LoRA. Combining the two shrink-tricks makes fine-tuning big models accessible.

6. You need the model to answer using constantly-changing internal docs. Best tool?

RAG. For fast-changing facts, retrieval is better; fine-tuning is for skills and style.

7. Why do LoRA adapters suit edge devices so well?

Tiny & swappable. Keep one base in memory and swap small adapters for different specialties — offline.

Score: 0 / 7

Mini-glossary

Fine-tuning
Continuing a model's training on your own examples to specialize it.
Full fine-tuning
Updating all of a model's weights — powerful but memory-, storage-, and compute-heavy.
LoRA
Low-Rank Adaptation: freeze the model and train a tiny add-on adapter instead.
Adapter
The small set of trained LoRA weights; a few megabytes, easy to store and swap.
Rank
How "thick" the LoRA add-on is — small rank = tinier adapter, larger rank = more capacity.
QLoRA
LoRA on a quantized (4-bit) base model, letting large models be fine-tuned on one GPU.
Prompting
Steering a model just by how you word the request (and examples you include).
RAG
Retrieval-Augmented Generation: fetch relevant documents and let the model answer with them (guide 3).

→ Next up: How Training Actually Works — where all these weights come from in the first place.