DistillMIKE: Editing Distillation of Massive In-Context Knowledge Editing in Large Language Models (2024)

Abstract: Among the recently emerging knowledgeediting methods, in-context knowledge editing (IKE) (Zheng et al., 2023) has shown respectable abilities in knowledge editing in terms of generalization and specificity. Noting the promising advantages but unexplored issues of IKE, we propose DistillMIKE as a novel extension of IKE, i.e., editing distillation of “Massive” In-context Knowledge Editing in large language models (LLMs), primarily consisting of two expansions: 1) Massive incontext knowledge editing (MIKE), which extends IKE to a massive editing task, aims to inject not a single edit but a set of massive edits into LLMs. To preserve specificity, our key novel extension is a “selective” retrieval augmentation, where the retrieval-augmented IKE is only applied to “in-scope” examples, whereas the unedited model without IKE is employed for “out-of-scope” ones. 2) Editing distillation of MIKE using low-rank adaptation (LoRA), which distills the editing abilities of MIKE to the parameters of LLMs in a manner that eliminates the need for lengthy in-context demonstrations, thereby removing the computational overhead encountered at the inference time. The experimental results on the zsRE and CounterFact datasets demonstrate that MIKE shows state-of-the-art performance, whereas DistilMIKE shows comparable performance to MIKE. Our code is available at https://github.com/JoveReCode/ DistillMIKE.git.

heading: 1 Introduction
text: While large language models (LLMs) have shown remarkable abilities across a broad spectrum of natural language processing (NLP) tasks (Touvron et al., 2023; OpenAI, 2023; Petroni et al., 2020), LLMs are still limited in the coverage and veracity of their world knowledge, thus causing reliance
*Corresponding author
on outdated knowledge (Onoe et al., 2022; Dhingra et al., 2022; Liška et al., 2022), or the generation of erroneous, hallucinatory, or biased contents (Zhao et al., 2023; Ji et al., 2023; Lazaridou et al., 2021; Agarwal and Nenkova, 2022; Gallegos et al., 2023). Given the evolving nature of world knowledge and the need to correct inaccurate information in LLMs, there has been a growing interest in the “knowledge editing” task, aiming at developing a scaled and effective editing mechanism that injects new knowledge into LLMs or corrects false and erroneous information in LLMs. In particular, this paper addresses the “massive editing” task, as in (Meng et al., 2022b), where a large number of edits are provided beyond just a single correction of an edit, the resulting editing mechanism needs to properly update more than hundreds or thousands of facts in LLMs simultaneously.
Among various approaches to knowledge editing, such as parameter updating (PU) (Cao et al., 2021; Tan et al., 2024; Meng et al., 2022a,b; Li et al., 2023; Huang et al., 2023; Dong et al., 2022a; Madaan et al., 2022) and memory-based methods (Mitchell et al., 2022b; Zheng et al., 2023; Onoe et al., 2023; Zhong et al., 2023; Madaan et al., 2022), in-context knowledge editing (IKE) has been newly proposed, inspired by in-context learning (ICL) emerged in LLMs (Brown et al., 2020; Dong et al., 2022b), showing noticeable editing performances in terms of generalization and specificity. Motivated by the respectable advantages of IKE, such as its human-interpretable editing method, we would like to go further toward expanding and improving IKE by addressing the following issues: 1) Extension to massive editing tasks: IKE has not been explored in the massive editing task, and thus, it remains largely unclear how IKE is generalized to the massive editing task, how IKE performs compared with other popular PU methods such as MEMIT, and whether the demonstration construction previously suggested in (Zheng et al., 2023)
7639
is also feasible in the addressed task. 2) Resolving the computational overhead caused by the use of lengthy prompts: IKE incurs computational and memory overhead at the inference stage, because the length of an input prompt becomes a “long,” resulting by prepending a non-trivial number of demonstrations.
Towards a novel extension for addressing the aforementioned issues, we propose DistillMIKE, the editing distillation of massive in-context knowledge editing in LLMs, which mainly consists of two components:
• Massive in-context knowledge editing (MIKE), which extends IKE to a massive editing task, leading to a retrieval-augmented IKE. A large number of massive edits (i.e. facts) to be injected into LLMs are first stored in a separate memory, namely the edit memory. Given an input query prompt, IKE is then preformed using its “relevant” edit retrieved from the edit memory, referred to a query-matched edit. To effectively preserve specificity, without employing IKE for all input prompts, we instead newly propose a “selective” retrieval augmentation, where the retrieval-augmented IKE is applied only for in-scope examples, not for other out-of-scope examples. Furthermore, given this selective nature of applying IKE, we further propose the use of scope-aware demonstrations, paying attention to in-scope cases, thus by including only “update” types of demonstrations that are likely useful for processing in-scope edits, but by excluding other “retain” types, as they may be mostly useful for out-of-scope cases.
• Editing distillation of MIKE using lowrank adapter (LoRA) for DistillMIKE, which distills editing abilities of MIKE to parameters of LLMs in a manner of eliminating the need of “lengthy” in-context demonstrations, aiming at reducing the computational overhead at the inference time. Inherited by the selective retrieval augmentation of MIKE, the editing distillation of MIKE is a multi-teacher distillation (Wu et al., 2021; Liu et al., 2020), where the two teachers are 1) the retrieval-augmented IKE for in-scope examples and 2) the unedited base model for out-of-scope examples. To substantially reduce the number of parameters to be updated, LoRA fine-tuning (Hu et al., 2022) is adopted
during the editing distillation, finally resulting in DistillMIKE.
Experimental results on the zsRE and CounterFact datasets demonstrate that MIKE achieves stateof-the-art performance in the CounterFact dataset, and DistillMIKE shows comparable performance with MIKE and improves existing editing methods such as IKE and MEMIT, even in the setting where lengthy in-context demonstrations and instructions do not appear in prompts.
Our contributions can be summarized as follows: 1) we propose MIKE, which extends IKE to the massive editing task based on selective retrieval augmentation depending on the scope type of an input query; 2) we further propose DistillMIKE, a LoRA-finetuned student model that is distilled from multi-teacher models – IKE and unedited base models – thereby injecting ICL prompts in MIKE into the model parameters, thus enabling inference without the need for lengthy demonstration prompts; and 3) the proposed MIKE and DistillMIKE show state-of-the-art and promising performances on the zsRE and CounterFact datasets.

