On this page
"Should we fine-tune or use RAG?" is often the wrong question, because the two solve different problems. Retrieval-augmented generation (RAG) gives the model facts it doesn't have, at the moment it needs them. Fine-tuning changes how the model behaves: its format, style, task skill or vocabulary. Many teams fine-tune to teach facts, which works poorly, or use RAG to fix formatting, which is clumsy.
This guide explains how each works, which problems each solves, what each costs, and the order of work that gets you to a good system with the least wasted effort.
#How each one works
RAG happens at question time:
- Your documents are split into chunks and each chunk is turned into an embedding (a vector) and stored in an index.
- When a question arrives, it's embedded too, and the most similar chunks are retrieved (often combined with keyword search, then re-ranked).
- The retrieved chunks are pasted into the prompt, and the model answers using them.
The model's weights never change. Knowledge lives in the index, which you can update, filter and inspect.
Fine-tuning happens before deployment:
- You collect examples of inputs and the outputs you want, usually hundreds to tens of thousands.
- You train the model on them, usually with LoRA, which learns a small set of extra weights instead of changing all of them (LoRA and QLoRA in depth).
- The tuned model now behaves more like your examples, without needing them in the prompt.
Knowledge, if any is learned, is spread across the weights, where you can't update, filter or inspect it.
#Why fine-tuning is a poor way to add facts
It seems natural to fine-tune on your documents so the model "knows" them. In practice:
- Models learn facts slowly and unreliably from fine-tuning. A fact seen a few times in training is often not recalled correctly, and the model may answer confidently with a blend of old and new information.
- Facts change. Every update to a policy or price list means another training run and another evaluation.
- No citations. The model can't point to where an answer came from, so users can't check it.
- No access control. Anything trained into the weights can come out for any user.
Retrieval handles all four: the fact is in the prompt word for word, updates are a re-index, the source can be shown, and each user only retrieves what they're allowed to see.
#Why RAG is a poor way to fix behaviour
The opposite mistake is just as common. If the model ignores your output format, uses the wrong tone or doesn't know how to do a narrow task, stuffing examples into every prompt helps a little but:
- It costs tokens on every request. Twenty examples at 300 tokens each add 6,000 input tokens to every call.
- It's brittle. Behaviour taught by examples in the prompt drifts as the conversation grows or the examples change.
- It caps how small a model you can use. A small model often can't follow complex instructions from examples alone, but can learn the same behaviour from fine-tuning.
#Match the tool to the problem
| Problem | Usually solved by | Why |
|---|---|---|
| The model doesn't know our documents, products or policies | RAG | Facts change; retrieval updates instantly and can cite sources |
| Answers must cite sources users can check | RAG | Citations point at retrieved passages |
| The model ignores our output format or schema | Prompting, then structured output, then fine-tuning | Constrained decoding fixes syntax; fine-tuning fixes habits |
| It must use our jargon, tone or a narrow task skill | Fine-tuning | Behaviour is learned from examples, not looked up |
| A small model should do one task as well as a big one | Fine-tuning (often distillation) | Specialising a small model cuts cost and latency |
| Both: domain facts and a house format | Both | Fine-tune for behaviour, retrieve for facts |
#Compared on what matters in practice
| RAG | Fine-tuning | |
|---|---|---|
| Time to first result | Days | Days to weeks (data is the slow part) |
| Keeping facts fresh | Re-index changed documents | Retrain |
| Cost per request | Higher: retrieved text adds input tokens | Lower if a smaller model can replace a larger one |
| Up-front cost | Parsing, indexing, retrieval tuning | Data collection and labelling, training runs, evaluation |
| Explainability | Sources can be shown | Opaque |
| Privacy and access control | Filter what each user may retrieve | Anything trained in can leak to every user |
| Main failure mode | Wrong or missing passages retrieved | Forgetting general skills, overfitting to the training set |
The privacy row deserves emphasis: never fine-tune on data some users must not see. Retrieval can enforce per-user permissions; weights can't.
#A worked cost comparison
Suppose a support assistant handles 1 million requests a month. Two designs:
- Design A: a large model with RAG and few-shot examples. Each request carries 4,000 tokens of retrieved context plus 3,000 tokens of examples and instructions.
- Design B: a fine-tuned small model with RAG. The examples are trained in, so each request carries the 4,000 tokens of context plus 500 tokens of instructions, and the model is several times cheaper per token.
Design B sends about 36% fewer input tokens per request (4,500 against 7,000) and pays a lower price per token. At high volume, that difference can easily pay for the fine-tuning work; at low volume, it usually doesn't. Run the numbers with your own traffic and prices (token cost calculator).
Note that Design B still uses RAG. Fine-tuning replaced the examples, not the facts.
#Three scenarios
An internal policy assistant. Employees ask about HR and expense policies, which change several times a year and differ by country. This is a knowledge problem with access control: RAG, with permission filters by region and role, and citations to the policy page.
A ticket classifier. Every incoming support ticket must be tagged with one of 40 categories and a priority, as JSON. The model knows English; it needs to learn your categories and output format. That's behaviour: start with a strong model and structured output, then fine-tune a small model on a few thousand labelled tickets to cut cost and latency.
A medical-coding assistant. It must apply a large, frequently updated code set and write notes in a strict house style. Facts change and must be cited; style is a habit. Both: retrieve the relevant code definitions, and fine-tune for the note format.
#A sensible order of work
- Prompt well with a strong model and measure on a golden set of real questions with known good answers.
- Add retrieval if the failures are missing knowledge (RAG evaluation loop). Measure retrieval separately: if the right passage isn't retrieved, no model can answer well.
- Add constrained decoding if the failures are format errors.
- Fine-tune if the remaining failures are behaviour, or if you need a smaller, cheaper model to match the large one (when to fine-tune).
- Re-evaluate after every step; stop when you meet the bar.
Skipping straight to step 4 is the most expensive mistake: weeks of data work for a problem that retrieval or a better prompt would have fixed.
#How to tell which problem you have
Look at 50 failed answers from your golden set and label each one:
| The model... | Problem type | Fix |
|---|---|---|
| Stated something false about your domain | Missing knowledge | RAG |
| Had the right passage but ignored it | Instruction following | Better prompt, stronger model, or fine-tune |
| Didn't get the right passage | Retrieval quality | Better chunking, hybrid search, re-ranking |
| Answered correctly in the wrong format | Format | Structured output, then fine-tune |
| Used the wrong tone or terminology | Behaviour | Fine-tune |
The mix of labels tells you where to spend effort.
#FAQ
Can fine-tuning reduce hallucinations? It can teach the model to say "I don't know" or to stick to provided context, which helps. It doesn't reliably add correct facts.
Do long-context models make RAG unnecessary? For small document sets, you can sometimes paste everything into the prompt. For large or changing collections, or with access control, retrieval is still cheaper and more precise. Prompt caching narrows the gap (prompt cache calculator).
How much data does fine-tuning need? For format and narrow tasks with LoRA, a few hundred to a few thousand good examples are often enough. Quality matters more than quantity.
#Go deeper
comparisonragfine-tuning
Found this useful?
Send it to someone who is learning the same thing.
Next: learn it step by step, free
Engines compared from the inside
How vLLM, SGLang, TensorRT-LLM and llama.cpp schedule, batch and cache, side by side. A free lesson with step-through diagrams and a quiz.