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

## Abstract

Abstract The knowledge within large language models (LLMs) may become outdated quickly.
While in-context editing (ICE) is currently the most effective method for knowledge editing (KE), it is constrained by the black-box modeling of LLMs and thus lacks interpretability.
Our work aims to elucidate the superior performance of ICE in KE by analyzing the impacts of in-context new knowledge on token-wise distributions.
We observe that despite a significant boost in logits of the new knowledge, the performance of ICE is still hindered by stubborn knowledge.
Stubborn knowledge refers to facts that have gained excessive confidence during pretraining, making them hard to edit effectively.
To address this issue and further enhance the performance of ICE, we propose a novel approach termed De coding by C ontrasting K nowledge (DeCK).
DeCK derives the distribution of the next token by contrasting the logits obtained from the newly edited knowledge guided by ICE with those from the unedited parametric knowledge.
Our experiments consistently demonstrate that DeCK enhances the confidence of LLMs in edited facts.
For instance, it improves the performance of LLaMA3-8B-instruct on MQuAKE by up to 219%, demonstrating its capability to strengthen ICE in the editing of stubborn knowledge.
DeCK can be easily integrated into any ICE method as a decoding component to enhance editing capabilities.
Our work paves the way to develop both effective and accountable KE methods for LLMs. 1 1 1 The source code is available at: https://github.com/byronBBL/DeCK .

## 1 Introduction

With the widespread deployment of large language models (LLMs) (OpenAI,, , ; ; ; Song et al.,, ), there is a rising demand for accessing accurate information through LLMs.
However, despite the extensive knowledge stored in LLMs, this information can become outdated due to changes in the real world.
This can potentially result in factual inaccuracies (Chen and Shu,, ) or false information (; ).

Unlike the high computational resource burden incurred by retraining from scratch, knowledge editing (KE)  (Sinitsin et al.,, ; De Cao et al.,, ; Zhu et al.,, ; Mitchell et al.,, ; Yao et al.,, ) has been proposed as an efficient means to update the knowledge of LLMs.
They aim to edit knowledge by incrementally injecting or modifying facts.

As LLMs demonstrate increasingly powerful in-context learning capabilities, recent research (Madaan et al.,, ; Zhong et al.,, ; Zheng et al.,, ; Cohen et al.,, ; Wang et al.,, ; Mei et al.,, ) has delved into easier and efficient methods for in-context editing (ICE), aiming to directly guide frozen LLMs in generating text with new knowledge through contextual prompts.
Figure 1 (left) illustrates an example of successful editing using ICE.
These ICE methods showcasing state-of-the-art performance without the need to alter internal model parameters, indicate the promising potential of modeling LLMs as black boxes for ICE guided by external contexts.

Figure: Figure 1: Comparison between in-context editing (ICE) and our DeCK. DeCK successfully edits stubborn knowledge, whereas ICE handles only simple knowledge and fails with complex cases.

However, as illustrated in Figure 1 (middle), there still exist deeply entrenched pieces of knowledge in LLMs that are difficult for ICE to modify, which we refer to as stubborn knowledge.
We argue that LLMs, through extensive pre-training, have developed strong confidence in certain facts, making them difficult to alter solely through external contextual prompts (Bi et al.,, ).
Therefore, despite the fact that the sophisticated methods such as enhancing retrieval (Shi et al.,, ), checking conflict (Zhong et al.,, ), and guiding reasoning (Wang et al.,, ) can enhance the overall performance of ICE, relying on these external methods still cannot genuinely improve the foundational capability for editing individual stubborn knowledge.

In this work, we focus on enhancing the state-of-the-art KE method, ICE, to reduce the negative impacts from the stubborn knowledge in LLMs.
First, we observe the impact of the in-context new knowledge in ICE on LLMs from the perspective of LLMs’ token-level distributions.
We find that incorporating this new knowledge significantly increases the predicted probability of generating edited facts during the decoding process.
A deeper exploration of the failed cases reveals the reasons why stubborn knowledge is difficult to edit.
Despite the significant improvement in the logits of new knowledge achieved by ICE, there persists a small gap between new knowledge and parametric knowledge, where parametric knowledge refers to the original unedited knowledge in LLMs.

Building upon the insights gained from above observations, we introduce a new decoding technique called Decoding by Contrasting Knowledge (DeCK) to enhance LLMs’ confidence in edited facts for better editing of stubborn knowledge.
DeCK consists of two components: (1) an editing enhancement module that improves attention to new knowledge, thus preventing it from being filtered out during contrastive decoding, and (2) a contrastive decoding strategy that compares the logical distributions after in-context editing with the original parametric logical distributions to predict the next token.

Overall, our contributions can be summarized by three points.
First, as far as we know, we are the first to elucidate superior performance of ICE on the KE from a model interpretability perspective.
Second, we find that stubborn knowledge significantly impacts the performance of ICE, and we propose DeCK to boost confidence in editing facts, enhancing ICE to overcome it.
Third, extensive experiments on MQuAKE indicate that our DeCK can effectively enhance the performance of ICE without altering the internal model or modifying external prompts.
DeCK can be easily integrated into any ICE method as a decoding component to enhance editing capabilities.
Our work paves the way to develop the both effective and accountable KE methods for LLMs.

## 2 Background

