Hallucination Detection — Factual Consistency Checking for LLM Outputs

Machine Learning
Introduced by
Established as a formal task by Maynez et al. (2020); SelfCheckGPT zero-resource variant by Manakul et al. (2023)
Year
2020 (faithfulness framing); 2023 (SelfCheckGPT)
Type
NLP evaluation / quality-assurance pipeline

What does it do?

Hallucination detection is a natural-language-processing pipeline that measures whether the output of a language model is consistent with a reference source document or with verifiable facts.

Formalised as a faithfulness evaluation task by Maynez et al. (2020) and extended to a zero-resource black-box setting by Manakul et al. (2023) with SelfCheckGPT, the approach is used to flag unreliable LLM outputs in high-stakes domains such as medicine, law, and journalism.

The intuition behind the method

Large language models generate fluent, confident-sounding text that can nevertheless contradict the very source they are supposed to summarise, or assert facts that are simply wrong. Hallucination detection treats this as a measurable mismatch: it takes the model output and a reference — a source document, a knowledge base, or consistency across multiple model samples — and asks whether the claims in the output are actually supported. The result is a score or label that tells you how much of the generated text can be trusted.

History

The systematic study of faithfulness in abstractive summarisation was formalised by Maynez et al. (2020) at ACL, who introduced the distinction between intrinsic hallucinations (contradicting the source) and extrinsic hallucinations (introducing unsupported information). As large generative language models became widespread, the problem extended beyond summarisation to other grounded generation tasks. Manakul et al. (2023) proposed SelfCheckGPT, which detects hallucinations without a reference document by exploiting the consistency of a model across multiple stochastic samples: if the model knows a fact, it tends to state it consistently, while confabulated details tend to vary. Maynez et al. (2020) addressed reference-grounded faithfulness, whereas Manakul et al. (2023) introduced the reference-free, sampling-based paradigm.

When to use it

Hallucination detection applies whenever a language model generates text that is supposed to be grounded in a source document or in verifiable facts. Abstractive summarisation, retrieval-augmented generation, medical report drafting, legal document analysis, and news generation are the canonical use cases. Reference-based verification (NLI or QA) requires an available source document or verification basis. Without one, only the sampling-based SelfCheckGPT variant can operate, and it requires the ability to draw multiple samples from the model. The method does not suit purely creative generation where factual grounding is not expected. Evaluating a detector needs a labelled set of reference-output pairs annotated for faithfulness; a small set gives unstable precision, recall, and F1 estimates. The minimum sample size recorded for this method is only a bare floor and does not make a set adequate; stable estimates generally require a substantially larger labelled set.

Limitations and considerations

  • NLI and QA verifiers are themselves language models and can fail on complex, multi-hop, or ambiguous claims.
  • The sampling-based approach (SelfCheckGPT) requires multiple inference calls per prompt, which increases computational cost and latency.
  • Performance depends on the quality and coverage of the reference source; incomplete or outdated references lead to false positives.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Provides an automated way to audit LLM outputs for factual consistency before they reach end users.
  • Multiple verification strategies suit different situations: NLI and QA checks against a reference when a source document exists, and the SelfCheckGPT sampling approach when only repeated sampling from the model is possible.
  • Fine-grained claim-level scoring reveals exactly which sentences are hallucinated, enabling targeted correction.

Applications

  • Verifying abstractive summaries of medical literature or clinical notes for factual accuracy before clinical use.
  • Quality-gating retrieval-augmented generation (RAG) pipelines to ensure that answers cite information actually present in the retrieved documents.
  • Auditing AI-generated news articles or press releases for unsupported claims before publication.
  • Filtering legal document drafts produced by LLMs to flag clauses that are not grounded in the cited statutes or case law.

How it works

How it works

1

The model-generated text and the associated reference material are assembled. The reference can be a source document provided to the model (for summarisation or retrieval-augmented generation), a structured knowledge base, or, in the zero-resource SelfCheckGPT setting, multiple stochastic samples drawn from the same model for the same prompt. Having both the claim and its reference in hand is the prerequisite for any verification step.

2

