DAFNet: Dynamic Auxiliary Fusion for Sequential Model Editing in Large Language Models (2024)

Abstract: Recently, while large language models (LLMs) have demonstrated impressive results, they still suffer from hallucination, i.e., the generation of false information. Model editing is the task of fixing factual mistakes in LLMs; yet, most previous works treat it as a one-time task, paying little attention to ever-emerging mistakes generated by LLMs. We address the task of sequential model editing (SME) that aims to rectify mistakes continuously. A Dynamic Auxiliary Fusion Network (DAFNet) is designed to enhance the semantic interaction among the factual knowledge within the entire sequence, preventing catastrophic forgetting during the editing process of multiple knowledge triples. Specifically, (1) for semantic fusion within a relation triple, we aggregate the intra-editing attention flow into auto-regressive self-attention with token-level granularity in LLMs. We further leverage multi-layer diagonal inter-editing attention flow to update the weighted representations of the entire sequence-level granularity. (2) Considering that auxiliary parameters are required to store the knowledge for sequential editing, we construct a new dataset named DAFSet, fulfilling recent, popular, longtail and robust properties to enhance the generality of sequential editing. Experiments show DAFNet significantly outperforms strong baselines in single-turn and sequential editing. The usage of DAFSet also consistently improves the performance of other auxiliary network-based methods in various scenarios 1.

heading: 1 Introduction
text: Transformer-based models, particularly LLMs (Devlin et al., 2019; Brown et al., 2020; Touvron et al.,
* T. Zhang, Q. Chen and D. Li contribute equally to this work.
† C. Wang and X. He are co-corresponding authors. 1The code and pre-trained models will be available at
https://github.com/qizhou000/DAFNet
2023; Roumeliotis and Tselikas, 2023) have become backbones of modern NLP and delivered promising results in various downstream tasks (Li et al., 2022; Zheng et al., 2022; Blevins et al., 2023; Blinova et al., 2023). However, LLMs still produce undesirable outputs occasionally (Basta et al., 2021; An et al., 2023). The cost of such mistakes is non-negligible and exhibits an inclination to generate hallucinations (Shi et al., 2023; Tam et al., 2023), resulting in seemingly plausible yet factually unsupported contents. To alleviate these problems, there has been growing interest in integrating knowledge into LLMs through model editing (Cao et al., 2021; Madaan et al., 2022; Meng et al., 2023). It updates the knowledge stored in relevant parameters in LLMs without fine-tuning the whole model.
In the literature, previous model editing methods2 can be divided into two categories, including Single-turn Editing and Sequential Editing. (1) Single-turn Editing edits one or a batch of knowledge triples at a time via modifying the original parameters of LLMs based on metalearning (Cao et al., 2021; Mitchell et al., 2022a) and locate-then-edit methods (Hartvigsen et al., 2022; Meng et al., 2022, 2023). These works struggle to handle factual knowledge that is continuously updated in real-world scenarios. (2) Sequential Model Editing (SME) based approaches learn the updated knowledge via adding extra modules (Dong et al., 2022; Mitchell et al., 2022b; Huang et al., 2023). The editing process of parameters is not achieved through back-propagation, but instead through weights independently calculated by extra modules associated with each fact. However, these methods do not take into account the effects of mutual semantic influence between these sequentially input facts. Another overlooked problem is that extra parameters are randomly initialized and can not
2“Model editing” and “knowledge editing” of LLMs share the same meaning. Thus, we use both terms interchangeably.
1588
provide a good starting point to cover the editing properties (Yao et al., 2023) of the testing data.3 As shown in Figure 1, previous model editing methods edit the sequential facts independently similar to single-turn editing in SME scenario. Thus, subsequent LLMs need to wait for previous LLMs to finish editing before they can be edited.
In this paper, we propose a dynamic auxiliary fusion network named DAFNet to explicitly capture the correlation among the input sequential triples for the update of knowledgeable parameters in LLMs. In addition, an auxiliary dataset named DAFSet for learning the meta-edit weights is constructed to compensate for the learning gap between extra cold-start parameters and testing properties in the training stage. To our knowledge, this is currently the first comprehensive training set in model editing4. Specifically, we introduce the above two main contributions as follows: DAFNet: Unlike previous methods that update parameters independently, we aggregate the representations of facts into intra- and inter-editing auto-regressive flows. The intra-editing attention flow gathers each token-level fact representation auto-repressively via assigning different semantic weights to tokens, decomposing the LLMs’ high-dimensional outputs to two low-rank representations as editing signal. The inter-editing attention flow obtains interactive representations of sentence-level sequential inputs through multilayer auto-regressive iterative diagonal attention between facts. Finally, our designed loss based on the desired editing properties is leveraged to train the auxiliary network. DAFSet: In previous works (Cao et al., 2021;
3The post-edit model should satisfy the following properties: reliability, generality and locality (Yao et al., 2023).
4Previous public datasets are used for testing editing ability of LLMs directly (Levy et al., 2017; Meng et al., 2022, 2023).
Mitchell et al., 2022a; Tan et al., 2023), weights of the original auxiliary network are usually randomly initialized and then combined with LLMs in multitask training. Therefore, the lack of training set for existing editing methods causes the inconsistency with the distributional characteristics of the final editing target solely by editing the facts (Bickel et al., 2007; Cai et al., 2023). The goal of constructing our auxiliary dataset is to learn auxiliary meta-weights to compensate for the bias caused by random weight distributions. DAFSet is designed to include four different properties (i.e., Recency, Popularity, Long-tailness and Robustness) based on the test editing properties. We collect data for these properties via subject frequency and output likelihood in various domains to make the learned auxiliary weights equipped with more generalized editing abilities.

