RAG vs Fine Tuning: Which One Should You Use?
Use retrieval-augmented generation (RAG) when answers depend on external facts that change, must be cited, or must be filtered by user access. Use fine-tuning when a model repeatedly fails at a stable task, such as applying a specialised classification rubric, even when it has the right information and clear instructions. Use both when the task requires reliable behaviour and current evidence.

The practical distinction is where you make the change. RAG modifies the input to the model at inference time. Fine-tuning modifies model parameters, or adds trainable parameters, before inference. A company travel assistant can retrieve the current reimbursement limit without changing model weights. A ticket classifier can learn how your support team distinguishes a billing dispute from a payment failure without retrieving a handbook on every request.
Start with a base model, clear instructions, and a small test set of realistic requests. For questions that require a source, also test the model with the correct passage supplied by hand. If the correct passage fixes the answer, build or improve retrieval. If the model still mishandles the task, investigate the instructions, the output constraints, and the model's ability before paying for training. This comparison matters because the same bad answer can come from missing evidence or from an inability to use evidence that was already present.
How Does RAG Use External Knowledge Without Training the Model?
Retrieval-augmented generation has two paths. The ingestion path parses documents, splits them into passages, and stores text with metadata such as source ID, effective date, and access rules. The request path identifies eligible passages, ranks them against the question, and adds selected text to the model prompt. Updating a document normally means updating the relevant index entries and cached results. The generator can stay unchanged. Some systems train a retriever or reranker, but that is optional and separate from fine-tuning the generator.
In dense retrieval, embeddings map queries and passages to vectors. When both vectors have unit length, their dot product equals cosine similarity. A high score indicates closeness in the embedding space. It does not establish that a passage is current, authorised, or sufficient to answer the question. Exact identifiers such as invoice codes can also be easier to find with keyword search. A hybrid retriever can combine keyword and dense candidates, then rerank them for relevance. The chapter on RAG chunking, retrieval, and reranking explains where each stage fits.
RAG can reduce unsupported claims when the evidence is both relevant and correctly used. Ask the model to cite the source IDs attached to its passages, then check that each ID was actually supplied. That check alone cannot establish that the passage supports the claim. For example, a citation to the hotel allowance section does not support a claim about taxi reimbursement. Evaluate claim support separately from citation validity.
A frequently refreshed index can answer questions about changing policies or product documentation. A live balance or order status often requires an authorised API or database query instead. An index refreshed overnight cannot report a status change that happened a minute ago. Whichever source you use, carry its effective date or observation timestamp into the response when freshness matters. For an exact lookup with no explanation needed, the application can return the structured result directly.
When Should You Fine-Tune an LLM Instead of Using RAG?
Fine-tuning with full updates, LoRA, or QLoRA makes sense when you can describe a repeatable failure and collect representative examples of the desired behaviour. Examples include extracting fields from Indian tax invoices, classifying contract clauses under a fixed rubric, or writing support replies that consistently distinguish a confirmed action from a proposed action. For invoice extraction, the model can learn how to interpret a field such as IGST, while the invoice image or text still supplies the actual amount.
In supervised fine-tuning for an instruction model, a training record typically contains an input x and a target response y. With loss restricted to the response, the objective is the mean of -log p_theta(y_t | x, y_<t) over unmasked target tokens. During training the model predicts each target token given the reference prefix. At inference it sees its own generated prefix, so a low training loss does not ensure a correct complete response. Full fine-tuning updates the base weights. LoRA keeps the base weights frozen and learns a low-rank update to selected matrices, commonly written as W_eff = W + (alpha/r)BA, where r is the adapter rank.
Fine-tuning does not always require labelled data. Continued pretraining uses text and a language modelling objective to adapt a model to domain language. Supervised fine-tuning uses target outputs to teach the desired behaviour. Neither gives you an authoritative, editable store of medical guidance, legal rules, or financial limits. If a rule can expire or a reviewer must verify it against a source, keep the rule in a document store or structured system and provide it at inference time.
Before training for format, try structured prompts and examples, schema-constrained decoding where available, and application-side validation. A schema can require a currency field and restrict its allowed values. It cannot establish that INR is the right value for a particular invoice. Fine-tuning can improve the semantic mapping when the model repeatedly chooses the wrong value despite having sufficient evidence. A trusted calculation, lookup, or validation rule is usually a better fix for errors that can be checked deterministically.
A small, approved dataset can be enough to run a useful pilot on a narrow task, but size alone says little about coverage. Check rare inputs, long documents, ambiguous examples, and negative cases where the correct answer is to abstain. Split related tickets or document templates across training and test by group rather than by individual row. Keep sensitive records out of training unless their use is explicitly authorised and managed. Removing a document from a retrieval index does not remove information already encoded in model weights.
RAG vs Fine Tuning Comparison: Data, Cost, and Failure Modes
| Decision factor | RAG | Fine-tuning |
|---|---|---|
| What changes | Selected evidence in the request context | Base weights or adapter parameters |
| Primary data | Source documents or records, plus metadata and evaluation queries | Task demonstrations for supervised tuning, or domain text for continued pretraining |
| Typical use | Answer questions from current, large, or access-controlled knowledge | Improve a recurring task, rubric, terminology, or response style |
| Update workflow | Refresh source entries, remove outdated versions, and invalidate affected caches | Train, evaluate, version, and deploy a new checkpoint or adapter |
| Serving cost | Retrieval and optional reranking add latency, and passages consume input tokens | Training adds compute upfront, while serving cost depends on the model, adapter setup, and prompt length |
| Traceability | Can preserve source IDs, versions, and passages used for a response | Training does not supply a per-claim source trail at inference |
| Typical failure | Missing, stale, distracting, or unauthorised evidence reaches the generation stage | The model overfits demonstrations, regresses on other tasks, or applies a learned pattern to the wrong input |
Compare total cost at your expected traffic. RAG has ingestion, indexing, retrieval, and extra prompt costs. Fine-tuning has data preparation, training, evaluation, and model versioning costs. If a tuned model replaces a long set of demonstrations or lets a smaller model pass the same tests, it may lower serving cost. Measure that change against the original baseline, including response latency at the 95th percentile. A hybrid system still pays for retrieving evidence when a request needs it.
Access control also changes the design. For RAG, apply user permissions and effective-date rules before passages reach the generator. If an unauthorised candidate is removed only after top-k selection, it can also crowd out eligible evidence. A shared model checkpoint is a poor place to encode facts that one user may see and another may not. Routing requests to different checkpoints does not remove the need for access controls around data, prompts, and logs.
Worked Example: RAG vs Fine Tuning for Policy Questions
Suppose an employee asks, “What is the Bengaluru hotel cap for Grade B?” A fictional policy for 2025 states ₹3,000, and the 2026 revision states ₹3,500. An older frequently used FAQ may match the question more closely than the current policy because it repeats the same wording. If k = 1 and the FAQ ranks first, the generator may return ₹3,000 with a valid citation to the wrong version. The fix is to determine eligibility from the query's effective date before ranking, then return the applicable source version with the answer.