The generated text is broken into verifiable units, typically individual sentences or atomic claims. Decomposition matters because a response can be partly faithful and partly hallucinated; evaluating the whole response as a single unit masks fine-grained errors. Claim splitting can be done with a dedicated extractor model or by treating each sentence as one unit.

3

Each claim is checked against the reference. In an NLI-based approach, a natural-language-inference model decides whether the reference entails, contradicts, or is neutral toward the claim. In a QA-based approach, a question is generated from the claim and answered against the reference; matching the original answer confirms support. In the SelfCheckGPT sampling approach, consistency across multiple model samples serves as a proxy for factuality: facts the model reliably knows tend to recur across samples, whereas hallucinated details tend to vary.

4

The per-claim verification outcomes are aggregated into a faithfulness or hallucination score for the full response. The aggregation rule is not fixed by the method and must be stated explicitly, because the meaning of the final score depends on it. A common choice is the hallucination rate: the number of claims judged unsupported divided by the total number of claims in the response. A rate of zero means every claim was supported, and a higher rate means a larger share of the response is unsupported. The method does not supply a cut-off, so the threshold at which a response is flagged must be calibrated on a labelled set of reference-output pairs before use. The score is then used to flag, filter, or rank outputs; in a deployment pipeline, responses that exceed a chosen hallucination-rate threshold (or fall below a chosen faithfulness threshold, depending on the rule used) can be withheld or sent for human review. Evaluating the detector itself requires a labelled set of reference-output pairs annotated for faithfulness.

Common pitfalls

  • Using a single whole-response consistency score without decomposing into claims obscures localised hallucinations that affect only part of the output.
  • Applying an NLI verifier trained on one domain (e.g., news) to a different domain (e.g., clinical text) without fine-tuning degrades reliability significantly.
  • Conflating faithfulness to the source with factual correctness — a model can faithfully reproduce an incorrect source document, so source quality must be independently guaranteed.
  • Treating a consistency score from the sampling approach as equivalent to ground-truth factuality, without a labelled evaluation set, makes it impossible to calibrate the threshold.

Frequently asked questions

What is the difference between an intrinsic and an extrinsic hallucination?

An intrinsic hallucination directly contradicts information present in the source document, for example, a summary that says a patient was treated with drug A when the source says drug B. An extrinsic hallucination introduces information that is neither supported nor contradicted by the source, such as adding a biographical detail that does not appear anywhere in the input. The distinction matters because extrinsic hallucinations are harder to catch with a simple contradiction check.

Do I need a reference document to run hallucination detection?

For NLI-based and QA-based verification you do need a reference source. The SelfCheckGPT approach is the exception: it draws multiple samples from the model for the same prompt and treats cross-sample consistency as a proxy for factuality, so no external reference is required. You do, however, need the ability to call the model multiple times, and you need to interpret the resulting consistency score carefully.

Which verification approach should I use: NLI, QA-based, or sampling?

If you have a well-defined source document (for example, in a retrieval-augmented generation pipeline or a summarisation task), an NLI model is a natural starting point because it gives per-claim entailment labels. If question generation is feasible, QA-based verification can be more precise on factual claims. If you have only black-box access to a model and no reference document, SelfCheckGPT is the appropriate choice. When several methods are combined, the combination rule matters: requiring all methods to agree before a claim is flagged lowers the flag rate, which reduces false positives but can increase false negatives, whereas flagging when any method flags does the reverse. In high-stakes domains, the right rule depends on the relative cost of missed hallucinations and of unnecessary human review.

How is hallucination detection evaluated?

A labelled dataset of reference-output pairs annotated by human experts for faithfulness is the reference standard. The detector's predictions are compared against these labels using precision, recall, and F1 at the claim or sentence level. The choice of benchmark should be stated explicitly, since results depend on the labelled data used.

Related methods

Sources

  1. Maynez, J., Narayan, S., Bohnet, B., & McDonald, R. (2020). On Faithfulness and Factuality in Abstractive Summarization. Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics (ACL), 1906-1919.

    Open publication reference
  2. Manakul, P., Liusie, A., & Gales, M.J.F. (2023). SelfCheckGPT: Zero-Resource Black-Box Hallucination Detection for Generative Large Language Models. Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing (EMNLP), 9004-9017.

    Open publication reference