How to Reduce Hallucinations in RAG Systems

By
Tom Dallimore
Published

Here is a support ticket I have seen in some form more times than I would like.
A customer asks the help-centre bot how long they have to request a refund. The bot replies, with total confidence, "You can request a refund within 14 days of purchase." The retrieved document says 30 days. It was sitting right there in the prompt.
Lovely.
That is a rag hallucination. The model was not short of information. It had the correct answer in front of it and still produced a beautifully written wrong one.
Most teams adopt retrieval augmented generation expecting it to make the hallucination problem go away. Give the large language model real documents instead of leaning on its training data, and surely it stops inventing things. It does not. RAG reduces AI hallucinations. It does not remove them.
The short version: most hallucinations in RAG are pipeline problems, not model problems. The wrong documents get retrieved, the right ones get buried in noise, or the prompt quietly lets the model fill gaps with guesses. Fix retrieval first, then the context, then the prompt, and then add detection on top. Swapping to a bigger model is usually the last thing that helps, not the first.
If you are new to this, start with my RAG pipeline guide. If you already know the basics, carry on.
What Counts as a Hallucination in RAG?
I use a narrow definition, because a narrow definition is one you can measure:
A rag hallucination is any claim in the final answer that is unsupported by, or contradicts, the retrieved context.
That is different from a generic artificial intelligence hallucination, where a model with no grounding at all invents facts from patterns in its training data. In a rag system, you judge the answer against the retrieved documents, not against the open web or some abstract idea of truth. That changes how you diagnose the problem and how you fix it.
Take the refund example. The provided context says "returns accepted within 30 days". Three things can go wrong:
Contradicted. The answer says "no returns after purchase". The context says the opposite.
Unsupported. The answer adds "and we refund shipping costs too". Nothing in the context documents mentions shipping.
Missing but harmless. The answer skips a detail about international orders that had nothing to do with the user's question. Not a hallucination. Just a shorter answer.
One more distinction matters. If the source document is wrong and the model repeats it faithfully, that is not a rag hallucination. The model did its job. Your data did not. Users will lose trust either way, so both need fixing, but they need different fixes.
And this is not a theoretical problem. A Stanford study of legal AI research tools found they hallucinated on somewhere between 17% and 33% of queries, including products marketed as "hallucination-free". These were serious generative AI products built on retrieval. It still was not enough.
Why RAG Still Hallucinates
A vanilla LLM hallucinates because it has no external knowledge to anchor it. Ask a base model "What is Fetch Hive's uptime SLA?" and it might happily tell you 99%, despite never having seen a single page of our documentation.
A RAG system with the right document in its index can still get it wrong. Say the retrieved SLA document states 98% uptime and the model answers 99%. The evidence existed. The generation step just did not use it properly. The model's own parametric memory (whatever it absorbed during training) competes with the retrieved information, and sometimes the memory wins.
Turning the temperature down to zero does not fix this, by the way. It makes the model consistently wrong instead of randomly wrong.
Dimension | Vanilla LLM | RAG system |
|---|---|---|
Where facts come from | Training data only | Retrieved documents plus model priors |
What you judge against | World knowledge | The retrieved context |
How it hallucinates | Pure invention | Ignoring, misreading or overextending the evidence |
Main fixes | Prompt engineering, fine tuning | Retrieval tuning, context management, guardrails |
The retrieval layer adds grounding. It does not remove the generator's habit of filling gaps.

Where Hallucinations Enter the RAG Pipeline
A typical rag pipeline looks like this:
Ingest → Chunk and index → Rewrite query → Retrieve → Rerank → Assemble context → Generate → Check
Every arrow is a place where things go wrong:
Ingestion. Documents are outdated, badly parsed or missing entirely. If the document is not in the index, no amount of clever prompting will find the correct answer.
Chunking and indexing. Chunks split meaning at awkward boundaries, a table loses its header, or the metadata is wrong.
Query understanding. The system misreads the user's query and retrieves for the wrong question. This fails silently.
Retrieval. The relevant documents are not in the top results, so the model guesses.
Context assembly. Too many chunks, in a bad order, with contradictions between them.
Generation. Even with perfect context, the model may generalize, round numbers, or blend in domain specific knowledge from pretraining.
Post-processing. Citations point to the wrong source, or formatting mangles an otherwise correct answer.
In my experience, most hallucinations show up before the generation step. Retrieval failure is the most common root cause by a distance. A single wrong answer is often several weaknesses stacked together: a missing document, plus weak reranking, plus a prompt that allows the model to infer. Treat the pipeline like a fault tree and find the stage that actually broke.