heading: 2 Related Works
text: Existing methods can be broadly categorized into PU- and memory-based methods. Yao et al. (2023) presented an extensive review of knowledge editing methods. In this section, we briefly review selected methods and discuss some of them in terms of the novelty of our work.

heading: 2.1 PU methods
text: PU methods can be further categorized into three approaches: Meta-learning, locate-and-edit, and parameter expansion methods.
Meta-learning Knowledge Editor (Cao et al., 2021) trains a hypernetwork to approximate the parameter changes required for the model to predict new knowledge and preserve old knowledge. MEND (Mitchell et al., 2022a) employs a hypernetwork to transform the initial fine-tuning gradient into a simplified representation using low-rank decomposition to produce parameter updates. More recently, MALMEN (Tan et al., 2024) further extended MEND to massive editing tasks by aggregating massive parameter updates into a single parameter update, motivated by MEMIT, demonstrating its scalability.
Locate-and-edit Dai et al. (2022) proposed the concept of knowledge neurons for precise factual knowledge editing at the instance level. ROME (Meng et al., 2022a) is a pioneering study that attempts to locate the model parameters associated with the target factual knowledge and rewrite the key-value pairs in the feed-forward network (FFN) module with newly computed vectors. MEMIT (Meng et al., 2022b) further expands ROME to become scalable for massive editing tasks by spreading weight changes over multiple model layers. PMET (Li et al., 2023) improves MEMIT by considering the knowledge-storing role of the multihead self-attention (MHSA) layer, thus preventing overestimation of the parameter updates required for the FFN layers.
Parameter expansion In parameter expansion methods, parameters of LLMs are enlarged by integrating the newly trained extra parameters to store new knowledge in the original parameters. T-Patcher (Huang et al., 2023) adds one neuron to the last layer of FNN to handle a specific edit request, and CaliNET (Dong et al., 2022a) extends T-Patcher by using multiple neurons to cover a set of edits.

heading: 2.2 Memory-based Methods
text: IKE (Zheng et al., 2023) extensively explored ICLbased knowledge editing by proposing a novel method for demonstration organization that comprises multiple types of demonstrations designed to simultaneously improve generalization and specificity, which are the main evaluation metrics of the knowledge editing task. MELLO (Zhong et al., 2023) stores edited facts externally and prompts the language model iteratively to generate answers that align with them.
SERAC (Mitchell et al., 2022b) stores edits in a separate edit memory and employs a scope classifier to determine whether a query edit can be considered an in-scope example within the edit memory. If a query edit is classified as in-scope, then SERAC uses a counterfactual model. Otherwise, it uses a frozen base model for a given query edit.
Similar to MIKE, SERAC maintains an edit memory, reacts differently to in-scope and out-ofscope examples, and uses a scope classifier. However, SERAC has not yet been scaled up for massive editing tasks. In addition, SERAC requires additional training of the parametric counterfactual
model and scope classifier, whereas MIKE does not use a PU method but relies only on the ICL mechanism.
Although DistillMIKE is considered a PU method, to the best of our knowledge, our work on DistillMIKE is the first to use distillation methods for knowledge editing tasks.

heading: 3 Task Definition
text: To formally define the massive editing task, suppose thatM is an autoregressive language model, M(x) is the output generated by the decoding step given a prefix sequence x, and new factual knowledge to be injected intoM is represented as a set of relational triples. More specifically, S is a set of real-world entities or concepts, R is a set of relations, and E = {ei}Ni=1 is a set of edits (or facts) to be injected intoM, where ei = (si, ri, o∗i ) is the i-th edit, i.e., a relational triple that consists of a subject si ∈ S, a relation ri ∈ R, and an object o∗i ∈ S. It is commonly assumed that M does not contain each fact ei precisely; given a prefix xi = (si, ri) as the prompt input, M(xi) = oi is usually not equal to the target object o∗i , i.e., oi ̸= o∗i for most i.
The goal of knowledge editing is to obtain an edited modelM∗ toward satisfying efficacy, generalization, and specificity, for “all” edits.
• Efficacy holds if M∗(si, ri) = o∗i for (si, ri) ∈ E .
• Generalization is satisfied if M∗(s′i, r′i) = o∗i for a “paraphrased” prefix (s ′ i, r ′ i) ∈ I(ei),
where I(ei) is the edit scope of ei, the set of in-scope examples.
• Specificity (or locality) holds ifM∗(s, r) = M(s, r) for any irrelevant prefix (s, r) ∈ O(ei) where O(ei) = U − I(ei) is the set of out-of-scope examples, given that U is a universal set of knowledge.
Examples of an edit, its prefix, in-scope and out-of-scope prefixes, and their correct objects are presented in Appendix B.

