A Token-level Reference-free Hallucination Detection Benchmark for Free-form Text Generation

Tianyu Liu, Yizhe Zhang, Chris Brockett, Yi Mao, Zhifang Sui, Weizhu Chen, Bill Dolan

Abstract: Large pretrained generative models like GPT-3 often suffer from hallucinating non-existent or incorrect content, which undermines their potential merits in real applications. Existing work usually attempts to detect these hallucinations based on a corresponding oracle reference at a sentence or document level. However ground-truth references may not be readily available for many free-form text generation applications, and sentence- or document-level detection may fail to provide the fine-grained signals that would prevent fallacious content in real time. As a first step to addressing these issues, we propose a novel token-level, reference-free hallucination detection task and an associated annotated dataset named HaDeS (HAllucination DEtection dataSet). To create this dataset, we first perturb a large number of text segments extracted from English language Wikipedia, and then verify these with crowd-sourced annotations. To mitigate label imbalance during annotation, we utilize an iterative model-in-loop strategy. We conduct comprehensive data analyses and create multiple baseline models.

1. Introduction

Large Language Models (LLMs) frequently "hallucinate"—generating text that is fluent and plausible but factually incorrect. Current detection methods face two major hurdles: granularity and the "reference trap." Most tools analyze entire sentences or documents, which is too low-resolution to pinpoint specific errors. Furthermore, existing benchmarks usually compare AI output against a human-written "oracle" reference, which is often unavailable in real-world applications like social chatbots or creative writing assistants.

This paper addresses these gaps by proposing a token-level, reference-free detection task: identifying specific hallucinated spans using only the surrounding context and world knowledge. This approach paves the way for "guardrail" systems that can catch and suppress factual errors as an LLM is generating them in real time.

2. Methodology: The HADES Dataset

To build a dataset for a task where "correct" references don't exist, the authors developed a clever Contextual Perturbation pipeline to turn factual Wikipedia text into "plausible hallucinations."

Overview of the Contextual Perturbation and Human Annotation process used to create the HADES dataset.

2.1 Contextual Perturbation Pipeline

  • Mask, Replace, and Rank: Wikipedia segments are processed by masking specific tokens (using BERT) and replacing them with new tokens that are syntactically correct but factually different. A GPT-2 model ranks these candidates, keeping only the most fluent ones to ensure the hallucinations are not obvious gibberish.
  • Model-in-the-loop Annotation: Since random perturbations often result in hallucinations, the dataset initially suffered from label imbalance. An iterative strategy was used: a model was trained to predict labels, and "hard" cases were specifically sampled for human annotators to verify, resulting in a balanced dataset of ~11,000 annotated instances.

3. Task Definition and Analysis

The core task involves labeling individual tokens as either "Hallucination" or "Not Hallucination" based on the provided context.

Example of token-level hallucination labeling where factual context is contrasted with a perturbed, hallucinated token.

3.1 Key Insights

  • The Overconfidence Paradox: Hallucinated tokens often have a higher average probability than factual ones. Models are often "overconfident" in their errors due to self-reinforcing patterns learned during training.
  • Entropy as a Signal: While probability is deceptive, entropy (uncertainty) proved to be a more reliable indicator. Hallucinations typically associate with higher entropy across the model's vocabulary distribution.
  • Context Saturation: Detection performance improves rapidly as context increases but plateaus around 75–80 tokens, suggesting that local context is often sufficient to spot a lie.

4. Experimental Results

The researchers established baselines using popular Transformer models in two modes:

  • Offline Performance: RoBERTa-large and XLNet-large were the top performers, achieving roughly 72% accuracy. These models benefited significantly from seeing "future" context (text appearing after the hallucinated span).
  • Online Performance: In the more difficult real-time setting, GPT-2 outperformed other models (71.58% accuracy). GPT-2's native unidirectional, left-to-right processing makes it better at judging the "fit" of a token based only on preceding text.

5. Conclusion and Future Work

HADES represents a significant step toward real-time hallucination suppression. While the current dataset uses synthetic perturbations, future work will focus on capturing the specific "flavor" of errors made by native models like GPT-4 and integrating external knowledge bases to verify claims in real-time across multiple languages and informal domains.

Summary updated

BibTeX
@inproceedings{liu2022token,
  author = {Tianyu Liu and Yizhe Zhang and Chris Brockett and Yi Mao and Zhifang Sui and Weizhu Chen and Bill Dolan},
  title = {{A Token-level Reference-free Hallucination Detection Benchmark for Free-form Text Generation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  url = {https://openreview.net/forum?id=bzWqB6i13q},
}
Figure