heading: 2 Related Work
text: In this section, we briefly overview the related works of model editing for LLMs in four aspects. Adding Extra Modules: This method stores all edit examples in memory and uses a retriever to extract the most relevant facts for each new input, guiding the model in generating the edited fact. SERAC (Mitchell et al., 2022b) adopts a distinct counterfactual model while leaving the original model unchanged. Other methods edit LLMs by prompting the model with the edited fact and retrieved edit demonstrations from the memory such as MemPrompt (Madaan et al., 2022), IKE (Zheng et al., 2023) and MeLLo (Zhong et al., 2023). Additional Parameters: This paradigm introduces additional trainable parameters in LLMs, which are trained using a modified knowledge dataset while keeping the original parameters unchanged. T-Patcher (Huang et al., 2023) and CaliNET (Dong
et al., 2022) integrate a new single neuron (patch) for each error in the last layer of the FFN. GRACE (Hartvigsen et al., 2022) maintains a discrete codebook module for the middle layer of the LLMs. Locate-Then-Edit: The initial step involves identifying parameters that correspond to specific knowledge and then modifying them through direct updates to the target parameters. The work (Dai et al., 2022) introduces a method for identifying the specific “knowledge neuron” (a key-value pair in the FFN matrix) that represents the knowledge, and subsequently updating these neurons. ROME (Meng et al., 2022) applies causal mediation analysis to locate the editing area. MEMIT (Meng et al., 2023) expands on the setup of ROME, realizing the situation of synchronous editing for multiple cases. Meta-learning: It utilizes a hyper-network to acquire the essential updated weights for editing. Knowledge Editor (KE) (Cao et al., 2021) utilizes a hyper-network to predict the weight updated for each data point. MEND (Mitchell et al., 2022a) learns to edit LLMs fastly improving the performance via employing a low-rank decomposition of gradients as the input. MALMEN (Tan et al., 2023) accommodates editing multiple facts with limited memory budgets via separating the computation on the hyper-network and LM enabling arbitrary batch size on both neural networks. Note that, all the above editing methods focus on singleturn edits with one or a batch of facts, not taking into account semantic connections among the facts in a sequential order.

heading: 3 Preliminaries of SME
text: In this section, we provide a brief introduction to SME for LLMs. A model f ∈ F can be defined as a function f : X 7→ Y that maps an input x to its
prediction f(x). Then, given a model f and an edit example pair (xe, ye) that f(xe) ̸= ye, a model editor (ME) outputs a post-edit model f ′.
ME : F× X× Y 7→ F (1) f ′ = ME(f, xe, ye) (2)
Given a sequence of facts (xe1 , ye1), ..., (xeT , yeT ) and an initial model f , a model editor ME needs to conduct edits successively when the model makes undesirable output:
ft = ME(ft−1, xet , yet) , t = 1, ..., T (3)
where assume f0 = f . Every edit in SME should satisfy the following three properties:
Reliability A reliable edit holds when the postedit model ft gives the target answer for the every cases (xeτ , yeτ ), τ ≤ t to be edited. The reliability is measured as the average accuracy on the edit cases: E(xe,ye)∼{(xeτ ,yeτ )}tτ=1I { argmax y ft (y | xe) = ye }
(4)
Generality The post-edit model ft should also satisfy the relevant neighbours N(xeτ , yeτ ), τ ≤ t. It is evaluated by the average accuracy of ft on examples drawn uniformly from the relevant neighborhood:
E(xe,ye)∼{(xeτ ,yeτ )}tτ=1E(xg ,yg)∼N(xe,ye)G(xg, yg)
s.t. G(xg, yg) = I { argmax
y ft (y | xg) = yg
}
(5)
Locality Editing should be implemented locally, which means the post-edit model ft should not change the output of irrelevant examples in outof-scope O(xeτ , yeτ ), τ ≤ t. Hence, the locality is evaluated by the rate at which the post-edit model ft’s predictions are unchanged as the preedit model f :
E(xe,ye)∼{(xeτ ,yeτ )}tτ=1E(xl,yl)∼O(xe,ye) L(xl, yl)
s.t. L(xl, yl) = I {ft (y | xl) = f (y | xl)} (6)