heading: 4 Method
text: Figure 1 presents the overall architecture of the proposed MIKE and DistillMIKE with a brief sketch of their construction.
• Inducing MIKE as a teacher model: i) At the training time, given E , a set of test edits (i.e. new facts), MIKE merely maintains E in an external “edit memory,” without updating parameters. ii) At the inference time, given a query prompt q = (s, r), MIKE first applies a fact retrieval function Ret(q), which returns the best-matched fact eq ∈ E , called a querymatched fact; otherwise, Ret(q) returns a null, i.e., Ret(q) = ∅. A simple scope classification is then performed; q is classified as an out-ofscope case when Ret(q) = ∅; otherwise, q becomes an in-scope case.
MIKE acts differently for in-scope and out-ofscope cases; for an in-scope case, MIKE prepares in-context demonstrations selected from a set of “training” edits, denoted by Demo(q), and prepends them to a query prefix x; on the other hand, for an out-of-scope case, no demonstration is provided in a prompt. The
resulting prompts, with or without demonstrations, are fed toM to finally predict the output sequence. With this selective retrieval augmentation, the inference process of MIKE is summarized as follows:
M∗(q) = { M(Demo(q); q), Ret(q) ̸= ∅ M(q), Otherwise.
(1)
• Training DistillMIKE by editing distillation using LoRA: Inspired by the work of (Choi et al., 2023), we distill MIKE to a student model Mstθ with parameters θ, based on a LoRA-based PU method, for eliminating the need for “lengthy” demonstrations for in-scope cases. Given a set of “test” edits E , we use its in-scope and out-of-scope test edits as a training dataset for editing distillation, denoted by I (E) = ∪ei∈EI(ei) and O (E) = ∪ei∈EO(ei), respectively.
Let pM(y|x) be the generative probability of a sequence y, given prefix x computed using M. The loss function used for the editing distillation is summarized as follows: Led = KL ( pM∗ ∥∥∥pMstθ ) (2)
≈ ∑
q=(s,r)∈E ′ Eo∼pM∗ (·|q) log
pMstθ (o|q) pM∗(o|q)
where E ′ = I (E) ∪ O (E) indicates a whole set of training examples used for editing distillation.
To trainMstθ using Eq. (2), we undertake the LoRA fine-tuning method of Hu et al. (2022) to substantially reduce the number of parameters to be updated.

heading: 4.1 Teacher Model: MIKE
text: As in Eq. (1), the inference step of MIKE employs Ret, the “fact retrieval” function and Demo, the “demo selection” module, whose details are presented as follows:
4.1.1 Fact retrieval: Ret(q) Given a query prompt q = (s, r), Ret(q) attempts to find a query-matched fact eq by maximally matching the subject and relation parts of q. The matching for fact retrieval is divided into four cases:
1) an exactly matched case with eq = ei where ei = (si, ri, oi) ∈ E is exactly matched with a subject and a relation of q, i.e., (si, ri) = (s, r).
2) a uniquely subject-matched case with eq = ei where ei = (si, ri, oi) ∈ E is uniquely matched with a subject of q, i.e., si = s, while no other test edits match the subject s.
3) a subject-matched but ambiguous case with eq = top− 1(q, Es where eq is the nearest test edit among all the subject-matched ones, i.e., given Es = {ei = (si, ri, oi)|si = s}, an additional dense retrieval is employed to compute the similarities between an edit ei and a query for finding the nearest edit. 4) an unmatched case with eq = ∅, where no edits match a subject part s of q.
An illustrated example of fact retrieval is shown in Figure 2, with more details on the process.
4.1.2 Demonstration selection: Demo(q) As in Eq. (1), MIKE requires the demonstration selection Demo(q) for in-scope examples when Ret(q) = eq ̸= ∅. To be more specific, given E a set of test edits, MIKE keeps a separate set of “training” edits, denoted as E tr = { etrj }M j=1 . Unless otherwise stated, an edit refers a “test” edit, not being a “training” edit. In contrast to a test edit, each j-th training edit etrj is pre-associated with a set of demonstrations, referred to as D(etrj ). Similar to (Liu et al., 2022), Demo(q) first finds the top-k “training” edits that are most similar to a query-matched fact eq, i.e., e′1, · · · , e′k where e′i ∈ E tr. The demonstration filter g is then further applied to demonstrationsD(e′i) of each i−-th nearest training edits, resulting in g (D(e′i)). All filtered demonstrations are concatenated and prepended as a prompt prefix to the given query q, which is fed to M to finally produce a predicted output. In summary, the formal definition of Demo(q) is as follows:
e′1, · · · , e′k = kNN ( eq, E tr )
Demo(q) = [ g(D(e′1)); · · · ; g(D(e′k)) ]
where kNN ( eq, E tr ) is an additional retrieval function that finds the top-k nearest neighbors in the “training” edits E tr, which are the most similar to eq; a kind of dense retrieval is deployed to compute the similarities between a training edit etrj and eq, whose details are presented in Appendix C. Scope-aware demonstration filtering: g For the demonstration filter g, we propose the scope-aware demonstration filter for g, by using only “update” types of demonstrations, not including other types such as “retrain” types. This use of scope-aware demonstrations is motivated by the selective retrieval nature of MIKE, where IKE is applied only to in-scope cases and not to out-of-scope cases. Because IKE is not applied to out-of-scope cases, excluding “retrain” types of demonstrations may not negatively impact the editing performance.
To formally describe the scope-aware filtering method in g, for the j-th training edit etrj , its demonstrations D(etrj ) further consist of three types of demonstrations: Dcp(etrj ), Dud(etrj ), and Drt(etrj ), which correspond to sets of copy, update, and retrain types, respectively1, i.e., D(etrj ) =
1Here, the demonstration types of copy, update and retrain correspond to the “requested,” “paraphrased,” and “neighborhood” prompts in the CounterFact dataset, respectively.
(Dcp(etrj ),Dup(etrj ),Dtr(etrj )). In the proposed scope-aware demonstration filter, g ( D(etrj ) ) is defined as follows:
g ( D(etrj ) ) = Dup(etrj ) (3)
The detailed examples of three types of demonstrations are presented in Appendix H.