#### Decoding in LLMs.

The current objective of LLMs decoding is to predict the subsequent words within a given context sequence.
Formally, given a sequence of tokens $\mathcal{X}=\{x_{1},x_{2},...,x_{t-1}\}$, the next token probability distribution is computed conditioned on the previous context:

$$ $\text{I\kern-1.49994ptP}(x_{t}|x_{<t})=\frac{\exp(\mathbf{h}_{t}^{\top}\mathbf {W}_{x_{t}}/\tau)}{\sum_{j\in\mathcal{V}}\exp(\mathbf{h}_{t}^{\top}\mathbf{W}_ {j}/\tau)}$ (1) $$

where $\tau$ represents a temperature parameter regulating the precision of the subsequent-token distribution.
In text generation, the language model samples from the conditional distribution $\text{I\kern-1.49994ptP}(x_{t}|x_{<t})$ to generate the next token $x_{t}$, continuing this process until an end-of-sequence token is produced.

#### Knowledge Editing.

KE aims to transform the behavior of the original model $f_{base}$ into post-edit model $f_{e}$.
Given an edit descriptor $z_{e}=(x_{e},r_{e},y_{e})$, where $(x_{e},r_{e},y_{e})$ represents a triplet such as (US, President, Joe Biden) meaning Joe Biden is the president of US.
KE ensures that $f_{e}(x_{e},r_{e})=y_{e}$ while $f_{base}(x_{e},r_{e})\neq y_{e}$.
A thorough edit not only modifies the corresponding knowledge but also all the knowledge within the multi-hop relations that are impacted by this edit.
For example, consider a two-hop question like "Who is married to the British Prime Minister?"
The original answer would be "Carrie Johnson" and the associated knowledge could be represented: (UK, Prime Minister, Boris Johnson), (Boris Johnson, spouse, Carrie Johnson).
With an edit $z_{e}=(\textit{UK},\textit{Prime Minister},\textit{Rishi Sunak})$ and existing knowledge $(\textit{Rishi Sunak},\textit{spouse},\textit{Akshata Murthy})$, $f_{e}$ should produce the updated response: "Akshata Murthy".

Figure: Figure 2: The changes of new knowledge and parametric knowledge before and after editing. We capture the first tokens of outputs to represent the corresponding knowledge and then record their original logits along with their ranks within the entire vocabulary.

## 3 Deep Insights into ICE through Decoding Perspectives

With $\phi(\cdot)$ replacing the affine layer to predict the probability of the next token over the vocabulary set $\mathcal{V}$, we can obtain a simplified representation of Equation (1).
Given a sequence of tokens $\mathcal{X}_{E}=\{x_{1}^{(E)},x_{2}^{(E)},...,x_{m-1}^{(E)}\}$, which includes guidance from an editing prompt, such as "Assume Tesla’s CEO is Jack Ma", we compute the probability of next token $x^{(E)}_{m}$ with editing guidance as follows:

$$ $\text{I\kern-1.49994ptP}^{E}(x^{(E)}_{m}|x^{(E)}_{<m})=\mathrm{softmax}(\phi( \mathbf{h}^{(E)}_{m})),\quad x^{(E)}_{m}\in\mathcal{V}$ (2) $$

We can also represent the parametric probability distribution $\text{I\kern-1.49994ptP}^{B}(x^{(B)}_{n}|x^{(B)}_{<n})$ by considering only the token sequence $\mathcal{X}_{B}$ containing the original question prompt without any editing content.
The distribution $\text{I\kern-1.49994ptP}^{E}(x^{(E)}_{m}|x^{(E)}_{<m})$ also reflects the feedback from the introduction of external knowledge, while $\text{I\kern-1.49994ptP}^{B}(x^{(B)}_{n}|x^{(B)}_{<n})$ solely represents the response of LLMs based on their parametric knowledge to the question.

### 3.1 How ICE Effectively Edits Knowledge in LLMs?

Although the ICE methods on LLMs (Zhong et al.,, ; Cohen et al.,, ; Wang et al.,, ) have demonstrated promising performance, they all rely on the black-box modeling of LLMs for editing, and the internal mechanisms behind their effectiveness remain unclear.
In this subsection, we delve into the intrinsic reasons behind the superior performance of ICE on KE.

We designed dedicated experiments to capture the logits output of knowledge that would be influenced by the edit.
A striking observation in Figure 2 is that the introduction of new knowledge through ICE leads to a significant rightward shift in the probability distribution of the new knowledge, while the logits for parametric knowledge remain largely unchanged or decrease to some extent.
This suggests that ICE significantly enhances the logits of new knowledge while having minimal impact on parametric knowledge.
Additionally, the number of top-ranked positions for new knowledge significantly increases after ICE, with the majority surpassing that of parametric knowledge.
This indicates that the in-context new knowledge can improve the confidence of LLMs in editing facts, thereby prompting responses with the edited answers.

### 3.2 Inherent Challenges of Stubborn Knowledge