heading: 4 The DAFSet Dataset
text: Due to the lack of training editing sets for various meta-learning based methods, we propose DAFSet to provide the initial editing ability of LLMs. It enables the model to better emerge with knowledge generalization ability (Yao et al., 2023; Cohen et al., 2023) in the test editing stage with four properties.

heading: 4.1 Data Collection
text: We leverage Wikidata5, a knowledge graph (KG) with relation triples represented as (eh, r, et), where eh is the head entity, r is the relation predicate and et is the tail entity. The specific collection steps for these properties are as follows. Recency: We gather triplets that have been recently added to Wikidata. The head eh and tail entities et are often associated with numerous redundant triples. To address this, we only collect relation triples associated with a set of 48 common relation predicates. We use the off-the-shelf tool6 to search the triples where each triple has been modified in the last 7 days. Then, we use templates to map the triples to construct the data samples, with templates shown in Appendix C.1. Popularity: We collect triples corresponding to popular entities, where head entities are from topviewed pages in Wikipedia. Next, we perform multi-hop selection of tail entities within 2-hops. Finally, we also leverage the above templates to construct the training samples. Long-tailness: LLMs often lack sufficient learning of low-frequency data, and thus editing effect on such knowledge is poor. We identify and con-
5https://en.wikipedia.org/wiki/Wikidata: Main_Page
6https://pypi.org/project/qwikidata/0.2.0/
struct training data related to long-tail knowledge from three perspectives: (1) Frequency: we first collect head entities and count their corresponding frequencies in Wikidata. Then, we set a threshold to select approximately 80% of entities with low frequencies. (2) In-out KG Degree: we calculate the connectivity of the corresponding head entities in KG, and then set the threshold to select low-frequency entities. (3) Likelihood: unlike the two intuitive statistics, our approach to identify long-tail data focuses on the semantics of the model’s output. Specifically, we input the sentence related to the head entity into LLMs and evaluate the model’s comprehension of the entity by examining the likelihood probability of its position7. Robustness: We employ three robustness properties (Omar et al., 2022) for constructing the training data, including text length, context, and emotions. To control the length of input prompts, we utilize the “loc” and “rephrase” fields of each edited data (Levy et al., 2017; Mitchell et al., 2022a; Cohen et al., 2023). Templates are used for training sentence construction, specifically for context and emotions, to prompt the LLMs for generation. To further enhance the robustness, we generate two opposite data attributes for each training data point, such as “positive” and “negative” in emotions.
7Detailed construction process is shown in Appendix C.1.
To learn auxiliary parameters and provide an initial meta-weight for editing, the data labeled as “recent” and “popular” is predominantly stable and frequently used to insert factual information. This leads to improved reliability and locality of test editing. In terms of the generality metric for test editing, the “long-tailness” and “robustness” categories can enhance the meta-weights, considering the sparsity of editing data. Overall, there are a total of 30,000 final constructed data samples for long-tailness, 13,000 for robustness, 30,000 for popularity, and 30,000 for recency.

heading: 4.2 Statistical Analysis on Our Dataset
text: We further conduct analysis on two complicated properties, i.e., long-tailness and robustness. As shown in Figure 2, we visualize the statistical results of our training data. The first subgraph on the left shows the frequency of head entities. We can see that the lower the frequency, the greater the proportion such as the sum of occurrence 1 and 2 has exceeded 80%. The second subgraph shows the proportion of head entities with different in-out kG’ degrees. We see that most of the data has neighboring edges with high degrees and thus we select long-tail triples with low in-out degrees. The third subgraph shows the output likelihood probability of target entities in editing sentences. We select data samples with low log likelihood (i.e., < −1.5) output corresponding to a large proportion as our long-tail training sentences. In the fourth subgraph, given that robustness needs to be applicable across various domains, we analyze the distribution of domains in the generated training data for robust editing.

heading: 5 The DAFNet Model
text: In this section, we formally introduce our DAFNet model, with an overall architecture shown in Figure 3.
In DAFNet, to obtain rich semantic representation for each knowledge triple, we perform a tokenlevel granularity fusion modeling by intra-editing attention flow in Section 5.2. Next, we leverage the auto-regressive modeling process to naturally capture the semantic interaction among sequential facts by inter-editing attention flow in Section 5.3.

