Table of Contents
Fetching ...

InstructEdit: Instruction-based Knowledge Editing for Large Language Models

Ningyu Zhang, Bozhong Tian, Siyuan Cheng, Xiaozhuan Liang, Yi Hu, Kouying Xue, Yanjie Gou, Xi Chen, Huajun Chen

TL;DR

This work tackles the challenge of editing knowledge in large language models across multiple tasks without sacrificing overall performance. It introduces InstructEdit, an instruction-guided unified editor built on a meta-learning (hypernetwork) editing framework to learn task-aware editing directions conditioned on natural-language instructions. Through multi-task datasets (CounterFact, Recent, ConvSent) and a hold-out ZsRE evaluation, InstructEdit achieves notable gains in reliability and strong OOD generalization, outperforming baselines on unseen instructions and hold-out tasks. Gradient analysis suggests instructions help steer optimization directions, promoting discriminative editing areas and better generalization as task diversity increases. The work provides practical insights on data balancing, instruction design, and the potential for scalable, instruction-based editing in real-world LLM deployment.

Abstract

Knowledge editing for large language models can offer an efficient solution to alter a model's behavior without negatively impacting the overall performance. However, the current approaches encounter issues with limited generalizability across tasks, necessitating one distinct editor for each task, significantly hindering the broader applications. To address this, we take the first step to analyze the multi-task generalization issue in knowledge editing. Specifically, we develop an instruction-based editing technique, termed InstructEdit, which facilitates the editor's adaptation to various task performances simultaneously using simple instructions. With only one unified editor for each LLM, we empirically demonstrate that InstructEdit can improve the editor's control, leading to an average 14.86% increase in Reliability in multi-task editing setting. Furthermore, experiments involving holdout unseen task illustrate that InstructEdit consistently surpass previous strong baselines. To further investigate the underlying mechanisms of instruction-based knowledge editing, we analyze the principal components of the editing gradient directions, which unveils that instructions can help control optimization direction with stronger OOD generalization. Code and datasets are available in https://github.com/zjunlp/EasyEdit.

InstructEdit: Instruction-based Knowledge Editing for Large Language Models

TL;DR

This work tackles the challenge of editing knowledge in large language models across multiple tasks without sacrificing overall performance. It introduces InstructEdit, an instruction-guided unified editor built on a meta-learning (hypernetwork) editing framework to learn task-aware editing directions conditioned on natural-language instructions. Through multi-task datasets (CounterFact, Recent, ConvSent) and a hold-out ZsRE evaluation, InstructEdit achieves notable gains in reliability and strong OOD generalization, outperforming baselines on unseen instructions and hold-out tasks. Gradient analysis suggests instructions help steer optimization directions, promoting discriminative editing areas and better generalization as task diversity increases. The work provides practical insights on data balancing, instruction design, and the potential for scalable, instruction-based editing in real-world LLM deployment.

Abstract

Knowledge editing for large language models can offer an efficient solution to alter a model's behavior without negatively impacting the overall performance. However, the current approaches encounter issues with limited generalizability across tasks, necessitating one distinct editor for each task, significantly hindering the broader applications. To address this, we take the first step to analyze the multi-task generalization issue in knowledge editing. Specifically, we develop an instruction-based editing technique, termed InstructEdit, which facilitates the editor's adaptation to various task performances simultaneously using simple instructions. With only one unified editor for each LLM, we empirically demonstrate that InstructEdit can improve the editor's control, leading to an average 14.86% increase in Reliability in multi-task editing setting. Furthermore, experiments involving holdout unseen task illustrate that InstructEdit consistently surpass previous strong baselines. To further investigate the underlying mechanisms of instruction-based knowledge editing, we analyze the principal components of the editing gradient directions, which unveils that instructions can help control optimization direction with stronger OOD generalization. Code and datasets are available in https://github.com/zjunlp/EasyEdit.
Paper Structure (34 sections, 8 equations, 4 figures, 3 tables)

This paper contains 34 sections, 8 equations, 4 figures, 3 tables.

Figures (4)

  • Figure 1: Top: The Single-Task Editor excels in specific tasks (e.g., turning screws) but fails in others (e.g., driving nails). Bottom: The vanilla Multi-Task Editor (all data mixed together) still struggles to choose the right tool for varied tasks without aid. Thus, we propose InstructEdit, enabling the Multi-Task Editor to respond aptly (such as using a hammer for nails) with instructional guidance.
  • Figure 2: Assuming access to multi-domain task data: Law, Geography, Medicine, and Math. Single-Task Editing) Original editing is domain-specific (e.g., a Geography Editor edits geography-related knowledge but can't transfer it to Medicine). Multi-Task Editing) Previous methods (Pre-Editor) trained across domains (Law, Geography, and Math) often misdirect In-Distribution Task Editing. For OOD Task Editing (Medicine), a lack of guidance $\nabla$ leads to missing the correct edit region. Instructions enable precise editing and improve generalization. Instruction Construction) We utilize GPT-4 to generate instructions through well-crafted prompts, evaluate metrics using the Trial Editor, and then employ GPT-4 for continuous Instruction Optimization, enhancing the instructions until there is no further improvement in metrics.
  • Figure 3: InstructEdit demonstrates proficiency in generalizing to Unseen instructions (unseen instructions introduced in Section \ref{['sec:instructedit']}), achieving results comparable to Seen instructions.
  • Figure 4: (a) Compares instruction effects on knowledge editing gradient $\tilde{\nabla}_{u_\ell}$. Recent (InstructEdit) and Recent (Multi-Task) illustrate $\tilde{\nabla}_{u_\ell}$ on Recent using InstructEdit and MEND in multi-task settings, respectively. Recent (Single-Task) shows MEND's results of training on Recent alone. (b) Demonstrates task scaling's impact on InstructEdit, with Recent$\rightarrow$ZsRE for training on Recent and testing on ZsRE, and Recent&CF$\rightarrow$ZsRE for joint training on Recent, CounterFact, and testing on ZsRE. (c) Illustrates the reliability and generalization performance across task scaling. (d) Balances ConvSent by extracting 1,427 entries for ConvSent (Balanced).