While ICE has significantly boosted the confidence of LLMs in new knowledge, we find that there are still instances where certain new knowledge ranks prominently but not as the top-1, as illustrated in Figure 2.
We term this phenomenon "stubborn knowledge", which refers to cases where editing fails due to either an excessive confidence in existing parametric knowledge or insufficient confidence in new knowledge.
The edit cases in Figure 3 deeply reveals the failed pattern for ICE in addressing stubborn knowledge, which happens when there is still an extremely small gap compared to the parametric knowledge after editing, despite the significant increase in new knowledge logits induced by the editing prompt.
Taking the last case as an example, after editing, the new knowledge "English" lags behind the parametric knowledge "French" by only 0.516 in terms of logical distribution, illustrating how a minor gap leads to editing failure.
This indicates the intrinsic reasons for the failure of black-box ICE methods to edit stubborn knowledge in LLMs in most cases.

Figure: Figure 3: Edit cases with changes in the first token for both parametric and new knowledge. We obtained the case results by conducting ICE in the LLaMA2-7B-chat model. ‘$\rightarrow$’ indicates the knowledge change after incorporating editing prompts. ‘logits’ and ‘rank’ pertain to the first token of knowledge answer, reflecting the confidence of LLMs in the corresponding knowledge.

## 4 DeCK: Enhancing LLMs’ Confidence on Edited Facts

Inspired by the observations in Section 3, we design our novel decoding strategy DeCK to enhance ICE in overcoming stubborn knowledge.
Figure 4 illustrates the process of using DeCK to handle the stubborn knowledge case shown in Figure 1 (right).
DeCK can be formalized as follows.
Using $\text{I\kern-1.49994ptP}(x_{t})$ to represent $\text{I\kern-1.49994ptP}(x_{t}|x_{<t})$ for notational brevity, we compute the probability of the next token by,

$$ $\text{I\kern-1.49994ptP}^{E}_{\text{Enh}}(x^{(E)}_{m})=\mathrm{Enh}(\text{I \kern-1.49994ptP}^{E}(x^{(E)}_{m}))$ (3) $$

$$ $\hat{\text{I\kern-1.49994ptP}}^{E}_{\text{Enh}}(x^{(E)}_{m})=\mathrm{softmax} \left(\mathcal{F}\left(\text{I\kern-1.49994ptP}^{E}_{\text{Enh}}(x^{(E)}_{m}), \text{I\kern-1.49994ptP}^{B}(x^{(B)}_{n})\right)\right)$ (4) $$

Here, the function $\mathrm{Enh(\cdot)}$ in Equation 3 is improve the attention to edit facts, as detailed in Section 4.1.
The operator $\mathcal{F}(\cdot,\cdot)$ in Equation 4 is used to contrast between the output distributions from enhanced new knowledge and parametric knowledge, as explained in Section 4.2.

Figure: Figure 4: Illustration of DeCK enhancing ICE to edit the stubborn knowledge. During decoding, DeCK contrasts the enhanced ICE distribution with the original distribution to highlight new knowledge, inducing LLMs to generate edited facts using chain-of-though (CoT) (Wei et al.,, ) during the reasoning process for answering input questions.

### 4.1 Editing Signal Enhancement

To enhance the confidence of LLMs in edited knowledge, we design an editing enhancement function that minimizes the Knowledge Enhancement Divergence (KED) between the enhanced distribution and a target distribution.
Assume that $\tilde{P}$ and $Q$ are discrete probability distributions over a finite vocabulary $V$, and that the weights $w_{i}$ are non-negative and sum to 1.

###### Definition 4.1 (Knowledge Enhancement Divergence) .

Let $\tilde{P}(x^{(E)}_{m})$ be the enhanced probability distribution of the next token $x^{(E)}_{m}$ after incorporating edited knowledge, and let $Q$ be the target distribution that assigns higher probabilities to tokens related to the edited knowledge. The KED between $\tilde{P}(x^{(E)}_{m})$ and $Q$ is defined as:

$$ $\text{KED}(\tilde{P}||Q)=\frac{1}{2}\sum_{i=1}^{n}w_{i}\left(\tilde{P}(v_{i}) \log\frac{\tilde{P}(v_{i})}{M(v_{i})}+Q(v_{i})\log\frac{Q(v_{i})}{M(v_{i})}\right)$ (5) $$

where $M=\frac{1}{2}(\tilde{P}+Q)$ is the average distribution, and $w_{i}=s(v_{i},E)$ is the weight assigned to the $i$-th token based on its semantic relevance score.

We introduce a semantic relevance function $s:V\times E\to\mathbb{R}$ that measures the relevance of a token $v_{i}\in V$ to the edited knowledge represented by $E$, defined as:

$$ $s(v_{i},E)=\max_{e_{j}\in E}\text{sim}(v_{i},e_{j})\cdot\phi(v_{i})$ $$

where $\text{sim}(\cdot,\cdot)$ is a similarity function, such as cosine similarity, that measures the semantic similarity between two token embeddings, and $\phi:V\to\mathbb{R}$ is a frequency-based weighting function:

$$ $\phi(v_{i})=\log(\text{freq}(v_{i})+\epsilon)\cdot\alpha$ $$

Here, $\text{freq}:V\to\mathbb{N}$ denotes the frequency of a token in the edited descriptor $E$, $\epsilon>0$ is a small constant to avoid taking the logarithm of zero, and $\alpha$ is a scaling factor.
We also define an enhancement function $\text{Enh}:\mathbb{R}^{n}\times\mathbb{R}^{n}\to\mathbb{R}^{n}$ that takes the original logits $\phi(h^{(E)}_{m})\in\mathbb{R}^{n}$ and the semantic relevance scores $s\in\mathbb{R}^{n}$ as inputs and produces the enhanced logits $\tilde{\phi}(h^{(E)}_{m})\in\mathbb{R}^{n}$:

