← Back to Series / Day 19 of 20
🛡️
RAG Series · Day 19

Stopping Hallucination

A three-layer strategy — strict prompt grounding, Is Supported verification, and better retrieval — for near-zero hallucination.

What Is Hallucination
🛡️

When AI Confidently Makes Things Up

Hallucination occurs when an LLM generates facts that sound plausible but are not in the retrieved context — or are simply wrong. LLMs are probabilistic: when they do not have the right answer, they still produce the most statistically likely next words. The result is confident, fluent, wrong information.

⚠️ Hallucination is dangerous because the LLM presents fabricated information with the same confidence as verified facts.
Root Causes
🔍

Why Hallucination Happens in RAG

Irrelevant documents retrieved — LLM never received useful context to work from
No strict prompt grounding — LLM is free to go beyond the provided context
Missing information — Topic is not in your documents — LLM fills the gap with guesses
No verification step — Generated answer is never checked against the source
Layer 1 Prevention
🏛️

Strict Prompt Grounding

The most effective and simplest technique — tell the LLM explicitly to answer only from the provided context. This one instruction dramatically reduces hallucination in most RAG systems.

"Answer ONLY from the provided context below"
"If the context is insufficient, say: I don't know"
"Do not use your general knowledge or make assumptions"
"Do not state anything that is not explicitly in the context"
Layer 2 Prevention
🔒

Is Supported Verification Check

After generation, verify the answer against the retrieved context. An LLM evaluator reads both the answer and the source documents and assigns a support level — fully supported, partially supported, or not supported.

Fully Supported — Every claim came from the retrieved documents — safe to return
Partially Supported — Some claims are fabricated — revise the answer and retry
Not Supported — Pure hallucination — reject, retry, or return I don't know
Layer 3 Prevention
🔗

Better Retrieval = Less Hallucination

If retrieval is poor, no prompt instruction will save the answer. Better retrieval means the LLM always has accurate, relevant context to draw from — leaving no gaps it needs to fill with guesses.

💡 Anti-hallucination stack: Better Retrieval + Strict Prompt Grounding + Is Supported Verification = Near-zero hallucination in production.

Stopping hallucination requires a multi-layer approach. Layer 1 — strict prompt grounding forces the LLM to use only provided context. Layer 2 — the Is Supported check verifies every claim post-generation. Layer 3 — better retrieval ensures relevant context exists. Three layers together produce a production RAG system where hallucination is the exception, not the rule.