Improving Sequential Model Editing with Fact Retrieval (2023)

Abstract: The task of sequential model editing is to fix erroneous knowledge in Pre-trained Language Models (PLMs) efficiently, precisely and continuously. Although existing methods can deal with a small number of modifications, these methods experience a performance decline or require additional annotated data, when the number of edits increases. In this paper, we propose a \textbf{R} etrieval \textbf{A} ugmented \textbf{S} equential Model \textbf{E} diting framework ( \textbf{RASE} ) that leverages factual information to enhance editing generalization and to guide the identification of edits by retrieving related facts from the fact-patch memory we constructed. Our main findings are: (i) State-of-the-art models can hardly correct massive mistakes stably and efficiently; (ii) Even if we scale up to thousands of edits, RASE can significantly enhance editing generalization and maintain consistent performance and efficiency; (iii) RASE can edit large-scale PLMs and increase the performance of different editors. Moreover, it can integrate with ChatGPT and further improve performance. Our code and data are available at: https://github.com/sev777/RASE.

## introduction pre-trained language models (plms) are trained on massive amounts of texts, encoding knowledge in their parameters, and having remarkably succeeded in knowledge-driven tasks such as question answering @xcite @xcite and reasoning @xcite . such parametric knowledge complements @xcite the explicit and structured knowledge in widely used knowledge graphs @xcite . as pre-trained language models are deployed widely, the need to keep their parametric knowledge correct and up-to-date without massive retraining costs becomes increasingly important (sinitsin other methods (a) involve continuous modification of plm's parameters. however, the efficiency of modification decreases as the number of edits grows, resulting in poor performance for sme. our method (b) leverages an fact retrieval framework, guaranteeing consistent modification efficiency regardless of the number of edits. this improvement enhances both the scalability and performance of sme. furthermore, by leveraging factual information relevant to editing, our retrieval method better adapts to sme scenarios. @xcite . prior works have proposed model editing @xcite , enabling fast, dataefficient plms updates without damaging model performance on unmodified data. these methods focus on simultaneously modifying edits; however, the errors in plms are unpredictable and pervasive, thus correcting them at once is impractical. to this end, sequential model editing (sme) @xcite has been proposed to fix a series of bugs in order while maintaining the previous edits and performance across unmodified data. this is a challenging task, since, for a highly non-linear model, even slight perturbations might significantly alter the model's output. as shown in @xcite , prior works on sme make modifications by either directly modifying the parameters of the lan-guage model @xcite or continuously adding parameters to the model @xcite , and they use additional storage to maintain the model's performance on unmodified data (locality). they have shown promise only to deal with a small number of modifications, and suffer from insufficient expressiveness: 1) as the number of edits increases, the model's parameters undergo significant changes, or the number of parameters becomes large, resulting in forgetting previous edits or unmodified data and gradually increasing the cost of modifications. 2) in sme, the edits may clash with pre-sampled data stored to preserve locality. thus, the cost of maintaining memory will increase when dealing with more edits. one feasible way to address the abovementioned issue is the memory-based method, which uses an edit-history memory while keeping the original model frozen. however, the existing method @xcite primarily focuses on batch editing, assuming that all editing data is known and utilizing the data to train models for data-type identification and modification, which makes it inefficient when handling sequential model editing. to fully leverage the advantages of the memorybased method, we propose rase, a retrieval augmented sequential model editing framework, (cf. @xcite ) stores edits with their fact description and parameter shift on plms in memory and uses a query module to retrieve from them to apply each modification individually. with this framework, we can simplify complex continuous modifications by breaking them down into multiple individual edits, and the sme can be decomposed into the following two sub-tasks: 1) edits classification: determining whether the input needs modification. we propose a fact-aware contrastive model to identify edits without pre-training on any annotated datasets by learning the sentence and fact embedding in a self-supervised way. 2) editing: determining how to efficiently modify each edit. we enhance the generalization capabilities of existing editors by incorporating factual information with the editing data. experimental results on fact-checking and question answering tasks indicate that rase can rectify a series of mistakes (up to thousands) while retaining the model's performance on unmodified data. ## approach figure 2 shows the overview of rase. in a nutshell, we first train a fact encoder and a sentence encoder in a self-supervised way to maximize the similarity between sentences and their corresponding fact description. after applying each edit successful, we encode the corresponding fact as a key (section 3.1.1), treat the required parameter shift as a value (section 3.1.2), and store the (key,value) pair. during the evaluation, we compare a given input with the keys in the memory (section 3.2). if a key is found, it indicates that the data needs modification, and the value will be applied to the language model to complete the editing. otherwise, the input is simply passed to the original model. we illustrate our approach by introducing the facts-patch memory's construction and usage. ## conclusion this paper focuses on sequential model editing and proposes rase, a retrieval augmented sequential model editing framework, to enhance the performance of existing editors in a plug-and-play manner, and achieve efficient, stable, and expansible sequence model editing. we construct a fact-patch memory in a self-supervised way and utilize the memory to enhance the model's continuous editing capability. during editing, we use fact information related to the modified data as prompt to enhance the generalization of the editor. rase has achieved favourable results under different scales of language models and varying numbers of edits. additionally, it can be flexibly applied to different editors and integrating with large language models like chatgpt can further enhance editing performance. in the future, on the one hand, we plan to investigate knowledge editing for some complex tasks, such as reasoning. and explore how to integrate retrieval methods with model editing better. on the other hand, we might look into the connections between editing parametric knowledge and knowledge editing for uncertain knowledge graphs @xcite @xcite @xcite .