Decoding by Contrasting Knowledge: Enhancing LLMs' Confidence on Edited Facts

Baolong Bi, Shenghua Liu, Lingrui Mei, Yiwei Wang, Pengliang Ji, Xueqi Cheng · DOI

Abstract

Large Language Models (LLMs) frequently encounter "stubborn knowledge"—pre-trained facts that the model is so confident in that it ignores contradictory new information provided in a prompt. This paper introduces Decoding by Contrasting Knowledge (DeCK), a plug-and-play decoding strategy designed to boost model confidence in edited facts. DeCK contrasts the "new" knowledge distribution against the "old" parametric distribution during inference. Experimental results demonstrate performance gains of up to 219% on complex multi-hop reasoning tasks, effectively overcoming the limitations of standard In-Context Editing (ICE).

Introduction: The Challenge of Stubborn Knowledge

The rapid pace of real-world information change necessitates efficient methods for updating LLM knowledge. In-Context Editing (ICE)—providing new facts directly within the prompt—is a common approach to avoid the high costs of retraining or fine-tuning. However, ICE often fails when the model has high confidence in its pre-trained "parametric" knowledge.

Comparison of In-Context Editing (ICE) and DeCK across easy and stubborn knowledge scenarios.

As illustrated in Figure 1, while ICE works for "easy" knowledge (facts with low pre-training confidence), it fails on "stubborn" knowledge. In these cases, the model's internal memory of the original fact is so dominant that the updated answer is narrowly suppressed during decoding. The authors' analysis reveals that while ICE increases the probability of the new fact, it often remains just below the original stubborn fact in the final token distribution.

Methodology: Decoding by Contrasting Knowledge (DeCK)

DeCK addresses stubbornness by modifying the output selection process rather than the model's weights. The method operates in two primary stages:

1. Editing Signal Enhancement

To prevent new knowledge from being drowned out by parametric noise, DeCK uses a semantic relevance function to "nudge" the logits of tokens related to the new information. This ensures that correct tokens remain viable candidates for the subsequent contrastive step.

2. Contrastive Decoding

This is the core innovation of DeCK. The model generates two distinct probability distributions:

  • Edited Distribution ($P_{edited}$): Derived from the prompt containing the new facts.
  • Parametric Distribution ($P_{para}$): Derived from the original question alone, reflecting the model's pre-trained biases.
The DeCK workflow: enhancing the editing signal and contrasting the edited distribution against the parametric distribution to produce the final output.

By calculating $Logit_{final} = Logit_{Edited} - \gamma \cdot Logit_{Parametric}$, DeCK effectively "subtracts out" the model's old biases, allowing the new information to emerge as the most probable choice (see Figure 6).

Experimental Evaluation

The researchers evaluated DeCK on several benchmarks, including MQUAKE (Multi-hop Knowledge Editing) and a custom STUBBORN dataset designed to highlight cases where standard ICE fails due to extreme model overconfidence.

Key Results

  • Significant Accuracy Gains: On the MQUAKE-HARD dataset, DeCK improved the performance of Llama3-8B-Instruct by 219% and Llama2-13B-Chat by 63%.
  • Overcoming Overconfidence: In the STUBBORN datasets, DeCK achieved over 70% accuracy in scenarios where the base model previously scored below 40%.
  • Universal Applicability: As a decoding strategy, DeCK is compatible with various ICE methods (e.g., IKE, MeLLo) and model families (Llama 2, Llama 3, Mistral) without requiring fine-tuning.

Discussion and Limitations

While DeCK provides a robust solution to stubborn knowledge, it introduces a 1.6x increase in latency because the model must process two sequences simultaneously. Additionally, performance is sensitive to the contrasting coefficient ($\gamma$); an excessively high value can amplify irrelevant tokens. Future research may focus on optimizing transformer architectures for dual-sequence processing or refining the contrastive logic for greater efficiency.

Conclusion

DeCK demonstrates that many knowledge-related failures in LLMs stem from biased output selection rather than a lack of "understanding" of new information. By contrasting edited and parametric distributions, DeCK offers a powerful, training-free mechanism to ensure LLMs remain adaptable to a changing world.

Summary updated

BibTeX
@misc{bi2024decoding,
  author = {Baolong Bi and Shenghua Liu and Lingrui Mei and Yiwei Wang and Pengliang Ji and Xueqi Cheng},
  title = {{Decoding by Contrasting Knowledge: Enhancing LLMs' Confidence on Edited Facts}},
  year = {2024},
  eprint = {2405.11613},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.11613},
}
Figure