Decoding by Contrasting Knowledge: Enhancing Large Language Model Confidence on Edited Facts

Baolong Bi, Shenghua Liu, Lingrui Mei, Yiwei Wang, Junfeng Fang, Pengliang Ji, Xueqi Cheng

Abstract

Large Language Models (LLMs) frequently struggle with "stubborn knowledge," a phenomenon where the model's pre-trained parametric knowledge overrides new information provided in-context. We introduce Decoding by Contrasting Knowledge (DeCK), a novel decoding-time strategy designed to boost an LLM's confidence in edited facts. DeCK contrasts the model's output distribution when provided with new context against its distribution without that context. Our experiments demonstrate that DeCK significantly improves performance on complex multi-hop reasoning tasks, achieving gains of up to 219% over standard In-Context Editing (ICE) methods.

Introduction

As LLMs are trained on static datasets, their internal "parametric knowledge" eventually becomes obsolete as the real world evolves. Knowledge Editing (KE) seeks to update these models with current information. In-Context Editing (ICE) has emerged as a preferred method due to its simplicity; it involves prepending the new fact to the user's prompt (e.g., "Assume the CEO of Tesla is Jack Ma").

However, ICE often fails when the model has high confidence in its original training data. This "stubborn knowledge" prevents the model from prioritizing the new context during generation, even when the context is explicitly provided. Figure 1 illustrates how standard ICE succeeds on "easy" knowledge but fails when the model's internal bias is too strong, whereas DeCK successfully navigates these stubborn cases.

Comparison of standard In-Context Editing (ICE) and DeCK on easy vs. stubborn knowledge.

Methodology: Decoding by Contrasting Knowledge (DeCK)

DeCK is a plug-and-play decoding strategy that can be integrated into any ICE-based system. It addresses the "Minor Gap" problem—where the probability of the correct updated token is increased by the prompt but remains slightly below the probability of the outdated parametric token.

1. Editing Signal Enhancement

To ensure that tokens relevant to the new fact are not discarded during the early stages of decoding, DeCK first calculates a "semantic relevance" score. It applies a slight boost to the logits of tokens related to the edit, ensuring they remain viable candidates for the contrastive step.

2. Contrastive Decoding

The core of DeCK involves two parallel forward passes for every token generated:

  • The Edited Pass: The model processes the prompt including the new knowledge.
  • The Parametric Pass: The model processes only the original query, relying solely on its internal knowledge.

By subtracting the log-probabilities of the Parametric Pass from those of the Edited Pass, DeCK isolates the change in distribution caused by the new information. This effectively acts as a high-pass filter, amplifying the signal of the newly provided facts while canceling out the model's inherent biases.

Experimental Evaluation

The effectiveness of DeCK was evaluated using several benchmarks:

  • MQUAKE-3K & MQUAKE-2002: Focused on multi-hop knowledge editing, where an update to one fact (e.g., a company's CEO) necessitates updates to related queries (e.g., the CEO's birthplace).
  • MQUAKE-HARD: A subset targeting the most challenging multi-hop relations.
  • STUBBORN Datasets: A custom evaluation set specifically designed to test scenarios where standard ICE methods typically fail due to entrenched parametric knowledge.

Key Results and Discussion

DeCK consistently outperformed standard In-Context Editing (IKE) and specialized fine-tuning methods like ROME across multiple architectures, including Llama 2, Llama 3, and Mistral.

  • Performance Gains: On the Llama3-8B-Instruct model using the MQUAKE-HARD dataset, performance improved from 14.3% to 45.7%, representing a 219% relative increase.
  • Robustness to Bias: On the STUBBORN dataset with Llama2-7B-Chat, DeCK raised the success rate from 37.8% to 55.9%.
  • Interpretability: By analyzing the logit shifts, the authors provide insights into why ICE fails—often due to a numerical gap as small as 0.5 logits—and how contrastive decoding bridges this gap.

Limitations and Future Work

The primary limitation of DeCK is its computational overhead. Requiring two forward passes per token results in a roughly 1.6x increase in latency. Future research may focus on optimizing this dual-stream architecture, perhaps through KV-cache sharing or more efficient parallelization. Additionally, exploring DeCK's utility in resolving knowledge conflicts or reducing hallucinations remains a promising avenue for future work.

Conclusion

DeCK offers a powerful, model-agnostic solution to the problem of stubborn knowledge in LLMs. By shifting the focus from raw probabilities to the contrastive influence of new information, it enables more reliable and accurate in-context knowledge editing.

Summary updated

BibTeX
@inproceedings{bi2025decoding,
  author = {Baolong Bi and Shenghua Liu and Lingrui Mei and Yiwei Wang and Junfeng Fang and Pengliang Ji and Xueqi Cheng},
  title = {{Decoding by Contrasting Knowledge: Enhancing Large Language Model Confidence on Edited Facts}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure