Mitigating Hallucination

There is no single fix for hallucination, so you stack several.

🔴 advanced5 min readllm
There is no single fix for hallucination, so in practice you stack several. The biggest is grounding: retrieve real documents and tell the model to answer only from them. Ask it to cite sources so claims can be checked. Use a low temperature so it picks likely words over creative ones. Tell it plainly that saying it does not know is fine. You can also ask the same question several times and flag answers that disagree, since invented details change between attempts while real facts stay put.

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 reduce 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