By Plainly Editorial

Updated

RAG vs fine-tuning

Filed under AI & modern tech

For most teams, RAG is the right first step when the problem is missing, private, or fast-changing knowledge, because it is cheaper, easier to update, and can cite its sources. Fine-tuning earns its place when you need a consistent format, tone, or narrow skill that prompting cannot reliably produce. Many production systems use both: a fine-tuned model that is good at using retrieved context.

Side-by-side

DimensionRAGFine-tuning
What it changesWhat the model sees: relevant passages are added to the prompt for each questionThe model's weights: it learns new patterns from training examples
Best atFacts, documents, policies, and data the model was never trained onStyle, format, tone, and narrow repeatable tasks such as classification
Keeping knowledge freshUpdate the document index and the next answer uses the new versionRequires collecting new examples and retraining
CitationsCan point to the exact passage it used, so answers are checkableKnowledge is blended into weights; it cannot say where a fact came from
Upfront effortChunk documents, create embeddings, set up a vector or keyword searchCurate hundreds to thousands of high-quality examples and run training jobs
Running costLonger prompts on every request, plus search infrastructureShorter prompts; training cost up front, sometimes higher per-token hosting
LatencyAdds a retrieval step before generationNo retrieval step; often faster per request
Hallucination riskLower on covered topics, but bad retrieval leads to confident wrong answersCan still invent facts; may learn to sound confident about things it half-learned
Access controlEasy to filter documents per user before they reach the modelAnything in training data may surface for any user
Main failure modeThe right passage is not retrieved, or too much noise is retrievedToo little or low-quality data, overfitting, or forgetting general skills

Choose RAG when

  • Your answers depend on internal documents, product manuals, or policies the base model has never seen.
  • The information changes weekly or daily, such as prices, inventory, tickets, or regulations.
  • Users need to see a source for each claim so they can verify it.
  • Different users are allowed to see different documents, and you need to enforce that.
  • You want something working in days rather than weeks, with no training data to prepare.

Choose Fine-tuning when

  • You need output in a strict, consistent format that long prompts still get wrong some of the time.
  • You want a specific brand voice or writing style applied every time without a long style guide in each prompt.
  • You have a narrow, high-volume task, such as routing support tickets, where a smaller fine-tuned model can replace a larger general one.
  • Prompts have grown so long with instructions and examples that cost and latency are becoming a problem.
  • You have at least several hundred good, representative examples of the exact input and output you want.

Common questions

Can fine-tuning teach a model new facts?

Only unreliably. Research comparing the two approaches, such as Ovadia and colleagues' 2023 study, found that retrieval consistently beat unsupervised fine-tuning for injecting knowledge, both for facts the model had partly seen and for entirely new ones. Models tend to need many rephrasings of the same fact to absorb it. If your goal is accurate recall of specific facts, start with RAG.

Can you use RAG and fine-tuning together?

Yes, and this is common in mature systems. Fine-tuning teaches the model the behavior you want, such as answering in your format, quoting sources, or saying it does not know when the passages do not cover the question. RAG then supplies the current facts at question time. The fine-tuned model becomes better at using retrieved context rather than replacing it.

Which is cheaper, RAG or fine-tuning?

RAG is usually cheaper to start because there is no training run and no dataset to label. Its ongoing cost is longer prompts, since retrieved passages add tokens to every request, plus the search index. Fine-tuning costs more up front but can lower per-request costs by shortening prompts or letting a smaller model do the job. At very high volume, fine-tuning can work out cheaper.

What is LoRA and why does it matter for fine-tuning?

LoRA (low-rank adaptation) is a technique that freezes the original model and trains a small set of extra weights instead of all of them. The original 2021 paper reported cutting trainable parameters for GPT-3 by about 10,000 times. In practice it makes fine-tuning far cheaper, lets you store many small adapters for one base model, and is how most open-weight models are customized.

Does a bigger context window make RAG unnecessary?

Not usually. Long context windows let you paste more material into a prompt, which helps with a single long report. But a company knowledge base can be millions of words, far beyond any window, and filling a huge prompt on every request is slow and expensive. Models can also miss details buried in very long inputs. Retrieval still picks the few passages that matter.

How much data do you need to fine-tune a model?

It depends on the task, but useful results for style or format often start at a few hundred carefully written examples, and harder tasks may need thousands. Quality matters more than volume: inconsistent or wrong examples teach the model to be inconsistent or wrong. Always hold back a test set and compare the fine-tuned model against a well-prompted base model before switching.

Can I fine-tune closed models like the ones behind ChatGPT or Claude?

Sometimes, but availability varies by provider and changes over time. Some providers offer hosted fine-tuning only for selected models or enterprise customers, and some have scaled back these programs. Open-weight models can always be fine-tuned on your own hardware or a cloud GPU, which is one reason teams with heavy customization needs choose them. Check your provider's current documentation.

Sources and further reading

  1. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks — arXiv (Lewis et al., 2020)
  2. Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs — arXiv (Ovadia et al., 2023)
  3. LoRA: Low-Rank Adaptation of Large Language Models — arXiv (Hu et al., 2021)

Keep reading