Abstract
Knowledge editing (KE) aims to update specific facts in Large Language Models (LLMs) without full retraining. However, existing editors often fail to generalize across different task types. We present InstructEdit, a unified framework that treats knowledge editing as an instruction-following task. By prepending task-specific instructions, InstructEdit enables a single editor to manage multiple disparate tasks and generalize to unseen categories. Our approach improves editing reliability by an average of 14.86% and shows a 42.04% improvement on out-of-distribution tasks compared to state-of-the-art meta-learning editors.
Introduction
Large Language Models (LLMs) frequently require updates to correct outdated or erroneous information. While Knowledge Editing (KE) methods offer a way to modify specific parameters without damaging general capabilities, they suffer from a significant "generalization gap." Most editors are specialized for single tasks—such as updating factual relations—and perform poorly when applied to different domains, like sentiment adjustment. This lack of flexibility necessitates training separate editors for every task, which is computationally prohibitive for dynamic real-world applications. As an analogy, a specialized editor might excel at "turning screws" but fail at "driving nails," even when the underlying mechanics of the update are similar.
Methods
InstructEdit addresses the generalization gap by framing knowledge editing as an instruction-following problem. The framework consists of three main components:
- Instruction Construction: Using GPT-4, the researchers generated 20 diverse natural language descriptions for various editing tasks to provide a rich set of conditioning signals.
- Meta-Learning Architecture: InstructEdit builds upon the MEND (Model Editor Networks using Gradient Decomposition) architecture. It utilizes a hypernetwork to predict necessary weight updates ($\Delta$) for the LLM based on the gradient of the desired change.
- Instruction Integration: Task instructions are prepended to the input during the editing process. This allows the hypernetwork to condition weight updates on the specific task requirements, helping the model identify a specific "editing area" in the parameter space that satisfies the requested change.
Experimental Setup
We evaluated InstructEdit using four datasets representing different task families:
- CounterFact: Focused on counterfactual knowledge updates.
- Recent: Focused on inserting new knowledge added to Wikidata after July 2022.
- ConvSent: A sentiment editing task for chatbots.
- ZsRE (Zero-Shot Relation Extraction): Used as a hold-out task to measure out-of-distribution (OOD) generalization.
Experiments were conducted on GPT2-XL (1.5B) and LLaMA-2 (7B) models.
Results and Discussion
InstructEdit demonstrates superior performance in multi-task environments. On average, it improves Reliability (the success rate of the intended edit) by 14.86% over the previous state-of-the-art meta-learning editor. Notably, on the unseen ZsRE task, InstructEdit achieved 82.83% reliability on GPT2-XL, a massive leap from the 40.79% achieved by standard MEND.
Analysis of the editing gradients using t-SNE reveals that instructions act as "control knobs," effectively separating the editing areas for different tasks and reducing interference. Furthermore, we observed a clear scaling effect: as the number of training tasks increases, the editor's ability to generalize to OOD data improves, suggesting that task diversity fosters a more robust understanding of the editing process.
Conclusion
InstructEdit provides a scalable and flexible solution for LLM knowledge editing. By leveraging natural language instructions, it bridges the generalization gap between disparate editing tasks. While the framework shows high robustness to novel instructions, future work will explore more complex natural language inputs and address scalability challenges in broader domains like cross-linguistic editing.
Summary updated