RAG vs fine-tuning: which should you use?

Short answer

Use retrieval-augmented generation (RAG) when the model needs knowledge it lacks, especially facts that change, are private or must be cited. Use fine-tuning when the model has the knowledge but behaves wrongly: the wrong format, tone or consistency at a narrow task, or a large model doing a job a smaller tuned one could. Try prompting first, then RAG, then fine-tuning, and combine them when you need both.

Written for engineers and technical founders choosing how to adapt a language model to their own data and tasks.

By , co-founder and CTO of Tellme AIPhD in AI, Queen’s University Belfast · Author of From Model to Product · Updated

Key facts

Definitions

Retrieval-augmented generation (RAG)
A pattern in which the application searches its own data for passages relevant to a request and adds them to the prompt, so the model answers from supplied facts rather than from memory.
Fine-tuning
Further training of a pretrained model on task-specific examples. It changes the model's weights, and so its default behaviour on every request.
LoRA
Low-Rank Adaptation, a parameter-efficient fine-tuning method that freezes the original weights and trains small added matrices, which makes fine-tuning far cheaper in memory and storage.
Embedding
A vector of numbers that represents the meaning of a piece of text. In RAG, embeddings let the system find passages close in meaning to a question, not only those sharing its words.

Knowledge or behaviour: the question that decides it

Ask what is wrong with the model's answers today. If it lacks facts, such as your policies, your products or anything after its training cut-off, that is a knowledge problem and retrieval fixes it. If it has the facts but answers in the wrong shape, tone or level of detail, or is inconsistent at a narrow task, that is a behaviour problem and fine-tuning is the stronger tool.

The research supports the split. Ovadia et al. found RAG consistently beat unsupervised fine-tuning at injecting knowledge, and Gekhman et al. found that fine-tuning on facts a model did not already know made it more prone to hallucinate. Their conclusion: models acquire knowledge mostly in pretraining, and fine-tuning mostly teaches them to use it.

Chapter 5 of From Model to Product, Model Architecture Patterns, sets out prompting, fine-tuning and retrieval as the three design patterns around a language model: retrieval for domain-specific, changing or proprietary information, and fine-tuning when outputs must follow strict formats or the domain's language defeats the base model.

The decision table

Read each row against your product. Most teams find the knowledge rows point to RAG and only one or two behaviour rows point to fine-tuning, which is the case for adding fine-tuning later rather than first.

FactorRAGFine-tuning
What it changesWhat the model sees on each requestThe model's weights, so its default behaviour
Knowledge that changesUpdate the documents and the next answer uses themRetrain to update, and old facts can linger
Private or per-user dataFilter retrieval by user, tenant or permission at request timeBaked into the weights, for everyone who uses the model
CitationsCan point to the passage behind each claimCannot say where a fact came from
Format, tone and styleInstructions and examples in the promptThe strongest tool for consistency at volume
Latency per requestAdds a retrieval step and a longer promptNo extra step, and shorter prompts once examples are trained in
Upfront costIngestion, chunking, embeddings and an indexCurating examples, training runs and evaluation
Running costMore input tokens on every callCan let a smaller, cheaper model do the job
Data you needThe documents themselvesReviewed input and output examples that cover real traffic
Main failure modeRetrieval misses the right passageThe model learns the wrong lesson from flawed or narrow examples

Try them in this order: prompt, retrieve, fine-tune

Each step is cheaper to try and to undo than the next, so move on only when your measurements say the current one has run out.

  1. Build a small evaluation set first: real inputs, each with what a good answer contains. Without it you cannot tell whether any later step helped; how to evaluate an LLM application covers how.
  2. Prompt well. Clear instructions, a response format and a few examples solve more than teams expect. Stop here if the evaluation passes.
  3. Add retrieval when answers fail for lack of facts. Retrieve only what each question needs, and check that the right passages come back before you judge the answers.
  4. Fine-tune when the evaluation still fails on behaviour that prompting cannot fix reliably, or when a prompt full of examples costs too much at volume.
  5. Revisit the choice as volume grows: a fine-tuned small model can take over a task that a large prompted model has proved worth doing.

When fine-tuning is the right call

Fine-tuning earns its cost when the problem is consistent behaviour at volume, and the evidence is failed evaluations rather than a hunch.

Parameter-efficient methods made it far cheaper. LoRA trains small added matrices instead of the whole model, and QLoRA fine-tuned a 65-billion-parameter model on a single 48GB GPU. Access is the other constraint: as of November 2026, OpenAI is winding down its self-serve fine-tuning, and a fine-tuned model lasts only as long as its base model. Tuning an open-weight model keeps that decision in your hands; open-weight vs proprietary models covers the trade.

Good reasons to fine-tune:

  • A strict output format or house style that instructions and schemas do not hold reliably across thousands of requests.
  • A narrow, high-volume task such as classification or extraction, where a small tuned model can replace a large prompted one at lower latency and cost.
  • Prompts that carry dozens of examples on every call, where training the examples in shortens every request.
  • Domain language, such as clinical or legal phrasing, that the base model handles poorly.

When RAG is the right call, and what it costs

RAG is the default whenever the answer depends on facts the model cannot know: your documents, your customers' records, today's prices, this week's policy. It is also the only one of the two that can show a source for each claim and respect per-user permissions at request time.

From practice: Legify.ai, the AI legal-contract platform Dr. Dulan Dias built at EchonLabs, uses a jurisdiction-based RAG engine. Legal content is a clear case for retrieval, because a clause that is right in one jurisdiction can be wrong in another, and the law changes, so the applicable text has to be selected at request time rather than trained into weights.