heading: 4.2 DistillMIKE
text: While MIKE presents promising results showing state-of-the-art performance on the massive editing task, as in Section 6, the major drawback is its additional computational overhead at the inference time, mainly caused by the increased prompts from a number of demonstrations. Inspired by (Choi et al., 2023), we would like to eliminate the need of using a lengthy sequence of demonstrations, and thus propose “editing distillation” from MIKE to a student model, such that the resulting student model, i.e., DistillMIKE, does not need to prepend a lengthy sequence of demonstrations but only use an input query prompt.
To substantially reduce the training cost for distillation, a student model is initialized by MEMIT and then fine-tuned using LoRA (Hu et al., 2022), where only a very small portion of the parameters need to be updated. It is noticeable that the proposed editing distillation of MIKE to a student model is somehow motivated by previous studies viewing ICL as gradient descent methods (Von Oswald et al., 2023; Dai et al., 2023), whereas their results are induced under rather limited settings such as the linear attention and few-shot learning abilities of ICL.
Because MIKE consists of two sub-models -– IKE and the unedited base model, the editing distillation applied to DistillMIKE can be seen as a multiteacher distillation, similar to (Wu et al., 2021; Liu et al., 2020). Suppose that training examples used for editing distillation E ′ are automatically classified into in-scope and out-of-scope examples, based on the scope classifier using Ret(q), denoted as I ′ and O′ respectively, defined as follows:
I ′ = { e ∈ E ′ ∣∣ Ret(e) ̸= ∅ }
O′ = E ′ − I ′ (4)
The loss function of Eq. (2) is rewritten as:
Led = Like + Lbase (5)
Like ∝ ∑
q=(s,r)∈I′ d=Demo(q)
Eo∼pM(·|d;q) log pMstθ (o|q) pM(o|d; q)
Lbase ∝ ∑
q=(s,r)∈O′ Eo∼pM(·|q) log
pMstθ (o|q) pM(o|q)
Therefore, under Eq. (5), it is clearly seen that for a given query q, DistillMIKE results from two teacher models – the IKE loss Like from pM(o|Demo(q); q) and the base loss Lbase from pM(o|q), depending on whether q ∈ I ′ or q ∈ O′.

heading: 5 Experiments

heading: 5.1 Dataset and Metrics
text: We evaluate MIKE and DistillMIKE on the ZeroShot Relation Extraction (zsRE, Levy et al. (2017)) and CounterFact datasets (Meng et al., 2022a) with 10,000 knowledge edits. The details and formats of the datasets are provided in Appendix H.
For zsRE, three metrics – Efficacy, Paraphrase, and Specificity – are employed to measure the editing capability concerning editing requests, paraphrases, and the retaining capability for out-ofscope examples. Detailed definitions of these metrics are provided in Appendix J.
For CounterFact, similar to the three metrics used in zsRE, we compute the Efficacy Score (ES), Paraphrase Score (PS), and Neighborhood Score (NS) to evaluate the editing accuracy (for editing requests and paraphrase prompts) or retaining accuracy (on neighborhood prompts), respectively. In addition, we report their mean differences in magnitude terms: Efficacy Magnitude (EM), Paraphrase Magnitude (PM), and Neighborhood Magnitude (NM), which measure the significance of editing. The aggregated Score (S) is calculated as the harmonic mean of ES, PS, and NS. A detailed definition can be seen in Appendix J.
The implementation details are provided in Appendix I.

