Contrastive Error Attribution for Finetuned Language Models

Faisal Ladhak, Esin Durmus, Tatsunori Hashimoto

Abstract

Hallucinations in large language models (LLMs) are frequently traced back to "noisy" or misannotated examples in training data that teach models incorrect associations. We introduce Contrastive Error Attribution (CEA), a framework designed to identify these problematic training instances. By analyzing how specific data points influence the gap between incorrect model outputs and human-corrected versions, CEA effectively isolates data noise. Our experiments demonstrate that CEA achieves near-perfect detection of synthetic errors and can reduce real-world entity hallucinations by up to 70% through targeted data cleaning.

Introduction

Large language models often "hallucinate," generating facts or entities absent from the source text. Research suggests a primary culprit is the training data: if a summarization dataset contains examples where summaries include extrinsic information, the model learns that hallucination is acceptable. Identifying these specific "needles in the haystack"—the few noisy examples among hundreds of thousands—is a significant challenge. Existing influence-based methods often fail in complex natural language generation tasks, proving brittle, computationally expensive, and sometimes less effective than simple keyword searches.

Methods: The CEA Framework

Contrastive Error Attribution (CEA) departs from standard influence functions through three key innovations:

  1. Contrastive Influence: Instead of identifying examples that make an incorrect output likely, CEA identifies examples that make the incorrect output more likely than a human-corrected version. This contrast filters out general language patterns to focus on the specific noise causing the error.
  2. Direct Loss Difference: Rather than using inaccurate Taylor expansions (Hessian approximations), CEA measures actual loss changes. It takes gradient steps on a small set of "error" examples and observes how the loss shifts across the training set. A loss spike in a training example when the model is "corrected" suggests that example is a source of the error.
  3. Distillation: To improve recall, the top-scoring (likely errors) and bottom-scoring (likely clean) examples are used to train a separate neural classifier (Electra). This classifier learns the general characteristics of data errors, enabling it to identify problematic examples beyond the initial influence scores.

Experimental Evaluation

The researchers evaluated CEA across three settings:

  • Synthetic Hallucinations (XSum): A "canary" dataset where entities were intentionally swapped (e.g., "England" to "China") to test detection accuracy.
  • Real-world Summarization (NYT): Targeting "PERSON" entity hallucinations in the New York Times dataset.
  • Data-to-Text (E2E): Testing semantic errors, such as omitting required fields, in structured data descriptions.

Key Results

CEA demonstrated superior performance in identifying data noise compared to traditional methods. In synthetic tests, CEA achieved a Mean Average Precision (mAP) of 0.93, vastly outperforming baselines like TracIn (0.03) and BM25 (0.13).

Performance comparison of CEA against baselines on synthetic hallucination detection tasks.

In real-world applications on the NYT dataset, removing 50,000 examples identified by CEA reduced entity hallucinations by 70%. This significantly outperformed the strongest baseline, which only achieved a 20% reduction. Furthermore, on the E2E dataset, CEA reduced semantic errors by 55%, proving its generalizability beyond entity-swapping.

Hallucination reduction and ROUGE-L performance on the NYT dataset after cleaning varying amounts of identified noisy data.

Discussion and Conclusion

A critical insight from this work is that "contrast" is essential; looking at incorrect outputs in isolation often leads models to flag generally relevant but correct training data. CEA proves that a small "seed" of human-corrected examples (as few as 20) can be leveraged to clean massive datasets effectively. While CEA currently requires a human-in-the-loop for these corrections, future work may involve automating this process using stronger LLMs to "fix" the errors of smaller models, creating a fully automated data-refinement pipeline.

Summary updated

BibTeX
@inproceedings{ladhak2023contrastive,
  author = {Faisal Ladhak and Esin Durmus and Tatsunori Hashimoto},
  title = {{Contrastive Error Attribution for Finetuned Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.643},
}
Figure