Six Hallucination Patterns Worth Knowing
Researchers benchmarking LLMs on RAG tasks (the RGB benchmark is the usual reference) group failures into a few abilities. I add two practical ones from production. Each points to a different fix.
Noise robustness. The model gets distracted by irrelevant chunks that are semantically similar to the question. An HR bot retrieves OCR-garbled text about "potfo1io returns" and produces a nonsense benefits answer, even though the right answer is elsewhere in the context.
Negative rejection. No supporting document exists and the model answers anyway instead of saying it does not know. A policy bot invents a refund timeline for a product that was never documented.
Information integration. The model combines details from several documents incorrectly. 2023 pricing plus 2024 terms equals a plan that never existed.
Counterfactual robustness. The retrieved sources contradict each other (or contain an error) and the model fails to resolve it. Think pre-amendment and post-amendment regulations blended into one answer.
Ambiguous queries. "What is the enterprise SLA?" with no region or product. Retrieval grabs whatever looks closest and the model guesses the rest.
Wrong citations. The model says "Section 4.2 confirms this" and the contract has no Section 4.2.
Fix Retrieval First
If you only remember one thing from this article, make it this: the cheapest way to reduce hallucinations is to get the right evidence into the prompt. If the right documents are not retrieved, the model is left generating accurate answers from evidence it does not have. That is not a model problem. That is an empty shelf.
The things I would look at, in order:
Use hybrid search. Vector search with an embedding model is brilliant at meaning. Keyword search (BM25) is brilliant at exactness: product codes, error IDs like FH-2047, policy numbers. Run both and merge the results. My Hybrid RAG guide covers how.
Filter on metadata before you rank. Effective date, product line, region and document version let you narrow the search before similarity scores are even computed. This is how you stop a deprecated 2022 policy turning up at rank one.
Chunk along the document's structure. Chunks that are too small lose context. Chunks that are too large bury the relevant passage in noise. Respect section boundaries and keep tables whole. More in my RAG chunking guide.
Add a reranker. Retrieve broadly, then let a cross-encoder rescore the candidates against the actual question.
Here is what a reranker does for a question about current uptime:
Chunk | First-stage score | Reranker score | Kept? |
|---|---|---|---|
SLA v2.1, Section 3: Uptime | 0.82 | 0.94 | Yes |
SLA v1.0, Section 3: Uptime (deprecated) | 0.79 | 0.41 | No |
Marketing FAQ: "Enterprise Plans" | 0.71 | 0.38 | No |
The first-stage scores are almost a tie. The reranker is what separates the current SLA from its deprecated twin. One warning: reranker scores are not comparable between models, so do not copy someone else's cut-off. Pick your threshold from your own labelled examples. My RAG reranking guide goes deeper on when it is worth the latency. If retrieval is still weak after all that, corrective RAG adds a step that grades the retrieved documents and searches again before the model answers. My adaptive RAG vs corrective RAG guide compares the two approaches.
Rewrite the Query Before You Search
Query rewriting turns messy, context-dependent questions into something the retriever can actually match. It is boring. It also works.
Resolve pronouns from chat history. The user asks "What about the enterprise tier?" after a conversation about API pricing. Rewrite: "What is Fetch Hive's enterprise tier pricing for the API product?"
Add the implicit constraints. The user asks "When does the new policy take effect?" Rewrite: "When does the updated data retention policy take effect?", plus a filter for the latest version.
Expand internal acronyms. "What is the SRT for P1s?" becomes "What is the service response time for Priority 1 incidents under the enterprise SLA?"
The rewriter takes the question, the conversation history and, ideally, the list of metadata fields you can filter on. It produces a retrieval query, not an answer. Better queries mean better relevant context, which means fewer guesses downstream.
Stop Stuffing the Context Window
More chunks do not mean fewer hallucinations. Past a point, they mean more.
Selection. Every irrelevant chunk competes with the relevant information for the model's attention and brings its own chance of contradicting the good one. Take fewer, better chunks, and prefer a set that covers different parts of the question over five near-duplicates.
Ordering. The "Lost in the Middle" research showed models use information at the start and end of a long context far better than information in the middle. Put your strongest chunks first, not at position three of seven.
Compression. For long sources, summarize or extract the relevant sections first. You cut input tokens, save computational resources and keep the semantic coherence of what the model reads.
As a starting point, I would keep assembled context to a few thousand tokens for simple questions and only go bigger when your evaluation shows it helps. Big context windows are a capability, not an instruction.
Let the Model Say "I Do Not Know"
A model that must answer every question will invent answers to the ones your corpus cannot support. That is negative rejection failing, and it causes a lot of ungrounded responses.
Make abstention a feature:
Say it in the prompt. "If the documents do not contain the answer, reply: I do not have enough information to answer that."
Test it. Build test cases where none of the retrieved sources are relevant and check that the model declines instead of improvising.
Watch the rate in production. An abstention rate near zero usually means the model is over-answering, not that your knowledge bases are perfect.
Catch the weasel words. "It is possible that…" with no evidence behind it is a hallucination wearing a fake moustache.
Handle Conflicting and Outdated Sources
Real knowledge bases are full of contradictions. Old policies sit next to new ones. Versioned documents pile up without anyone marking them deprecated.
Example: a company updated its data retention policy in January 2025, but the 2022 version is still indexed. Someone asks about current retention rules. A naive system retrieves both and produces this:
"Data is retained for 5 years, with reviews every 2 years."
The 5 years came from the 2025 policy. The 2-year review cycle came from the 2022 one. Each half is real. The whole is misleading information.
What you want instead:
"Under the current policy (effective January 2025), data is retained for 5 years with annual reviews. An older version had a different review cycle and has been replaced."
To get there: filter by effective date, deprecate or delete old versions at ingestion, score sources by reliability, and tell the model explicitly to prefer the most recent source and flag conflicts rather than blend them.
Complex Queries Need a Plan
Complex queries like "Compare our 2023 and 2024 enterprise pricing in Europe" need several documents, a geography filter and an accurate comparison. Three things go wrong: retrieval finds 2024 but not 2023, the model answers from half the evidence, or it merges numbers from different documents.
Common sense reasoning will not fill a gap in the evidence when the task needs exact figures. What helps:
Break the question into sub-queries and retrieve for each one separately.
Ask the model to note what each document says before it compares them.
Require a citation per claim, so every number points to a specific source.
Include multi-hop questions in your test set, built from your own traffic.
This is the territory where agentic retrieval (search, check the results, search again) starts to earn its keep. It also costs more, so use it where the questions need it. My agentic RAG guide walks through how RAG agents plan, retrieve and verify.
Prompt Engineering Helps, But It Is Not Magic
Prompt engineering cannot fix a broken retriever. Once retrieval is decent, though, a good prompt makes a real difference.

