A year into the enterprise LLM boom, most teams have built a prototype and many are moving to production. The most frequent architectural question we hear is: should we use retrieval-augmented generation (RAG), or fine-tune a model?
The options are no longer theoretical. RAG frameworks and vector databases have matured, OpenAI has offered fine-tuning for GPT-3.5 Turbo since last August, and open models such as Llama 2 and Mistral can be fine-tuned cheaply with LoRA. Context windows have also grown dramatically, which changes the trade-offs again.
The key distinction
It helps to ask what is actually wrong with the base model's answers:
- "It doesn't know our information" (policies, products, documents, recent events). That is a knowledge problem. RAG is usually the answer.
- "It knows enough, but doesn't behave the way we need" (format, tone, domain conventions, a specialised task). That is a behaviour problem. Fine-tuning is often the answer.
Fine-tuning is a poor way to teach a model facts. It may partially memorise them, but it cannot cite them, cannot be updated quickly, and still hallucinates around the edges. RAG cannot make a model follow a complex output schema consistently or adopt a house style it has never seen.
A decision framework
flowchart TB
S[Start: build an eval set of real tasks] --> P{Does a well-prompted<br/>base model pass?}
P -->|yes| Done[Ship with prompting]
P -->|no| K{Failures due to<br/>missing knowledge?}
K -->|yes| RAG[Add RAG]
K -->|no| B{Failures due to format,<br/>style or specialised skill?}
B -->|yes| FT[Fine-tune]
B -->|no| M[Try a stronger model<br/>or decompose the task]
RAG --> Re{Still failing?}
Re -->|behaviour| Both[RAG + fine-tuning]Use RAG when:
- information changes often (prices, policies, tickets, documentation),
- answers must cite sources for trust or compliance,
- different users may see different data (permissions),
- the corpus is large, or
- you need to remove information quickly (for example, for data protection requests).
Use fine-tuning when:
- you need consistent output format or structure that prompting cannot reliably achieve,
- a specific tone, style or domain convention matters,
- the task is narrow and high-volume, so a smaller fine-tuned model can replace a larger, pricier one,
- prompts have grown huge with instructions and examples, or
- latency matters and you want to shorten prompts.
Combine them when you need both: for example, a support assistant fine-tuned to your tone and escalation rules, using RAG to retrieve the relevant knowledge-base articles.
What about long context windows?
Models now accept 100,000 tokens or more, and research previews go further. For small, stable corpora (a single long contract, a product manual), simply putting the whole document in the prompt can beat a RAG pipeline for simplicity.
For large or frequently changing corpora, RAG still wins on cost, latency and access control. Long context is also not perfect recall: models can overlook details buried in the middle of very long inputs.
Costs compared
| Cost | RAG | Fine-tuning |
|---|---|---|
| Upfront | Indexing pipeline, vector store | Data preparation, training runs |
| Per request | Retrieval + longer prompts | Often lower (shorter prompts, possibly smaller model) |
| Maintenance | Keep the index fresh | Retrain when behaviour needs to change |
| Skills | Search and retrieval engineering | Data curation and ML evaluation |
Whatever you choose, evaluate first
Both approaches fail silently without evaluation. Before building either:
- Collect real questions or tasks with good reference answers, 50 to 200 to start.
- Define what "good" means: correctness, faithfulness to sources, format, tone.
- Measure the base model with a strong prompt as a baseline.
- For RAG, measure retrieval (were the right passages found?) separately from generation.
- For fine-tuning, hold out a test set that never touches training, and check for regressions on general behaviour.
# A tiny evaluation harness shape: run every system variant on the same cases.
cases = load_jsonl("eval/support_questions.jsonl") # {"question", "reference", "sources"}
for variant in ["prompt_only", "rag_v2", "ft_v1", "rag_v2+ft_v1"]:
results = [grade(run(variant, c["question"]), c) for c in cases]
print(variant, summarise(results)) # accuracy, faithfulness, format pass rate, cost, latencySecurity considerations
- RAG: enforce permissions at retrieval time, and treat retrieved documents as untrusted input that may contain injected instructions.
- Fine-tuning: training data can be memorised and reproduced, so do not fine-tune on secrets or unnecessary personal data. Protect training datasets from tampering.
- Both: log inputs and outputs for audit, with appropriate privacy controls.
The bottom line
RAG and fine-tuning are not competitors; they solve different problems. Diagnose whether your failures come from missing knowledge or unwanted behaviour, measure with a real evaluation set, and reach for the simplest approach that passes. Often that is a good prompt plus RAG, with fine-tuning added later where it earns its keep.
Our agentic AI security team designs, evaluates and secures both RAG and fine-tuned systems for production.