LLMs & GenAI

Mitigating Hallucination

Systematic architectural patterns to detect, measure, and eliminate false LLM generations.

🔴 advanced5 min readllm
LLM Hallucination refers to generated text that is factually incorrect, nonsensical, or ungrounded in provided context. Hallucinations stem from parametric memory corruption, over-generalization, exposure bias, and sycophancy. Mitigation strategies span RAG grounding, low-temperature sampling (T → 0), Self-Check GPT (sampling multiple paths to measure factual consistency), Strict System Prompt Refusal rules ("If answer is unknown, respond 'I don't know'"), and Citation Enforcement.

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

Check yourself

Question 1 of 3

What is the difference between Intrinsic Hallucination and Extrinsic Hallucination in LLM outputs?

More in LLMs & GenAI

See all →
Pretraining → SFT → RLHF5 minFine-Tune vs RAG vs Prompt: Choosing5 minRetrieval-Augmented Generation5 min