Regularized Contrastive Decoding with Hard Negative Samples for LLM Hallucination Mitigation

Haonan Sheng, Dou Hu, Lingwei Wei, Wei Zhou, Songlin HuEMNLP 2025

TL;DR

This paper introduces Regularized Contrastive Decoding (RCD), a novel inference-time method to combat hallucinations in Large Language Models (LLMs). By adversarially training a "weaker" model on hard negative samples, RCD generates more informative signals to guide the LLM towards factual outputs, significantly improving hallucination mitigation without substantial computational overhead.

What Problem Does This Paper Address?

Large Language Models (LLMs) are increasingly powerful, but a persistent issue is their tendency to "hallucinate" – generating factually incorrect or unfaithful outputs. This unreliability poses significant risks in critical domains like legal consultation or medical advice. While existing methods attempt to mitigate hallucinations, they often struggle with subtle inaccuracies or require extensive external knowledge bases. This paper tackles the challenge of improving hallucination mitigation, particularly for nuanced errors, by enhancing the contrastive decoding approach with more effective negative sampling.

Methods

The core innovation of RCD lies in its two-stage approach:

  1. Adversarial Fine-tuning with LoRA: The authors first train a "factually weaker" LLM. This is achieved by using an adversarial fine-tuning strategy with LoRA (Low-Rank Adaptation) adapters. They employ the Fast Gradient Method (FGM) to generate "hard negative samples" – outputs that are subtly incorrect but semantically close to the truth. These samples are used to train the weaker model, making it adept at identifying and generating diverse hallucination patterns.
  2. Contrastive Decoding with Factually Weaker Model: During inference, RCD combines the outputs of the original, strong LLM with the newly trained, weaker LLM. This contrastive decoding process uses the signals from the weaker model to penalize potentially hallucinated tokens and amplify the probability of factual ones. The method uses a specific formulation to balance the influence of both models and an adaptive relative top filtering mechanism to refine token selection.

Datasets

The paper evaluates RCD on four public hallucination benchmarks:

  • TruthfulQA: Assesses truthfulness of LLM outputs.
  • FACTOR: Evaluates factual accuracy in text completion tasks.
  • TriviaQA: A large-scale question-answering dataset.
  • Natural Questions (NQ): Another question-answering dataset.

For training the hallucination model, they utilize the HaluEval dataset, which covers factual and faithfulness hallucinations across question answering, summarization, and dialogue formats.

Key Insights and Ideas

  • Hard Negatives are Key: The paper demonstrates that simply contrasting with any incorrect output isn't enough. Using "hard negative samples" – subtly wrong but plausible hallucinations – is crucial for training a weaker model that can effectively guide the stronger model.
  • Adversarial Training for Hallucination Detection: Adversarial training, typically used for robustness, is repurposed here to make a weaker model better at hallucinating in specific ways, which then becomes useful for detecting hallucinations in the main model.
  • Inference-Time Efficiency: RCD operates at inference time, meaning it doesn't require extensive retraining of the base LLM. This makes it practical for deployment.
  • Generalization: The method shows strong performance across different LLM sizes, task formats, and training data sizes, suggesting its robustness.

Key Results

  • RCD consistently outperforms existing inference-time hallucination mitigation methods across all tested benchmarks.
  • On TruthfulQA, RCD achieved significant improvements, with +19.75 absolute score increases on MC2 and +12.71 accuracy on FACTOR Expert.
  • The method introduces only a negligible overhead compared to standard contrastive decoding, maintaining efficiency.
  • RCD preserves the base model's performance on general benchmarks like MMLU and ARC-Challenge, indicating it doesn't harm overall capabilities.
  • Ablation studies confirm the effectiveness of adversarial perturbations and the hard negative sampling strategy.

Limitations and Future Work

  • Computational Cost: While RCD is an inference-time method, it still requires additional computational resources for generating adversarial perturbations and fine-tuning the weaker model.
  • LLM Architecture Specificity: The evaluation primarily focused on the Llama-2 family of models. The authors suggest exploring its effectiveness on other LLM architectures as a future direction.
  • Ethical Considerations: The paper acknowledges that training a model prone to hallucinations raises ethical concerns regarding potential misuse for generating misinformation. They emphasize responsible use within controlled research environments.

Summary updated

BibTeX
@inproceedings{sheng2025regularized,
  author = {Haonan Sheng and Dou Hu and Lingwei Wei and Wei Zhou and Songlin Hu},
  title = {{Regularized Contrastive Decoding with Hard Negative Samples for LLM Hallucination Mitigation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure