Improving Factuality in Large Language Models via Decoding-Time Hallucinatory and Truthful Comparators

Dingkang Yang, Dongling Xiao, Jinjie Wei, Mingcheng Li, Zhaoyu Chen, Ke Li, Lihua Zhang

Abstract

Large Language Models (LLMs) frequently generate plausible but factually incorrect content, a phenomenon known as hallucination. This paper proposes Comparator-driven Decoding-Time (CDT), a framework that enhances LLM truthfulness during inference. By contrasting the target model's predictions against two specialized auxiliary models—a truthful comparator and a hallucinatory comparator—CDT effectively steers generation toward factual accuracy. The framework incorporates a Mixture of Experts (MoE) approach to handle diverse task types and employs adversarial training to sharpen the truthful model's ability to reject false patterns. Experimental results across multiple benchmarks, including TruthfulQA and XSUM, demonstrate significant improvements in factuality over state-of-the-art baselines.

Introduction

Despite their remarkable capabilities, Large Language Models (LLMs) suffer from a persistent "hallucination dilemma," where they generate content that contradicts verifiable facts or user instructions. These hallucinations are often categorized into various types, such as extrinsic (introducing outside misinformation) or intrinsic (contradicting the provided context).

Examples of hallucinations in dialogue and summarization tasks, comparing baseline LLaMA-2-7B-Chat with the proposed CDT framework.

Current solutions typically involve either labor-intensive fine-tuning (SFT/DPO) or brittle internal activation editing. Fine-tuning can inadvertently "wash out" a model's original knowledge, while representation editing often fails to account for the multifaceted nature of hallucinations across different tasks. CDT addresses these issues by providing a "plug-and-play" decoding-time intervention that suppresses diverse hallucination patterns without damaging the model's core capabilities.

Methodology: Comparator-driven Decoding-Time (CDT)

The core of CDT is a contrastive decoding strategy that adjusts the probability distribution of the target LLM during token generation based on two auxiliary "comparators."

The CDT framework architecture, illustrating the contrastive decoding process and the MoE structure.

The Comparators

Using Low-Rank Adaptation (LoRA), the framework creates two lightweight versions of the base model:

  1. Truthful Comparator: Trained on factual data to favor correct information.
  2. Hallucinatory Comparator: Intentionally trained on known hallucinations to identify and penalize incorrect patterns.

Instruction Prototype-guided Mixture of Experts (PME)

To address the task-specific nature of hallucinations, CDT employs a Mixture of Experts (MoE) approach. Different LoRA adapters specialize in various task types (e.g., summarization, Q&A). A Gaussian Mixture Model (GMM) clusters input instructions to route them to the most relevant "expert" adapter, ensuring the intervention is tailored to the specific context.

Hallucination Perturbation Adversarial Training (PAT)

To prevent the truthful comparator from becoming overly repetitive, the authors use adversarial training. Gradients from hallucinated responses are used to "perturb" the training process, forcing the truthful model to actively learn to distinguish and reject specific false patterns rather than just learning positive examples.

Decoding Strategy

At inference time, the final token probability is boosted if the truthful comparator favors it and penalized if the hallucinatory comparator favors it. An adaptive plausibility constraint ensures that the selected tokens remain grammatically and contextually coherent.

Experimental Evaluation

The authors evaluated CDT across a wide range of tasks using several key benchmarks:

  • TruthfulQA: Assesses whether LLMs mimic human falsehoods.
  • XSUM: Tests factual consistency in document summarization.
  • KNIGHT-Judge: A knowledge-driven dialogue dataset for hallucination recognition.
  • Alpaca-Judge: Evaluates general-purpose instruction following.
  • HaluEval: Used for the initial multi-task SFT training of the comparators.

Key Results and Insights

CDT consistently outperformed the base LLaMA-2-7B-Chat and several state-of-the-art (SOTA) baselines:

  • TruthfulQA: CDT achieved a 50.74% MC1 score, a significant improvement over the baseline (37.62%) and the previous SOTA, ICD (46.32%).
  • Summarization (XSUM): Factual consistency (measured by FactKB) improved by 34.87% over the vanilla baseline.
  • Dialogue (KNIGHT-Judge): The framework improved the F1 score for hallucination recognition by 14.19%.

The success of CDT highlights that using both positive (truthful) and negative (hallucinatory) signals simultaneously provides a sharper signal for factuality than using either alone. Furthermore, the PME strategy confirms that hallucinations are task-specific, requiring specialized experts for optimal mitigation.

Conclusion

While effective, CDT introduces some computational overhead due to running three models (Target + 2 Comparators) during decoding, although LoRA adapters mitigate this. The performance also depends on the diversity of the initial training data for the comparators. Future research may explore integrating this decoding-time logic with Retrieval-Augmented Generation (RAG) to further strengthen factual grounding.

Summary updated

BibTeX
@inproceedings{yang2025improving,
  author = {Dingkang Yang and Dongling Xiao and Jinjie Wei and Mingcheng Li and Zhaoyu Chen and Ke Li and Lihua Zhang},
  title = {{Improving Factuality in Large Language Models via Decoding-Time Hallucinatory and Truthful Comparators}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i24.34751},
}
Figure