Enhancing Hallucination Detection through Perturbation-Based Synthetic Data Generation in System Responses

Dongxu Zhang, Varun Gangal, Barrett Martin Lattimer, Yi YangACL 2024

Abstract

Large Language Models (LLMs) frequently generate hallucinations—text that is factually incorrect or unverifiable—limiting their utility in high-stakes applications. This paper introduces a fully automated pipeline to train hallucination detectors by using a powerful LLM to "perturb" system responses into both faithful and hallucinated versions. By fine-tuning a modest T5-base model on this synthetic data, we achieve superior detection accuracy compared to GPT-4 zero-shot baselines, while operating over ten times faster and at a fraction of the cost.

Introduction

As LLMs are increasingly deployed in production, the need for reliable "guardrail" models to detect hallucinations in real-time has become critical. Traditional methods for building these detectors rely on expensive human annotation or rigid, rule-based synthetic data generation (e.g., simple entity swapping). These approaches often fail to capture the subtle and diverse error patterns exhibited by modern LLMs. We address this by focusing on the target LLM's own output distribution, creating a more representative training set for hallucination detection.

Methodology: Perturbation-Based Generation

The proposed approach utilizes a three-step process to generate high-quality synthetic training data without human intervention:

  1. Sampling: Responses are collected from a target LLM (e.g., GPT-4) based on specific knowledge sources and dialogue histories.
  2. Rewriting: A "rewriting LLM" transforms these responses into two versions: a strictly faithful response and a response containing a subtle hallucination.
  3. Finetuning: A T5-base model (223M parameters) is fine-tuned on this paired synthetic data to distinguish between faithful and hallucinated text.
Overview of the perturbation-based synthetic data generation process.

By prompting the rewriter to be "inconsistent with the knowledge" rather than following fixed rules, the system discovers a broad spectrum of realistic error types, such as "adding attributes" to correct entities.

Datasets and Evaluation

The study evaluates the detector on two primary knowledge-grounded dialogue benchmarks: OpenDialKG and BEGIN. To validate the approach against real-world LLM behavior, the authors introduced OpenDialKG-Eval, a new benchmark consisting of 402 responses from a simulated GPT-4 chatbot, manually verified by human annotators via Amazon Mechanical Turk.

Key Results

The fine-tuned T5-base model demonstrates significant improvements in both accuracy and efficiency over existing baselines:

  • Superior Accuracy: On the OpenDialKG-Eval benchmark, the proposed approach achieved an F1 score of 0.762, outperforming GPT-4 zero-shot baselines (0.608) and existing synthetic methods like HaluEval (0.702).
  • Efficiency Gains: The model maintains a low latency of 0.20 seconds per response, nearly 15x faster than the GPT-4-based "G-Eval" method (2.79 seconds).
  • Cost-Effectiveness: Synthetic data generation cost approximately $0.008 per example, representing a 25x reduction compared to typical human annotation costs ($0.20).
Performance comparison of hallucination detection methods showing F1 scores and latency.

Discussion and Insights

A key finding is that distributional alignment is crucial; training on perturbed LLM outputs is more effective than using perturbed human text because the detector learns the specific linguistic nuances of the target model. Furthermore, the results prove that small, specialized models can outperform massive general-purpose models like GPT-4 when provided with high-quality, task-specific synthetic data.

While effective, the method's performance remains linked to the rewriting LLM's ability to generate complex hallucinations. Future work will explore adapting this strategy to more subjective tasks and diverse domains such as long-form Q&A and summarization.

Summary updated

BibTeX
@inproceedings{zhang2024enhancing,
  author = {Dongxu Zhang and Varun Gangal and Barrett Martin Lattimer and Yi Yang},
  title = {{Enhancing Hallucination Detection through Perturbation-Based Synthetic Data Generation in System Responses}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.789},
}
Figure