The costs are real. Every retrieved passage is input tokens on every call, so RAG raises cost per request; see LLM cost per user. Retrieval quality caps answer quality, and long contexts are no shortcut: Liu et al. found models use information in the middle of a long input markedly worse than at its start or end.

Storage is often simpler than vendors suggest. Chapter 11 of From Model to Product builds retrieval from ordinary database queries with no vector database at all, and pgvector or a vector database covers when semantic search earns a store of its own.

Using RAG and fine-tuning together

The two are not rivals: retrieval supplies the facts and fine-tuning shapes how the model uses them. Each common combination fixes a specific weakness.

  • Fine-tune the generator to use retrieved context. RAFT trains a model to answer from the relevant documents, ignore distractors and cite the supporting passage, which suits a domain with a settled body of documents.
  • Fine-tune the retrieval side. When search misses your domain's vocabulary, tuning the embedding model or adding a reranker can lift answer quality without touching the generator.
  • Distil a prompted system into a smaller model. Run a large model with RAG, review its outputs, and, where the large model's terms allow it, train a smaller model on the good ones; it keeps the retrieval step but costs less per call.
  • Fine-tune for format, retrieve for facts. A model tuned to your schema or house style still gets its facts from retrieval, so they stay current without retraining.

Mistakes that waste the effort

Most disappointing projects in this area make one of five mistakes.

  • Fine-tuning to teach facts. It is slow, the facts go stale, and on the evidence above it can raise hallucination rates.
  • Judging RAG by its answers alone. Measure retrieval separately, since no generator can fix a passage that never arrived.
  • Fine-tuning without a held-out evaluation set, so nobody can tell whether the tuned model is better or just different.
  • Stuffing whole documents into the prompt because the context window allows it, which raises cost and buries the passage that matters.
  • Forgetting the lifecycle. A fine-tuned model is tied to its base model, and an index is tied to its embedding model, so plan for retraining and re-embedding when either is replaced.

Frequently asked questions

Is RAG cheaper than fine-tuning?

Usually to start, not always to run. RAG needs no training run, but every retrieved passage adds input tokens to every request, and the index needs upkeep. Fine-tuning costs more upfront in curated examples, training and evaluation, but can let a smaller model handle the task with shorter prompts. At high volume on a narrow task, that can make fine-tuning cheaper per request, so model both with your own token counts.

Can fine-tuning teach an LLM new facts?

Poorly. A study comparing the two found retrieval consistently outperformed unsupervised fine-tuning at injecting knowledge, and a separate study found that fine-tuning on facts the model did not already know was learned slowly and increased its tendency to hallucinate. Fine-tuning is good at teaching a model how to behave. Put facts in documents the model can retrieve, where they can be updated and cited.

Can a long context window replace RAG?

For a small, stable set of documents, sometimes: put them in the prompt and skip the index. At scale it stops working. Every request pays for every token, latency grows with prompt length, and models use information in the middle of a long input less reliably than at its start or end. Retrieval sends only what the question needs, which is cheaper, faster and usually more accurate.

How much training data do you need to fine-tune an LLM?

There is no fixed number; coverage and quality matter more than count. Start with a carefully reviewed set of examples that spans the inputs you really see, awkward ones included, and keep a separate held-out set to measure against. If the evaluation improves, add examples where errors cluster. If a small set changes nothing, more of the same rarely helps, so check whether the problem is really knowledge rather than behaviour.

What is the difference between RAG and fine-tuning in simple terms?

RAG is an open-book exam: the model looks up the relevant pages before it answers, so the answer is only as good as what it finds. Fine-tuning is extra study before the exam: it changes how the model answers by default, but gives it no reference it can check or cite. Use the book for facts that change, and the study for habits that should not.

Does fine-tuning reduce hallucinations?

It depends what you train on. Research published at EMNLP 2024 found that fine-tuning on new facts can increase hallucination. Fine-tuning on examples that answer strictly from supplied context, and decline when the context lacks the answer, can make a model more faithful to retrieved documents. Either way, measure the hallucination rate on a held-out set before and after, rather than assuming the tuned model is safer.

Should you fine-tune the embedding model for RAG?

Only after measuring retrieval. If the right passages already come back in the top few results, the embedding model is not your problem. If they do not, and your domain uses vocabulary a general model handles poorly, a tuned embedding model or a reranker can help. Changing the embedding model means re-embedding every document, because vectors from different models are not comparable.

Sources

  1. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (arXiv 2005.11401)
  2. Ovadia et al., Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs (arXiv 2312.05934)
  3. Gekhman et al., Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations? (arXiv 2405.05904)
  4. Hu et al., LoRA: Low-Rank Adaptation of Large Language Models (arXiv 2106.09685)
  5. Dettmers et al., QLoRA: Efficient Finetuning of Quantized LLMs (arXiv 2305.14314)
  6. Zhang et al., RAFT: Adapting Language Model to Domain Specific RAG (arXiv 2403.10131)
  7. Liu et al., Lost in the Middle: How Language Models Use Long Contexts (arXiv 2307.03172)
  8. OpenAI API deprecations
Dr. Dulan Dias

About the author

Dr. Dulan Dias is co-founder and Chief Technology Officer of Tellme AI in Belfast; founder of EchonLabs, grown from 2017 to more than 60 people before its acquisition in 2026; holder of a PhD in AI and data science from Queen’s University Belfast; and the author of From Model to Product.

Who is Dr. Dulan Dias?

All answers