Learning to Edit: Aligning LLM s with Knowledge Editing (2024)

Abstract: Knowledge editing techniques, aiming to efficiently modify a minor proportion of knowledge in large language models (LLMs) without negatively impacting performance across other inputs, have garnered widespread attention. However, existing methods predominantly rely on memorizing the updated knowledge, impeding LLMs from effectively combining the new knowledge with their inherent knowledge when answering questions. To this end, we propose a Learning to Edit (LTE) framework, focusing on teaching LLMs to apply updated knowledge into input questions, inspired by the philosophy of “Teach a man to fish.” LTE features a two-phase process: (i) the Alignment Phase, which fine-tunes LLMs on a meticulously curated parallel dataset to make reliable, in-scope edits while preserving out-of-scope information and linguistic proficiency; and (ii) the Inference Phase, which employs a retrieval-based mechanism for real-time and mass knowledge editing. By comparing our approach with seven advanced baselines across four popular knowledge editing benchmarks and two LLM architectures, we demonstrate LTE’s superiority in knowledge editing performance, robustness in both batch and sequential editing, minimal interference on general tasks, and rapid editing speeds. The data and code are publicly available at https://github.com/YJiangcm/LTE.

## introduction the transformative potential of large language models (llms) @xcite @xcite has been unequivocally underscored by their unparalleled efficacy across a myriad of applications @xcite @xcite . nonetheless, the dynamic nature of the world necessitates frequent updates to llms to rectify outdated information or integrate new knowledge, thereby safeguarding their sustained pertinence. naively training a new llm from scratch to incorporate updated knowledge could result in substantial computational overhead and is frequently deemed impractical. to this end, the concept of knowledge editing has been introduced @xcite , aiming to efficiently modify llms' outputs towards targeted queries while preserving overall performance across other unrelated ones. for example, updating the knowledge of "the current british prime minister is rishi sunak" not only modifies the response to "who is married to the pm of the uk?" but leaves unaffected the answer to "when was rishi sunak born?" some knowledge editing approaches rely on auxiliary modules or models to either predict the llm's weight adjustments @xcite or function as scope classifiers for query response applicability @xcite . while these innovations demonstrate potential, they fail to inherit the advanced capabilities of llms, thus rendering output quality degeneration. others attempt to identify and modify parameters related to specific knowledge within llms to update their embedded knowledge @xcite @xcite . nonetheless, the correlation between localization and editing efficacy has been scrutinized by @xcite , which suggests that localization results from causal tracing are statistically uncorrelated with the success of an edit injecting a new fact into mlp weights. thus, it is plausible that the detrimental effects of such approaches could be amplified with the scale of llms. in essence, these methods predominantly rely on memorizing the updated knowledge (see figure 1 ), hindering llms from effectively combining the new knowledge with their inherent knowledge when answering the input queries. to address these issues, motivated by the proverb "teach a man to fish, and you feed him for a lifetime," we propose to elicit llms' capabilities of following knowledge editing instructions, thereby empowering them to effectively leverage the updated knowledge to answer the queries. specifically, we propose a learning to edit (lte) framework to align llms with knowledge editing by leveraging supervised fine-tuning (sft), which has become foundational in tailoring llms for desired behaviors @xcite . the lte framework is structured around two pivotal stages: the alignment phase and the inference phase. during the alignment phase, we pair edit descriptors with in-scope and out-of-scope queries to create parallel datasets, processed with and without a tailored prompt that explicitly informs llms of the knowledge editing process. by fine-tuning llms on this meticulously constructed dataset, we aim to cultivate a trio of essential capabilities within llms-in-scope capability (generating reliable, logically consistent edits), out-of-scope capability (preserving the integrity of unrelated content), and linguistic capability (maintaining linguistic proficiency)-to ensure nuanced application of updated knowledge. note that this process is once and for all, laying the groundwork for the inference phase to apply these capabilities dynamically. in the inference phase, to extend to mass editing, we implement a retrieval-based mechanism to obtain the most pertinent updated knowledge from a memory bank. such an approach enables llms to adapt their responses with the most current information in real time, thereby streamlining both batch and sequential knowledge editing processes. in this paper, we assess our proposed lte method against seven advanced baselines across four benchmarks in single, batch, and sequential editing scenarios. our findings reveal four major strengths of the lte method: (i) it establishes a new state-of-the-art (sota) in overall knowledge editing performance, surpassing existing methods by a substantial margin of over 20 absolute points in terms of portability; (ii) the robustness of lte is evident in its ability to handle batch and sequential knowledge editing requests, showing a markedly reduced rate of performance deterioration compared to its counterparts; (iii) it is proficient in facilitating knowledge edits with minimal interference to the model's cognitive functions across varied unrelated domains. (iv) lte distinguishes itself by combining the fastest editing speeds with exceptional performance. ## task formulation the objective of knowledge editing is to efficiently adjust the behavior of an initial base llm f θ , where θ represents the model's parameters, in response to specific edit descriptors {( in this context, x * i refers to the edit input that triggers the knowledge in llms (e.g., the current british prime minister is), y * i is the corresponding edit target (e.g., rishi sunak), and n signifies the total number of edit descriptors. the efficacy of knowledge editing is evaluated among four dimensions: edit success measures the average accuracy of the post-edit model f * θ on these edit cases: portability evaluates how well updated knowledge transfers to related queries, enhancing the model's utility in varied contexts. for example, correctly answering who is married to the british prime minister? with akshata murty post-edit indicates successful knowledge transfer. locality assesses the precision of edits, ensuring modifications are confined to targeted areas without affecting unrelated knowledge. for example, ensuring the current british chancellor remains jeremy hunt exemplifies effective locality. fluency quantifies the linguistic quality of the model's output post-edit, focusing on coherence and diversity to avoid repetitive patterns. following @xcite , we calculate fluency by in-scope out-of-scope with editing without editing [updated information]: association football was created in france [query]: which country is the origin of the sport associated with ac milan? france. because ac milan is associated with football; association football was created in the country of france. which country is the origin of the sport associated with ac milan? england. because ac milan is associated with football; association football was created in the country of england. [updated information]: association football was created in france [query]: what is the governing body of association football? the governing body of association football is fifa. what is the governing body of association football? the governing body of association football is fifa. edit descriptor query answer alignment phase: learning to edit inference phase: on-the-fly edit 1. association football was created in france 2. buffalo courier-express was created in the united kingdom ⋯ [updated information]: association football was created in france [query]: what are the attractions in the country where football was invented? what are the attractions in the country where football was invented? the eiffel tower, louvre museum, mont saint-michel, etc. measuring the weighted average of bi-and tri-gram entropies given byk f (k) log 2 f (k), where f (•) is the n-gram frequency distribution. ## methodology as illustrated in figure 2 , we propose a learning to edit (lte) framework to align llms with ever-changing, complicated, and diverse knowledge editing requests in real-time. this framework consists of two phases: (i) in the alignment phase, we enlighten llms' capabilities of applying updated knowledge through the utilization of a knowledge editing prompt "[updated information] {edit descriptor}\n[query] {query}"; (ii) in the inference phase, llms are enabled to conduct on-the-fly and streaming knowledge editing by retrieving relevant updated knowledge to the query from the stored memory. ## conclusion we present the learning to edit (lte) framework, a novel approach for effective, efficient knowledge editing of llms. lte equips llms with the ability to apply updated knowledge through a two-phase process: an alignment phase that teaches essential knowledge editing capabilities, and an inference phase that implements retrieval-based, on-the-fly knowledge editing. our framework demonstrates superior performance in knowledge editing tasks, outperforming existing methods in robustness and speed across various benchmarks.