heading: 5.2 Settings and Baselines
text: We use the GPT-J 6B model (Wang and Komatsuzaki, 2021), which is a widely employed backbone model in relevant studies, to compare MIKE and DistillMIKE with various existing knowledge-editing methods. In DistillMIKE, we
adopt MEMIT as the initial student model because it provides a good starting point for editing performance, as discussed in Section 6.2. The baseline methods include fine-tuning and four PU methods: MEND (Mitchell et al., 2022a), ROME (Meng et al., 2022a), MEMIT (Meng et al., 2022b), and PMET (Li et al., 2023). We also include IKE, an instance-level ICL-based method (Zheng et al., 2023).

heading: 6 Results

heading: 6.1 Main Results

heading: 6.1.1 Editing 10k knowledge in zsRE.
text: Table 1 presents the comparison results of MIKE, DistillMIKE, and other baselines on the zsRE dataset. MIKE achieves the best overall performance in terms of Score, with a particularly noticeable improvement in Paraphrase. DistillMIKE also achieves improvements over the baseline models but shows slightly lower performance compared to its teacher MIKE.
GPT-J, the original unedited model, shows a Specificity score of 27.0 only on the zsRE dataset; thus, it is likely that Specificity is not significantly improved by varying knowledge editing methods.

heading: 6.1.2 Editing 10k knowledge in CounterFact.
text: We initially assesse performance using GPT-J 6B in line with most baselines. and subsequently scale up to the larger GPT-NeoX 20B model to demonstrate the scalability.
Table 2 presents the comparison results of MIKE and DistillMIKE and the baselines in terms of both the accuracy metrics ES, PS, and NS, and the magnitude metrics EM, PM, and NM.
In the comparison based on GPT-J, the proposed MIKE and DistillMIKE significantly outperform all baselines in terms of overall performance (i.e., Score). MIKE and DistillMIKE demonstrate substantial improvements in Generalization and, noticeably, in Specificity. The fine-tuned (FT) model performs well in terms of Efficacy and Generalization, however, it shows a substantial deterioration in Specificity. While MEND also shows admirable Specificity, its other editing capabilities are largely weak in the case of 10,000 edits. IKE exhibits strong performance in terms of Efficacy and Generalization but underperforms in terms of Specificity. We clearly observe substantial performance gaps in the Generalization between DistillMIKE and other baseline methods, such as MEMIT, PMET, and ICL-based methods (i.e., IKE), and the results con-
firm the effectiveness of editing distillation again. On the GPT-NeoX 20B model, DistillMIKE exhibits superior overall performance compared to MEMIT and PMET, particularly demonstrating noticeable improvements in Generalization and Specificity.

heading: 6.2 Ablation Study
text: In Table 3, we further examine the effect of using the in-scope and out-of-scope teachers on editing distillation, denoted by MIKEike and MIKEbase, respectively, compared to the MEMIT-initialized student model. MIKEike and MIKEbase are the runs using M (Demo(q); q) (using our scope-aware demonstrations) andM (q) in Eq. (1) for “all” test queries, regardless their scope types.
MIKEike achieves near-perfect performances in ES and PS (i.e., Efficacy and Generalization) while
showing a very low value of NS (i.e., Specificity). By contrast, as expected, MIKEbase presents an almost upper bound of NS while showing low values of ES and PS. As the initial student model, MEMIT exhibits a balanced performance of the three metrics, however, its PS and NS performances are still far lower than those of MIKEike and MIKEbase, respectively.
Given its improved performance in Table 1-2, it is expected that DistillMIKE benefits by integrating distinct abilities from both worlds of the two teachers, i.e., learning the “editing” ability from MIKEike and the “retaining” ability from MIKEbase during editing distillation. Table 3 further shows the result of performing the “partial” distillation using only MIKEike with Like in Eq. (5). Compared to the full-fledged version (i.e., Like + Lbase), there is a substantial decrease in
NS, indicating that learning the “retraining” ability is not sufficiently done during distillation, using Like alone.
We believe that the use of MEMIT as a student model leads to a good starting point, where MEMIT already pursues a balancing mechanism in a manner of keeping the “retrain” ability, and thus the subsequent editing distillation does not seriously cause the catastrophic forgetting problem for outof-scope examples.
To examine the effect of using MEMIT as a student model, Table 4 presents the performances of NS before and after applying the partial editing distillation, when using different versions of MEMIT (including GPT-J) as student models, by varying the number of edits. It is shown that as the number of edits imposed on MEMIT increases (i.e., more extensively “surgical” pre-parametric updates are applied), the corresponding LoRA-distilled DistillMIKE keeps NS performances with greater stability. Thus, the results confirm that the choice of MEMIT as a student model is indeed necessary to achieve a balanced editing performance for Generalization and Specificity.

heading: 6.3 Inference Efficiency
text: To examine the inference efficiency of DistillMIKE and MIKE, Table 5 presents the average inference times and prompt lengths “per query” of these proposed models, compared to IKE and the unedited GPT-J. MIKE achieves a significant improvement in inference efficiency compared to IKE, mainly due to its selective retrieval augmentation manner. Furthermore, DistillMIKE leads to substantially make improvements over MIKE given its manner that does not require the retrieval augmentation, eventually achieving similar inference efficiency to the unedited GPT-J model.