heading: 5.1 Editing Signal Acquisition
text: In auxiliary network-based methods, we need to first determine the editing position before performing editing. We heuristically select linear layers
at the last few layers of LLMs (Meng et al., 2022; Mitchell et al., 2022a). Then, we obtain the editing signal input to the auxiliary network by decomposing gradients of the editing weight matrix.
Specifically, the gradient of the editing loss w.r.t. the weight matrix (to be edited) of a certain linear layer W in a language model f is a summation of B rank-1 matrix, where B is the token count of an editing sample (xe, ye). Formally, we have
∇WLedit(xe, ye) = B∑
i=1
u(i)⊤ · δ(i)
s.t. Ledit(xe, ye) = − log f(ye|xe) (7)
where u(i) ∈ R1×din , δ(i) ∈ R1×dout are the input and the output gradient of the linear layer at the ith token position, respectively. Thus, the editing signal of weight W for editing sample (xe, ye) is defined as h = [u; δ] ∈ RB×(din+dout). Note that editing signals w.r.t. different W s are independently fed into auxiliary networks.

heading: 5.2 Intra-editing Attention Flow
text: In SME, the semantic modeling among facts has a significant influence on the overall performance. We first separately fuse the edited signal after dimensional reduction w.r.t. each token, and then aggregate the fused edited sequence fact into autoregressive self-attention to further enhance the interaction between fact tokens.
Let the editing signal of the tth editing fact as h0t ∈ RBt×(din+dout), which is the input to the first intra-editing attention module. Assume the input to the kth layer is hk−1t . For the sake of simplicity, the layer symbol k is omitted below in this subsection. We obtain the token attention score αi via allocating the representation importance. The aggregated fact representations ĥt ∈ Rdin+dout fuse the tokens’ representations together with the token attention score. Specifically, we first transform the editing signal output into fused representation h′t ∈ RB×(din+dout) through a residual module as:
h′t = (σ(htW1 + b1))W2 + b2 (8)
where W1 ∈ R(din+dout)×ddown and W2 ∈ Rddown×(din+dout) are the linear layer weights. σ is ReLU function (Agarap, 2018). Then, we calculate the token attention weight α ∈ RBt×1 using the transformed representation h′t. The fused editing representation ĥt is learned from the token-span
representation h′t as follows:
α = φ(σ(h′tW3 + b3)W4 + b4), ĥt = α⊗ h′t (9)
h̄t =
Bt∑
i=1
ĥ (i) t , ĥ ′ t = ĥt + ht (10)
where W3 ∈ R(din+dout)×ddown , W4 ∈ Rddown×1. φ is the softmax non-linear activation function. ⊗ is the element-wise multiplication. Finally, each fused fact representation h̄t ∈ R1×(din+dout) is aggregated by the token importance. After obtaining the fused representations of all facts in the sequence, we transform the fused representations into the auto-regressive model for iteration learning to enhance the semantic information modeling between the fused facts:
h̄′1, h̄ ′ 2, ..., h̄ ′ T = fintra(h̄1, h̄2, ..., h̄T ) (11)
h̃t = ĥ ′ t ⊕ h̄′t, t = 1, 2, ..., T (12)
where fintra is the auto-regressive self-attention layer to fuse the facts sequentially. h̄′t ∈ R1×(din+dout) is the ith auto-regressive fact representation. T is the number of facts for sequential editing modeling. ⊕ is the element-wise addition. h̃t ∈ RBt×(din+dout) is the final intra-editing attention fusion representation. The intra-editing attention flow module is stacked by K layers. Finally, h̃t is fed as the input into the next module.

heading: 5.3 Inter-editing Attention Flow
text: Considering the effect of enhancing the interaction between facts in a sequence on updating iteration weights, we use the multi-layer auto-regressive diagonal attention to fuse the previous edited fact representations within a sequence. For each achieved editing fact weight score, we aggregate the last layer editing fusion weight representation h̃t, t = 1, ..., T to update the original LLMs.
Specifically, we use another multi-layer autoregressive self-attention layer to learn the relationship of facts for sequential editing modeling:
βk = diag ( fksa ( h̄1, h̄2, . . . , h̄T )) , k = 1, ...,K
(13) where fksa is the function to obtain the autoregressive self-attention matrix at kth layer. diag(∗) is the function to achieve diagonal values of a matrix. βk ∈ RT . Then, we aggregate the diagonal results of K layers into the averaged facts’
importance: β̄ = 1K ∑K k=1 β k where β̄ ∈ RT . Finally, the inter-editing fusion representations of each fact is h̃Kt ∈ RBt×(din+dout) at last Kth layer. We recover it to the original LLM’s weight shape to obtain updated weights of the T sequential facts and then sum them weighted by β̄:
[ũt; δ̃t] = h̃ K t , ∆Wt = ũ⊤t ⊗ δ̃t Bt
(14)
∆W̃T =
T∑
t=1
( T∏
τ=t+1
1− β̄τ ) β̄t ·∆Wt (15)
where ũt ∈ RB×din and δ̃t ∈ RB×dout are the decomposed weight representations, respectively. ∆W̃T ∈ Rdin×dout aggregates all the token weight representations together to achieve the fact updated weights’ representation. Finally, the process of sequential editing by T facts can be formulated as: fT = Γ(fT−1,∆W̃T ) where Γ indicates adding ∆W̃T to the corresponding matrix to be edited. Algorithm 2 in the appendix describes the implementation of how DAFNet performs each edit one by one in sequential editing. Next we formulate the losses of fT to model T edits into DAFNet.

