Skip to content

Hallucination Detection

Hallucination in large language models refers to when an LLM generates plausible but false or unfactual statements, sometimes called "confabulation." This is a critical problem for deploying LLMs in fact-sensitive applications, and a key source of AI-generated misinformation. Hallucination detection methods aim to identify when LLM outputs contain false claims without necessarily requiring external knowledge bases or model internals access.

The hallucination problem

LLMs like GPT-3, GPT-4, and other transformer-based models are trained on massive text corpora and learn patterns of language fluency and factuality together. However, they can generate responses that:

  • Sound plausible and coherent
  • Contain false factual claims not grounded in training data
  • Appear to follow a logical structure but contain fabricated evidence or reasoning
  • Diverge substantially from the model's actual knowledge when prompted differently

This divergence is particularly problematic because humans are often poor at detecting the boundary between fluent, factual output and fluent, false output. Hallucinations enable sophisticated misinformation generation at scale.

Detection approaches

Hallucination detection strategies vary by what information is available:

Black-box approaches (text-in, text-out only):

  • SelfCheckGPT: Zero-Resource Black-Box Hallucination Detection for Generative Large Language Models — Samples multiple completions and measures consistency; factual statements are stable across samples while hallucinated facts diverge. Achieves 93.42 AUC-PR with no external resources.
  • Self-evaluation: Prompting an LLM to check its own output for consistency (often effective but computationally expensive)
  • Consistency scoring: Measuring semantic agreement across multiple sampled responses

Grey-box approaches (access to output probabilities):

  • Token-level probability: Using the model's output probability distribution over tokens; factual tokens often have lower uncertainty (higher probability) than hallucinated tokens
  • Entropy-based metrics: Computing Shannon entropy of the output distribution as an uncertainty measure

White-box approaches (access to model internals):

  • Hidden representation analysis: Examining internal model states to detect when the model "knows" less about certain outputs
  • Attention pattern inspection: Analyzing which parts of input the model relies on for different outputs

Limitations

Current hallucination detection methods face fundamental challenges:

  • Domain dependence: Methods trained on one domain (e.g., biographies) may not generalize to others (e.g., news, scientific claims)
  • Computational cost: The most effective methods require multiple model queries or external fact-checking resources
  • Coverage gaps: No method reliably detects all hallucinations at near-zero false positive rate; practical systems require trade-offs
  • Fine-grained factuality: Most methods work at sentence or passage level; detecting hallucinations in individual facts, relations, or numerical claims remains challenging
  • Adversarial robustness: Models can be prompted to make hallucinations consistent across samples, defeating consistency-based detection

Connection to misinformation

Hallucination detection is essential for preventing AI-generated misinformation. As LLMs become more capable and more widely deployed, the ability to distinguish their factual from non-factual outputs determines whether they can be safely used in high-stakes domains (news, medical, legal, scientific). Unchecked LLM hallucinations feed automated misinformation generation pipelines and undermine trust in AI systems.

Key papers in this wiki

Papers on this topic