heading: 7 Conclusion
text: In this paper, we proposed MIKE, which extends previous in-context knowledge editing methods from the instance level to a massive scale. Furthermore, we conducted an editing distillation of MIKE to induce DistillMIKE, which implicitly injects ICL prompts into model parameters, such that DistillMIKE significantly reduces the computational overhead caused by lengthy demonstration prompts. Extensive experiments conducted on the zsRE and CounterFact datasets demonstrated that MIKE and DistillMIKE surpassed existing knowledge editing methods, achieving state-of-the-art overall performance.
In future work, we would like to invent a direct unified approach for inducing DistillMIKE, motivated by existing studies that reveal that ICL can be equivalently projected to gradient descent methods (Von Oswald et al., 2023; Dai et al., 2023). Noting that incremental learning on knowledge editing is arguably important, it would be worthy to generalize the current editing distillation toward “continual” distillation, given the stream of sets of new edits. It would also be interesting to evaluate MIKE on other knowledge editing datasets, such as MQuAKE (Zhong et al., 2023).
Limitations
Current models primarily process data samples presented in tuple form, such as (subject, relation, object), while real-world natural language exhibits greater diversity and complexity. Investigating whether the current research can extend its applicability to universal text formats is an important issue for future research. In addition, the scope classifier proposed and utilized in our study is currently a straightforward method applicable to existing datasets. Further exploration is required to develop more intricate and advanced scope classifiers for more diverse data,
In practical applications, the iterative model updates requires incremental knowledge editing. This process involves continuing to edit new additional knowledge on a previously edited model. Therefore, exploring whether massive knowledge editing can be performed stably in an incremental iterative manner is an important avenue for future work. We would also like to conduct experiments on largerscale models, such as GPT-NeoX 20B and models from the Llama (Touvron et al., 2023) family, to investigate the effectiveness of deploying massive knowledge editing on larger models.
Furthermore, real-world questions are interrelated, and practical questions often exhibit multihop characteristics for question-answering tasks. However, exploration in the realm of multi-hop question-answering remains limited in existing literature. We also aim to explore the application of massive knowledge editing in multi-hop question answering, such as extending it to the MQuAKE (Zhong et al., 2023) dataset.
Finally, existing knowledge editing datasets are insufficient in scale and contain a considerable amount of noisy data. In the future, we will strive to create a larger and more comprehensive dataset to explore knowledge editing on a larger scale.

heading: Acknowledgement
text: This work was supported by Institute of Information & Communications Technology Planning & Evaluation(IITP) grant funded by the Korea government(MSIT) (RS-2023-00216011, Development of artificial complex intelligence for conceptually understanding and inferring like human). Shanbao Qiao and Xuebing Liu were also supported by China Scholarship Council (CSC).

heading: A Details of MEMIT
text: Note the MLP weights in a Transformer (Vaswani et al., 2017) as W that can be operated as a keyvalue store, where WK ≈ V , K = [k1|k2|...] and V = [v1|v2|...]. Given requested edits E = {(si, ri, oi)}, language modelMθ, layers to edit L = {L1, L2, ..., Ll}, and pre-cached covariance constant CL of k computed from Wikipedia samples (Meng et al., 2022a). For each (si, ri, oi) ∈ E , a target vector zi will be computed:
zi ← hLli + δi, (6)
where δi is optimized by:
δi ← argmin δi
1
P
P∑
j=1
ξi
ξi = − logPM(hLli +=δi)[oi|xj ⊕ (si, ri)] (7) Then for each editing layer L ∈ L, the hidden state is updated by:
hLi ← hL−1i + aLi +mLi (8)
where a and m denote the "attention" and "MLP" contributions computed from previous layers in Transformer (Vaswani et al., 2017) model. On the current layer, for each (si, ri, oi) ∈ E , the MLP key is updated as follows:
kLi ← kLi = 1
P
P∑
j=1
k(xj + si) (9)
where xj represents random prefixes that aid generalization across contexts. The distributed residual ϕ over remaining layers is computed as follows:
ϕLi ← zi − hLli
l − idx(L) + 1 (10)
where idx(L) denotes the number index of L. Thus in this layer kL = {kLi } and ϕL = {ϕLi }.
To update the MLP weights in the editing layers, for each layer L ∈ L, the adding weight is computed as follows:
∆L ← ϕLkLT(CL + kLkLT)−1, (11)
Finally, in current layer L the MLP weights are updated as follows:
WL ←WL +∆L, (12)
After the above updating performed on all the editing layers, we can obtain the parametric updated modelMθ∗ .

