InstructEd: Soft-Instruction Tuning for Model Editing with Hops (2024)

Abstract: The task of model editing becomes popular for correcting inaccurate or outdated parametric knowledge in Large Language Models (LLMs). However, there are major limitations of state of the art (SOTA) model editing methods, including the excessive memorization issue caused by the direct editing methods, as well as the error propagation and knowledge conflict issues from the memory enhancement methods, resulting in hindering models’ portability, e.g., the ability to transfer the new knowledge to related one-hop or multi-hop content. To address these issues, we propose the InstructEd method, the idea of which is to insert soft instructions into the attention module so as to facilitate interactions between instructions and questions and to understand and utilize new facts. Our main findings are: (i) InstructEd has achieved SOTA performance on three datasets for onehop/multi-hop evaluation with LLaMAs and GPT2, achieving 10% (5%) improvement in one-hop (multi-hop) model editing. (ii) Different from earlier methods on editing parameters in FFN, we show that editing attention can also help. (iii) Model editing is highly related to retrieval augmented methods, which can help improve the locality of model editing while slightly decrease the editing performance with hops. Our code is available at https://github.com/sev777/InstructED.

heading: 1 Introduction
text: Large Language Models (LLMs) have accumulated substantial parametric knowledge (Pan et al., 2023), showcasing remarkable progress in knowledge-driven tasks such as question answering (Kwiatkowski et al., 2019; Chen et al., 2021, 2022; Hu et al., 2023) and reasoning (Mihaylov et al., 2018; He et al., 2023). However, LLMs are susceptible to errors stemming from inaccurate or outdated parametric knowledge (Zheng et al., 2024),
* Contact Authors
restricting the reliability of these models. Previous research has introduced Model Editing (ME) (De Cao et al., 2021; Mitchell et al., 2022b) to rectify or update parametric knowledge in LLMs without the need for expensive re-training processes.
These methods either update the parametric knowledge within LLMs with either some given factual knowledge (called ‘modification based setting’) or some external knowledge repository (called ‘memory based setting’). In this paper, we propose a method that can address both settings.
In order to assess ME methods’ effectiveness in understanding and application of related factual knowledge, Yao et al. (2023); Zhong et al. (2023) proposed two new benchmarks, introducing the notion of portability, e.g., the ability to apply the new knowledge to related one-hop (Yao et al. (2023)) or multi-hop (Zhong et al. (2023)) content.
As illustrated in Fig.1, modification-based methods (Mitchell et al., 2022a; Meng et al., 2022, 2023a) calculate the parameter shift θ based on the new fact, which can only used to recall modified knowledge (Q-ED). Once the facts are discrepant with the new fact (such as Re-ED1), they cannot answer these questions based on the modified facts. As for the memory-based methods (Zheng et al., 2023; Mitchell et al., 2022b) maintain LLMs parameters unchanged and retrieve knowledge relevant to the current edit from a pre-constructed memory to achieve editing. Some recent memory based methods like MeLLo (Zhong et al., 2023) and PokeMQA (Gu et al., 2023) have been proposed to address multi-hop question editing. These methods rely on the retrieval results and necessitate decomposing multi-hop questions into subproblems. However, the knowledge conflict issue2 between retrieved results and LLMs, and error prop-
1Before addressing the question "What city is Messi’s team in?" we need to know "Messi is playing for Inter Miami."
2LLMs prioritize their own parametric knowledge and overlook retrieved non-parametric knowledge
1 14953
agation issue caused by decomposition, make these methods unstable to handle Q-ED and Re-ED.
Recently, instruction-tuning (Zhang et al., 2023) has emerged as a new paradigm for tuning LLMs to generate responses based on natural language instruction, which has been extensively researched in language (Gupta et al., 2023; Li et al., 2023a) and vision domains (Brooks et al., 2023; Liu et al., 2023a,b). These methods enhance LLMs by finetuning them using high-quality (instruction, output) pairs, boosting the model to comprehend user intentions and follow instructions more accurately.
In this paper, we present InstructEd, a novel approach for the challenging task of model editing with hops, by using soft instruction tuning. We construct an instruction dataset based on existing editing data to facilitate training. Unlike previous methods, we augment a set of learnable soft-instruction prompts as prefixes to the input instruction tokens in the attention module (rather FFN). We use a relevance score between the instruction and inputs to learn how to use knowledge and inject new knowledge (instructions) into the frozen LLMs.
Experimental results on three datasets demonstrate that our approach achieves superior portability of edits while maintaining stability in other essential properties. The main contributions of our work are as follows:
1) We propose a novel method InstructEd, enhancing the capability of LLMs to effectively utilize knowledge by adaptively modifying the atten-
tion module in LLMs, in both modification based and memory based settings. This is different from previous model editing efforts focusing on the FFN module.
2) Experimental on three datasets demonstrate that InstructEd exhibits excellent ability to understand and use instructions, achieving SOTA editing performance, achieving 10% (5%) improvement in one-hop (multi-hop) model editing over previous SOTA.
3) We investigated the feasibility of retrieval augmentation on model editing with hops and found that it can help improve the locality of model editing while slightly decrease the editing performance with hops.

