Mitigating Hallucination
Systematic architectural patterns to detect, measure, and eliminate false LLM generations.
Intrinsic vs Extrinsic Hallucinations
RETRIEVED CONTEXT
"Company X was founded in 2012 by Alice and Bob in Boston."
│
┌──────────────────────────┴──────────────────────────┐
▼ ▼
INTRINSIC HALLUCINATION EXTRINSIC HALLUCINATION
"Company X was founded in 2018 in Boston." "Company X was acquired by Google in 2020."
(Directly CONTRADICTS provided context!) (Plausible claim, but UNSUPPORTED by context!)
5-Layer Hallucination Defense Stack
HALLUCINATION DEFENSE STACK
┌──────────────────────────┬──────────────────────────┬──────────────────────────┬──────────────────────────┐
│ 1. SYSTEM REFUSAL RULES │ 2. LOW TEMPERATURE (T=0) │ 3. CITATION ENFORCEMENT │ 4. SELF-CHECK & GUARDRAILS│
├──────────────────────────┼──────────────────────────┼──────────────────────────┼──────────────────────────┤
│ "Answer using ONLY text. │ Shrinks logit entropy; │ Force inline citations; │ RAGAS Faithfulness audit;│
│ If facts are missing, say│ disables stochastic tail │ verify claims against │ drop ungrounded claims │
│ 'I don't know'." │ sampling. │ source text spans. │ via secondary NLI model. │
└──────────────────────────┴──────────────────────────┴──────────────────────────┴──────────────────────────┘
SelfCheckGPT: Zero-Resource Detection
How do you detect hallucinations when no ground-truth reference text exists?
User Prompt: "Tell me about Dr. John Doe's research"
│
▼
Sample N = 5 Stochastic Generations (T = 0.7)
│
Sample 1: "Pioneered quantum algorithms at MIT."
Sample 2: "Won Nobel prize in Biology at Harvard." ──► Facts fluctuate wildly!
Sample 3: "Founded a robotics company in Tokyo." HIGH FACTUAL DISAGREEMENT = HALLUCINATION!
If generated facts fluctuate across samples, the claim is a hallucination. If facts stay identical ("Pioneered quantum algorithms" across all 5 samples), the claim is factually grounded in parametric memory.
Say this out loud
"Hallucinations are intrinsic (contradicting context) or extrinsic (unsupported claims). We eliminate hallucinations using low-temperature sampling T=0, strict system prompts requiring explicit 'I don't know' refusals, and inline citation enforcement. For open-ended text, SelfCheckGPT detects hallucinations by sampling multiple completions to flag fluctuating claims."
Follow-ups to expect
- What is Chain-of-Verification (CoVe)? A 4-step framework: 1) Draft initial response, 2) Plan verification questions, 3) Answer verification questions independently to avoid bias, 4) Rewrite response incorporating verified answers.
- What is Sycophancy Hallucination? When an LLM agrees with false assumptions in the user's prompt (User: "Why did Einstein invent the iPhone?", LLM: "Einstein invented the iPhone because..."). Mitigate via RLHF preference tuning against sycophantic responses.
Check yourself
What is the difference between Intrinsic Hallucination and Extrinsic Hallucination in LLM outputs?