heading: B Edit Examples
text: Here, we present additional examples on CounterFact, which edit the factual answers to pseudofactual ones: example1:
• Editing request ei: "The 46th president of the US is Biden".
• Editing Prefix (si, ri): "The 46th president of the US is". Predict o∗: "Biden".
• In-scope prefix (Paraphrase) (s′i, r ′ i) ∈ I(ei):
"The winner of the 46th US presidential election is". Predict o∗: "Biden".
• Out-of-scope prefix (s, r) ∈ O(ei): "The president of Colombia is". Predict o: "Petro".
example2:
• Editing request ei: "Fiat Multipla is a product of IBM".
• Editing prefix (si, ri): "Fiat Multipla is a product of ". Predict o∗: "IBM".
• In-scope prefix (s′i, r ′ i) ∈ I(ei): "Fiat Multi-
pla is produced by". Predict o∗: "IBM".
• Out-of-scope prefix (s, r) ∈ O(ei): "Fiat Brevetti is created by". Predict o: "Fiat".
example3:
• Editing request ei: "Tor Endresen, who is a citizen of Nigeria".
• Editing prefix (si, ri): "Tor Endresen, who is a citizen of ". Predict o∗: "Nigeria".
• In-scope prefix (s′i, r ′ i) ∈ I(ei): "Tor En-
dresen holds a citizenship from". Predict o∗: "Nigeria".
• Out-of-scope prefix (s, r) ∈ O(ei): "Leonhard Hess Stejneger, a citizen of ". Predict o: "Norway".
example4:
• Editing request ei: "Kirsti Huke plays opera".
• Editing prefix (si, ri): "Kirsti Huke plays ". Predict o∗: "opera".
• In-scope prefix (s′i, r ′ i) ∈ I(ei): "Kirsti Huke
performs". Predict o∗: "opera".
• Out-of-scope prefix (s, r) ∈ O(ei): "Zeena Parkins performs". Predict o: "jazz".

heading: C Details of kNN Function
text: We use the dense retrieval for the kNN based on the cosine similarity between the training edit eTj and the given requested edit ei. More precisely, suppose thatMsent is an additional sentence encoder, whereMsent(s) ∈ Rd is the sentence vector for a given sentence s. For notational convenience, given an edit e = (s, r, o),Msent(e) =Msent([s; r; o]) where [s; r; o] is the natural language format that concatenates s, r, and o using a proper verbalizing template. The similarity between e = (s, r, o) and e′ = (s, r, o) is defined as follows:
sim(e, e′) = cos(Msent(e),Msent(e′)) (13) For a given edit ei ∈ E , kNN (ei, T ) is defined as follows:
top-k { (etj , sim(ei, e t j)) }M j=1
(14)
where top-k is the operator for selecting the top-k elements given a set of pairs of objects and their associated similarities. ForMsent, we deploy a pretrained sentence encoder (Reimers and Gurevych, 2019).

heading: D Ablation: KL-Divergence
text: We further present the KL divergences in ES, PS, and NS between the MEMIT-initialized student models under different scales of parametric updating and the teacher model of full DistillMIKE in Figure 3. The KL divergences on ES, PS, and PS are computed using Eq. (2) but summing over three types of query examples, namely copy-scope, inscope, and out-of-scope ones, corresponding to E , O (E), and O (E), respectively.
KLES = ∑
q=(s,r)∈E Eo∼pM∗ (·|q) log
pMstθ (o|q) pM∗(o|q)
KLPS = ∑
q=(s,r)∈I(E) Eo∼pM∗ (·|q) log
pMstθ (o|q) pM∗(o|q)
KLNS = ∑
q=(s,r)∈O(E) Eo∼pM∗ (·|q) log
pMstθ (o|q) pM∗(o|q)
(15)
This demonstrates that when using more extensive pre-parametric updating, the distribution gap between the output logits of the student and teacher models decreases. This also provides evidence that pre-parametric updating leads to faster convergence and better distillation results.
E ICL Demonstration
The ICL demonstration is shown in Table 6.

heading: F Ablation of the Number of Demonstrations
text: We further tested the affect of using different numbers of demonstrations on performance of MIKE. As shown in Table 7, reducing the number of demonstrations decreases Generalization, primarily because we rely exclusively on update-type demonstrations, which are specifically designed to enhance Generalization.

heading: G Retrieval-based Demonstration
text: Construction of Demo(q)
In the pre-editing stage, a set of “training” edits with their pre-associated demonstrations are prepared in advance; The j-th training edit etrj is pre-associated with its demonstrations of copy,
update and retrain types, denoted by D(etrj ) =( Dcp(etrj ),Dud(etrj ),Drt(etrj ) ) .
Figure 4 illustrates Demo(q) of the retrievalbased demonstration construction.