heading: 2 Realted work

heading: 2.1 Model Editing
text: Model Editing emerges as a viable strategy for precisely updating LLMs without the expensive resources (Wang et al., 2023; Zhang et al., 2024). Recent studies on model editing can be divided into two categories based on whether the original parameters of the edited model are modified (Yao et al., 2023). One category involves directly modifying model parameters, exemplified by hypernetworks (De Cao et al., 2021; Mitchell et al., 2022a; Han et al., 2023a) and located-and-edit techniques (Meng et al., 2022, 2023a; Li et al., 2023b). The other incorporates additional modules to LLMs (Mitchell et al., 2022b; Han et al., 2023b;
2
Hartvigsen et al., 2022). Recently, in-context-based editing methods have gained attention. These methods guide the model in learning knowledge updates by providing editing examples (Zheng et al., 2023; Yu et al., 2023; Gu et al., 2023), offering greater flexibility. Nonetheless, this approach relies on the context selection and the scale of input prompt data. Additionally, PMET improved editing performance by modifying attention mechanisms. Inspired by this, we believe that attention, as an interaction module, can better facilitate the interaction between instructions and knowledge. Building on these concepts, we investigate how to guide the model in learning knowledge with minimal prompts and present an editing model grounded in instruction learning.

heading: 2.2 Instruction Tuning
text: Instruction tuning of language models has demonstrated its capability to enhance model generalization across unseen tasks, leveraging in-context learning with just a few examples (Zhang et al., 2023; Gupta et al., 2023; Li et al., 2023a). Recent works have leveraged instruction-driven fine-tuning methods, improving performance on previously unseen tasks through supervised fine-tuning on a limited number of examples (Li et al., 2023a; Ye et al., 2023). Furthermore, researchers have applied instruction tuning methods to image editing. They discern that the intent in the instructions successfully facilitates adaptive modifications to image content (Brooks et al., 2023; Liu et al., 2023a,b). In this work, we leverage the transfer ability of instruction to guide the model to learn how to utilize instructional knowledge adaptively, achieving generalization and portability in editing.

heading: 2.3 Prompt Tuning
text: Prompt (prefix) tuning (Li and Liang, 2021; Liu et al., 2022) is an efficient way to fine-tune LLMs. prompt refers to a text or instruction that guides the model in generating specific output types commonly applied in classification and questionanswering tasks (Chan et al., 2020; Pei et al., 2023; Huang et al., 2023). On the other hand, prefix refers to specific markers or sequences of words added before the input text to alter or control the model’s behavior, with many scholars recently applying it in Controllable text generation (Li and Liang, 2021; Lester et al., 2021; Meng et al., 2023b). This paper explores understanding instructions and utilizing and editing knowledge through fine-tuning with
inserted prefixes while freezing LLMs parameters. More discussion can be found in Appendix D.6.

heading: 3 The Proposed Method

heading: 3.1 Problem Formulation
text: We formally define the Model Editing (ME) task. To better explaining the complex editing scenarios of Multi-Hop Editing, Subject Replacement, and Reversed Relation we define facts in the form of triples. However, our proposed method does not require facts to be in the form of triples.
In particular, we denote LLMs as f and a fact to be edited as a triple e = (s, r, o), consisting of a subject (s), a relation (r), and an object (o). To convert the triple e into natural language, we employ the prompt template tr(·) 3. The editing task aims to update the object o to o∗ in e that shares the same subject and relation in LLMs f . This can be formally expressed as: f(tr(e)) = o → f(tr(e); ε) = o
∗, where ε represents the editor. Simultaneously, the editing model needs to handle both in-scope data Din, and out-scope data Dout. The in-scope data includes inputs generated by different templates tr for the same triple e. Outscope data refers to entities unrelated to e, such as any entity distinct from either the subject s or the relation r.
Following previous work (Yu et al., 2023; Gu et al., 2023), the post-edit model f(·; ε) is designed to satisfy the following properties: (1) Reliability: Ensuring that f(tr(e); ε) can output the target answer o∗. (2) Generalization: Ensuring that f(tr(ei); ε) can generate the target answer o∗ for ei ∈ Din, where ei share the same subject and relation with e. (3) Locality: Ensuring that f(tr(eo); ε) can generate the original answer o for eo ∈ Dout. (4) Portability: Ensuring that the model not only updates the current editing but also maintains consistency with other facts ep relevant to the current edits e.
Specifically, there are three aspects of Portability (Yao et al., 2023). (1) Hop-editing: For an n-hop question constructed by a chain of facts Q = {(s1, r1, o1), ..., (sn, rn, on)}, updating any object oi ∈ Q should result in the post-edit model outputting new results based on the new object o∗i within the chain
3For instance, given the triple (Messi, play for, Inter Miami CF), the template tr is "subject is playing for object", resulting in the sentence: Messi is playing for ___.
3
Q∗ = {(s1, r1, o1), (si, ri, o∗i ), ..., (s∗n, rn, o∗n)}.4 (2) Subject Replacement: Replace the subject s in the edited triple (s, r, o) with its alias s ′ , and the post-edited model should maintain the answer o, such as (Messi,playing for, *) and (Leo Messi, playing for, *). (3) Reversed Relation: When the target of a subject and relation is edited, the attribute of the target entity should also change, such as for an edit "Who is Mike’s Father? Bob → Tom", the answer for "Who is the son of Tom?" should update to "Mike".

