Learn
RAG & vector databases

Fine-Tuning vs. RAG: Which One Should You Choose?

The short answer

Fine-tuning changes how a model behaves; RAG changes what it can see. Most teams frame this as a binary and then pick the wrong side. This compares both on cost, latency, data requirements and failure modes, and shows why the mature answer is usually a fine-tuned shape over retrieved facts.

On this page

Two different failures, two different fixes

A model giving a wrong answer is failing in one of two ways. It may not know the fact, in which case no amount of instruction tuning will install it reliably. Or it may know it but produce the wrong shape — wrong tone, wrong JSON keys, wrong level of detail. The first is a knowledge problem, the second a behaviour problem. RAG addresses the first, fine-tuning the second.

Teams get into trouble using one to solve the other. Fine-tuning on documents to teach facts produces a model that sounds like the documents and confabulates their contents. Retrieving passages to fix a formatting problem produces a prompt full of examples the model partially imitates. Both can look good on the demo queries that motivated them and fail on the long tail, which is why the distinction is worth settling before any code.

What fine-tuning actually changes

Supervised fine-tuning adjusts weights on pairs of input and desired output. With LoRA or QLoRA you freeze the base weights and train small low-rank adapters, typically 0.1 to 1 percent of the parameter count, which is why a 7B model can be tuned on a single 24 GB card. The adapter learns a conditional distribution: given this kind of input, produce this kind of output. That is extremely effective for style, structure, tone, domain vocabulary, classification labels and tool-call formats.

It is also effective for compression. If a large model with a long, elaborate prompt performs a narrow task well, you can generate thousands of examples from it and fine-tune a smaller model to imitate the behaviour. The student loses generality but keeps the task, and inference becomes an order of magnitude cheaper. This is the most economically compelling use of fine-tuning and has nothing to do with knowledge.

What the adapter cannot do is hold a mutable database. Weights are a compressed, distributed representation; there is no addressable slot for the refund policy as of March. Facts that appear a handful of times in training data are learned weakly or not at all, and the model has no way to signal which facts it learned and which it guessed. Fine-tuning on facts therefore buys fluency about a subject rather than accuracy within it, which is precisely the failure mode that looks fine in a demo.

The decision that matters: knowledge or behaviour

Ask what has to change when the world changes. If a document is updated and the system must reflect it by tomorrow, that is a retrieval problem: re-index the document and you are done. If the requirement is that every answer be phrased in the brand voice and end with a specific disclaimer, that is a fine-tuning or prompting problem, and retrieval will not help. If both are true, you need both, which is the common case.

A second question narrows it further: does the answer need to be attributable? Regulated domains, legal review and internal audit all require that a claim trace to a source. A fine-tuned model can produce a citation-shaped string, but the string is generated, not looked up, and it will sometimes point at a document that does not exist. Retrieval gives you citations as a byproduct because the evidence is literally in the prompt.

A third: is the knowledge per-user? If each customer may only see their own contracts, retrieval with metadata filters is the only approach that scales. Baking tenant data into weights is both an access-control hazard and an operational impossibility once the tenant count passes a few dozen.

Cost arithmetic, both directions

Fine-tuning has a fixed cost and a low marginal cost. Take a 7B model, 50,000 examples of 500 tokens, three epochs: 75 million training tokens. On one 80 GB GPU at roughly 3,000 tokens per second that is about seven hours, so a rented A100 run lands in the tens of dollars; the data collection is the real expense, usually weeks of someone's attention plus review. Hosted APIs add a monthly charge for keeping the tuned model loaded.

Serving a fine-tuned model means serving a model. If you were calling a hosted API, you now either pay that provider's tuned-model premium or you run GPUs yourself. A 7B model at four bits needs roughly 5 GB of weights and fits on a 24 GB card with room for batching; a 70B model does not, and the economics change completely. Budget the ops surface, not just the training run.

RAG's cost profile is inverted. Indexing a million chunks costs single-digit dollars in embedding calls plus storage. Each query pays for an extra embedding, a search and — the dominant term — several thousand extra input tokens. At 3,500 context tokens and fifteen cents per million, that is about half a cent per query, so 100,000 queries a month is around fifty dollars. RAG is cheap to start and scales with traffic; fine-tuning is expensive to start and cheap per token if you already have somewhere to run the model.

