Detecting Hallucinated Content in Conditional Neural Sequence Generation

Chunting Zhou, Jiatao Gu, Mona T. Diab, Paco Guzman, Luke Zettlemoyer, Marjan Ghazvininejad

Abstract

Neural sequence models can generate highly fluent sentences, but recent studies have also shown that they are also prone to hallucinate additional content not supported by the input. These variety of fluent but wrong outputs are particularly problematic, as it will not be possible for users to tell they are being presented incorrect content. To detect these errors, we propose a task to predict whether each token in the output sequence is hallucinated (not contained in the input) and collect new manually annotated evaluation sets for this task. We also introduce a method for learning to detect hallucinations using pretrained language models fine tuned on synthetic data that includes automatically inserted hallucinations. Experiments on machine translation (MT) and abstractive summarization demonstrate that our proposed approach consistently outperforms strong baselines on all benchmark datasets. We further demonstrate how to use the token-level hallucination labels to define a fine-grained loss over the target sequence in low-resource MT and achieve significant improvements over strong baseline methods. We also apply our method to word-level quality estimation for MT and show its effectiveness in both supervised and unsupervised settings.

Introduction

Neural sequence models have achieved remarkable fluency in tasks like machine translation and abstractive summarization. However, this fluency often masks a critical failure: hallucination. Models frequently generate content—such as names, dates, or facts—that is entirely unsupported by the source input. Because these outputs sound natural, they are deceptive; a user without access to the source language or original document has no way to verify the model's claims.

Existing evaluation metrics like BLEU or ROUGE are insufficient for this problem as they measure similarity to a reference rather than faithfulness to the source. Furthermore, sentence-level detection is often too coarse for practical model improvement. This work addresses these gaps by proposing a framework for token-level hallucination detection, identifying specific words that lack grounding in the source text.

Methodology

The proposed detection framework is designed to be reference-free, requiring only the source text and the generated output at inference time. The training process relies on a three-step pipeline to generate training data without human intervention:

  1. Synthetic Data Generation: To simulate hallucinations, the authors utilize a pretrained BART model. By masking or removing tokens from a correct target sentence and asking BART to fill the gaps without seeing the source, the model is forced to produce fluent but ungrounded (hallucinated) content.
  2. Automatic Labeling: The original faithful sentence is compared against the BART-generated version using edit distance. Tokens that were substituted or inserted are automatically labeled as hallucinated (1), while matching tokens are labeled as faithful (0).
  3. Detector Training: A pretrained encoder (XLM-RoBERTa for MT, RoBERTa for summarization) is fine-tuned on this synthetic data. The model learns to predict the binary label for every token in a (Source, Target) pair.
Synthetic hallucination generation using BART and edit distance labeling.

Experimental Evaluation

The framework was evaluated across multiple domains and tasks:

  • Abstractive Summarization: Benchmarked on the XSUM dataset using post-processed human annotations.
  • Machine Translation: Evaluated on a multi-domain Chinese-English dataset, including specialized benchmarks for Patents and COVID-19 (TICO) to test out-of-domain robustness.
  • Low-Resource MT: Tested on WMT19 Nepali-English and Sinhala-English tasks to evaluate the detector's utility in corpus filtering and model training.

Results and Discussion

The unsupervised detector achieved an F1 score of approximately 0.6 across various benchmarks, consistently outperforming heuristics based on word-alignment or overlap.

POS Analysis and Insights

Analysis of the hallucinated tokens revealed that nouns (NN) are the most frequently hallucinated part of speech across both MT and summarization tasks. In summarization specifically, cardinal numbers (CD) also represent a high-risk category for hallucinations.

Distribution of hallucinated tokens across different Parts-of-Speech (POS) tags for MT and XSum tasks.

Rectified Training

Beyond detection, the authors demonstrated that these token-level labels can improve model training. By implementing Token Loss Truncation—where the model ignores the loss from tokens predicted as hallucinations—they achieved a 1.7 BLEU point improvement in self-training setups for MT. On the noisy WMT19 Nepali-English task, the method set a new state-of-the-art BLEU score of 7.4 by effectively filtering out misaligned training segments.

Conclusion

This work provides a robust, reference-free method for identifying unfaithful content in neural sequence generation. While the approach shows significant promise, limitations remain regarding context window constraints in long-form summarization and the inherent difficulty of defining hallucinations versus creative paraphrasing. Future research will explore extending this detection to data-to-text tasks where factual grounding is paramount.

Summary updated

BibTeX
@inproceedings{zhou2021detecting,
  author = {Chunting Zhou and Jiatao Gu and Mona T. Diab and Paco Guzman and Luke Zettlemoyer and Marjan Ghazvininejad},
  title = {{Detecting Hallucinated Content in Conditional Neural Sequence Generation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.findings-acl.120},
}
Figure