heading: 3.2 Instruction Prompt for editing
text: To train the InstructEd, we first generate instructions based on the existing editing dataset CounterFact (Meng et al., 2022) and ZsRE (Levy et al., 2017). Subsequently, we design instruction templates to construct input data.

heading: 3.2.1 Generating instructions
text: For CounterFact (Meng et al., 2022), the original dataset provides triple information with modified knowledge and offers prompt templates to convert these triples into natural language. Therefore, we directly employ the natural language of the modified knowledge as instructions for the current data. As illustrated in Table 1, consider the edited triple in C-Edit: "(Messi, play for, Inter Miami CF)". Here, we utilize the natural language expression
4For example, with a two-hop chain: {(Messi, play for, PSG), (PSG, located in, Paris)}, updating the object "PSG → Inter Miami CF" should lead to the answer for the question "What city is Messi’s team in?" being "Miami" not "Paris," as the new triple is (Inter Miami CF, located in, Miami).
"Messi is playing for Inter Miami CF" as the instruction for the current editing instance.
For ZsRE (Levy et al., 2017), the original dataset lacks suitable prompts for transforming triplet information into natural language. To address this, we concatenate the question and the target answer to create the instruction. For instance, the instruction for the edited triple "(Messi, play for, Inter Miami CF)" is "Which team does Messi play for? Inter Miami CF".

heading: 3.2.2 Construct Input
text: For each modified data, we concatenate the instructions with four distinct types of questions, forming the input for the model and subsequently assessing the editing model based on four metrics. The input template is as follows:
Instructions: {Instructions} \n Input:{Input}. We used the four types of input mentioned above to train the editor. To adapt to real-world editing scenarios, we evaluate the editing based on whether the instructions for input (‘ED-Ins’ in Figure 2) are known or unknown, referring to both modification based and memory based settings. Appendix B shows the input cases and details of two editing scenarios.

