Paper deep dive
Transformer-Patcher: One Mistake worth One Neuron
Zeyu Huang, Yikang Shen, Xiaofeng Zhang, Jie Zhou, Wenge Rong, Zhang Xiong
Models: BART-base, BERT-base
Intelligence
Status: succeeded | Model: google/gemini-3.1-flash-lite-preview | Prompt: intel-v1 | Confidence: 94%
Last extracted: 3/12/2026, 8:02:38 PM
Summary
Transformer-Patcher is a novel model editor for Sequential Model Editing (SME) that corrects errors in large Transformer-based language models by adding and training specific neurons in the last Feed-Forward Network layer, ensuring reliability, generality, and locality without retraining the entire model.
Entities (6)
Relation Signals (3)
Transformer-Patcher → performs → Sequential Model Editing
confidence 100% · Transformer-Patcher... achieves state-of-the-art performance for Sequential Model Editing (SME).
Transformer-Patcher → modifies → Feed-Forward Network
confidence 95% · It only adds a handful of trainable neurons (patches) to the last Feed-Forward Network (FFN) layer
Sequential Model Editing → requires → Reliability
confidence 90% · The desiderata of a qualified sequential model editor are three properties... 1)Reliability
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
Abstract:Large Transformer-based Pretrained Language Models (PLMs) dominate almost all Natural Language Processing (NLP) tasks. Nevertheless, they still make mistakes from time to time. For a model deployed in an industrial environment, fixing these mistakes quickly and robustly is vital to improve user experiences. Previous works formalize such problems as Model Editing (ME) and mostly focus on fixing one mistake. However, the one-mistake-fixing scenario is not an accurate abstraction of the real-world challenge. In the deployment of AI services, there are ever-emerging mistakes, and the same mistake may recur if not corrected in time. Thus a preferable solution is to rectify the mistakes as soon as they appear nonstop. Therefore, we extend the existing ME into Sequential Model Editing (SME) to help develop more practical editing methods. Our study shows that most current ME methods could yield unsatisfying results in this scenario. We then introduce Transformer-Patcher, a novel model editor that can shift the behavior of transformer-based models by simply adding and training a few neurons in the last Feed-Forward Network layer. Experimental results on both classification and generation tasks show that Transformer-Patcher can successively correct up to thousands of errors (Reliability) and generalize to their equivalent inputs (Generality) while retaining the model's accuracy on irrelevant inputs (Locality). Our method outperforms previous fine-tuning and HyperNetwork-based methods and achieves state-of-the-art performance for Sequential Model Editing (SME). The code is available at this https URL.
Tags
Links
Trouble viewing inline? Open PDF directly →
Full Text
54,952 characters extracted from source content.
Expand or collapse full text
Published as a conference paper at ICLR 2023 TRANSFORMER-PATCHER: ONEMISTAKE WORTHONENEURON Zeyu Huang 1,2 , Yikang Shen 4 , Xiaofeng Zhang 1,2 , Jie Zhou 5 , Wenge Rong 1,3 , Zhang Xiong 1,3 1 State Key Laboratory of Software Development Environment, Beihang University, China 2 Sino-French Engineer School, Beihang University, China 3 School of Computer Science and Engineering, Beihang University, China 4 Mila, University of Montreal, Canada, 5 WeChat AI, Tencent Inc, China zeroy.huang,yikang.shn@gmail.com,withtomzhou@tencent.com xiaofengz,w.rong,xiongz@buaa.edu.cn ABSTRACT Large Transformer-based Pretrained Language Models (PLMs) dominate almost all Natural Language Processing (NLP) tasks. Nevertheless, they still make mis- takes from time to time. For a model deployed in an industrial environment, fixing these mistakes quickly and robustly is vital to improve user experiences. Previ- ous works formalize such problems as Model Editing (ME) and mostly focus on fixing one mistake. However, the one-mistake-fixing scenario is not an accurate abstraction of the real-world challenge. In the deployment of AI services, there are ever-emerging mistakes, and the same mistake may recur if not corrected in time. Thus a preferable solution is to rectify the mistakes as soon as they appear nonstop. Therefore, we extend the existing ME into Sequential Model Editing (SME) to help develop more practical editing methods. Our study shows that most current ME methods could yield unsatisfying results in this scenario. We then introduce Transformer-Patcher, a novel model editor that can shift the behav- ior of transformer-based models by simply adding and training a few neurons in the last Feed-Forward Network layer. Experimental results on both classification and generation tasks show that Transformer-Patcher can successively correct up to thousands of errors (Reliability) and generalize to their equivalent inputs (Gen- erality) while retaining the model’s accuracy on irrelevant inputs (Locality). Our method outperforms previous fine-tuning and HyperNetwork-based methods and achieves state-of-the-art performance for Sequential Model Editing (SME). The code is available athttps://github.com/ZeroYuHuang/Transform er-Patcher. 1INTRODUCTION Transformer-based models, particularly large Pretrained Language Models (PLMs) (Devlin et al., 2019; Brown et al., 2020) have become the backbone model of modern Natural Language Pro- cessing (NLP) and have enabled promising results in various downstream tasks (Lv et al., 2019; Budzianowski & Vulic, 2019; Ramnath et al., 2020). However, PLMs still produce undesirable out- puts occasionally (Zhao et al., 2019; Basta et al., 2021). The cost of such mistakes is non-negligible. For example, a mistaken automatic translation result could get a person arrested (Hern, 2018). One of the most usual expedients was using a manual cache (e.g., lookup table) to overrule these problem- atic predictions (Sinitsin et al., 2020). Though convenient and straightforward, it lacks robustness and generality because it could be disabled by the slightest change in the input, such as paraphras- ing in natural language. On the other hand, one can also re-train the model on the original dataset supplemented with problematic examples. While superior in performance, it is computationally and temporally expensive to re-train large PLMs with billions or even trillions of parameters. Previous research formalized such problems as Model Editing (ME) and proposed various methods to intervene model’s behavior on a specific example while preventing the model from forgetting other examples. Some straightly finetune the model on the example and used a constraint loss to maintain the model’s overall performance (Zhu et al., 2020; Sotoudeh & Thakur, 2021). Some edit 1 arXiv:2301.09785v1 [cs.CL] 24 Jan 2023 Published as a conference paper at ICLR 2023 the model through a HyperNetwork, which regards the model and the false predicted example as inputs and produced a weight update for the model’s parameters (Cao et al., 2021; Sinitsin et al., 2020; Mitchell et al., 2022a). Despite their impressive progress, they mostly focus on one-step edit- ing (fixing one mistake), which is not applicable to practical situations. Because models deployed for real-world applications are expected to face different errors ceaselessly. And the same error may pop up repeatedly and bother different users. In addition, as illustrated in Figure 1, once a wrong an- swer appears in an online question-answering (QA) model, leaving it unfixed and waiting for future corrections could mislead more people. Therefore, an ideal model editor should providecontinuous andpromptlyfixing of newly emerged mistakes in an effective and efficient manner. 2022/11/11 19:03 图片4.svg file:///C:/Users/黄泽宇/Desktop/图片4.svg1/1 Instant correcon improves user experience The slower the fixing, the more users are bothered A QA model online WrongAnswer occurs! Instant Correcon UserCorrecon User botheredError Figure 1: Once an error occurs in a QA model online, it could bother many users contacting the model if not fixed in time. Instant correction is a superior choice to improve the user experience, motivating us to propose a Sequential Model Editing problem. Thus we extend the ME task into the sequential setting and formalize it asSequential Model Edit- ing(SME) task, which requires a model editor to fix a series of mistakes as soon as they appear. The desiderata of a qualified sequential model editor are three properties (Section 3). For each editing, the post-edit model should be of 1)Reliability: make the desirable output given the input; 2)Gener- ality: generalize over other equivalent inputs; 3)Locality: retain its accuracy over irrelevant inputs. We then propose a standard SME experiment pipeline that is compatible with different tasks and five evaluation metrics to evaluate the three properties. Experiments show that most existing model editors could fail to generalize to the sequential editing scenario. Fine-tuning-based methods are vulnerable to forgetting previous edits. HyperNetwork-based editors are strongly coupled with the initial model that they are trained with, thus failing to edit the model after several steps (Section 5). To handle SME, we introduce Transformer-Patcher. Unlike previous methods, Transformer-Patcher retains all original parameters to prevent harming the model’s overall performance. It only adds a handful of trainable neurons (patches) to the last Feed-Forward Network (FFN) layer to revise the model’s behavior on the problematic input and achieve a low editing cost. Furthermore, we train the patch to only respond to specific inputs with the proposed activation loss and memory loss. Experimental results on fact-checking (classification) and question answering (auto-regressive generation) indicated that Transformer-Patcher could rectify a series of mistakes (up to thousands) while almost perfectly retaining the model’s overall performance. The main contributions of this work are twofold: 1) We formally propose a sequential model editing task, as well as its standard experiment pipeline and evaluation metrics. 2) We introduce Transformer-Patcher, a simple yet effective model editor to revise transformer-based PLMs, achiev- ing state-of-the-art SME performance. 2RELATED WORKS Feed-forward NetworkBoth the Transformer encoder and decoder contain the Feed-Forward Network (FFN). Recent works (Geva et al., 2021; Dai et al., 2022) analogously observed that FFN operates as key-value neural memories (Sukhbaatar et al., 2015). They regarded the input of FFN as a query, the first layer as keys, and the second as values. Thus the intermediate hidden dimension of FFN can be interpreted as the number of memories in the layer, and the intermediate hidden state is a vector containing activation values for each memory. Therefore, the final output of FFN can be viewed as the weighted sum of values activated. Model editorsExisting model editors are mainly separated into two types: fine-tuning-based and HyperNetwork-based. Fine-tuning-based editors usually straightly tune the model with an extra loss to eschew over-fitting to edit examples. For instance, Zhu et al. (2020) proposed an extra loss 2 Published as a conference paper at ICLR 2023 to reduce the distance between pre-edit and post-edit parameters. Mitchell et al. (2022a); Meng et al. (2022) equipped fine-tuning with KL-divergence to restrict the post-edit model’s output space. For another, HyperNetwork-based editors require additional training phrases. Sinitsin et al. (2020) proposed a Meta Learning-based (Finn et al., 2017) approach named Editable Training to learn editable parameters for model modification. Cao et al. (2021) proposed KnowledgeEditor (KE) trained with constrained optimization to produce weight updates. Mitchell et al. (2022a) proposed MEND that learns to transform the gradient obtained by standard fine-tuning to edit large language models (Raffel et al., 2020). In addition, some works only focus on specific tasks, such as masked language modeling (Dai et al., 2022) and autoregressive language modeling (Meng et al., 2022; Geva et al., 2022). They require special input other than edit examples to conduct model editing. Continual LearningThe proposed SME task could be regarded as an emergent variant of Con- tinual Learning (CL) (Mundt et al., 2020). And dynamically expandable networks are employed for CL as well (Rusu et al., 2016; Li & Hoiem, 2018). But there are some differences in the setting. In CL, usually, the model is continually trained using different datasets and tasks. But SME deals with only one example at once and all examples are from the same task. The difference in setting renders SME an unexplored area with new challenges that may not be properly addressed by general CL methods. For example, KL divergence loss and L2 normalization are usual methods to address the catastrophic forgetting in CL (De Lange et al., 2022), but previous works (Cao et al., 2021; Mitchell et al., 2022a) and our experiments show that they can hardly maintain models accuracy on irrelevant inputs in ME task. And methods that add task-specific parameters for CL usually need extra train- ing (Yoon et al., 2018; Wortsman et al., 2020; de Masson d’Autume et al., 2019), thus falling short of SME’s application efficiency requirement. 3SEQUENTIALMODELEDITING PROBLEM exampe (푥 1 ,푦 푥 1 )that 푓 0 푥 1 ≠푦 푥 1 Model 푓 0 Model Editor Model 푓 1 Model Editor ............ A series of mistakes exampe(푥 2 ,푦 푥 2 )that 푓 1 푥 2 ≠푦 푥 2 Post-edit Model푓 푇 Figure 2: The process of sequential model editing task. Given thet-th mistake(x t ,y x t ), the editor takes the modelf t−1 and(x t ,y x t )as input, and outputs the revised modelf t . Following Mitchell et al. (2022a), a modelf∈Fcan be defined as a functionf:X7→Ythat maps an inputxto its predictionf(x). Then, given a modelfand an edit example pair(x e ,y x e )that f(x e )6=y x e , a model editorMEis to output a post-edit modelf ′ . ME :F×X×Y7→F (f,x e ,y x e )→f ′ = ME(f,x e ,y x e ) Given a data stream(x 1 ,y x 1 ),·,(x s ,y x s )and an initial modelf 0 , a model editorMEneeds to conduct edits successively when the model makes undesirable output, as shown in Figure 2. f t = f 0 ift= 0, f t−1 eliff t−1 (x t ) =y x t , ME(f t−1 ,x t ,y x t )else. (1) And after every edit in SME the post-edit modelf ′ should satisfy the following three properties: Property 1Reliability: the post-edit model should output the desired prediction: f ′ (x e ) =y x e (2) Property 2Generality: given an edit examplex e ,E x e =x j |y x j =y x e is defined as the set of its equivalent inputs (e.g. rephrased sentences). Then the post-edit modelf ′ should satisfy: ∀x j ∈E x e ,f ′ (x j ) =y x e (3) 3 Published as a conference paper at ICLR 2023 Property 3Locality: the edit should be implemented locally and precisely, which means the post- edit model should remain accurate on the irrelevant examples setI x e =X x e : ∀x j ∈I x e ,f ′ (x j ) =y x j (4) In particular, an edit should not disrupt the results of past edits in SME setting, which means: f t (x k ) =y x k ,forkwheref k−1 (x k )6=y x k (5) 4TRANSFORMER-PATCHER Classification: Elizabeth Truss is the UK Prime Minister Autoregressive Generation: Who is the UK Prime Minister? True (×) False (√) Patcher ElizabethTruss(×) RishiSunak(√) PatcherPatcher Transformer Layer ×(N-1) Input example Attention Layer Layer N Frozen Original Neurons A Patch (a neuron) Figure 3: Transformer-patcher enables efficient correction for classification and generation tasks, it rectifies the model’s behavior by adding and training several extra neurons in the last FFN layer. First, we call one misclassification or one wrongly generated token onemistakein the rest of the paper. Aiming at the SME task for transformer-based models, we proposeTransformer-Patcher shown in Figure 3. It freezes all original parameters and adds one neuron (patch) to the last FFN layer for one mistake. And we train the patch to take effect only when encountering its correspond- ing mistake. For classification, we add only one patch to rectify the model. For auto-regressive generation, we count how many tokens are wrongly generated under the teacher-forcing setting and add one patch for each of them. This section describes how to add and train one patch. Multiple patch editing follows exactly the same principle and is formally described in Appendix A. 4.1WHAT IS A PATCH? As mentioned in Section 2, FFN operates as key-value neuron memories. Its forward computation is a process that retrieves values from matrixVby matching keys in matrixKand the input query q. For a standard FFN, given a queryq∈R d , its outputFFN(q)is: a= Act(q·K+b k )(6) FFN(q) =a·V+b v (7) whereAct(·)is a non-linear activation function (e.g., Relu or Gelu),ais the vector of activation values,b k , andb v are two bias vectors. A patch is an extra neuron (an extra key-value pair) added to the last FFN layer. After patching, the new outputFFN p (q)is: [ a p ] = Act(q·[ K k p ] + [ b k b p ])(8) FFN p (q) = [ a p ]· [ V v p ] +b v (9) wherek p ∈R d is the patch key,v p ∈R d is the patch value,b p is a scalar named patch bias, a p = Act(q·k p +b p )represents the activation value of the patch. With the substitution of equations 6 and 7, equation 9 can be reformulated as: FFN p (q) =FFN(q) +a p ·v p (10) 4.2TRAINING A PATCH FOR EDITING An ideal edit requiresreliability,generality, andlocalityproposed in Section 3. Forreliability, a patch needs to be activated according to equation 10. Letq e represent the input query of the mistake, 4 Published as a conference paper at ICLR 2023 the patch keyk p and patch biasb p should satisfy: a p = Act(q e ·k p +b p )6= 0(11) WhenActis ReLU or GeLU, the above condition can be approximated as follows: q e ·k p +b p >0(12) To meet the constraint 12, we propose a activation lossl a to maximize the activation value: l a = exp(−q e ·k p −b p ))(13) Once a patch is activated, according to equation 10, it adds a bias terma p ·v p to the output of the last layer. Because we are editing the last layer of the model, the output of the model can be adjusted to any result without worrying that other components of the model would cancel the editing effect. To obtain the target output, we leverage the task’s original loss function and rename it as edit loss l e . Formally, for an edit example(x e ,y e ), the patched model’s output isp e ,l e is defined as: l e =L(y e ,p e )(14) whereL(·)is a function of labely e and model outputp e and depends on the specific task. Forlocality, the model’s behavior should not be shifted on irrelevant examples, thus the patch should not be activated by any irrelevant examples. When using ReLU or GeLU, it can be approximated as that all queries from irrelevant examplesq i should have a patch activation value less than or equal to a thresholdβ, i.e., the maximum of them is less than or equal toβ: ∀i∈I x e ,q i ·k p +b p ≤β→max i (q i ·k p +b p )≤β(15) Thus we propose the memory lossl m to enforce the constraint 15. To imitate the distribution of queries from irrelevant examples, we randomly retain some queries from previously seen examples as memories. Each query is ad-dimensional vector and we can stack them as a matrixM∈R d m ×d , whered m is the number of queries saved. Our proposed memory lossl m is the sum of two terms. The first terml m1 is introduced to make the patch inactivated to all queries inM: l m1 =S(M·k p +b p −β;k)(16) whereS(·;k)is a function that receives a vectorvand outputs a scalar S(v;k) = Avg[TopK(exp(v);k)](17) It first employs element-wise exponential function tovand then selectsklargest elements to com- pute their average as the output. Although constraint 15 is about the maximum, we employTopK here for more efficient optimization. In case thatl m1 can not absolutely ensure the constraint 15, we proposel m2 to distance the activation value ofq e andq i . That is, the activation value of the mistaken example is larger than that of the irrelevant examples by a certain marginγ. l m2 =S((M−q e )·k p +b p −γ;k)(18) To sum up, the lossl p for training a patch is defined as a weighted sum of the above losses: l p =l e +al a +ml m =l e +al a +m(l m1 +l m2 )(19) wherea,mare hyper-parameters.βis selected as -3 for GeLU and 0 for ReLu, since GeLU(- 3)≈0.004 is small enough and ReLU(0)=0.γis selected as 3 for GeLU and 0 for ReLU. 5EXPERIMENTS 5.1EXPERIMENTAL SETTINGS ANDEVALUATION METRICS We proposed an experimental pipeline for SME used for standard datasets with training setD train , validation setD val , and test setD test . There are two differences between our setting and the previous Model Editing setting. First, we employ multi-step editing rather than one-step. Second, previous works usually generate counterfactual edit examples (e.g., replacing the answer to a question with a random one), while we employ authentic examples where the model makes mistakes. We first split 5 Published as a conference paper at ICLR 2023 the originalD train into an edit setD edit and a new training setD ′ train . To evaluate generality, back- translation could be utilized to generate the equivalent setE x e for edit examplex e ∈D edit following previous works (Cao et al., 2021). To evaluate locality, a subsetD tr randomly sampled fromD ′ train is used to see how the post-edit model performs on its training data. Our SME pipeline starts with an initial modelf 0 trained onD ′ train and validated usingD val , the model is sequentially edited while encountering mistakes inD edit . After thetth edit example(x t e ,y t e ), we obtain a post-edit modelf t . Supposing that there areTtotal edits andIrepresents the indicator function, our proposed metrics are calculated as follows: 1)Success Rate(SR): to evaluate the reliability, we test if the post-edit model outputs the desired prediction. Thus, SR is: SR= 1 T T ∑ t=0 I(f t (x t e ) =y t e )(20) 2)Generalization Rate(GR): to evaluate the generality, we test the post-edit modelf t on the equivalent setE x t e =x t e,1 ·,x t e,N t of the edit examplex t e , thus GR is: GR= 1 TN t T ∑ t=0 N t ∑ i=1 I(f t (x t e,i ) =y t e )(21) 3)Edit Retain Rate(ER): to evaluate locality and reliability, we evaluate how many past edits are retained by the final modelf T . In a real application, a reliable model editor should keep the fixed bugs from recurring again, thus SR alone cannot evaluate reliability, and we define ER by testing the final model on all its past edit examplesE pe : ER= 1 T T ∑ t=0 I(f T (x t e ) =y t e )/T(22) 4)Training Retain Rate(TrainR): to evaluate locality, we compare the performance of the final model off T and the initial modelf 0 on subsampled testD tr . Thus, the TrainR is defined as: TrainR= ∑ (x,y)∈D tr I(f T (x) =y) ∑ (x,y)∈D tr I(f 0 (x) =y) (23) 5)Test Retain Rate(TestR): to evaluate locality, we see if the post-edit model still retains the generalization ability over unseen data. Then the TestR is defined as: TestR= ∑ (x,y)∈D test I(f T (x) =y) ∑ (x,y)∈D test I(f 0 (x) =y) (24) Datasets and BaselinesBoth classification and auto-regressive generation tasks are selected for evaluation. Following Cao et al. (2021) and Mitchell et al. (2022a), we employ Fact-Checking (FC) for classification and closed-book Question Answering (QA) for generation. For FC, we apply a BERT base model (Devlin et al., 2019) and the FEVER dataset (Thorne et al., 2018). For QA, we apply a BART base model (Lewis et al., 2020) and the Zero-Shot Relation Extraction (zsRE) dataset (Levy et al., 2017). We directly use the equivalent set released by Cao et al. (2021). We use the same data split as Cao et al. (2021). Both FC and QA are evaluated using accuracy. Our baselines include (1)Fine-Tuning-based editors: TheFTdirectly fine-tunes the model on the edit example. Following Mitchell et al. (2022a),FT+KLis selected as a baseline. It fine-tunes the model with an extra KL divergence lossl kl . Following Sinitsin et al. (2020) and Zhu et al. (2020), we report fine-tuning-based baselines by fine-tuning all parameters (FT(all)andFT(all)+KL) or the last layer (FT(last)andFT(last)+KL). (2)Two HyperNetwork-based editors: KE(Cao et al., 2021) and MEND(Mitchell et al., 2022a). (3)SERA: a variant of the latest SOTA memory-based model editor SERAC (Mitchell et al., 2022b). Other details of our baselines are reported in Appendix B. Experiment DetailsInitial models for two tasks are obtained following the same training settings as Cao et al. (2021). For FC, the accuracy of the initial model attains 94.1% onD tr , 76.9% on D test . For QA, the accuracy of the initial model attains 56.6% onD tr , 23.1% onD test . To reduce the experimental uncertainty, we randomly split the edit set inton= 20folders to run SME20 6 Published as a conference paper at ICLR 2023 Table 1: The Success Rate (SR), Generalization Rate (GR), Edit Retain Rate (ER), Training Retain Rate (TrainR), Test Retain Rate (TestR) of Transformer-Patcher (T-Patcher) and the baselines on FEVER and zsRE dataset. * denotes that the SR of the T-patcher on QA is 0.9987.†means the method requires extra training phases and training data. FEVER Fact-CheckingzsRE Question-Answering Editor BERT-base (110M)BART-base (139M) SRGRERTrainRTestRSRGRERTrainRTestR FT(last)1.000.610.590.8930.9461.000.580.300.9140.924 FT(all)1.000.740.830.9680.9941.000.680.430.8650.910 FT(last)+KL1.000.530.450.9680.9981.000.570.280.9230.933 FT(all)+KL1.000.710.490.9981.0111.000.680.390.8890.925 MEND † 0.040.030.060.3490.652 0.410.370.000.0000.000 KE † 0.140.120.280.4860.6500.090.080.000.0000.000 SERA † 1.000.891.000.9040.9161.000.900.980.9060.901 T-Patcher1.000.821.000.9991.0001.00*0.820.990.9970.996 Table 2: The experimental results when utilizing all data inD edit as a single run of SME on QA task. The results of the FC task are presented in Table 7 in Appendix C. E represents how many edits have been conducted. N represents how many mistakes have been made by the initial model f 0 on the entire edit setD edit . EditorSRGRERTrainRTestREN FT(all)+KL1.000.690.140.9360.97428212766 SERA1.000.900.970.7280.69435582766 T-Patcher0.990.810.970.9120.94823082766 times and report the averaged performance as the final result. The initial modelf 0 makes about 63 mistakes in an FC folder and about 139 in a QA folder on average. For methods requiring memories (fine-tuning with KL and ours), 40,000 memory examples are sampled fromD ′ train tr are employed for both tasks and are updated as editing proceed. The hyperparametersaandmare selected as 1 and 10 respectively for both tasks to make the extra losses and the original task loss in the same order of magnitude. Other details can be found in Appendix B. 5.2EXPERIMENTAL RESULTS Main resultsThe experiment results are shown in Table 1. Our method achieves strong perfor- mance in all five metrics across two tasks. It could make a series of model corrections (SR≈1) while nearly retaining every past edit (ER≈1) and almost perfectly keeping the model’s overall per- formance (TrainR≈1, TestR≈1). The fine-tuning-based editors could partly preserve the model’s behavior and achieve high SR, but it is vulnerable to forgetting previous edits (low ER). Two HyperNetwork-based editors fail in the SME setting. They have trouble retaining models’ over- all performance (low ER, TrainR, TestR) and conducting a series of edits (low SR and GR). SERA achieves the highest GR, while can only partially preserve the model’s overall performance (TestR, TrainR≈0.9) compared to T-Patcher. Apart from being effective, our method is efficient enough as well. Using a V100, one edit costs only 7.1s for FC and 18.9s for QA. We could further improve the efficiency to 4.7s and 12.4s by decreasing the number of memory examples to 10,000. Scale up to thousands of editsTable 1 shows that Transformer-Patcher achieves good perfor- mance for about 60 edits on FC and 140 edits on QA, thus we wonder if it could handle more edits. So we utilize all data inD edit as a single data stream to run SME. As shown in Table 2, Transformer-Patcher could effectively correct up to thousands of mistakes and retain the model’s overall performance simultaneously compared with the other two strong baselines. It’s interesting to notice that the number of edits E of Transformer-Patcher is less than the number of actual mis- takes N made by the initial model. In other words, our method can fix some potential mistakes in the initial model before the error actually happens. On the contrary, the fine-tuning-based method fixes more mistakes than the original model, which means it created more errors during the editing 7 Published as a conference paper at ICLR 2023 process. It seems contradictory that our method attains fewer E and lower TestR, this may due to the distribution shift betweenD edit andD test . See more explanation in Appendix C. Furthermore, the post-edit model only gets1.4%larger for FC and4.5%larger for QA. We believe this cost is acceptable for automatically correcting the model’s mistakes from time to time during deployment. In practice, we suggest using the transformer-patcher to provide a timely response for each mistake online, and after accumulating certain quantities of mistakes, we could fine-tune the original model on all accumulated mistakes, so that the patches can be removed. In this way, we could achieve a good balance between model size and editing effectiveness. 5.3ANALYSES 0306090120150 0.0 0.2 0.4 0.6 0.8 1.0 TPatcher MEND KE (a) Success Rate on FC 0316293124155 0.0 0.2 0.4 0.6 0.8 1.0 MEND KE TPatcher (b) Success Rate on QA Figure 4: Variation of success rate (SR) with the number of edits. Different methods have different edit times, we plot until they converge. The collapse of MEND and KEWe discuss here why MEND and KE fail in the SME. Figure 4 presents how SR varies with the number of edits on both FC and QA. Figure 4 shows that MEND and KE are effective in the first few steps, but shortly after they are no longer able to produce valid edits. However, in their original paper (Cao et al., 2021; Mitchell et al., 2022a), they both reported that they achieved high SR when dealing with one-step editing. We find this phenomenon reasonable since both HyperNetwork-based editors are trained with the initial modelf 0 and thus strongly coupled with the original parameters. As the editing proceeds, the model becomes more different from the initial one, resulting in their failure. We tried to retrain HyperNets after every edit using the post-edit model, but the cost for re-training is unacceptable as it costs hours to train a HyperNet model editor. Table 3: The ablation results for two alternatives of memory loss. Patch FEVER Fact-CheckingzsRE Question-Answering SRGRERTrainRTestRSRGRERTrainRTestR w/ol m 0.990.940.610.7370.8440.990.940.210.0690.154 KL1.000.760.990.9960.9980.940.690.490.4810.710 w/ol m 2 0.950.820.950.9940.992 0.950.820.940.9910.984 T-Patcher1.000.821.000.9991.0001.000.820.990.9970.996 Memory lossTo validate the effectiveness of our proposed memory loss, we apply several alter- native patches: (1) T-Patcher w/ol m , (2) KL Patch, wherel m is replaced with the KL divergence loss, (3) T-Patcher w/ol m 2 . The ablation results in Table 3 show that memory loss is critical. Sim- ply adding patches without memory loss hurts the model’s overall performance severely. The KL divergence partially alleviates this problem (higher TrainR, TestR, and ER) but is still unsatisfying on the more complex QA task, which is similar to the Fintuning with KL results in Table 1. By comparing w/ol m 2 and T-Patcher, we observe that the main contribution of our proposed memory loss comes froml m 1 , while addingl m 2 still improves the method’s performance. Furthermore, to investigate whether our added patches do solely respond to the specific error we visualize the acti- vation values of different patches on their corresponding mistakes in Figure 5 for the QA task. The X-axis represents the mistake (8.2 represents the second mistake of the 8th edit example) and the Y-axis represents the patch. Figure 5a shows that the patch can be activated by multiple irrelevant queries without the constraint of memory loss, leading to low ER, TrainR, and TestR. Figure 5b is a lot darker, indicating that the KL loss tends to deactivate patches to bridge the distribution gap 8 Published as a conference paper at ICLR 2023 123 4.14.25.15.25.35.46.16.26.36.46.56.66.77.17.27.38.1 8.1 7.3 7.2 7.1 6.7 6.6 6.5 6.4 6.3 6.2 6.1 5.4 5.3 5.2 5.1 4.2 4.1 3 2 1 0 2 4 6 8 10 12 14 (a) T-Patcher w/ol m 1.11.22.12.2 3456 7.17.27.37.48.18.28.39.19.2 101112 12 11 10 9.2 9.1 8.3 8.2 8.1 7.4 7.3 7.2 7.1 6 5 4 3 2.2 2.1 1.2 1.1 0 2 4 6 8 (b) KL Patch 12345 6.16.26.36.4 7 8.18.2 9 10.110.211.111.211.3 12 13.1 13.1 12 11.3 11.2 11.1 10.2 10.1 9 8.2 8.1 7 6.4 6.3 6.2 6.1 5 4 3 2 1 0 2 4 6 8 10 (c) T-Patcher Figure 5: The activation values of three different patches on their corresponding mistakes. 0.5 0.6 0.7 0.8 0.9 1 SRGRERTrainRTestR 5000100002000040000 0.74 0.76 0.79 0.81 0.5 0.6 0.7 0.8 0.9 1 Layer 0Layer 1Layer 2Layer 3Layer 4Layer 5 GRSRERTrainRTestR (a) Patched layer position 0.5 0.6 0.7 0.8 0.9 1 SRGRERTrainRTestR 5000100002000040000 0.74 0.76 0.79 0.81 0.5 0.6 0.7 0.8 0.9 1 Layer 0Layer 1Layer 2Layer 3Layer 4Layer 5 GRSRERTrainRTestR (b) Memory size Figure 6: The ablation studies about patched layer position and the memory size . before patching and after patching. And figure 5c presents a clear diagonal line, which means each patch takes charge of its corresponding mistake. Further analysis of the activation value of different patches is presented in Appendix C. Patched layer positionTo validate the benefits of patching the last layer, we focus on the QA task and patch each decoder layer separately. The ablation results are illustrated in Figure 6a. First, patching the bottom layer (layer 0 and 1) can not make effect edits. This may be because patching the bottom layer severely influences every token in the input sequence, making the patch’s optimization more difficult. While the patches added to the last layer only influence correspondent mistaken to- kens, Then, compared to the other metrics, what the patching position influenced most is GR, which increases from 0.74 of layer 2 to 0.81 of layer 5, proving that patching the top layers may improve thegenerality. This phenomenon is aligned with previous studies (Jawahar et al., 2019) which found that high-level semantic features are encoded at the top layers and superficial information is encoded in lower layers. Besides, patching the last layer could ameliorate the editing efficiency as well. Because computation results of previous layers could be cached and reused while editing. Memory sizeIn order to verify the robustness of our method, we conduct experiments using different memory sizes (from 5,000 to 40,000) on the QA task. As is shown in Figure 6b, our method is not very sensitive to the size of the memory set. Reducing memory examples only causes slight drops in SR, ER, TrainR, and TestR, and a slight increase in GR. 6CONCLUSION In this work, we proposed the Sequential Model Editing task, as well as its experiment pipeline and evaluation metrics. We then introduce Transformer-Patcher, a practical method for sequentially editing transformer-based language models. Experiments on both classification and autoregressive generation tasks demonstrate its ability to edit the model up to a thousand times continuously. This method could have a positive social impact by fixing serious mistakes in large PLMs, including generating biased predictions and hate speech, benefiting a broad spectrum of audiences. 9 Published as a conference paper at ICLR 2023 REFERENCES Christine Basta, Marta R. Costa-juss ` a, and Noe Casas. Extensive study on the underlying gender bias in contextualized word embeddings. NeuralComputingandApplications, 33(8):3371–3384, 2021. Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhari- wal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In Proceedingsofthe 2020AnnualConferenceonNeuralInformationProcessingSystems, 2020. Pawel Budzianowski and Ivan Vulic. Hello, it’s GPT-2 - how can I help you? towards the use of pretrained language models for task-oriented dialogue systems. InProceedingsofthe3rd WorkshoponNeuralGenerationandTranslation, p. 15–22, 2019. Nicola De Cao, Wilker Aziz, and Ivan Titov. Editing factual knowledge in language models. In Proceedingsofthe2021ConferenceonEmpiricalMethodsinNaturalLanguageProcessing, p. 6491–6506, 2021. Damai Dai, Li Dong, Yaru Hao, Zhifang Sui, Baobao Chang, and Furu Wei. Knowledge neurons in pretrained transformers. In Proceedingsofthe60thAnnualMeetingoftheAssociationfor ComputationalLinguistics, p. 8493–8502, 2022. Matthias De Lange, Rahaf Aljundi, Marc Masana, Sarah Parisot, Xu Jia, Ale ˇ s Leonardis, Gregory Slabaugh, and Tinne Tuytelaars. A continual learning survey: Defying forgetting in classification tasks.IEEETransactionsonPatternAnalysisandMachineIntelligence, 44(7):3366–3385, 2022. Cyprien de Masson d’Autume, Sebastian Ruder, Lingpeng Kong, and Dani Yogatama. Episodic memory in lifelong language learning. InProceedingsofthe2019AnnualConferenceonNeural InformationProcessingSystems, p. 13122–13131, 2019. Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. InProceedingsofthe2019Conferenceof theNorthAmericanChapteroftheAssociationforComputationalLinguistics:HumanLanguage Technologies, p. 4171–4186, 2019. Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. InProceedingsofthe34thInternationalConferenceonMachineLearning, p. 1126–1135, 2017. Mor Geva, Roei Schuster, Jonathan Berant, and Omer Levy. Transformer feed-forward layers are key-value memories. In Proceedingsofthe2021ConferenceonEmpiricalMethodsinNatural LanguageProcessing, p. 5484–5495, 2021. Mor Geva, Avi Caciularu, Guy Dar, Paul Roit, Shoval Sadde, Micah Shlain, Bar Tamir, and Yoav Goldberg. LM-Debugger: An interactive tool for inspection and intervention in transformer-based language models. CoRR, abs/2204.12130, 2022. Alex Hern.Facebook translates “good morning” into “attack them”, 2018.URL https://w.theguardian.com/technology/2017/oct/24/facebook-p alestine-israel-translates-good-morning-attack-them-arrest. Ganesh Jawahar, Beno ˆ ıt Sagot, and Djam ́ e Seddah. What does BERT learn about the structure of lan- guage? In Proceedingsofthe57thConferenceoftheAssociationforComputationalLinguistics, p. 3651–3657, 2019. Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Proceedings ofthe3rdInternationalConferenceonLearningRepresentations, 2015. 10 Published as a conference paper at ICLR 2023 Omer Levy, Minjoon Seo, Eunsol Choi, and Luke Zettlemoyer. Zero-shot relation extraction via reading comprehension. In Proceedingsofthe21stConferenceonComputationalNatural LanguageLearning, p. 333–342, 2017. Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Veselin Stoyanov, and Luke Zettlemoyer. BART: Denoising sequence-to-sequence pre- training for natural language generation, translation, and comprehension. In Proceedingsofthe 58thAnnualMeetingoftheAssociationforComputationalLinguistics, p. 7871–7880, 2020. Zhizhong Li and Derek Hoiem. Learning without forgetting.IEEETransactionsonPatternAnalysis andMachineIntelligence, 40(12):2935–2947, 2018. Zhengwei Lv, Duoxing Liu, Haifeng Sun, Xiao Liang, Tao Lei, Zhizhong Shi, Feng Zhu, and Lei Yang. AUTOHOME-ORCA at semeval-2019 task 8: Application of BERT for fact-checking in community forums. In Proceedingsofthe13thInternationalWorkshoponSemanticEvaluation, p. 870–876, 2019. Kevin Meng, David Bau, Alex Andonian, and Yonatan Belinkov. Locating and editing factual knowledge in GPT. CoRR, abs/2202.05262, 2022. Eric Mitchell, Charles Lin, Antoine Bosselut, Chelsea Finn, and Christopher D. Manning. Fast model editing at scale.In Proceedingsofthe10thInternationalConferenceonLearning Representations, 2022a. Eric Mitchell, Charles Lin, Antoine Bosselut, Christopher D. Manning, and Chelsea Finn. Memory- based model editing at scale. InProceedingsofthe2022InternationalConferenceonMachine Learning, p. 15817–15831, 2022b. Martin Mundt, Yong Won Hong, Iuliia Pliushch, and Visvanathan Ramesh. A wholistic view of continual learning with deep neural networks: Forgotten lessons and the bridge to active and open world learning.CoRR, abs/2009.01797, 2020. Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer.JournalofMachineLearningResearch, 21:140:1–140:67, 2020. Sahana Ramnath, Preksha Nema, Deep Sahni, and Mitesh M. Khapra. Towards interpreting BERT for reading comprehension based QA. InProceedingsofthe2020ConferenceonEmpirical MethodsinNaturalLanguageProcessing, p. 3236–3242, 2020. Andrei A. Rusu, Neil C. Rabinowitz, Guillaume Desjardins, Hubert Soyer, James Kirkpatrick, Ko- ray Kavukcuoglu, Razvan Pascanu, and Raia Hadsell. Progressive neural networks.CoRR, abs/1606.04671, 2016. Anton Sinitsin, Vsevolod Plokhotnyuk, Dmitry V. Pyrkin, Sergei Popov, and Artem Babenko. Editable neural networks.In Proceedingsofthe8thInternationalConferenceonLearning Representations, 2020. Matthew Sotoudeh and Aditya V. Thakur. Provable repair of deep neural networks. In Proceedings ofthe42ndACMSIGPLANInternationalConferenceonProgrammingLanguageDesignand Implementation, p. 588–603, 2021. Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory networks. InProceedingsofthe2015AnnualConferenceonNeuralInformationProcessingSystems, p. 2440–2448, 2015. James Thorne, Andreas Vlachos, Christos Christodoulopoulos, and Arpit Mittal. FEVER: A large- scale dataset for fact extraction and verification. InProceedingsofthe2018Conferenceofthe NorthAmericanChapteroftheAssociationforComputationalLinguistics:HumanLanguage Technologies, p. 809–819, 2018. Mitchell Wortsman, Vivek Ramanujan, Rosanne Liu, Aniruddha Kembhavi, Mohammad Rastegari, Jason Yosinski, and Ali Farhadi. Supermasks in superposition. InProceedingsof2020Annual ConferenceonNeuralInformationProcessingSystems, 2020. 11 Published as a conference paper at ICLR 2023 Jaehong Yoon, Eunho Yang, Jeongtae Lee, and Sung Ju Hwang. Lifelong learning with dynam- ically expandable networks. In Proceedingsofthe6thInternationalConferenceonLearning Representations, 2018. Jieyu Zhao, Tianlu Wang, Mark Yatskar, Ryan Cotterell, Vicente Ordonez, and Kai-Wei Chang. Gender bias in contextualized word embeddings. In Proceedingsofthe2019Conferenceofthe NorthAmericanChapteroftheAssociationforComputationalLinguistics:HumanLanguage Technologies, p. 629–634, 2019. Chen Zhu, Ankit Singh Rawat, Manzil Zaheer, Srinadh Bhojanapalli, Daliang Li, Felix X. Yu, and Sanjiv Kumar. Modifying memories in transformer models. CoRR, abs/2012.00363, 2020. 12 Published as a conference paper at ICLR 2023 AMULTIPLE NEURON PATCHING In auto-regressive generation tasks, the model may make multiple mistakes in one example. Since FFN is a position-wise network, every mistake in the output can be ascribed to one query to the last FFN layer. Therefore, for an example where the model makesnmistakes, each mistake can be ascribed to a queryq i e to the last FFN layer, and we addnpatches to handle each of them. Specifically, given an input queryq, the new outputFFN p (q)of a FFN withnpatches is: [ a a p ] = Act(q·[ K K p ] + [ b k b p ])(25) FFN p (q) = [ a a p ]· [ V V p ] +b v (26) whereK p ∈R d×n is the patch key,v p ∈R n×d is the patch value,b p ∈R n is the patch bias, a p = Act(q·k p +b p )is a vector containing activation values of patches. With the substitution of equations 6 and 7, equation 9 can be reformulated as: FFN p (q) = FFN(q)ifa p = ~ 0 FFN(q) +a p ·v p else (27) During calculating the activation loss for multiple patches, we just constraint the patchk i p to be acti- vated by its corresponding queryq i e , letq e ∈R n×d represent the matrix containingncorresponding queries, then we can obtainA∈R n which is defined as a vector containing activation values of each patch on its corresponding query: A i =q i e ·k i p +b i p (28) It can also be formulated as follows: A= diag(q e ·k p ) +b p (29) wherediagis a function to select the diagonal elements from a matrix. Then the activation loss for npatches can be calculated as follows: l a =S(−A;k a )(30) whereSis the function defined in Equation 17,k a is a hyper-parameter. Memory lossl m for multiple patches remains the sum of two termsl m1 andl m2 , wherel m1 is identical as Equation 16. As forl m2 , we restrict that fori-th patchk i p , all its activation value to a query inMshould be smaller than that to its corresponding queryq i e , thusl m2 becomes: l m2 =S(M·k p +b p −A−γ;k)(31) For initialization, every patchk i p is initialized as its normalized related query q i e |q i e | 2 so that the initial activation value is 1. BEXPERIMENTALDETAILS Data splitsWe utilize the same data split of training and testing following Cao et al. (2021). For closed-book fact-checking, the binary FEVER dataset originally has 104,966 training instances and 10,444 validation instances. In order to adapt it to the SME task, we keep the original validation set intact and employ it asD test , and split the original training data into three subsets: a new training setD ′ train , a new validation setD val and an edit setD edit in the ratio of0.8 : 0.1 : 0.1. As a result, we get 10,496 instances for the edit set. Since the Bert-based classifier attains 88.3% on the edit set, the ideal edit sequence length is 10496*88.3%/20=63 on average. For closed-book question answering, we employ the zsRE dataset released by Cao et al. (2021), which originally has 244,173 examples for training and 27,644 examples for validation. We first filter out examples with only one answer and then employ the same data split process as FEVER in the ratio of0.9 : 0.075 : 0.025. Finally, we get 5,317 edit data and 15,982 for validation, and 24,051 for testing. Since the Bart-based model attains 47.9% on the edit set, the ideal edit sequence length is 5317*47.9%/20=139 on average. For both datasets, we randomly sampled a subset from D ′ train with the size of 10,000 asD tr , and the edit setD edit is split inton= 20folders to run SME n= 20times independently. For the model editor requiring memories (fine-tuning with KL and Transformer-Patcher), we randomly sampled a subset fromD ′ train tr with the size of 40000 and update it as the editing proceeds. 13 Published as a conference paper at ICLR 2023 Initial models trainingInitial models are trained following Cao et al. (2021). For the Fact- Checking task, we fine-tune a BERT base model with an additional linear layer that maps the hidden state of the BOS (beginning of a sentence) token to the probability of the positive label. We maxi- mize the model likelihood and the final model attains an accuracy of 76.9% onD test , 94.1% onD tr and 88.3% onD edit . For the QA task, we fine-tune a BART base model by maximizing the model likelihood regularized with dropout and label smoothing. The final model attains an accuracy (exact match between model prediction and ground truth) of 23.1% onD test , 56.6% onD tr and 47.9% onD edit . And these results are comparable with results that the model trained and released by Cao et al. (2021) has achieved. Transformer-Patcher training detailsFor FC, we add one patch for every edit example. For QA, we employ the teacher forcing setting and count how many target tokens are not assigned to the highest likelihood as the mistake number. For one edit example, we add up to 5 patches.FC and QA task share almost the same hyper-parameters. We repeat one edit example 8 times and feed them to Transformer-Patcher as a batch for training. The initial learning rate is set as 0.01. Adam optimizer (Kingma & Ba, 2015) is applied for both tasks. Every patch is initialized with the normalized corresponding query q e |q e | 2 . Such a method makes each patch activated with an initial activate value 1. The patch valuev p ∈R n×d is parameterized as element-wise production of two matrices:v ′ p ∈R n×d andn p ∈R n×d ,v ′ p is initialized with the random number between 0 and 1, and elements inn p is initialized with an integer 5 to make the patch value dominant over existing valuesV.The parameterk a mentioned in equation 30 is set as 5, and parameterkfor memory loss is set as 1000. All hyper-parameters are chosen by running a few examples on the validation set. Baseline implementation detailsFor KE, we directly utilize the released trained HyperNetwork for conducting SME experiments (Cao et al., 2021). For MEND, there is no HyperNetwork released and we re-implement the released code with hyper- parameters set as Mitchell et al. (2022a). We employ fine-tuning-based methods following Mitchell et al. (2022a) and Cao et al. (2021). For all fine-tuning-based baselines, we set the learning rate as 1e-5 and utilize Adam’s optimizer to fine-tune the model until the mistaken example is corrected. For the computation of KL loss for fine-tuning +KL-constraints baselines, we randomly sample a batch of examples in a memory set with the size of 512. For SERAC (Mitchell et al., 2022b), we implement one variant of it: SERA. The SERAC main- tains a cache of all edit examples. Given an input, it first employs a scope classifier to estimate if the input is relevant to (falls in the scope of) any cached edit examples. If so, it then employs a counterfactual model (needs to have the identical output space as the original model) to produce the output relying on the most relevant cached example. Otherwise, it returns the output of the original model. In our proposed SME experiment setting, the in-scope examples have the same label as the edit example, thus the function of the counterfactual model is to reproduce the answer of the relevant example. During the implementation of QA, we choose the Bart-base as the counterfactual model, but we find is not trivial for the Bart model to reproduce the answer (the original paper use T5 for generation tasks), thus it is more practical to directly return the label of the cached edit example. We refer to this direct-return method as SERA and include it as our baseline for both Fact-Checking and Question-Answering tasks. All other implementation details about SERA are the same as the original paper (Mitchell et al., 2022b). Environment detailsFor all methods, we run SME experimentn=20 times onndifferent edit folders simultaneously using 8 NVIDIA Tesla V100 GPUs. And it cost around 1 hour for running Trnasformer-Patcher on FEVER and around 3 hours on zsRE. CEXTRA EXPERIMENT RESULTS Variation of locality with the number of editsThe metric ER, TestR, and TrainR reflect the locality of the final model, but how models behave in the middle is still unclear to us. Thus we choose KE, MEND, FT(all)+KL, and Transformer-Patcher and investigate how their locality varies with the number of edits on the QA task. The results are shown in Figure 7. As editing continues, 14 Published as a conference paper at ICLR 2023 Table 4: Mean and deviation of absolute patches activation values on three different kinds of exam- ples Patch FEVER Fact-CheckingzsRE Question-Answering EditPast-editRandomEditPast-editRandom w/ol m 34.3±9.315.7±8.10.5±3.011.32±7.31.23±1.640.14±0.3 KL9.15±2.70.01±0.160.05±0.21.12±1.870.03±0.060.12±0.1 T-Patcher10.25±2.30.00±0.00.05±0.1 6.78±2.580.00±0.000.10±0.1 Table 5: The standard deviation of Edit Retain Rate (ER), Training Retain Rate (TrainR), Test Retain Rate (TestR) of Transformer-Patcher (T-Patcher) and fine-tuning based baselines on FEVER and zsRE dataset. FEVER Fact-CheckingzsRE Question-Answering Editor BERT-base (110M)BART-base (139M) ERTrainRTestRERTrainRTestR FT(last)0.055890.062420.033220.039810.009200.01860 FT(all)0.070080.033680.021780.051680.023220.01781 FT(last)+KL0.059290.025160.016350.031730.012930.01697 FT(all)+KL0.062480.006770.011160.064330.016590.01953 T-Patcher0.000000.000450.000480.009160.001010.00115 w/ol m 0.103320.218720.14569 0.232590.050630.15795 KL0.000780.005360.002480.071240.082370.02469 more and more damage has been done to the model by other baselines, except Transformer-Patcher. 0295887116145 0.0 0.2 0.4 0.6 0.8 1.0 KE FT(all)+KL MEND TPatcher (a) Edit Retain Rate 0295887116145 0.0 0.2 0.4 0.6 0.8 1.0 KE FT(all)+KL MEND TPatcher (b) Test Retain Rate 0295887116145 0.0 0.2 0.4 0.6 0.8 1.0 KE FT(all)+KL MEND TPatcher (c) Train Retain Rate Figure 7: Variation of ER, TestR, and TrainR with the number of edits on QA task. Standard deviation of experiment resultsSince some values in Table 1 and Table 3 are very close, we report the standard deviation in Table 5. Note that the SR and the GR are calculated using all different folders at the same time, the standard deviation is therefore 0. According to Table 5, Transformer-Patcher achieves the smallest deviation on ER, TrainR, and TestR. Statistics of activation values of different patchesIn order to study the activation situation of patches on different examples. we present the mean and deviation of absolute patches activation values on three different mistakes: 1) Edit: the mistake for which the patch is added; 2) Past-edit: mistakes from previous edit examples; 3) Random: mistake of examples randomly sampled from D test . As BERT and BART utilize GeLU, both positive and negative activation values could activate the patch. We employ absolute value to measure to what extent the patch is activated. The results are shown in Table 4. First, the T-Patcher w/ol m attains the highest value for Edit queries, indicating the effectiveness of our activation loss. Then our memory loss can effectively push the activation values of Past-edit and Random queries to 0, thus disabling the patch on irrelevant examples. The 15 Published as a conference paper at ICLR 2023 Table 6: The Success Rate (SR), Generalization Rate (GR), Edit Retain Rate (ER), Training Retain Rate (TrainR), Test Retain Rate (TestR) of Transformer-Patcher (T-Patcher) with a fixed memory set. FEVER Fact-CheckingzsRE Question-Answering Editor BERT-base (110M)BART-base (139M) SRGRERTrainRTestRSRGRERTrainRTestR T-Patcher1.000.820.9991.0001.0001.000.820.970.9990.997 Table 7: The experimental results when utilizing all data inD edit as a single run of SME. E repre- sents how many edits have been conducted. N represents how many mistakes have been made by the initial modelf 0 on the entire edit setD edit . TaksSRGRERTrainRTestRENEditor FEVER1.000.821.000.9991.0009981231 T-Patcher zsRE0.990.810.970.9120.94823082766 FEVER1.000.540.160.9981.00212501231 FT(all)+KL zsRE1.000.690.140.9360.97428212766 FEVER1.000.891.000.7170.70915881231 SERA zsRE1.000.900.970.7280.69435582766 KL Patch has the lowest activation value of Edit query on both tasks, which explains the lower SR of QA in Table 3. Editing results of Transformer-Patcher with fixed memory setThe experimental results 1 are obtained using a memory set that is updated with the editing proceeds. Thus in Table 6 we present the editing results of Transformer-Patcher using a fixed memory set. We only observe a slight decline in ER and a slight rise in TrainR. The results further show the robustness of our method. Besides, we have to highlight that our method allows us to save more previous edits as memory and leverage more memories in the training process. Because we do not need to save original raw data but only corresponding input queries (several constant vectors that do not require gradients). On the contrary, KL requires feeding a mini-batch of raw data into the pre-edit model and post-edit model separately, thus the GPU memory becomes a restriction of the number of memories utilized in one batch. But Transformer-Patcher could apply hundreds of thousands of memory vectors in one batch and cost minimal GPU memory and computation resources. Contradictory of lower E and lower TestR in Table 2It seems inconsistent that Transformer- Patcher has achieved fewer E and lower TestR than FT(all)+KL method. Because one would expect the model to reduce future errors and behave better on the test set by fixing errors. The phenomenon may be because of the data distribution gap between the edit set and the test set. Thus the improve- ment of “reducing future errors” can not directly lead to higher TestR. For FEVER, the accuracy of the initial model attains 88.3% on the edit set and 76.9% on the test set. For zsRE, the accuracy of the initial model attains 47.9% on the edit set and 23.1% on the test set. A distinct gap between the edit set and test set is observed. Thus we should comprehensively consider all metrics to evaluate methods. Another reasonable explanation is that our modified model may slightly overfit the edit example. But fitting more to edit examples may be a desired feature in actual applications because we expect the model to be closer to the real data met during deployment. ACKNOWLEDGMENTS This work was partially supported by the State Key Laboratory of Software Development Environ- ment of China under Grant SKLSDE-2023ZX-16. 16