A Stitch in Time Saves Nine: Detecting and Mitigating Hallucinations of LLMs by Validating Low-Confidence Generation

Neeraj Varshney, Wenlin Yao, Hongming Zhang, Jianshu Chen, Dong YuarXiv 2023 · DOI

Introduction

Large Language Models (LLMs) have demonstrated remarkable capabilities in text generation, yet they remain prone to "hallucinations"—the generation of factually incorrect information that appears syntactically sound. A critical observation in this domain is the "snowball effect": once an LLM introduces a factual error, it tends to generate subsequent hallucinations to maintain internal consistency with the initial mistake. This paper proposes an active framework to detect and mitigate these errors during the generation process, rather than relying on post-hoc corrections.

The Hallucination Snowball Effect

Research indicates that hallucinations are rarely isolated incidents. If a model generates a false statement in one sentence, the probability of subsequent sentences containing errors increases significantly. This dependency creates a drift where the model moves further away from factual reality as the document progresses. By intervening at the moment of low confidence, the proposed system prevents this error propagation and keeps the model grounded.

Proposed Framework: Active Detection and Mitigation

The core contribution is a multi-stage pipeline integrated directly into the decoding process. Instead of checking every word, which would be computationally prohibitive, the system focuses on "low-confidence" segments.

The Active Detection and Mitigation framework pipeline showing the multi-stage process from concept identification to repair.

The process follows five key steps:

  1. Concept Identification: The LLM is prompted to extract key entities and phrases from a generated sentence.
  2. Uncertainty Calculation: The system analyzes the logit output values for these concepts. The "Minimum of Token Probabilities" within a phrase serves as a reliable indicator of potential hallucination.
  3. Validation: Concepts falling below a confidence threshold trigger a validation check. The system generates a verification question and performs a real-time web search (via Bing API) to gather evidence.
  4. Repair: If external evidence contradicts the generated text, the model is instructed to rewrite the sentence using the retrieved knowledge.
  5. Continuation: The corrected sentence is appended to the prompt, ensuring the model remains grounded for the next generation step.

Experimental Results

The framework was evaluated across diverse tasks, including article generation across various domains (Sports, Politics, Music, etc.), multi-hop QA (HotpotQA), and adversarial "False Premise" questions.

Comparison of hallucination rates between baseline GPT-3.5 and the proposed active mitigation framework.

Key findings include:

  • Significant Error Reduction: In article generation, the hallucination rate for GPT-3.5 (text-davinci-003) dropped from 47.5% to 14.5%.
  • High Detection Recall: The logit-based detection achieved approximately 88% recall, successfully identifying the vast majority of factual errors.
  • Effective Repair: The mitigation step successfully corrected 57.6% of identified hallucinations.
  • Adversarial Robustness: On "False Premise" questions (e.g., "Why does Mars have three moons?"), the system correctly identified and rectified the false premise in 76% of cases, whereas the baseline model failed 100% of the time.

Conclusion and Future Work

This "active" approach demonstrates that validating low-confidence generations in real-time is a powerful strategy for maintaining LLM factuality. While the system introduces additional latency and API costs due to the search and validation steps, it effectively breaks the hallucination snowball effect. Future work may involve parallelizing the validation process or applying the framework to summarization tasks where a source document provides the ground truth instead of a web search.

Summary updated

BibTeX
@misc{varshney2023stitch,
  author = {Neeraj Varshney and Wenlin Yao and Hongming Zhang and Jianshu Chen and Dong Yu},
  title = {{A Stitch in Time Saves Nine: Detecting and Mitigating Hallucinations of LLMs by Validating Low-Confidence Generation}},
  year = {2023},
  eprint = {2307.03987},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.03987},
}
Figure