heading: 3.3 InstructEd
text: We employ instruction editing data to train an InstructEd to learn to utilize edits based on instructions. Figure 2 shows that we use frozen LLMs with L layers. The input to the LLMs consists of three components: (1) The questions in natural language Q with Qn tokens. (2) The instructions in natural language I with In tokens. (3) A set of learnable adaption prompts P for instructionfollowing tuning. The prompts at layer l in the LLMs are represented as Pl, with a length of nl and a dimension of hp which is equal to the LLMs’ hidden dimension. Note that the prompts inserted into N layers of the LLMs are different (N < L).
The input is formulated as follows:
[Pl; I;Q] ∈ R(nl+Qn+In)∗h (1)
The instruction I serves as a prompt for LLMs when answering question Q. However, due to the knowledge conflict, LLMs may struggle to reconcile non-parametric instruction knowledge with their own parameterized knowledge. To address this, we introduce trainable prompts Pl as a prefix, which offers several advantages:
4
1) Prompts facilitate interactions between question Q and instruction I , enabling the model to consider more contextual information during generation. 2) Prompts assist in handling different types of instructions. For example, for Locality data, Pl should guide the model to rely less on the information within the instruction I . We have designed the following strategies to achieve the above objectives, as illustrated in Figure 2.
Insert prompts into the middle layer of the LLMs. In autoregressive models, tokens draw information solely from the above tokens (Meng et al., 2022, 2023a):
hl = hl−1 +ATTl−1 + FFNl−1, (2)
where ATT and FFN refer to the Attention and Feed-Forward module in transformer architecture. We perform prompt training in the L intermediate layers of LLMs (L = N/3), leveraging higher layers to capture semantic information representation between Q and I .
Editing the attention for interaction between Q and I . As the attention module serves as an interactive module in the transformer, it is crucial to leverage attention to facilitate interaction among Q, I , and Pl. Specifically, as shown in Figure 2, we modify the attention from layer l to l +N . In the attention mechanism of the preceding l layers, after generating M tokens (M< (Qn+In)), the attention
score of (M + 1)-th token t at layer l − 1 is calculated by several linear projections Linearq,k,v,o(·):
Queryl−1 = Linearq([M, tl−1]), (3)
Keyl−1 = Lineark([M, tl−1]), (4) Valuel−1 = Linearv([M, tl−1]), (5)
Sl−1 = Queryl−1Key T l−1/
√ C, (6)
where Queryl−1,Keyl−1,Valuel−1 ∈ R(M+1)∗h, Sl−1 ∈ R1∗(M+1), finally the attention output of l − 1 layer is:
tol−1 = Linearo(Sl−1Valuel−1). (7)
At layer l, we incorporate the prompts Pl into the attention mechanism. Subsequently, we concatenate the prompt with the (M + 1)-th token t and compute the new representations for Queryl, Keyl, and Valuel at layer l:
Queryl = Linearq([M ; tl]), (8)
Keyl = Linearq([Pl;M ; tl]), (9) Valuel = Linearq([Pl;M ; tl]), (10)
where Queryl ∈ R(M+1)∗h, and Keyl,Valuel ∈ R(nl+M+1)∗h. The attention score at layer l is:
Sl = QuerylKey T l /
√ C, (11)
where Sl ∈ R1∗(nl+M+1), and Sl can be reformulated in three parts:
Sl = [S nl l ;S In l ;S Qn l ] T , (12)
where nl, In and Qn are the prefix, instruction, and question length respectively. This implies that the attention score comprises both the instruction prompt pl, the tokens for instructions I and the question Q. Consequently, tl can learn information from all its preceding tokens and the prompt pl, fostering interaction between the question Q and the instructions I through pl:
tol = Linearo(SlValuel). (13)
Re-weight the attention score. For the editor to learn how to process the Locality instruction, we mitigate the impact of irrelevant instructions on the output by adjusting the attention weights. More precisely, we utilize the similarity scores between instructions and questions:
sim = Cos(Enc(Q),Enc(I)), (14)
5
where we employ the Enc(·) to encode both question Q and instruction I , utilizing the contriever encoder as described in (Izacard et al., 2022). Subsequently, we utilize the similarity score sim to re-weight the attention score:
S =
{ [sim ∗ (Snli ;SIni );S Qn i ]
T i ∈ [l, l +N ], [sim ∗ SIni ;S Qn i ]
T Else, (15)
where Snli , S In i , and S Qn i represent the attention scores for prompts, instruction, and questions, respectively.

heading: 4 Experiments

heading: 4.1 Experimental Setup

heading: 4.1.1 Dataset
text: We conduct comprehensive experiments on three widely recognized editing datasets: CounterFact (CT), ZsRE for one-hop evaluation, introduced in Yao et al. (2023), and MQUAKE for multi-hop evaluation, as described in (Zhong et al., 2023). We adopt the same data split of training and testing following Yao et al. (2023) and Zhong et al. (2023). The detail of the data is provided in Appendix A.

heading: 4.1.2 Setup
text: We conduct experiments on three autoregressive LLM: LLaMA1(7B,13B), LLaMA2(7B,13B) and GPT2-XL (1.5B) models. We compare our method against three classes of editors, encompassing a total of 11 models: 1) Preserving LLMs Parameters as our baselines: SERAC(Mitchell et al., 2022b), IKE(Zheng et al., 2023), RASE(Han et al., 2023b), GRACE(Hartvigsen et al., 2022). 2) Modifying LLMs parameters: FT(Zhu et al., 2020a), LoRA, ROME(Meng et al., 2022), MEMIT(Meng et al., 2023a), PMET(Li et al., 2023b). 3) Retrievalbased method for Multi-hop editing method: Mello (Zhong et al., 2023) and PokeMQA (Gu et al., 2023). To train InstructEd, we sample 10000 training instances from CT, which exclusively include the recall edits, and 2200 training instances from MQUAKE-CF-3k, which contains 2,3,4-hop edits in the following distribution 1000:910:290. The training process spans 10 epochs, with each batch comprising 6 instances of edits and 6 instances of unmodified data. For additional settings, please refer to Appendix B.

heading: 4.1.3 Metrics
text: We use Reliability (Rel), Generalization (Gen), and Locality (Loc) for single editing evaluation, Porhop
for one-hop evaluation, PorNhop and Hop-Acc for multi-hop editing evaluation, respectively Yao et al. (2023); Gu et al. (2023). Note that PorNhop refers to the results on multi-hop question answering after modifying one fact, while Porhop refers to the results on one-hop question answering after modifying one fact. Furthermore, to examine the generalization-specificity trade-off, we present the mean and harmonic mean scores of Rel, Gen, Loc, and Porhop as Score and Harmonic Score (H). Details on metrics can be found in Appendix C.

