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:
- Sampling: Responses are collected from a target LLM (e.g., GPT-4) based on specific knowledge sources and dialogue histories.
- Rewriting: A "rewriting LLM" transforms these responses into two versions: a strictly faithful response and a response containing a subtle hallucination.
- Finetuning: A T5-base model (223M parameters) is fine-tuned on this paired synthetic data to distinguish between faithful and hallucinated text.
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).
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