heading: 5.4 Sequential Editing Training
text: Our auxiliary network considers three editing properties including reliability, generality and locality. Hence, the total loss with a T sequential editing facts is defined as follows:
Lrel(fT ) = T∑
t=1
− log fT (y(t)e |x(t)e ) (16)
Lgen(fT ) = T∑
t=1
N (t) g∑
j=1
− log fT (y(t)gj |x(t)gj ) (17)
Lloc(f, fT ) = T∑
t=1
N (t) l∑
j=1
KL(f(x (t) lj )||fT (x(t)lj ))
(18)
Ltotal = Lrel(fT ) + Lgen(fT ) + Lloc(f, fT ) (19)
where (x(t)e , y (t) e ) is the reliability sample of the tth fact, i.e., the editing sample itself. (x(t)gj , y (t) gj ) and x (t) lj are the jth generality and locality sample of tth fact, respectively. N (t) g and N (t) l are the corresponding loss sample number of tth fact. KL is the Kullback-Leibler Divergence function. Algorithm 1 describes the training process of DAFNet.

heading: 6 Experiments
text: In this section, we extensively evaluate the proposed method and compare it with strong baselines. Due to space limitation, we describe experimental settings including datasets, baselines and implementation details in Appendix A.

heading: 6.1 General Results of Sequential Editing
text: We first evaluate our DAFNet model over ZSRE (Levy et al., 2017), CounterFact (CF) (Meng et al., 2022) and RIPE datasets (Cohen et al., 2023), which are editing benchmarks. We compare the editing performance with 10, 100 and 1000 edits.8
8Due to the space limitations, the experimental results of single-turn and 1000 edits in Appendix C.3
Table 1 shows the overall performance. We can observe that: (1) Extra-module-based and metalearning methods show poor results in all metrics. We conjecture that meta-learning methods do not consider the sequential fusion modeling of facts. These methods only focus on single-turn editing with one fact. KN (Dai et al., 2022) achieves editing by amplifying the activation of located neurons, and thus multiple facts can lead to excessive amplification of activation. (2) Locate-then-edit methods in sequential editing scenario show normal performance. The reason may be that multiple backpropagation gradient signals can partially capture the inherent connections between the corresponding sequences. (3) DAFNet achieves significant improvement and the vast majority of results are the best, which proves the effectiveness of our method.
We further evaluate our DAFNet in single-turn editing scenario shown in Table 2 with LLAMA2 (7B) backbone. Our model also achieves the competitive performance over the specifically designed baselines for single-turn model editing.

heading: 6.2 Detailed Analysis
text: Influence of Properties in DAFSet. We discuss different properties of DAFSet. We choose typical meta-learning methods such as KE (Cao et al., 2021) and MEND (Mitchell et al., 2022a) as baselines to compare with DAFNet. Other baselines do not need extra data to learn random initialized parameters. We choose the entity-centric ZSRE (Levy et al., 2017) and the relation-centric dataset RIPE (Cohen et al., 2023) as our testing sets.
Based on Figure 4, we can see that (1) For Reliability and Generality, all training data with each property is beneficial for performance
improvement on the testing data. The KE model shows the performance on individual and combined data is poor. We suggest that the training of KE is based on a fixed batch of editing and modeling on the original model and thus the auxiliary network cannot adapt to new models generated by more than one edit. As the number of edits increases, the performance of these two indicators gradually decreases due to the increase in modeling complexity. (2) From the Locality results, we can also observe that the model performance can be further improved by adding our data to learn the meta weights. The locality results increase as the number of model edits increases. Influence of Attention Flows. In intra- and interattention flows, we use the auto-regressive attention mapping to all previous token and fact granularities. Considering that different window sizes may have different impacts on semantic interaction, we control different window sizes to test the model during editing. For the inter-attention flow, we need to explore whether the model really pays attention to the previous editing data during the sequence editing process. Specifically, we evaluate our DAFNet model on ZSRE using LLAMA2.
From Figure 5, we explore the window size influence of intra-editing attention flow. We can see that as the number of attention modeling window size increases, the results of these two indicators steadily improve. The reason is that these two editing metrics are highly relevant to the data of the test edited facts and thus the performance can be greatly improved based on the generality of the data. From Figure 6, the multi-layer inter-editing attention flow shows the self-attention importance with 1,000 edits. We can see that the importance
of semantic modeling for each interactive sentence is the greatest, which is consistent with the selfattention mechanism. With the increase of editing interactions, we can see that the data distribution of self-attention becomes more uniform, and the model can better focus on previously edited data.

heading: 6.3 Ablation Study
text: To assess the impact of intra- and inter-editing attention flows, we conduct an ablation study where we remove each module. This study demonstrates the performance on ZSRE (Yao et al., 2023) and RIPE (Cohen et al., 2023) using GPT-J. From Table 3, when the intra-editing attention flow module is removed, the editing performance of LLMs deteriorates rapidly. The results suffer when the dynamic token modeling process is removed, as it hampers the effective transfer of previously edited semantic memory to the editing of the next token in the facts. When we remove two main modules simultaneously, our model degenerates to only use the autoregressive attention modeling to perform the input gradient signal. Hence, it is easier to capture the semantic connections between sequentially edited data than other meta learning-based methods.

heading: 7 Conclusion
text: In this paper, we propose a dynamic auxiliary fusion model (DAFNet) for sequential editing, including the intra-editing and inter-editing attention flow modules. To obtain better meta weights for updating LLMs’ original weights in the auxiliary network, we further propose the DAFSet dataset to enhance the editing ability of LLMs. Experimental results show that our model achieves state-of-theart results over the strong baselines.
Limitations
For DAFSet, the raw data we currently use only contains factual knowledge from the Wiki. There-
fore, in the future, we will consider building a more widely distributed training set on other types of raw data. For DAFNet, due to the need for training, the preparation work before editing is more tedious and time-consuming compared to locatethen-editing based methods. In addition, due to limitations in machine resources, our model has only been tested at a parameter scale of around 10B. If there are more resources, we can experimentally demonstrate our results on a larger parameter scale.

heading: Acknowledgements
text: We would like to thank anonymous reviewers for their valuable comments. This work is supported by Alibaba Group through Alibaba Research Intern Program.

heading: A Experimental Settings
text: A.1 Training Data Following Yao et al. (2023), we use the ZSRE training data containing 162555 entries, the CF training data containing 10000 entries, and our proposed enhanced dataset DAFSet to train meta-learning
based models, including KE (Cao et al., 2021), MEND (Mitchell et al., 2022a), and our DAFNet model.
A.2 Evaluation Data ZSRE (Levy et al., 2017): It uses BART (Lewis et al., 2020) to answer questions and manually filtering, where each piece of data contains an editing sample, rephrased counterpart and an irrelevant sample corresponding to the reliability, generality and locality indicators, respectively. Inspired by (Yao et al., 2023), we divide it into a training set and a testing set with 162555 and 19009 entries. CF (Meng et al., 2022): The characteristic is that the facts to be edited are all false facts. Hence, the probability of the model answering correctly before editing is low, thereby increasing the difficulty of editing evaluation. Similar to ZSRE, each data contains an editing sample, rephrased data and an irrelevant sample. Following (Yao et al., 2023), both the training and testing sets contain 10000 entries. RIPE (Cohen et al., 2023): It finely divides the generality and locality into multiple parts. The generality includes logical generalization, combination I, combination II, and subject aliasing (Cohen et al., 2023). The locality includes forgetfulness and relation specificity. It is also an dataset editing false fact like CF, coupled with its fine-grained evaluation making it a difficult and comprehensive dataset. After pre-processing, a total of 4388 entries are collected.
A.3 Baselines In this work, besides using fine-tuning as the basic baseline, we mainly compare our DAFNet with three types of editing methods: Adding Additional Parameters: T-Patcher (Huang et al., 2023) attaches and trains additional neurons in the FFN of the last layer of the model to be edited. GRACE (Hartvigsen et al., 2022) proposes a General Retrieval Adapters for Continuous Editing (GRACE), which maintains a dictionary like structure to construct new mappings for potential representations that need to be modified. Locate-then-Edit: (1) KN (Dai et al., 2022) uses an integral gradient-based method to locate neurons in FFN, achieving editing by amplifying the activation of the located neurons. (2) ROME (Meng et al., 2022) first uses causal mediation analysis to locate the layer that has the greatest impact on the editing sample. They propose Rank One Model Editing
(ROME) to modify the FFN weight of the located layer. (3) MEMIT (Meng et al., 2023) expands the editing scope to multiple layers based on ROME, which improves editing performance and supports batch editing. Meta learning-Based: (1) KE (Cao et al., 2021) trains a bidirectional LSTM auxiliary network to predict weight updates of the editing samples. (2) MEND (Mitchell et al., 2022a) trains an MLP to transform the low-rank decomposition of the gradients of the model to be edited with respect to the editing samples, and updates the model with the transformed gradients to achieve editing.
We conduct a comprehensive comparison including the methods with additional or without additional data to train the auxiliary network. Some methods require additional data, while others inherently do not require additional data. Each method can be divided into three categories based on the different editing modes: (1) adding extra parameters modules (2) locate-then-editing and (3) metalearning based approach. Both meta-learning based methods and locate-then-editing based methods require additional data at different stages such as “ROME, MEMIT, KE, MEND”. Our DAFSet dataset aims to enhance meta-learning based editing methods. The meta-learning methods in our main experiment of Table 1 are all trained on data enhanced with DAFSet such as “KE” and “MEND”. From Figure 4, we can observe that our DAFNet model also achieves SOTA competitive performance without using additional DAFSet data. If DAFSet data is used, our modeling performance for SME can be further improved.
A.4 Model Settings and Training Details
DAFNet (1) Hyperparameter Settings: We use GPT-J 9 and LLAMA2 10 as our backbone models to edit and the same hyperparameter settings for the DAFNet auxiliary network. The basic module (including intra-editing attention flow and interediting attention flow) of the auxiliary network has 2 layers. We set ddown = 1024. All self-attention’s head numbers and middle dimensions (including K,Q, V,O) are set as 2 and 1024, respectively. Regarding the selection of editing weights, we use settings consistent with MEND and KE: GPT-J and LLAMA2 both use the FFN weights of the last
9https://huggingface.co/docs/transformers/ model_doc/gptj
10https://huggingface.co/docs/transformers/ model_doc/llama2
Algorithm 1 Training of DAFNet 1: Input: Language model to be edited f ,
initialized DAFNet M, training set D ={( x (i) e , y (i) e , { x (i) gj , y (i) gj }N(i)g j=1 , { x (i) lj }N(i) l j=1 )}N
i=1
,
maximum number of sequential editing modeling Tmax, EMA loss coefficient α, EMA loss initial value Lini, iteration number to increase sequential modeling number Iinc, increment scale γ for increasing sequential editing modeling number, maximum iteration number Imax, DAFNet learning rate η.
2: Output: trained DAFNetM. 3: # Current sequential editing modeling number. 4: Tnow = 1 5: # Initialize EMA loss and minimum EMA loss. 6: Lmin = Lema = Lini 7: # Set the iteration number of minimum EMA loss. 8: imin = 1 9: # Training iterations for DAFNetM.
10: for i← 1 to Imax do 11: # Randomly sample editing number T smaller than current modeling number Tnow. 12: Sample integer T from Uniform(1, Tnow) 13: D ← Sample T data from D 14: # Collect editing signals for T editing samples. 15: Sedit = [] 16: for (x(t)e , y(t)e , _, _) in D do 17: # Get editing signal by hook functions. 18: ut, δt = Hook(f, (x (t) e , y (t) e )) 19: Sedit.append([ut; δt]) 20: end for 21: # Input editing signals of the T sequential editing
modeling samples and obtain corresponding editing weights.
22: [∆W1, ...,∆WT ], [h̄1, ..., h̄T ], β̄ =M (Sedit, []) 23: # Compute the fused editing weight of the T editing samples and update the language model f . 24: Compute ∆W̃T by formula 15 25: fT = Γ(f,∆W̃T ) 26: # Compute loss using data from D. 27: Ltotal = Lrel(fT ) + Lgen(fT ) + Lloc(f, fT ) 28: # Update DAFNetM. 29: M← Adam (∇MLtotal, η) 30: # Update EMA loss and minimum EMA loss. 31: Lema = (1− α)Lema + αLtotal 32: if Lema < Lmin then 33: Lmin = Lema 34: imin = i 35: end if 36: # Update current sequential modeling number Tnow, which will increase exponentially until Tmax. 37: if i− imin > Iinc and Tnow < Tmax then 38: Tnow = Tnow +max(10, ⌊γTnow⌋) 39: Lmin = Lema = Lini 40: imin = i 41: end if 42: end for 43: return M
three layers of the model. Different editing matrices with the same shape and a shared DAFNet. Embedding layers are used to remap the representations of editing matrices of different FFN layers inputting into the same DAFNet.
(2) Training Details: As shown in Algorithm 1,
Algorithm 2 The tth Edit of DAFNet in Sequential Editing Scenario 1: Input: Language model to be edited f , trained DAFNet M, the tth edit sample (x(t)e , y(t)e ), the editing weight of previous t − 1 edits ∆W̃t−1 (zero when t = 1), the fused fact representations of previous t− 1 edits H̄t−1 = [h̄1, ..., h̄t−1] (empty list then t = 1).
2: Output: Edited model ft, the updated editing weights ∆W̃t, the updated fact representations H̄t. 3: # Get editing signal by hook functions. 4: ut, δt = Hook(f, (x (t) e , y (t) e )) 5: # Below input current editing signal [ut; δt], and past fused fact representations for Intra-editing Attention H̄t−1. Output the editing weight ∆Wt of the current fact, the fused representations h̄t of current fact, and the vector β̄ ∈ Rt described in subsection 5.3.
6: ∆Wt, h̄t, β̄ =M ( [ut; δt], H̄t−1 ) 7: # Update editing weight. 8: ∆W̃t = (1− β̄t)∆W̃t−1 + βt∆Wt 9: # Add updated editing weight to f .
10: ft = Γ(f,∆W̃t) 11: # Append fused representation of current fact into the list.
12: H̄t = [h̄1, ..., h̄t−1, h̄t] 13: return ft, ∆W̃t, H̄t
we define the initial sequential editing modeling number Tnow = 1. The moving coefficient of exponential moving average (EMA) loss α = 0.01, and set Iinc = 1000. We set the scale to increase the current sequential editing modeling number Tnow as 0.25, i.e., γ = 0.25. The upper limit for the sequential editing modeling number is 1000, i.e., Tmax = 1000. When the sequential editing modeling number reaches the maximum value, we perform an additional 20000 iterations before stopping. We store checkpoints every 1000 iterations and the checkpoint with the lowest loss would be selected for evaluation. The learning rate η is set as 1e-6. The training process takes 7 days on 8 NVIDIA A800 GPUs. These experiments are presented on average with 5 random runs with different random seeds and the same hyper-parameters.
Baseline Models For the baselines, we use the same settings in EasyEdit (Wang et al., 2023) to train and evaluate other editing methods.

heading: B The Editing Algorithm
text: In order to facilitate readers to better understand the model training and editing process, we have presented the algorithm pipeline of the training and editing in Algorithm 1 and Algorithm 2.

heading: C Additional Experimental Results
text: C.1 Dataset Construction The collected dataset samples are shown in Table 4, including the manual templates used to prompt the LLMs. The detailed long-tail dataset construction process is shown as follows:
• We use the LLMs to perform language modeling on each data in the dataset to obtain the log likelihood probability for each token position in the sentence.
• The sentence semantic representation is obtained by multiplying the log likelihood probability of all tokens.
• We select the subject in the sentence that is lower than the threshold as the long tail sentence.
Since the editing samples are all obtained through a single triple transformation, each editing sample only contains one entity and relation such as above samples. Therefore, the semantic of this sentence is usually dominated by entity and corresponding relation. If the log likelihood probability of the sentence is relatively low, it indicates that the semantic of the entity triple is not well memorized in the LLMs and the entity triple is low-frequency sparse knowledge (Godbole and Jia, 2023; Kandpal et al., 2023). Hence, it can be used for capturing the longtailnesses of those subject entities. Note that the construction process of long-tail data involves concatenating knowledge triples with conjunctions or articles to form a natural language. Their training samples lengths are basically the same. Meanwhile, we multiply by the corresponding sample length to maintain the fairness of the prediction probability as much as possible. Most samples have lengths between 6 and 8, and thus there is no unfairness in comparison after multiplication.
C.2 Computational Resource Analysis In order to evaluate the computational cost of our model and baselines, we compare the scores of different editors including “No training” and “Training” before editing on all datasets. The average score is performed on the editing numbers of 1, 10 and 100. Specifically, we evaluate the model’s overhead on machine resources by comparing Training time, GPU memory and Inference time.
From the Table 5, we can conclude that although our DAFNet model is not the optimal design in
terms of machine resources overhead, our model results have achieved significant improvement under the GPU memory. Our inference time also has strong competitiveness. Since the LLMs are usually trained once and can be reused, our training time is also acceptable. The high memory overhead is mainly due to the need for two different auxiliary networks to model the semantic interaction within and between facts. We can unify the modeling of the fusion process in two scenarios to save memory costs in the future.
C.3 Results of 1000 Sequential Edits The results of 1000 sequential edits are presented in Table 6. They also show the similar conclusion with general results, which prove the effectiveness of our approach.

heading: Future Work
text: We can unify the modeling of the fusion process in two scenarios to save memory costs in the future. C. 3 Results of 1000 Sequential Edits The results of 1000 sequential edits are presented in Table 6