heading: 4.2 Main Results
text: Results on CounterFact. The edits in CounterFact are the facts that do not exist in the real world, which can ensure the manipulated/modified data have not occurred during the training of LLMs. Consequently, evaluations on CounterFact can better measure the editor’s editing capabilities.
InstructEd can better understand and utilize edited facts, outperforming existing models of varying scales, showcasing a remarkable enhancement in model editing with hops. As shown in Table 2, our approach demonstrates significant advantages in both Gen and Porhop. Compared with methods directly updating model parameters (M), our method flexibly updates various types of editing data and applies the updated knowledge in the model’s inference, avoiding issues of excessive memorization caused by direct parameter updates. Furthermore, in contrast to the memory-based method (P), we learn and leverage instructional knowledge to prevent the accumulation of errors when solving multi-hop editing while modifying attention parameters to alleviate knowledge conflicts in the model effectively. Results on LLaMA (13B) and more analysis are in Appendix D.1.
Results on ZsRE. In contrast to CounterFact, the ZsRE is specifically designed to rectify LLM errors. Consequently, as shown in Tabel 2, there is a notable enhancement in retaining LLM parameters due to incorporating additional modules or memory to constrain the output of LLM, especially IKE, which encourages model editing by providing external editing samples. However, InstructEd can still demonstrate greater generalization and robustness on ZsRE, showing good performance even when trained only on CounterFact and tested on ZsRE, further indicating that enhancing a model’s ability to utilize knowledge can fundamentally improve model editing with hops.
Results on MQuAKE. Table 3 shows the results
6
on MQuAKE-T (Zhong et al., 2023). In multi-hop question answering, we retrieve instructions for each multi-hop question through search. For example, for an N-hop question, we retrieve N facts (the top N retrieved facts) as instructions. Our method demonstrates excellence in both PorNhop and HopAcc, indicating that InstructEd can flexibly utilize instructional knowledge, providing advantages in multi-hop editing. Additionally, the accuracy of retrieval will affect the performance of our model. More discussion can be found in Appendix 4.5.

heading: 4.3 Further Analyses of InstructEd
text: Performance without Instructions We compared our method with the model without instructions
and the model without soft-instructions. All results were tested using CounterFact and MuQAKE-T. As shown in the Table 5: (1) InstructED can improve the generalization of editing and reduce the impact on the performance of the original model. Compared with ’-O’, InstructED shows a higher improvement in ’Gen’ and a lower decline in ’Loc’ than ’-Ins’, indicating that InstructED possesses a more stable editing ability. (2) InstructED demonstrates stronger instruction utilization ability. In comparison with ’-O’, the performance enhancement of InstructED on Hop, Multi-hop, and HopACC surpasses that of ’-Ins’. Furthermore, the improvement tends to increase as the model size increases, suggesting that InstructED enhances the model’s capacity to utilize instructions effectively.
Results for portability. InstructEd has not only achieved an advantage on the Porhop but obtained excellent results in the other two aspects of portability: Subject Replace (Rep) and Reversed Relation (Rev). As shown in Table 6, the InstructEd could gain great performance on Rev. However, for Rep, InstructEd is not ideal at the beginning. After we add additional instruction that never occurs during training and is unrelated to the edits (s is also known as s ′ ), the performance increases significantly, demonstrating its robust understanding and utilization of instructions. Details can be found in Appendix D.4.
Sequential editing Results. InstructEd is a plug-
7
and-play model that can address both batch editing and sequential editing. The results in Table 2 are obtained by modifying one edit at a time. InstructEd uses additional prefixes to achieve editing, allowing it to handle varying amounts of editing data flexibly and perform sequential editing while maintaining the performance. Therefore, whether editing a batch of data simultaneously or sequentially, InstructEd’s performance remains unaffected. In contrast, performance declines with the direct modification of model parameters as the number of sequential edited data increases. Details can be found in Appendix D.2.
Results of Different Model Scales. To validate the generality of our approach, we also tested it on models of varying scales, including GPT2-XL (1.5B) and LLaMA2 (13B). As shown in Appendix D.1. We observed that our method can be flexibly applied across models of different scales while maintaining consistent performance.
Efficiency of InstructEd. We utilized the A100 (40G) GPU to train InstructEd on LLaMA (7B) which took 7 hours. The inference speed is consistent with the original LLaMA model, averaging around 0.5 seconds per edit. Note that we assess the modification of each data point from four data, so the inference speed for each data point is 0.5/4 seconds. Regarding storage, InstructEd requires
approximately 0.8M of additional storage space.

heading: 4.4 Ablation experiment
text: In this section, we analyze the impact of different modules on InstructEd’s editing performance. Results are shown in Table 4.
"w/o re-weight" remove sim in Eq.15 and use the original attention weights, significantly reducing the locality. Indicate that InstructEd, when equipped with re-weighting, can effectively learn how to leverage knowledge flexibility.
"L:20-30" shows an additional ablation editing deep layer (20-30) in LLMs, rather than middle layer (10-20). The results indicate that editing deeper layers impedes the model’s effective use of knowledge (lower propagation scores) and leads to more pronounced negative impacts on the model (lower Locality scores). See Appendix D.3 for ablation experiments on editing layers.
"FFN" shows an additional ablation editing FFN weights rather than the attention module. Introducing a Adapter module to each FFN at layers 10-20 in LLMs reveals that editing the FFN remains a viable alternative, yielding a higher propagation score while maintaining other editing metrics. However, a lower Locality implies that imprecise editing of the FFN could lead to substantial adverse consequences. This paper validates that editing attention can achieve comparable or even superior results to editing FFN. More Discussion about FFN can be found in Appendix D.5.

heading: 4.5 Results with Retrieval augment
text: The results (+Retrieval) in Table 2 indicate that retrieval augmented can improve the performance of InstructEd especially on localization performance.
To assess the effectiveness compared to using only retrieval-augmented methods, we conducted a comparison with the Self-RAG (Asai et al., 2023).
8
The results in Table 7 show that the retrievalaugmented demonstrates great performance on ZsRE regarding localization. It can accurately determine whether a query is relevant to the input. However, the high correlation between the location data and input in CT makes the performance on CT is mediocre. For example, both edit input and loc input involve queries about the team to which a player belongs, leading to errors in judging relevance. The retrieval-augmented model has shown promise regarding editing, as pointed out by Pinter and Elhadad (2023), directly modifying the model can result in unknown and uncontrollable impacts on the original LLMs, using retrieval-augmented methods to achieve the model editing is safer and interpretable (Gupta et al., 2024; Gu et al., 2024).

heading: 5 Discussion

heading: 5.1 Retrieval-augmented for editing
text: Through comparative analysis with retrievalaugmented methods, we have found that Retrieval can provide factual support for model editing. While model editing requires fact-question-answer pairs, obtaining facts or evidence automatically in real-world applications remains essential. Retrieval facilitates acquiring updated facts, thereby provide data support for model editing. Model editing efficiently harnesses retrieval information. Retrieval typically yields non-parametric text-based information, whereas model editing transforms nonparametric knowledge into parametric knowledge.
This enables the model to utilize the information more effectively and alleviate knowledge conflicts.
Recently works retrieved facts from a preconstructed memory to enhance the performance of model editing, which limits the application scenarios of model editing. In the future, developing more efficient methods to combine retrieval-augmented with model editing will be key to implementing applied model editing.

heading: 5.2 Editing on Attention Layer
text: We aim to enhance the model’s comprehension and application of edited facts by improving its ability to follow instructions. Specifically, InstructEd enhances the model’s interaction between instructions and inputs by training additional prefixes that act on attention in certain layers, which we call softinstruction. In line with recent work (Xiao et al., 2024), they find that LLMs tend to pay more attention to the initial token during computation, with the initial tokens interacting more frequently with subsequent tokens in training, thereby more easily capturing some information that the model considers important. Likewise, Mu et al. (2024) achieves information compression and enhances the model’s ability to follow instructions by inserting certain GIST tokens. Similar to these methods, we have improved editing performance through modifications to the attention parameters, especially enhancement in multi-hop inference performances. Indicating that the interaction between instructions and questions can be better facilitated by editing attention, thereby helping the model understand and apply edited facts.

heading: 6 Conclusion
text: In this paper, we have presented an instruction tuning based method InstructEd for modeling editing with hops. We validate the effectiveness of InstructEd on varying scales of LLMs under three datasets, demonstrating InstructEd’s excellent generalization in both modification based and memory based settings. Our experiments indicate that, unlike previous editing methods, modifying attention parameters can model editing. Last but not least, we investigated the feasibility of retrieval augmentation on model editing and found that the retrievalaugmented methods can enhance the locality of model editing while slightly decreasing the editing performance with hops.
9

heading: 7 Limitations
text: In this paper, we introduce an effective method for model editing with hops. Although we achieve good results, there are still limitations in the following aspects: 1) We only focus on model editing with hops. In the future, we plan to look into model editing with more complex reasoning involved. 2) We utilize the retrieval augmented model to enhance InstructEd and verify the performance of the retrieval model Self-RAG (Asai et al., 2023) in editing tasks. However, novel integration of retrieval-augmented methods with model editing remains a challenge that needs further exploration in the future.

heading: Acknowledgements
text: This work has been supported by the National Natural Science Foundation of China (No.61936012), by the Science and Technology Cooperation and Exchange Special Project of ShanXi Province (No.202204041101016), by the Chang Jiang Scholars Program (J2019032), and by the Key Research and Development Program of Shanxi Province (No.202102020101008).

heading: A Dataset
text: We conduct comprehensive experiments on three widely recognized editing datasets: CounterFact
(CT), ZsRE for portability evaluation, introduced in Yao et al. (2023), and MQUAKE for Multi-hop evaluation, as described in (Zhong et al., 2023), the dataset has been divided into MQ-CF (for counterfactual edits) and MQ-T (for real-world fact updates) two sub-datasets. The detail of the data is provided in Table 8.
Both four datasets include single-hop and multihop editing data, while CT and ZsRE only contain up to 2-hop question-answer pairs, and MQ contains up to 4-hop question-answer data. ‘Overlap’ indicates whether there is a final multi-hop question answer in the edited factual calm. For example, for a 2-hop question: "What city is Messi’s team in?" if the edit is "Messi is playing for Inter Miami." Then, the overlap is 0 because the model needs to know that "Inter Miami is located in Miami." But if the edit is "Inter Miami is located in Pairs," the final answer "Pairs" is present in the edits, so the overlap is 1.