The naive version:
A better version:
Abstention, citations and a ban on outside knowledge do most of the work. Asking the model to quote its supporting evidence before writing the final answer can help too, though I would test it on your data rather than assume it does.
Do not go overboard. A 2,000-word system prompt begging the model not to hallucinate eats tokens that should be going to evidence. Keep it short and direct.
Better Data Beats Better Prompts
Plenty of hallucinations are really data problems: outdated documents, duplicates that disagree, OCR errors, missing fields. Garbage in, garbage retrieved.
Where a fact lives in a structured system (prices in a product catalog, plan details in a billing database), fetch it from there rather than from a PDF that describes it. Structured sources leave much less room for interpretation. A sensible pattern: retrieve the documentation passage, cross-check it against the live pricing table, and flag any mismatch instead of letting the model pick a winner.
Knowledge graphs can help with questions about relationships between entities ("Which EMEA enterprise customers have open billing tickets?"), but they are a lot of engineering. I would only go there once ordinary retrieval is solid and your test set shows a clear gap.
How to Measure Hallucinations
You cannot reduce what you do not measure. These are the metrics I would track (my RAG evaluation guide covers them properly):
Context recall. Did the retrieved context contain the information needed? Low recall means missing evidence.
Context precision. How much of the retrieved context was actually useful? Low precision means noise.
Faithfulness. Supported claims divided by total claims, from 0 to 1. This is your main hallucination metric.
Answer relevancy. Did the answer address the specific question? A model can be faithful and still useless.
Completeness. Did the answer cover everything the context supported?
The useful bit is reading them together. High recall and low faithfulness: the evidence was there and the model ignored it, so look at generation. Low recall and high faithfulness: the model behaved, but it was working from too little, so look at retrieval.
A worked example. The answer says "Fetch Hive guarantees 99.5% uptime and offers rollback credits proportional to downtime." The uptime figure is in the context. The rollback credits are not.
Metric | Score | What it tells you |
|---|---|---|
Context recall | 1.0 | Everything needed was retrieved |
Context precision | 0.5 | One of two chunks was noise |
Faithfulness | 0.5 | One of two claims was unsupported |
Answer relevancy | 0.9 | On topic, just partly invented |
That is a generation overreach. For legal, medical or financial answers, I would want faithfulness consistently above 0.9 before letting anything near users.

