الانتقال إلى المحتوى
Deep Learning و LLMsFine-tuning· 7 دقائق للقراءة

Fine-Tuning Won't Teach Your Model Your Docs: RAG vs Fine-Tuning

Training on your documents teaches how they sound, not reliably what they say. Retrieve facts at request time, and fine-tune for behavior.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
محتويات المقال

An HR team wants an assistant that knows the employee handbook, so an engineer fine-tunes an open-weight model on all 400 pages. The demo impresses: it uses the company's terms, the handbook's tone, even the names of internal tools. Then someone asks how many weeks of parental leave they get. The answer is fluent, specific and wrong, a number that appears nowhere in the handbook. Nobody can say where it came from. And when HR changes the policy next month, the only fix on offer is another training run.

The common misconception

"To make an LLM know our company documents, fine-tune it on them." It sounds like how models learn everything else:

  • Pretraining taught the model its facts from text, so more training on your text should add your facts.
  • A fine-tuned model visibly changes: it picks up your vocabulary, format and tone, which looks like learning the content.
  • Fine-tuning is a short script or a few clicks on many platforms.
  • Retrieval looks like a workaround. "Pasting documents into the prompt" feels less permanent than real training.

The half-truth: weights do hold knowledge, and pretraining put it there. But pretraining sees a fact many times, in many phrasings, across an enormous corpus. Your handbook states each policy once. Training on it is a different regime, and the evidence says it's a poor way to add facts.

What actually happens

Two places knowledge can live

The paper that named (RAG), Lewis and colleagues in 2020, describes two kinds of memory. Parametric memory is the model's weights: whatever it absorbed in training. Non-parametric memory is an index of documents the system searches at request time and places in front of the model. writes into the first; RAG reads from the second. That choice decides how you update, audit and secure what the model knows.

What fine-tuning on documents measured

Ovadia and colleagues at Microsoft tested this exact belief in 2023. They continued training Llama 2 7B, Mistral 7B and Orca 2 7B on Wikipedia text, unsupervised, the way you'd train on a document dump, and compared that with RAG over the same text. For truly new knowledge, they built 910 multiple-choice questions about US events from August to November 2023, after the models' training data ended.

For Mistral 7B, fine-tuning moved accuracy from 48.1% to 50.4%. RAG took it to 87.5%. Llama 2 7B got worse after fine-tuning, dropping from 35.3% to 21.9%. On knowledge-heavy MMLU subjects such as anatomy and astronomy, which the models had partly seen in pretraining, fine-tuning usually helped a little and RAG usually helped more. On the new facts, pairing the fine-tuned model with RAG did worse than RAG alone. The authors' verdict: RAG is the more reliable choice for adding knowledge.

Why one pass over your docs doesn't stick

One thing did help: repetition. When the team trained on GPT-4 paraphrases of each chunk, accuracy rose steadily with the number of paraphrases for all three models. With ten paraphrases, Mistral reached 58.8%, still far below RAG. Their hypothesis: to teach a pretrained model a new fact, the fact must be repeated in numerous ways, because memorizing a sentence isn't the same as knowing what it says. Your handbook won't come with ten rewordings of every policy, and you'd need to regenerate them at every change.

Retrieval puts the fact in front of the model

With RAG, the model doesn't have to remember the leave policy; it has to read it. The answer is built from text in the context, so there's something to check it against. Lewis and colleagues also showed the update path. They swapped their December 2018 Wikipedia index for one from December 2016 and asked about 82 world leaders who had changed in between. With the index matching the year asked about, the model answered 70% and 68% correctly; with mismatched ones, 12% and 4%. Same weights, different knowledge: updating meant replacing the index, not retraining.

That property is the operations story. A policy changes: re-index one page. An employee mustn't see a document: filter it out of their search. A page is deleted: it's gone from the next answer. None of this works for facts baked into weights.

What fine-tuning is actually for

Fine-tuning changes behavior: format, tone, terminology, a labeling scheme, how to handle your kind of input. It can even teach a model to use retrieval better. RAFT, from Zhang and colleagues in 2024, fine-tuned Llama 2 7B on questions paired with the right document plus distractor documents, teaching it to quote the relevant passage and ignore the rest. It beat ordinary domain fine-tuning, with or without RAG, on PubMed, HotpotQA and API-documentation datasets. The lesson isn't "never fine-tune". It's "fine-tune how the model reads, and retrieve what it reads".

The same question, from weights and from documents

The first version asks the model directly, which is what a fine-tuned model amounts to at request time. The second retrieves the pages this employee may read and sends them as search_result blocks with citations enabled.

Python ask_handbook.py
import anthropicclient = anthropic.Anthropic()reply = client.messages.create(    model="claude-opus-5-5", max_tokens=16000,    messages=[{"role": "user", "content": QUESTION}],)# Fine-tuned or not, the answer comes from the weights alone: no page# behind it, and a policy change means a new training run.print(next(b.text for b in reply.content if b.type == "text"))

Anthropic's docs describe search_result blocks for exactly this case: each needs a source, a title and text content. Citations are off by default, and all search results in a request must use the same setting. With them on, text blocks that draw on your content carry citations of type search_result_location, with the source and title you sent. A wrong answer now points to a page you can open.

Fine-tuning on your docsRAG over your docs
Where facts liveIn the weightsIn an index you control
A policy changesAnother training runRe-index the page
Evidence for an answerNothing to showThe passages, with citations
Who sees whatEveryone gets the same weightsSearch filtered per user
Best atFormat, tone, labels, task behaviorFacts, policies, anything that changes

How to apply it in your project

  1. Build the index before any training setSplit documents into passages and store each with its source, version, owner and audience. That's your knowledge layer.
  2. Filter by permission at search timeRetrieve only from documents the current user may read, so access control lives in one query and not in the prompt.
  3. Demand sources in every answerSend passages as search_result blocks with citations on, tell the model to answer only from them, and treat an uncited claim as a bug.
  4. Re-index on every changeHook the document system so an edited or deleted page is re-indexed or removed within minutes, not at the next release.
  5. Fine-tune only for behavior, with retrieval in the loopIf format or style still falls short after prompting, fine-tune on examples that include retrieved passages, some of them irrelevant, as RAFT did.

Key takeaways

  • Fine-tuning on documents teaches their style far more reliably than their facts.
  • In Ovadia and colleagues' 2023 tests on three 7B models, RAG outperformed fine-tuning for familiar and new facts.
  • New facts stick only with heavy repetition, and training on them can raise hallucinations.
  • Retrieval makes knowledge updatable, filterable per user and citable, without touching weights.
  • Fine-tune for behavior, including how to read retrieved passages, and retrieve for facts.

📚 المصادر

  1. Ovadia et al., Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs, arXiv:2312.05934
  2. Gekhman et al., Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations?, arXiv:2405.05904
  3. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, arXiv:2005.11401
  4. Zhang et al., RAFT: Adapting Language Model to Domain Specific RAG, arXiv:2403.10131
  5. Search results — Claude API Docs

التعليقات (0)