heading: B Experimental Details
text: Construct Input
To train the InstructEd, we use the following input template as the inputs:
Instructions: {Instructions} \n Input:{Input}. For example, as shown in Table 1, the instruction for edits is "Messi is playing for Inter Miami.". Accordingly, the Reliability input is "Instructions: Messi is playing for Inter Miami. \n Input: Which team does Messi play for?".
The Generalization input is "Instructions: Messi is playing for Inter Miami. \n Input: In which team does Messi play?".
The Locality input is "Instructions: Messi is playing for Inter Miami. \n Input: When was the recent World Cup held?".
The Portability input is "Instructions: Messi is playing for Inter Miami. \n Input: What city is Messi’s team in?.
12
Evaluate Strategy
During the testing phase, two strategies emerge depending on whether the gold instruction information is known:
(1) When the gold instruction for each edit is known, we concatenate the instruction with the corresponding data for assessment. The instruction is combined with a randomly selected and unrelated data point before evaluation for locality data.
(2) When we do not know the gold instruction for each edit, we rely on retrieving relevant instructions from a pre-constructed instruction memory. If no instructions were found, it indicates the current data point does not necessitate modification.
Evaluate with Retrieval When the gold instructions for each data are unknown, we use the retrieval model msmarco (Izacard et al., 2022) to retrieve instructions relevant to the current input from a pre-constructed instruction memory. If certain conditions are met, the data with the highest-ranked retrieval result is considered the current input instruction. Otherwise, the current data is deemed unnecessary to edit, and the original LLMs are used to calculate.
Specifically, we calculate the standard deviation of the scores for the top 5 ranked retrieval results. When the standard deviation is larger than 0.1, the similarity score of the highest-ranking result is significantly higher than the scores of the other 4 data. In this case, we consider the data with the highest ranking as the instruction for the input. Otherwise, the input does not contain a suitable instruction and does not require editing.
Experimental Setting We follow the setting provided in Yao et al. (2023) and Han et al. (2023b) for the baseline methods. We training InstructEd on 2 A100 (40G) GPUs for 10 epochs. The warmup epochs, batch size, learning rate, and weight decay are set to 4, 6, 9e-3, and 2e-2, respectively. We add 5 prefixes per layer and edit 10 to 20 layers in LLM.

heading: C Evaluation metrics
text: To evaluate the performance of a post-edit model, following Yao et al. (2023) and Gu et al. (2023), We use the following editing properties: Reliability,Generalization, and Locality for single editing evaluation. Portability, PorNhop , and Acc-Hop are used for multi-hop editing evaluation. We denote I
as the indicator function, and the post-edit model is fT .
Reliability is measured as the average accuracy on the edited dataset (xt, yxt) ∈ Ded, T is the length of Ded :
Rel = 1
T
T∑
t=0
I(fT (xt) = yxt). (16)
Generalization is measured as the average accuracy on the equivalent neighbor of edit dataset Dgen, we denote each edit case has Nt neighbors:
Gen = 1
TNt
T∑
t=0
Nt∑
i=0
I(fT (x i t) = yxit). (17)
Locality is evaluated by the rate at which the postedit model fT ’s predictions are unchanged as the pre-edit model f0 on Dloc, L is the length of Dloc:
Loc = 1
L
L∑
(x,y)∈Dloc
I(fT (x) = y) I(f0(x) = y) . (18)
For InstructEd, the y is the output of f0(·) or the True label.
portabilityhop is measured as the average accuracy on the multi-hop questions of edit case on Dpor, note that each x ∈ Dpor is related to an edit xt ∈ Ded:
Porhop = 1
T
T∑
(x,y)∈Dpor I(fT (x) = y). (19)
PorNhop is measured as the average accuracy on the multi-hop questions of edit case on MQuAKET Dmqt :
PorNhop = 1
T
T∑
(x,y)∈Dmqt I(fT (x) = y). (20)
Hop-Acc is measured if the post-edit model can answer the sub-questions for multi-hop questions on MQuAKE-T Dmqt, suppose each multi-question x can be decomposed to s sub-questions xs:
Hop-Acc = 1 T ∗ s T∑
(x,y)
s∑
(xi,yi)
I(fT (xi) = yi).
(21)
13