The break-even is rarely where people guess. If you are doing 10,000 queries a month, RAG's token overhead is trivial and the engineering time to build an index dwarfs it. If you are doing 50 million queries a month on a narrow task, distilling a small fine-tuned model can pay back its development cost in weeks. Volume and task narrowness, not accuracy, decide the economics.

Latency and serving shape

Fine-tuning shortens prompts. A task that needed a 2,000-token instruction with eight few-shot examples can run with a 200-token instruction once the behaviour is in the weights, which cuts prefill time and input cost. It also makes the model's behaviour more consistent, which matters when you are parsing outputs downstream. That is a real advantage and it is frequently the actual reason a team fine-tunes.

RAG adds a retrieval round trip before generation: 20 to 200 milliseconds depending on whether you rerank. That is small next to generation latency but not free, and it sits on the critical path to the first token. Retrieval also adds variance, since a vector-index cache miss costs more than a hit and a slow lexical query can dominate the tail. With a hard 300-millisecond budget, retrieval plus a small fine-tuned model may fit where a large prompted one does not.

A practical hybrid: fine-tune for the prompt shape so the instruction is short, then retrieve a small number of high-precision chunks. You get fewer input tokens than either approach alone and better grounding than fine-tuning alone.

Data you need, and what it costs to get

RAG needs a corpus and an evaluation set. The corpus usually exists but is messy: duplicated documents, superseded versions, scanned PDFs, pages behind a login. The work is parsing, deduplication and permission metadata. The evaluation set is 100 to 300 questions with the passage that answers each one annotated, and building it takes a domain expert a few days. This is the cheapest high-value artefact in the project.

Fine-tuning needs demonstrations, not documents. A thousand to ten thousand input-output pairs that show the behaviour you want, written or at least reviewed by someone who can judge quality. If you have a production system already, you may have logs you can mine and filter — but logs contain bad answers as well as good ones, and training on them teaches the bad ones too. Budget for labelling.

Synthetic data closes part of the gap. A strong model can draft outputs that a human edits, which cuts labelling cost by a factor of three to five. It cannot invent the judgement about what counts as correct, and a student trained on unreviewed teacher output inherits the teacher's errors with none of its caution. Use synthesis for coverage of rare cases and human review for the cases that matter.

The hybrid that most systems converge on

Fine-tune the shape, retrieve the facts. The adapter learns the output contract — the JSON schema, the citation format, the tone, the refusal phrasing, the domain's shorthand. Retrieval supplies the content, including the parts that changed last week. Each component then has one job, which makes failures diagnosable: a malformed answer is a tuning problem, a wrong fact is a retrieval problem.

There is a second, less obvious hybrid: fine-tune the retrieval components rather than the generator. A domain-tuned embedding model or cross-encoder trained on a few thousand labelled query-passage pairs often lifts retrieval quality more than swapping to a bigger general embedder, and it is cheap because the models are small. If your generator is a strong general model and your answers are still wrong, the bottleneck is usually retrieval, and this is where the tuning budget belongs.

A third: distil the whole pipeline's behaviour into a small model for the easy majority of traffic, and route hard cases to the full RAG path. Classification of query difficulty is itself a small fine-tuned model, and the routing threshold is a business decision about cost per mistake.

How fine-tuning fails

Catastrophic forgetting is the classic. Train hard on one narrow distribution and general instruction-following degrades — the model becomes excellent at insurance claims and forgets how to follow a negation. The standard mitigation is to mix 5 to 10 percent general instruction data into the training set, and to keep a held-out general benchmark in your evaluation suite so you notice the regression.

Overfitting shows up as memorisation of training phrasings. The model reproduces exact answers to exact questions and collapses on paraphrases. If your eval set was drawn from the same distribution as training, you will not see it. Hold out by document or by customer, not randomly by example, or near-duplicates will leak across the split and inflate your scores.