This minimal Python example uses sentence-transformers, faiss-cpu, and NumPy. The embeddings are normalised, so IndexFlatIP performs exact cosine ranking over the filtered passages. The example uses one synthetic permission field and a single effective year. In production, resolve permissions from the authenticated identity and apply effective date ranges based on the requested date. For a large corpus, keep the index between requests and use a retrieval system that supports the required eligibility filters.
import faiss
import numpy as np
from sentence_transformers import SentenceTransformer
docs = [
{"id": "travel-2025", "year": 2025, "audience": "employee",
"text": "Bengaluru Grade B hotel cap: INR 3000 per night."},
{"id": "travel-2026", "year": 2026, "audience": "employee",
"text": "Bengaluru Grade B hotel cap: INR 3500 per night."},
{"id": "audit-2026", "year": 2026, "audience": "auditor",
"text": "Internal audit notes on travel allowance exceptions."},
]
encoder = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
def retrieve(question, year, audience, k=2):
eligible = [
doc for doc in docs
if doc["year"] == year and doc["audience"] == audience
]
if not eligible:
return []
vectors = np.ascontiguousarray(encoder.encode(
[doc["text"] for doc in eligible], normalize_embeddings=True
), dtype=np.float32)
query = np.ascontiguousarray(encoder.encode(
[question], normalize_embeddings=True
), dtype=np.float32)
index = faiss.IndexFlatIP(vectors.shape[1])
index.add(vectors)
scores, indices = index.search(query, min(k, len(eligible)))
return [
(eligible[i]["id"], eligible[i]["text"], float(score))
for score, i in zip(scores[0], indices[0])
]
hits = retrieve("What is the Bengaluru hotel cap for Grade B?",
year=2026, audience="employee")
evidence = "\n".join(f"[{doc_id}] {text}" for doc_id, text, _ in hits)
print(evidence)
# [travel-2026] Bengaluru Grade B hotel cap: INR 3500 per night.
The resulting passage can go into the model prompt with an instruction to answer from the supplied evidence and cite the source ID. The expected response is ₹3,500 per night, citing travel-2026. Because only one passage is eligible, the output demonstrates the filter, not the quality of the embedding model. An unrelated question can still return that passage. A production assistant must check evidence sufficiency and abstain when the passage does not answer the question.
Now consider an illustrative evaluation with 50 answerable questions and one annotated sufficient passage per question. The production retriever returns that passage in its top three for 40 questions, so recall at three is 40 / 50 = 0.80. Suppose the model produces 34 correct, supported answers on those 40 questions and none on the 10 misses. End-to-end supported accuracy is 34 / 50 = 0.68. When an evaluator supplies the verified passage directly for all 50 questions, the same model answers 45 correctly with support, giving 45 / 50 = 0.90.
The 22 percentage point gap gives you a reason to investigate the evidence path before training. It does not predict the exact gain from fixing the retriever: the verified-passage run also removes distractors and changes the prompt contents. Inspect failures question by question. Tune retrieval for missed passages, reduce distractions when evidence was present but ignored, and check the five verified-passage failures for stable generation errors. Add a separate set of unanswerable questions to measure whether the model abstains instead of guessing.
Can You Combine RAG and Fine-Tuning for Better Results?
Yes. A travel assistant can use RAG for the applicable allowance and a tuned generator for consistent decisions under a stable rubric. For example, the model can learn to distinguish eligible, not_eligible, and insufficient_evidence while always reading the amount, date, and exception rules from retrieved text. If a required Boolean check can instead be expressed as application logic, implement it there and use the model to extract inputs or explain the result.
When training the generator for RAG, include retrieved-style context in the examples. Use inputs with irrelevant passages, missing evidence, and conflicting versions, and give target responses that behave correctly under those conditions. Teach the model to reference source IDs in the input rather than memorising IDs and amounts. Hold out policy versions, source documents, or both, and test whether the model follows a new supplied value when it conflicts with a value seen during training. This checks that the model uses the evidence rather than repeating a familiar answer.
Compare four runs on the same held-out requests: base model alone, base model with retrieval, tuned model alone, and tuned model with retrieval. Keep the application rules and scoring criteria fixed where possible. Track grounded answer accuracy and hallucination rates alongside schema validity, task accuracy, abstention quality, and latency. For each metric, define its denominator. For example, report supported accuracy over answerable questions and correct abstention over unanswerable questions. Report slice sizes for rare cases so a gain on common requests does not hide a failure on exceptions.
Choose the simplest configuration that meets your acceptance criteria. If the base model follows the rubric once retrieval is fixed, keep RAG alone. If a fixed task improves with tuning and needs no outside facts, serve the tuned model alone. If each method fixes a different measured failure, use both and version the model, prompt, and retrieval configuration separately so you can identify which change caused a regression.
Key Takeaways
- RAG supplies external evidence at inference time. Fine-tuning adapts model behaviour before deployment.
- Keep frequently changing or access-controlled facts in an authoritative source rather than relying on model weights.
- Test with verified evidence before deciding whether a poor answer needs better retrieval or better task behaviour.
- Use schemas and deterministic rules for constraints that software can enforce or verify directly.
- Fine-tune for repeatable task failures and test on held-out document families, versions, or templates.
- Evaluate retrieval, grounding, abstention, latency, and task accuracy separately before choosing a hybrid system.
Frequently Asked Questions
Is RAG better than fine-tuning for domain-specific knowledge?
RAG is usually the better fit when domain facts must be current, cited, or removed on request. Fine-tuning is useful when the model needs to interpret domain language or apply a stable rubric more consistently. For example, retrieve the applicable tax guidance and tune only if the model still misclassifies invoice fields after seeing the correct evidence.
Does RAG require labelled training data?
A basic RAG system can use an existing embedding model and generator without labelled training data. It still needs an evaluation set with representative questions, expected answers, and, where possible, annotations for supporting passages. Labels become training data if you use them to adapt a retriever or reranker. Keep separate examples for final evaluation.
Can fine-tuning eliminate hallucinations?
No. Fine-tuning can teach a model to abstain in familiar situations or answer from supplied evidence, but it can still produce unsupported claims on unseen inputs. Check whether the evidence supports each material claim, and test cases where the right answer is unavailable. Use a trusted source or deterministic validation for values that must be exact.
How much data do I need for fine-tuning?
There is no universal minimum. Start with reviewed examples covering common cases, rare cases, and inputs for which the model should ask for clarification or abstain. Hold out related examples by document or template family. Add more training data in batches and check whether improvements on held-out cases persist without regressions on tasks that already worked.
What should I try if RAG is failing on complex questions?
First test whether the model succeeds when given every required passage directly. If it does, inspect query decomposition, filtering, chunk boundaries, and reranking. If it still fails, check whether the task requires calculations, joins, or rule execution that software can perform directly. Consider fine-tuning when a stable failure remains and you can demonstrate the desired behaviour with examples.