heading: D Extended Discussion of Results
text: D.1 Analyse for Baselines
Tabel 9 and Table 10 shows the results for GPT2XL (1.5B) and LLaMA2 (13B) on two datasets. Furthermore, we analyzed the results obtained by different methods in Table 2 to verify the effectiveness of InstructEd.
Fine-tuning (Zhu et al., 2020b), as the most direct editing method, does not show ideal results, resulting in lower local alignment scores while achieving lower editing capabilities. LoRA improves performance by training low-rank matrices to replace parameters in FFN compared to finetuning, but it also exhibits poor generalization. Both methods directly modify parameters in LLMs through gradient descent, neglecting the impact of parameter changes on other aspects of the model’s performance. Additionally, editing performance cannot be guaranteed when there is limited editing data.
ROME and MEMIT (Meng et al., 2022, 2023a), as representatives of the located-and-edit methods, generally exhibit great and stable performance. However, as they directly modify parameters in LLMs, there are still unknown impacts on the model and the risk of overfitting caused by excessive memorization resulting from editing(Hoelscher-Obermaier et al., 2023).
RASE and SERAC (Han et al., 2023b; Mitchell et al., 2022b) utilize additional cache as retrieval memory, training other parameters and additional modules for editing. However, as the results indicate, both approaches perform poorly on portability. This is attributed to their focus on knowledge updates during additional training modules, neglecting how to use knowledge effectively.
IKE (Zheng et al., 2023), as the most competitive method, achieves good performance on realworld datasets ZsRE by providing additional editing examples to prompt the model to learn the current task format. However, the lower performance on CounterFACT reflects the significant knowledge conflict with the LLMs, leading to unsuccessful modifications. Additionally, the performance of IKE is influenced by the number of additional prompts, requiring the model to have the capability to handle long texts.
Our approach focuses on learning how to utilize knowledge for LLMs. We design instructions and guide the model through the interaction of instructions and questions, achieving comprehensive edit-
ing performance in learning and utilizing knowledge. Furthermore, our approach maintains the parameters of LLMs, enabling application across various datasets while combining with retrievalaugmented methods to enhance performance.
D.2 Sequential editing Results.
As shown in Table 11, after continuous editing of 100 edits, the overall performance of MEMIT significantly deteriorates, and other methods are also heavily impacted, especially in terms of the Porhop metric. This is attributed to the continuous parameter adjustments these methods make to the LLM, leading to an increasing difficulty in editing and gradual degradation of model performance. In contrast, by freezing the parameters of LLMs, SERAC experiences a slower performance decline but fails to achieve satisfactory results in GEN and Porhop.
D.3 Ablation experiments on editing layers
The results of ablation experiments are shown in Figure 1. We tested the insertion of 5, 10, and 15 layers of prefixes into LLM. The results indicate that adding additional parameters beyond the 20th layer in LLM leads to an overall performance decrease compared to before the 20th layer, especially in terms of local performance. This suggests that modifying parameters in the higher layers of LLM is more likely to impact model performance.
When modifying parameters in the lower layers of LLM, the model exhibits lower success rates in editing. However, when modifying intermediate layers, there is a noticeable improvement in overall performance (such as 0-15 and 10-20). In order to maximize editing efficiency, we chose to modify layers 10-20.
D.4 Results for portabilit
We use the dataset in Yao et al. (2023) to evaluate the results on Subject Replace (Rep) and Reversed Relation (Rev). As the results in Table 6 show. Regarding Reversed Relations, InstructEd can understand and reason based on current instructions for reversed relations. In terms of Subject Replace, InstructEd performs modestly without the use of instructions. However, its effectiveness improves when relevant instructions are provided, indicating that our approach can significantly enhance the model’s comprehension and ability to use instructions.
14
D.5 Discussion of the role of ATT and FFN in Model Editing
In the Large Language Model (LLM), there exists a significant amount of parameterized knowledge. The mechanism for storing knowledge in the LLM remains an open question. Some studies have experimentally verified that more knowledge is retained in the Feedforward Neural Network (FFN). Building on this finding, corresponding editing models have been proposed, yielding certain advantages by updating parameters in the FFN.
However, Attention serves as a crucial module in the Transformer, and its role in the knowledge storage process still warrants investigation. Previous research conducted through ablation analysis found that Attention has a relatively minor impact on editing and that achieving knowledge editing through parameter updates in Attention is challenging. This perspective is one-sided, particularly given that At-
tention can equip the Transformer with potent interactive capabilities, making it a vital aspect in model editing. Furthermore, precise knowledge updates can be achieved by controlling the Query, Key, and Value (QKV) components within Attention. A deeper understanding of Attention in the future can facilitate the proposal of more efficient and accurate model editing methods.
D.6 Discussion of the prompt-tuning
Our approach achieves understanding and utilization of instructions by inserting additionally trained prompts into different layers of attention. As shown in Table 13, when not using prefix and only applying editing in the form of instructions to the original LLMs, the base model performs well on "Rel", indicating that instructional knowledge can provide the model with good factual support, and the model can extract knowledge from it. However, the lower
15
performance on "Gen", "Loc" and "Por" reflects the inability of the base model to transfer new knowledge to relevant content, which means they fail to understand and utilize the knowledge.
In addition, there are many other efficient finetuning methods such as Adapter, LoRA, Prompt, etc. Besides utilizing prefixes, we compared with Adapter ("w FFN" in Table 4) and LoRA ("LoRA" in Table 2), respectively.
Overall, while LoRA and adapters can improve the efficiency of fine-tuned models, they add the incremental change ∆h, obtained from the feedforward layer with the original h from the previous layer, the adapter or LoRA modifies the hidden representation calculated by the pre-trained model h = h+∆h, which is lack interaction with the information in the LLM. And the prefix requires fewer parameters. They can interact with the context in the LLM by adding the trainable prefix, which enables more efficient guidance for the model to perform corresponding reasoning and computations based on instruction knowledge. As shown in Table.13
16

heading: Future Work
text: A deeper understanding of Attention in the future can facilitate the proposal of more efficient and accurate model editing methods. D