$$ $\mathrm{Enh}(\phi(h^{(E)}_{m}),s)=\alpha\cdot\phi(h^{(E)}_{m})+\beta\cdot s$ $$

where $\alpha,\beta\in\mathbb{R}$ are scaling coefficients that control the balance between the original logits and the semantic relevance scores. Hence, the target distribution $Q$ over the vocabulary $V$ is constructed to assign higher probabilities to the tokens related to the edited knowledge:

$$ $Q(v_{i})=\begin{cases}\frac{1}{m}&\text{if }v_{i}\in E\\ \epsilon&\text{otherwise}\end{cases}$ $$

where $\epsilon>0$ is a small constant to ensure a valid probability distribution.

###### Definition 4.1 (Knowledge Enhancement Divergence) .

### 4.2 Decoding by Contrasting Knowledge

The idea of Decoding by Contrasting Knowledge is to highlight the output probability increment of new knowledge by contrasting it with the parametric knowledge from the inherent knowledge of the LLMs.
Given the ICE probability distribution $\text{I\kern-1.49994ptP}^{E}_{\text{Enh}}(x^{(E)}_{m}))$ after editing enhancement in Section 4.1 and the original parametric probability distribution $\text{I\kern-1.49994ptP}^{B}(x^{(B)}_{n}))$, we aim to amplify the outputs of new knowledge during the generation process while downplaying the outputs of paprametric knowledge.

Following the Contrastive Decoding approach from  Li et al., ().
We subtract the original log probabilities of parametric outputs guided by knowledge question alone from those of the outputs guided by ICE with the in-context new knowledge.
Then, we use this resulting distribution as the next-word prediction for the generation guided by editing prompts.
Therefore, the operator $\mathcal{F}(\cdot,\cdot)$ in Equation 4 can be expanded as follows:

$$ $\mathcal{F}(\text{I\kern-1.49994ptP}^{E}_{\text{Enh}}(x^{(E)}_{m})),\text{I \kern-1.49994ptP}^{B}(x^{(B)}_{n}))=\begin{cases}\log\dfrac{\text{I\kern-1.499 94ptP}^{E}_{\text{Enh}}(x^{(E)}_{m}))}{\text{I\kern-1.49994ptP}^{B}(x^{(B)}_{n })},&\text{ if }x^{(E)}_{m}\in\mathcal{V}_{\text{head }}(x^{(E)}_{m}|x^{(E)}_{ <m}),\\ -\infty,&\text{ otherwise. }\end{cases}$ (6) $$

The contrasting coefficient $\gamma$ is also introduced to adjust the proportion of the subtraction: $\log\text{I\kern-1.49994ptP}^{E}_{\text{Enh}}(x^{(E)}_{m})-\gamma\log\text{I
\kern-1.49994ptP}^{B}(x^{(B)}_{n})$.
And the subset $\mathcal{V}_{\text{head }}(x^{(E)}_{m}|x^{(E)}_{<m})\in\mathcal{V}$ is defined as whether or not the token has high enough probabilities from the editing output,

$$ $\mathcal{V}_{\text{head}}(x^{(E)}_{m}|x^{(E)}_{<m})=\left\{x^{(E)}_{m}\in \mathcal{V}:\text{I\kern-1.49994ptP}^{E}_{\text{Enh}}(x^{(E)}_{m}))\geq\lambda \max_{w}\text{I\kern-1.49994ptP}^{E}_{\text{Enh}}(w)\right\}.$ (7) $$

As adaptive plausibility constraint (APC) strategy proposed in  Li et al., (), we use $\mathcal{V}_{\text{head}}$ to filter out tokens with low probabilities in $\text{I\kern-1.49994ptP}^{E}_{\text{Enh}}(x^{(E)}_{m})$ and considering only high-score tokens.
Without APC, some extremely low-probability tokens could be excessively amplified by the softmax function after subtraction, leading to the generation of implausible words and severely impacting the performance of contrastive decoding.
Specifically, the Editing Signal Enhancement module in Section 4.1 cleverly avoids being filtered out in Equation 7 by enhancing the new knowledge signal before contrastive processing, ensuring that DeCK can function effectively.

The key to our contrastive decoding approach is the simultaneous maintenance of two token sequences’ generation, which differs from previous methods (Li et al.,, ; Chuang et al.,, ; ).
In iterative decoding, we predict the next token based on $\hat{\text{I\kern-1.49994ptP}}^{E}_{\text{Enh}}(x^{(E)}_{m})$ in Equation 4.
Then, a key step involves simultaneously concatenating the new token to two separate token sequences $\mathcal{X}_{E}$ and $\mathcal{X}_{B}$, which may have different lengths.
This ensures that updates to both sequences are synchronized, preventing any implausible discrepancies in the log distribution during iteration.

## 5 Experiments

### 5.1 Experimental setup

#### Datasets

We conducted extensive experiments using the MQuAKE-3k dataset (Zhong et al.,, ) and its derivatives, MQuAKE-2002 and MQuAKE-hard, proposed by Wang et al., ().
MQuAKE provides multi-hop knowledge questions containing extensively edited facts, which are used to evaluate KE on counterfactual edits.
Additionally, we constructed corresponding stubborn datasets in 5.3 to further evaluate the effectiveness of editing stubborn knowledge

#### Models and Baselines

Our experiments examine three types of LLaMA-chat models (2-7b, 2-13b, 3-8b) () and also Mistral-7B-instruct (Jiang et al.,, ).
We employ the state-of-art in-context editing methods IKE (Cohen et al.,, ) and MeLLo (Zhong et al.,, ), alongside advanced model-editing techniques ROME () as baseline approaches on the aforementioned open-source models.
IKE prompts LLMs to edit given knowledge by providing contextual demonstrations.
MeLLo edits multi-hop knowledge by decomposing sub-questions, prompting LLMs to generate answers, and retrieving contradictions from the edit memory.

#### Implementation Details

We implement IKE with multi-hop question-answering demonstrations and chain-of-thought (COT)  (Wei et al.,, ; Li et al.,, ) prompting to enhance its in-context editing performance.
Our decoding strategy DeCK is inherently deployed onto IKE and MeLLo to validate their enhancements without any additional adjustments. It simply requires providing the relevant factual guiding context before generating the edited answers.
The model editing methods ROME in our baselines are deployed using EasyEdit (Wang et al.,, ).

**Table 1: Experimental results (accuracy; %) across various models and datasets. We set the batch size of the edit memory to 1 to evaluate the foundational capability of directly editing knowledge. The best editing result on every LLM is highlighted in bold font.**
| Model | Method | MQuAKE-3k | MQuAKE-2002 | MQuAKE-hard |
| --- | --- | --- | --- | --- |
| LLaMA2- | ROME () | 18.2 | 19.1 | 15.7 |
| 7B-chat | IKE (Zheng et al.,, ) | 85.4 | 85.1 | 88.9 |
| IKE w/ DeCK (ours) | 91.3 | 89.4 | 98.6 |  |
| LLaMA2- | ROME () | 39.4 | 39.7 | 35.2 |
| 13B-chat | IKE (Zheng et al.,, ) | 63.8 | 64.1 | 55.2 |
| IKE w/ DeCK (ours) | 84.6 | 84.4 | 89.7 |  |
| LLaMA3- | ROME () | 14.5 | 15.9 | 12.7 |
| 8B-instruct | IKE (Zheng et al.,, ) | 31.6 | 32.5 | 14.3 |
| IKE w/ DeCK (ours) | 54.7 | 55.9 | 45.7 |  |
| Mistral- | ROME () | 28.1 | 30.2 | 26.3 |
| 7B-instruct | IKE (Zheng et al.,, ) | 34.1 | 35.6 | 15.6 |
| IKE w/ DeCK (ours) | 46.7 | 48.5 | 19.2 |  |

### 5.2 Main Results

We evaluate the foundational capability of KE methods in directly editing explicit new knowledge by considering multi-hop questions containing 1,000 instances and setting the batch size of the edit memory to 1.
The batch size means the number of instances providing the edited facts for knowledge retrieval.
Table 1 displays the performance of different baselines and the enhanced in-context editing through our DeCK across various models and datasets.
As with previous work, ICE methods exhibit superior performance in multi-hop KE tasks compared to model-editing methods ROME.
Overall, IKE enhanced by our DeCK (IKE w/ DeCK) consistently exhibits the best performance, indicating that the DeCK can reliably improves the foundational KE capabilities of ICE for LLMs.
Specifically, as the model parameters increase, LLMs tend to retain more stubborn knowledge, resulting in a decrease in the accuracy of ICE.
For instance, the average accuracy of LLaMA2-13B-chat is 61%, whereas that of LLaMA2-7B-chat is 86%.
Additionally, although the parameters of llama3 are not extensive, its more refined pretraining and instruct tuning also may instill greater confidence in its acquired knowledge, resulting in poor performance in ICE.
However, to our great surprise, our DeCK has significantly enhanced ICE’s editing of these stubborn knowledge.
Notably, on the HARD dataset, DeCK has increased ICE’s editing success rate in LLaMA2-13B-chat by an impressive 63% and in LLaMA3-8B-instruct by an amazing 219%.

In-context editing methods typically require retrieving edit demonstrations from the edit memory and then editing LLMs with the retrieved knowledge.
Therefore, we follow the setup of previous work (Zheng et al.,, ; Zhong et al.,, ; Madaan et al.,, ) to conduct experiments for ICE methods with the full batch size edit memory.
As shown in Table 2, the experimental results illustrate that DeCK enhances ICE methods to varying degrees in full batch experiments.
The IKE methods does not exhibit consistent improvement in this regard, potentially constrained by its inherent editing accuracy.
We ingeniously integrate our DeCK into MeLLo, aiding MeLLo in generating crucial edited answers during the reasoning process.
We find that leveraging the foundational editing capabilities provided by DeCK consistently improves MeLLo’s performance across all experiments.
This indicates that our DeCK holds significant potential for real-world KE applications.

**Table 2: Experimental results (accuracy; %) using LLaMA2-chat models. We conduct the experiments with the full batch size edit memory to evaluate the performance of memory based KE.**
| Model | Method | MQuAKE-3k | MQuAKE-2002 | MQuAKE-hard |
| --- | --- | --- | --- | --- |
|  | IKE (Zheng et al.,, ) | 20.7 | 20.6 | 2.3 |
| LLaMA2- | IKE w/ DeCK (ours) | 22.4 | 20.4 | 3.8 |
| 7B-chat | MeLLo (Zhong et al.,, ) | 32.6 | 40.8 | 5.1 |
|  | MeLLo w/ DeCK (ours) | 43.1 | 45.8 | 5.8 |
|  | IKE (Zheng et al.,, ) | 19.4 | 18.8 | 2.7 |
| LLaMA2- | IKE w/ DeCK (ours) | 20.6 | 18.4 | 3.5 |
| 13B-chat | MeLLo (Zhong et al.,, ) | 33.4 | 35.9 | 3.9 |
|  | MeLLo w/ DeCK (ours) | 36.8 | 38.2 | 6.2 |

### 5.3 Metamorphosis of Stubborn Knowledge

To further explore the reasons behind the significant improvement brought by DeCK to ICE, we conduct a statistical analysis of the ranking changes.
Specifically, we sample the new knowledge with probability rankings between top 2-100 after the original ICE method, and examine the changes in their ranks after integrating DeCK.
The results in Table 3 demonstrate that our DeCK effectively improves the ranking of new knowledge that failed to be edited by ICE, leading to a metamorphosis of stubborn knowledge.

**Table 3: Improvement of new knowledge ranking by DeCK on MQuAKE-3k. Here, ’original rank’ refers to the ranking of new knowledge after the original IKE w/o DeCK. The table shows the average ranking of new knowledge and the improvement after integrating DeCK.**
| Original Rank | 2 | 3-5 | 6-10 | 11-20 | 21-50 | 51-100 |
| --- | --- | --- | --- | --- | --- | --- |
| LLaMA2-7B-chat | $1.6$($\uparrow 0.4$) | $2.7$($\uparrow 0.9$) | $4.3$($\uparrow 3.6$) | $4.6$($\uparrow 8.2$) | $4.8$($\uparrow 24.3$) | $6.1$($\uparrow 61.3$) |
| LLaMA2-13B-chat | $1.4$($\uparrow 0.6$) | $1.9$($\uparrow 1.9$) | $2.2$($\uparrow 4.9$) | $2.8$($\uparrow 13.4$) | $4.1$($\uparrow 34.1$) | $5.4$($\uparrow 72.7$) |

We constructed corresponding stubborn datasets for different models to specifically evaluate ICE’s performance on stubborn knowledge.
The stubborn datasets are categorized into different difficulty levels based on the proportion of correct answers when using ICE methods to edit the same knowledge multiple times with different knowledge questions.
The experimental results on the stubborn datasets are presented in Table 4.
We found that IKE’s performance on stubborn significantly declined compared to other datasets, as shown in Table 1, and even fell below that of the model editing method ROME on LLaMA2-13B-chat.
Our DeCK consistently brings about a dramatic improvement for IKE, with enhancements of up to 80% on LLaMA2-13B-chat, ensuring that IKE w/ DeCK maintains the highest performance.
This suggests that DeCK brings about improvements by enhancing ICE methods’ ability to edit stubborn knowledge.

**Table 4: Performance of LLaMA2-7B-chat and LLaMA2-13B-chat on their respective stubborn datasets. ‘stubborn > 67%’ indicates instances from the MQuAKE-3k dataset where IKE failed to edit knowledge more than 67% of the time. ‘stubborn > 33%’ follows the same criterion.**
| Model | stubborn | ROME | IKE | IKE w/ DeCK (ours) |
| --- | --- | --- | --- | --- |
| LLaMA2- | $>33\%$ | 17.7 | 56.4 | 72.3 |
| 7B-chat | $>67\%$ | 19.3 | 37.8 | 55.9 |
| LLaMA2- | $>33\%$ | 42.5 | 38.9 | 70.1 |
| 13B-chat | $>67\%$ | 40.2 | 29.4 | 48.5 |

Figure 5 reveals the underlying reasons why DeCK can effectively edit stubborn knowledge.
ICE w/ DeCK has a higher distribution in the high-probability range, while ICE w/o DeCK is concentrated in the low-probability range.
This further indicates that DeCK boosts the confidence of LLMs in low-confidence new knowledge, making them more likely to accept the edited facts.

Figure: Figure 5: Probability Statistics of New Knowledge for LLaMA2-7B-chat on Stubborn Datasets. The probabilities are derived from softmax calculations.

### 5.4 Ablation Study

We conduct ablation experiments on the key components of our DeCK.
Table 6 shows how the contrasting coefficient introduced in Equation 6 affects DeCK’s performance.
DeCK is highly sensitive to the contrasting coefficient. If $\gamma$ is too large, it can excessively amplify unreasonable token probabilities, significantly reducing DeCK’s performance, even below that of the original ICE.
Table 6 demonstrates that the editing signal enhancement introduced in Section 4.1 can consistently enhance DeCK’s performance. This is because it ensures that the enhanced edited knowledge is not filtered out by Equation 7.

**Table 5: Ablation results on MQuAKE-3k with LLaMA2-chat models.**
| Size | $\gamma=0.1$ | $\gamma=0.2$ | $\gamma=0.5$ |
| --- | --- | --- | --- |
| -7b | 88.7 | 91.3 | 80.2 |
| -13b | 76.1 | 84.6 | 48.5 |

## 6 Related Work

#### Hallucinations and Misinformation

Hallucination (Kang et al.,, ) is one of the main source of LLM-generated misinformation.
In general, there are two lines of works on hallucination mitigation.
In training stage,  Hu et al., (); Pan et al., () has investigated training data curation or knowledge grounding methods to integrate more knowledge.
In the inference stage, recent works have explored methods including confidence estimation  (), knowledge retrieval (Feng et al.,, ; Yang et al.,, ) and KE to improve accurate outputs.

#### Contrast Decoding

The recent contrasting decoding method achieves the desired output by contrasting logical distribution during the decoding phase.
CD (Li et al.,, ) compares powerful expert language models with weaker amateur language models to enhance fluency and coherence.
DoLa (Chuang et al.,, ) contrasts mature layers with premature layers, while ICD () compares with models injected with hallucinations, aiming to enhance the factual accuracy of the model.

#### Model Editing and In-Context Editing

Model Editing is a type of effective technique for KE, altering the model’s internal structure to modify its output regarding the edited content.
Current model editing methods (; ; Mitchell et al.,, ; Yao et al.,, ; Xu et al.,, ) for LLMs involve integrating an auxiliary network with the original model or modifying and adding model parameters to manipulate the model’s output.
The emergent method of ICE (Madaan et al.,, ; Zhong et al.,, ; Zheng et al.,, ), demonstrates significant potential, enabling the editing of language models by prompting them with edited fact and retrieving editing demonstrations from the edit memory.

## 7 Conclusion and Limtations

In this paper, we introduce Decoding by Contrasting Knowledge (DeCK), a novel decoding strategy aimed at enhancing in-context editing in overcoming stubborn knowledge for LLMs.
Based on observations at the token-level of edited knowledge, DeCK contrasts the logits of new knowledge with those from parametric knowledge to amplify the changes in model knowledge brought about by in-context editing.
Experimental results show that DeCK significantly improves editing accuracy.
Overall, DeCK is a critical step in enhancing in-context editing to overcome stubborn knowledge.

DeCK also has limitations; it requires the reception of input from two different token sequences during the generation process, resulting in approximately a 1.6X increase in latency compared to original decoding.
This suggests that we can pursue further optimization within the transformers architecture or explore alternative, more cost-effective versions of DeCK.

## Acknowledgements

This paper is partially supported by the National Science Foundation of China under Grant No. U21B2046 and 6237075198, and National Key R&D Program of China (No. 2023YFC3305303).