Hallucination Detection Techniques
Hallucination detection in RAG has an advantage that general chatbots do not. You know exactly what evidence the model was given, so you can check the answer against it. There are four families of techniques for detecting hallucinations:
LLM-as-a-judge. A second model splits the answer into individual claims and labels each one against the retrieved context. Most accurate, most expensive, adds latency. Tools like RAGAS implement faithfulness this way.
Semantic similarity. Embed each answer sentence and compare it with the retrieved chunks. If no chunk is close, the sentence is suspicious. Cheaper, but it has a nasty blind spot: "14-day refund policy" and "30-day refund policy" look almost identical to an embedding. Similar is not the same as correct.
Lexical overlap. ROUGE-style or token-overlap scores. Very cheap, good as a pre-filter, bad at paraphrases and subtle contradictions.
Rules. Check that cited document IDs exist, that dates and version numbers match the sources, that quoted prices fall in allowed ranges. No model calls, limited coverage, excellent for the failures you already know about.
There are other methods too. SelfCheckGPT-style approaches sample several answers to the same question and treat disagreement between them as a warning sign, which is handy when you have no reference to check against. In RAG, though, you have the context, so checking against it directly is usually the better use of your budget.
Here is a simplified judge prompt:
In production, combinations work best:
Lexical pre-filter flags answers with almost no overlap with the context.
Semantic check handles the borderline ones, using the same kind of embeddings you use for retrieval.
LLM judge makes the call on anything flagged or high-risk.

Match Detection to the Risk
Running an LLM judge on every response to your office-snacks FAQ bot is a very thorough way to set money on fire. Skipping checks entirely on a medical triage bot is a quick way to end up in the news.
Low budget | Higher budget | |
|---|---|---|
Low risk (FAQs, general info) | Lexical overlap plus basic similarity | Similarity plus spot-check LLM judge |
High risk (legal, medical, finance) | Similarity plus rule checks | LLM judge, citation checks and human review |
This is also the "when not to" angle. If your rag applications answer low-stakes questions and users can easily check the source, you probably do not need a judge model in the request path. Sample a slice of traffic offline instead and spend the latency budget on better retrieval, which does more for overall performance anyway.
Guardrails: The Hallucination Veto
Output guardrails check the generated responses before a user sees them. The simplest useful version is a veto:
The answer gets a hallucination score from your detector.
If it crosses your threshold (say 0.3 for a high-risk domain), a fallback kicks in.
The fallback regenerates with a stricter prompt, asks the user a clarifying question, or declines.
Every vetoed answer is logged so you can fix the pipeline, not just the response.
I like keeping business rules (prices in range, no promises the contract does not make) separate from the generic faithfulness check. You can change one without breaking the other.
For high-traffic, low-risk queries, run the check asynchronously and review later. For high-risk ones, run it before the answer is sent.
Test Before You Ship
Spot-checking ten questions in a notebook is not testing. Build a proper set that covers:
Clear questions with one obvious answer in the corpus.
Ambiguous questions like "What is the SLA?" with no product named.
Questions with no answer in the corpus, to test abstention.
Multi-hop questions that need several documents.
Adversarial prompts that try prompt injection or push the model outside its rules.
Then turn every real production failure into a regression test. When a user reports a wrong answer, save the query, the context and the expected behavior. Over a few months, that becomes the most valuable test set you have, because it is made of your actual failures.
Run it on every document update, prompt change and model swap. A jump in hallucination rates after a re-index is much nicer to find in CI than in a customer email.
Observability: Find Out Where It Broke
When a user reports a hallucination, the question is not "why is the model so stupid?". It is "which stage failed?". You can only answer that if you logged what happened.
For every request, I would store:
Field | Why |
|---|---|
Original and rewritten query | Catch query rewriting mistakes |
Retrieved document IDs and scores | See what retrieval found and how confident it was |
Reranker scores | Spot good chunks being demoted |
Assembled context | Know exactly what the model saw |
Model, prompt version, temperature | Reproduce the call |
Detection score | Faithfulness for that request |
Final answer and user feedback | The outcome, and whether anyone complained |
With that trace you can identify in minutes whether it was a retrieval failure (wrong documents), a data failure (right document, stale content) or a generation failure (right context, wrong answer).
WARNING: Shameless self-promotion incoming. This is why I care so much about tracing in Fetch Hive. Every step of a workflow, from the query rewrite to the retrieved chunks to the llm generated responses, is logged so you can see where a hallucination came from instead of guessing. You do not need Fetch Hive to do this, but you do need something that does it. Our AI observability page has the details if you are curious.
Example: Hardening an Internal Policy Assistant
Here is a composite of a pattern we see a lot. A company launches an internal assistant for 1,200 employees covering benefits, PTO and compliance. Basic vector search, default chunking, a generic prompt, no detection.
Within a week, the complaints arrive. The bot quotes PTO accrual rates from a 2022 handbook that was updated in 2024. It invents a "bereavement leave extension". It cites handbook sections that do not exist.
The traces show three causes:
Both handbook versions were indexed with no effective-date metadata.
Fixed-size chunking cut the PTO accrual table into three pieces.
The prompt never told the model it was allowed to say "I do not know".
The fixes were not exciting. Date metadata with a filter to current versions. Chunking along section boundaries. Hybrid search with a cross-encoder reranker. An abstention rule in the prompt. An LLM judge with a veto on high-risk topics.
Illustrative before-and-after numbers for that kind of change:
Metric | Before | After |
|---|---|---|
Faithfulness | 0.70 | 0.93 |
Reported hallucinations per 1,000 queries | ~48 | ~6 |
Correct abstentions on unanswerable questions | 30% | 88% |
Same model. Better pipeline. That is the whole bargain.
A Practical Checklist for Reducing RAG Hallucinations
If I were mitigating hallucinations in a RAG system tomorrow, this is the order I would work in:
Clean the data. Remove stale versions, fix OCR, add effective dates and version metadata.
Fix retrieval. Hybrid search, metadata filters, sensible chunking, a reranker.
Rewrite queries. Resolve pronouns, expand acronyms, add the filters the user implied.
Trim the context. Fewer, better chunks, strongest first.
Allow abstention. Make "I do not know" an acceptable answer, and test it.
Tighten the prompt. Context only, cite everything, no outside knowledge.
Add detection. Layered checks, sized to the risk.
Log everything. You cannot fix what you cannot see.
Test continuously. Every production failure becomes a regression test.
The Takeaway
RAG hallucinations are mostly retrieval and context problems. They are measurable, and they are fixable with fairly boring engineering.
The model is rarely the weakest link. The pipeline around it usually is. Pick one stage from the checklist, measure it this week, and fix what the numbers tell you to fix.
The goal is not a smarter model. It is getting the right evidence into the prompt before the model starts talking.
Share this post