heading: H Datasets
text: In zsRE, each knowledge sample consists of one factual statement (editing request) along with its paraphrase, and a natural question unrelated to the editing request. In CounterFact, each knowledge sample includes a factual statement, two paraphrase prompts, and 10 neighborhood prompts, amounting to 21,919 samples.
H.1 Dataset Format
Dataset Format Example of CounterFact dataset: {
"case_id": 0,
"requested_rewrite": { "prompt": "The mother tongue of is", "target_new": “str": "English",, "target_true": "str": "French",, "subject": "Danielle Darrieux" }, "paraphrase_prompts": [
"Danielle Darrieux, a native", "Danielle Darrieux spoke the language"
], "neighborhood_prompts": [
"The native language of Montesquieu is", "The native language of Raymond Barre is", "Jacques is a native speaker of", . . . (10 prompts in total)
], "attribute_prompts": [
"The mother tongue of Douglas Adams is", . . . (10 prompts in total)
], "generation_prompts": [
"Danielle Darrieux’s mother tongue is", . . . (10 prompts in total)
] }
Dataset Format Example of zsRE dataset:
{ "case_id": 0, "requested_rewrite": {
"prompt": "What university did {} attend?", "subject": "Watts Humphrey", "target_new":
"str": "Illinois Institute of Technology" "target_true":
"str": "
" }, "paraphrase_prompts": [
"What university did Watts Humphrey take part in? "
], "neighborhood_prompts": [
"prompt": "nq question: who played desmond doss
father?", "target": " Hugo"
] }
I Implementation Details
To facilitate a fair comparison with related work, we conducted experiments using the GPT-J 6B model. We use the sentence-transformer toolkit as a retriever for any retrieval process.
For the zsRE (Levy et al., 2017) dataset, we extract 10,000 samples as the editing/test set to perform massive knowledge editing following related works (Meng et al., 2022b; Li et al., 2023), and use the remaining set (172,282 samples) as the retrieval corpus for ICL demonstration construction. We follow IKE to use 12 “update” demonstrations, but we do not use the “copy” and “retain” type.
For the CounterFact (Meng et al., 2022a) dataset, the original dataset comprises 21,919 samples. However, some samples may involve editing of new facts with the same prefix (s, r), leading to conflicts in multiple knowledge editing. To address this, we filtered the dataset following (Meng et al., 2022b), resulting in a total of 20,877 samples. We also use 10,000 samples as the editing/test set and utilize the remaining samples as a retrieval corpus to construct ICL demonstrations.
For distillation, we distill all the in-scope samples from the editing set and all out-of-scope samples from zsRE (only one is provided). However, for the CounterFact dataset, we use two out-ofscope samples (the dataset provides 10). This does not hinder the improvement in NS performance on the CounterFact dataset because the neighbors of the same editing request are usually similar; thus, each neighbor possesses a certain level of representativeness. We consider this an indication of the model’s generalization on “out-of-scope” scenarios.
All of our experiments were conducted on NVIDIA A6000 GPUs.

heading: J Detailed Definition of Evaluation Metrics
text: zsRE Metrics For Efficacy and Paraphrase:
E[o∗ = argmaxM∗(s, r)], (16)
where (s, r) is the prefix query for an editing request or its paraphrase. For Specificity:
E[o = argmaxPM∗(s, r)], (17)
where (s, r) is the prefix query for an unrelated statement. The overall Score is the harmonic mean
of the above three metrics that reflects the integrated performance of the model. CounterFact Metrics Accuracy Terms: For Efficacy Score (ES) and Paraphrase Score (PS):
E[P∗M(o∗|(s, r)) > PM∗(o|(s, r))], (18)
where (s, r) denotes the prefix query of the editing request (for ES) or the paraphrase prompt (for PS). For Neighborhood Score (NS):
E[PM∗(o∗|(s, r)) < PM∗(o|(s, r))]. (19)
where (s, r) denotes the prefix query of the neighborhood prompt. Magnitude Terms:
Note that Magnitude metrics do not represent the editing quality and have no absolute positivecorrelation with editing accuracy across different methods. For Efficacy Magnitude (EM) and Paraphrase Magnitude (PM):
E[PM∗(o∗|(s, r))− PM∗(o|(s, r))], (20)
where (s, r) denotes the prefix query of the editing request (for ES) or the paraphrase prompt (for PS). For Neighborhood Magnitude (NM):
E[PM∗(o|u(s, r))− PM∗(o∗|u(s, r))]. (21)
where (s, r) denotes the prefix query of the neighborhood prompt.

heading: Future Work
text: In future work, we would like to invent a direct unified approach for inducing DistillMIKE, motivated by existing studies that reveal that ICL can be equivalently projected to gradient descent methods (Von Oswald et al. , 2023; Dai et al. , 2023). Noting that incremental learning on knowledge editing is arguably important, it would be worthy to generalize the current editing distillation toward “continual” distillation, given the stream of sets of new edits. It would also be interesting to evaluate MIKE on other knowledge editing datasets, such as MQuAKE (Zhong et al. , 2023). Limitations
Current models primarily process data samples presented in tuple form, such as (subject, relation, object), while real-world natural language exhibits greater diversity and complexity. Investigating whether the current research can extend its applicability to universal text formats is an important issue for future research. In addition, the scope classifier proposed and utilized in our study is currently a straightforward method applicable to existing datasets. Further exploration is required to develop more intricate and advanced scope classifiers for more diverse data,
In practical applications, the iterative model updates requires incremental knowledge editing. This process involves continuing to edit new additional knowledge on a previously edited model. Therefore, exploring whether massive knowledge editing can be performed stably in an incremental iterative manner is an important avenue for future work. We would also like to conduct experiments on largerscale models, such as GPT-NeoX 20B and models from the Llama (Touvron et al. , 2023) family, to investigate the effectiveness of deploying massive knowledge editing on larger models. Furthermore, real-world questions are interrelated, and practical questions often exhibit multihop characteristics for question-answering tasks. However, exploration in the realm of multi-hop question-answering remains limited in existing literature. We also aim to explore the application of massive knowledge editing in multi-hop question answering, such as extending it to the MQuAKE (Zhong et al. , 2023) dataset. Finally, existing knowledge editing datasets are insufficient in scale and contain a considerable amount of noisy data. In the future, we will strive to create a larger and more comprehensive dataset to explore knowledge editing on a larger scale