The subtler failure is learning the wrong thing. Train on outputs where every answer cites a source and the model learns to produce a citation-shaped string whether or not it has support. Train on refusals and it becomes timid; train on a verbose teacher and you have bought verbosity. Every fine-tune encodes its data's artefacts, including unintended ones, which is why a human-reviewed sample of outputs before and after is not optional.

How RAG fails, briefly

RAG fails when retrieval misses, when the corpus is stale, when a document contradicts another and the model picks one silently, and when permission filters are applied after the fact rather than in the query. It also fails politely: given irrelevant context, a well-instructed model says it cannot answer, which is correct behaviour but a product failure if the passage existed and was simply not found.

The characteristic RAG failure is a plausible answer assembled from the wrong passages, with citations that technically contain the words but not the meaning. Component-wise evaluation — recall at k for retrieval, faithfulness for generation — is the only way to tell these apart, and it is why RAG projects need more measurement discipline than fine-tuning projects, not less.

Evaluation differs, and so does the cadence

A RAG system is evaluated continuously against a changing corpus. Every document update can change an answer, so the regression suite runs on every index build, and the metrics are retrieval recall plus answer faithfulness. A fine-tuned model is evaluated at training time and then monitored for drift; its answers change only when you retrain or the input distribution shifts. The cadence difference matters operationally: RAG needs CI around the index, fine-tuning needs a disciplined experiment tracker.

For fine-tuning, compare against the base model on the same held-out set, with the same prompt and decoding parameters, and report per-slice numbers rather than one average. A model that gains three points overall while losing eight on the smallest customer segment is a regression you will hear about. Also evaluate on a general benchmark to catch forgetting, and on adversarial inputs to catch the model having learned to bluff.

For both, the useful question is not which scores higher but where the errors land. A fine-tuned model's errors are systematic and hard to patch; a RAG system's are usually traceable to a document or chunk and fixable in an afternoon. That asymmetry often decides the architecture before any benchmark does.

When neither is the answer

A surprising number of requests for fine-tuning are requests for a better prompt. If the failure is that the model ignores a constraint, restate the constraint, put it in the system message, add two examples, or validate the output against a schema and retry. If the failure is that the model lacks a tool, give it the tool. These fixes take hours and are reversible; a fine-tune takes weeks and is not.

Similarly, a surprising number of RAG projects should start with grep. If the corpus is 200 documents and users ask exact-match questions about identifiers, a keyword search over a full-text index with a good prompt beats an embedding pipeline on quality, cost and debuggability. Build the vector index when semantic matching demonstrably earns its keep, and let the evaluation set tell you when that is.

A decision procedure

  • Facts change without a code deploy, or answers need citations: RAG, regardless of anything else.
  • Output must follow a strict format, tone or schema: fine-tune, or use constrained decoding if the provider supports it.
  • Knowledge is per-user or per-tenant: RAG with filters in the query. Never bake it into weights.
  • Task is narrow, volume is high, and a large prompted model already does it well: distil into a small fine-tuned model.
  • Corpus is under roughly 100,000 tokens and traffic is low: skip both, put the whole thing in the prompt with caching.
  • Both knowledge and behaviour are wrong: fine-tune the shape, retrieve the facts, and evaluate the halves separately.
  • Nothing is obviously wrong and the model just ignores instructions: fix the prompt and add schema validation first.

Common mistakes

  • Fine-tuning on documents in the hope that facts will stick, then discovering the model confabulates details it never really learned.
  • Building a vector index for a 50-document corpus where keyword search and a good prompt would have been enough.
  • Evaluating a fine-tune on examples drawn from the same distribution as training, where near-duplicates inflate every score.
  • Forgetting to hold out general instruction data, then shipping a model that is excellent at the task and unable to follow a simple negation.
  • Assuming fine-tuning removes the need for retrieval because the prompt got shorter, when the facts still have to come from somewhere.
  • Treating the embedding model as a config value, so an upgrade silently invalidates every vector in the index.
  • Comparing a tuned model against a RAG system with different prompts and decoding settings, which measures the harness rather than the architecture.
Page feedback

Was this helpful?

A quick signal helps improve these notes.

Report a mistake Straight to the lab inbox

Put it to work

See the models, datasets and gateway this lab runs.