Consecutive Batch Model Editing with H oo K Layers (2024)

Abstract: As the typical retraining paradigm is unacceptably time- and resource-consuming, researchers are turning to model editing to find an effective way that supports both consecutive and batch scenarios to edit the model behavior directly. Despite all these practical expectations, existing model editing methods fail to realize all of them. Furthermore, the memory demands for such sequential model editing approaches tend to be prohibitive, frequently necessitating an external memory that grows incrementally over time. To cope with these challenges, we propose CoachHooK, a model editing method that simultaneously supports sequential and batch editing. CoachHooK is memory-friendly as it only needs a small amount of it to store several hook layers whose size remains unchanged over time. Experimental results demonstrate the superiority of our method over other batch-supportive model editing methods under both single-round and consecutive batch editing scenarios. Extensive analyses of CoachHooK have been conducted to verify the stability of our method over a number of consecutive steps.

## introduction large language models (llms) @xcite @xcite have been demonstrated to be capable of recalling factual knowledge about the real world @xcite . nevertheless, researchers also reveal that llms often fail to recall the most up-to-date knowledge or information and some specialized knowledge if they are not periodically updated @xcite @xcite . despite the fact that fresh and customizable knowledge is highly desired in many areas, such as text generation, question-answering, reasoning, etc., updating the model via retraining is both timeand resource-consuming. additionally, researchers have uncovered that well-trained llms do make mistakes. one popular sort of mistake is called hallucination @xcite , which means that llms generate text based on "hallucinated" fake knowledge. although many researchers have tried to mitigate this issue @xcite @xcite , the strategy to fix this bug remains unclear. therefore, researchers have started to seek an efficient approach that could edit llms in a customizable, cost-effective way. to this end, recent years have witnessed many efforts in investigating the model-editing techniques to bypass the retraining paradigm and edit the llms directly @xcite @xcite . accordingly, several new datasets (e.g., zsre @xcite and counterfact @xcite ) and corresponding metrics (e.g., reliability, generality, locality, portability @xcite ) are proposed to facilitate the development in this field. however, these methods either require extra expensive training of a meta-network @xcite , or a classifier @xcite , which causes time and resources overhead, or demands an external memory of explicit edit instances for reference @xcite , which inevitably escalates the memory requirement. further, most of existing methods are only evaluated on single-round editing, where the model is rolled back to the initial state after each edit step. this deviates from the application scenario in reality since most users anticipate an editing approach that allows sequential and batch editing. in light of these issues, we propose a novel method, named coachhook foot_0 , which performs consecutive batch model editing with hook layers. specifically, coachhook supports consecutive batch editing and utilizes the hook layers to separate weight change from the original model weight. coachhook does not need any training on parameters or large explicit external memory that stores editing instances. it only needs a reasonable amount of memory to collect the optimized weight in the hook layer. to achieve this, we propose a new transformer memory updating mechanism that supports consecutive batch editing settings and design a simple yet effective local editing scope identification technique used in the hook layer that can accurately detect the inputs in the local editing scope. we demonstrate the effectiveness of our method via extensive experiments on zsre and counterfact datasets using two popular autoregressive language models, gpt2-xl and gpt-j (6b). both the single-round batch settings and consecutive batch settings are included, with the total number of editing instances ranging from 1k to 10k. an analysis of the editing scope identification has also been conducted to validate the method. beyond all these, we implement comprehensive ablation studies to verify the validity of each component and discuss the optimal hyperparameter settings in the method. ## preliminaries of model editing as defined by @xcite , the task of model editing is to efficiently modify an initial base model f θ into an edited model f θ ′ whose responses to a particular set of input instances x t are adjusted as desired without affecting the responses of the model to other instances. the intended edit descriptor is denoted as (x t , y t ), where x @xmath0. the post-edit model f θ ′ is supposed to produce the expected output to an intended edit instance x t , while preserving the original output to other instances: in particular, there are three standard criteria for model editing, namely reliability, generality, and locality @xcite . suppose the prediction of the original model to the prompt "what is the native language of joe biden?" is "french", and the expected post-edit model prediction is "english". to verify the reliability, we use the same original prompt as input and then assess whether the post-edit model predicts "english" as desired. for generality, a rephrased prompt "the mother tongue of joe biden is" could be inputted into the edited model to assess whether the output of the model remains as "english". locality suggests that the model output of an irrelevant prompt like "what is the native language of donald trump?" should remain unaffected, which means that the post-edit model should output whatever the initial model output to this prompt. the current problem settings of model editing can be generally categorized into three groups @xcite : 1) single instance editing evaluates the post-edit model performance when only one single knowledge update is performed: in this work, we investigate a new and more practical setting for model editing, namely consecutive batch editing, which aims at executing the editing in a consecutive batch editing way: ## method we first discuss our method under the single-layer consecutive batch editing setting. explicitly, we first discuss the process of extending the singlelayer updating mechanism in memit @xcite from a scenario of single-round batch editing to consecutive batch editing. then, we introduce the hook layer and the local editing scope identification operation employed in the hook layer. the practicality of the operation is also clarified. finally, we broaden the method from single-layer to multi-layer scenarios. @xcite demonstrate an effective singlelayer editing method using minimal squared error. although it supports multiple edits on a single round, the updates do not account for scenarios involving consecutive updates. in this section, we extend this approach to include consecutive scenarios. following @xcite , we analyse the model layer weights w 0 as a linear associative memory @xcite that stores associations between a set of keys k i and values v i using minimal squared error: ## related work linear associative memory linear associative memory @xcite treats the model weights w as a set of associations between a set of keys and values. many researchers have adopted this technique as a memory component in their methods. @xcite @xcite @xcite . recent research @xcite finds that the transformer feed-forward layers are likely to be a key-value memory. this significantly helps researchers to understand what is happening inside the transformer black box and inspires researchers in the field of model editing to first locate where the knowledge is stored and then edit the corresponding parameters @xcite . model editing recent years have witnessed prosperous development in the field of model editing. according to @xcite , the proposed methods so far can be generally classified into two groups, i.e., modify the model's weight or not. the methods that do not directly alter the model weights generally follow two directions: they either employ an external memory or introduce additional adjustable parameters. methods like t-patcher @xcite and calinet @xcite apply new neurons that are responsible for specific mistakes in the last layer of the ffn model. grace @xcite introduces a timely adjusted code book to edit the model's behavior. another group of methods like serac @xcite integrates an ex-plicit external memory as edit descriptors to help editing scope recognition. some other techniques like ike @xcite , mello @xcite , and memprompt @xcite ) take advantage of the recent development of in-context learning and use carefully designed demonstration context prompts to edit the model. @xcite also discussed the possible transformation between context and parameter update. on the other hand, those directly altering the model's weight either train a hyper-network to predict the change required by the edits or first locate corresponding parameters responsible for specific knowledge and then edit the located parameters. for example, methods like ke @xcite , mend @xcite , and malmen @xcite follow the idea of meta-learning and use the trained hypernetwork to predict the desired parameter change for editing. rome @xcite , memit @xcite , pmet @xcite , kn @xcite , and wilke @xcite first locate the parameters responsible for knowledge and then using a designed optimization mechanism to shift the parameters. despite the good performance of the proposed methods, researchers investigated the harmful consequences of these methods. @xcite points out even few edits could result in the collapse of a model. @xcite shows that scaling up the edits could lead to catastrophic forgetting of the previous edits. @xcite argues that editing could lead to the degradation of the model's general capabilities. although the rationality of these investigations is still under discussion, they reveal the potential risk that model editing techniques could bring to the base model. ## conclusion this work introduces a novel model editing method, coachhook, which advocates the more practical consecutive batch model editing. coachhook uses an expanded editing mechanism to support consecutive editing and newly proposed hook layers to identify the editing scope. compared to existing model editing methods, coachhook does not require large external memory nor extra training for meta-networks or classifiers. instead, it adopts hook layers whose size remains fixed over time for storing associations. comprehensive experiments are conducted to verify the method's effectiveness over single-round and consecutive batch editing.