## Peer Reviews

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: How does the proposed method compare to e.g., CAD, and other approaches in this space?
Does the method generalise beyond MQuaKE? What about NQ-Swap?
soundness: 3
strengths: Efficient and simple method for in-context editing of knowledge in LLMs that does not require access to the model parameters.
summary: This paper introduces Decoding by Contrasting Knowledge (DeCK), a decoding strategy for editing knowledge in LLMs -- DeCK addressses the problem that, even when using in-contextk nowledge editing, the model might still decide to rely on its parametric knowledge (this phenomenon is referred to as "stubborn knowledge" in this paper). DeCK relies on contrastive decoding: during generation, it decreases the likelihood of the tokens that would have been selected without in-context editing, and increases the likelihood of the tokens that would be selected with in-context editing. Contrastive decoding (CD) is an extremely effective technique that has been used in many uses cases recetly, such as mitigating faithfulness hallucinations (e.g., https://arxiv.org/abs/2305.14739, https://arxiv.org/abs/2410.18860, https://arxiv.org/abs/2309.03883), alignment (e.g., https://arxiv.org/abs/2401.08565), and controlled generation (https://aclanthology.org/2021.acl-long.522/) -- this paper is yet another success story of CD.

To assess the effectiveness of DeCK, the authors use the MQuaKE dataset -- why? There are several widely used knowledge conflicts datasets in the literature, like NQ-Swap (https://arxiv.org/abs/2109.05052), MacNoise (https://aclanthology.org/2024.findings-naacl.159/), and ConflictBank (https://arxiv.org/pdf/2408.12076); why did they go specifically for MQuaKE, and only considered MQuaKE variants? Does the proposed approach generalise beyond MQuaKE?

The authors say that "we are the first to elucidate superior performance of ICE on the KE" -- however, the shortcomings of other knowledge editing approaches compared to in-context editing were already shown by e.g. https://arxiv.org/abs/2306.09306

The authors consider a very tiny number of knowledge editing baselines -- mainly ROME, IKE, and MeLLo. However, there is a large number of knowledge editing approaches, including ones that aim to bridge the gap between parameter editing and in-context editing (e.g., https://arxiv.org/abs/2306.09306); even ROME has a set of more efficient and effective developments (e.g., MEMIT: https://memit.baulab.info/). Some potential approaches the authors could experiment with for increasing the reliance of the model on the edited knowledge are listed in e.g., https://arxiv.org/abs/2410.15999 Tab. 1 (DoLA, SAE, CAD, etc.). How does DiKE compare to this? Note that many of these rely on contrastive decoding and/or do not require any additional gradient-based training, so it should be easy to include these in the comparison.
weaknesses: Lack of comparison baselines. For example, the proposed method is very similar to CAD (https://arxiv.org/abs/2305.14739), that aims to do something very similar (increase reliance on a given context), but there is no comparison with CAD and related methods.
I mentioned other potential weaknesses in the Summary (e.g., lack of datasets), but this one might be the main weakness.

---

confidence: 4
contribution: 2
initial_rating: 3
presentation: 3
questions: Has the author considered the potential security risks introduced by the proposed method?
soundness: 2
strengths: The writing in this article is well-organized, and the proposed approach is clear and easy to understand.
summary: The authors suggest that stubborn knowledge hinders the performance of in-context editing.
Then, the authors introduce Decoding by Contrasting Knowledge (DeCK), a novel decoding strategy aimed at enhancing in-context editing in overcoming stubborn knowledge for LLMs.
Experimental results show that DeCK significantly improves editing accuracy.
weaknesses: 1. The experiment is insufficiently thorough: The baseline only includes naive versions of ROME and IKE, overlooking other types of knowledge editing methods such as SERAC and MEND.

2. The evaluation metrics for the results seem to overlook several common editing metrics, such as locality.

3. The proposed method aims to enhance the model’s reliance on in-content text rather than on stubborn parametric knowledge. Intuitively, this would likely increase the chances of incorporating new knowledge in responses. However, it also **introduces safety risk** by raising the likelihood of the model being bypassed by jailbreak prompts. Specifically, if malicious knowledge is appended to the query, this approach heightens the probability of the model using that malicious information.

---

confidence: 4
contribution: 2
initial_rating: 3
presentation: 2
questions: Will you consider to add baselines?
soundness: 2
strengths: 1. This paper finds that previous in-context editing methods fail to follow new knowledge and propose new decoding methods to address the weakness.

2. This paper conducts a detailed ablation study to verify the effectiveness of the proposed method.
summary: To improve the performance of in-context editing methods on multi-hop knowledge editing tasks, this paper introduces a new decoding method DeCK to lead the language model output the new knowledge. In detail, DeCK uses an editing enhancement module that improves attention to new knowledge and uses a contrastive decoding strategy to predict the new knowledge. The experiments show that the in-context editing with DeCK outperforms the in-context editing methods a lot.
weaknesses: The main weakness of this method is the absence of robust baselines for fair comparison. While ROME and MELO serve as overly simplistic baselines for multi-hop editing tasks in MQUAKE, there are several other methods, such as RAE [1] and Pokemqa [2], that have gained acceptance.

2. DeCK specifically targets single-fact editing, as in-context editing simplifies complex multi-hop questions into single-hop ones. Therefore, DeCK should be compared with traditional knowledge editing tasks. For instance, IKE [3] closely aligns with DeCK’s objectives, using external example prompts to enable LLMs to incorporate new knowledge effectively.
[1] Shi, Yucheng, et al. "Retrieval-enhanced knowledge editing for multi-hop question answering in language models." arXiv preprint arXiv:2403.19631 (2024).
[2] Gu, Hengrui, et al. "Pokemqa: Programmable knowledge editing for multi-hop question answering." arXiv preprint arXiv:2312.15194 (2023).
[3] Zheng, Ce, et al. "Can we edit factual knowledge by in-context learning?" arXiv preprint arXiv:2305.12740 (2023).

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 2
questions: 1. How does model size impact DeCK's performance? For instance, would DeCK show different results if applied to much larger models, such as the LLAMA 3 70B?

2. How would DeCK perform on datasets beyond MQUAKE? The experiments primarily use the MQUAKE dataset and its derivatives; would DeCK’s effectiveness hold across other types of datasets?
soundness: 2
strengths: 1. The paper offers insights into in-context editing (ICE) by exploring it through a decoding lens, enhancing the understanding of ICE's mechanisms and its limitations in knowledge editing.

2. Extensive experiments showcase the effectiveness of DeCK in tackling stubborn knowledge, demonstrating significant performance improvements and validating its impact across challenging cases.

3. The paper is well presented.
summary: This paper examines the performance of In-Context Editing (ICE) for knowledge editing in large language models (LLMs) and introduces "Decoding by Contrasting Knowledge" (DeCK) to enhance ICE’s effectiveness. DeCK achieves this by contrasting the logits of newly edited knowledge with the model's original parametric knowledge, thereby strengthening the model's adherence to updated information. Experimental results on the MQUAKE dataset demonstrate performance improvements, particularly in handling difficult-to-edit "stubborn knowledge".
weaknesses: 1. The concept of "stubborn knowledge" is introduced but lacks a precise, quantifiable definition. A clearer, potentially quantitative description of what constitutes stubborn knowledge would help clarify how DeCK differentiates from conventional methods.

2. The paper would benefit from a deeper examination of why current IKE methods fall short in handling certain cases, particularly where stubborn knowledge resists alteration. A more detailed analysis of these limitations and how DeCK specifically overcomes them would enhance the understanding of DeCK’s improvements.

3. DeCK requires generating inferences twice for each instance, increasing computational demands. This added cost may be a barrier for practical applications.