Knowledge Editing on Black-box Large Language Models

Xiaoshuai Song, Zhengyang Wang, Keqing He, Guanting Dong, Yutao Mou, Jinxu Zhao, Weiran XuarXiv 2024 · DOI · OpenReview

Introduction

Large Language Models (LLMs) serve as vast repositories of information, yet they suffer from a "frozen-in-time" limitation. As the world evolves, facts within these models become outdated. Retraining trillion-parameter models for every factual update is computationally prohibitive, leading to the emergence of Knowledge Editing (KE). KE aims to surgically update specific facts without compromising the model's broader knowledge base.

While most KE research assumes "white-box" access to model weights, real-world applications often rely on "black-box" models accessed via APIs (e.g., GPT-4). Existing black-box editing methods face two critical challenges: privacy leaks, where sensitive new knowledge must be sent to the API provider, and style drift, where the model's unique linguistic "soul" is lost during the editing process. Researchers from the Beijing University of Posts and Telecommunications propose postEdit, a framework designed to address these issues by performing edits locally on the model's output.

The postEdit Framework

The postEdit approach shifts the editing process to the end of the pipeline, treating it as a text-to-text refinement task. This architecture consists of three primary components: an Edit Memory for storing new facts, a Retriever to identify relevant edits for a given query, and a Post-editor—a smaller, fine-tuned model (such as LLaMA-2-7B) that performs the final modification.

Comparison of black-box knowledge editing methods: IKE, SERAC, and the proposed postEdit. The example demonstrates how postEdit preserves both privacy and original response style compared to baselines.

Unlike In-Context Learning (IKE), which includes the new fact in the prompt, or Surrogate Models (SERAC), which replace the entire response, postEdit modifies only the specific spans of text that are factually incorrect. This "surgical" precision ensures that the original model's tone, formatting, and sentence structure remain largely intact. Furthermore, because the edit happens locally after the API call, the new knowledge is never exposed to the upstream provider, ensuring data privacy.

Methodology and Training

To train the Post-editor, the researchers utilized a data augmentation strategy. They employed GPT-4 to generate "perfectly edited" versions of responses from a base LLM, creating a high-quality dataset that demonstrates how to transition from an outdated fact to a new one while maintaining stylistic consistency. This supervised fine-tuning allows the Post-editor to learn the nuances of factual correction without over-editing.

Experimental Results

The framework was evaluated on two standard benchmarks: CounterFact, which tests the ability to adopt counterfactual information, and zsRE (Zero-Shot Relation Extraction), which assesses relational fact updates.

Performance comparison across different base models and datasets. postEdit consistently achieves high editing scores while significantly outperforming IKE and SERAC in retention scores.

The results demonstrate that postEdit achieves nearly optimal factual accuracy while providing a massive +20.82% improvement in style retention over baselines. As shown in the performance charts, postEdit maintains a high "Retention Score" across various models, including ChatGPT, PaLM 2, and LLaMA-2-70B. This indicates that the framework successfully preserves the "voice" of the original model while correcting its factual errors. Additionally, postEdit proved robust against query rephrasing, a common failure point for in-context methods.

Conclusion

The postEdit framework represents a significant advancement in black-box knowledge editing. By decoupling the factual update from the primary generation process, it solves the dual problems of privacy and style drift. While it introduces some local computational overhead, its ability to provide "plug-and-play" generalization across different API-based models makes it a practical solution for maintaining up-to-date, stylistically consistent, and private LLM applications.

Summary updated

Abstract

Knowledge editing (KE) aims to efficiently and precisely modify the behavior of large language models (LLMs) to update specific knowledge without negatively influencing other knowledge. Current research primarily focuses on white-box LLMs editing, overlooking an important scenario: black-box LLMs editing, where LLMs are accessed through interfaces and only textual output is available. In this paper, we first officially introduce KE on black-box LLMs and then propose a comprehensive evaluation framework to overcome the limitations of existing evaluations that are not applicable to black-box LLMs editing and lack comprehensiveness. To tackle privacy leaks of editing data and style over-editing in current methods, we introduce a novel postEdit framework, resolving privacy concerns through downstream post-processing and maintaining textual style consistency via fine-grained editing to original responses. Experiments and analysis on two benchmarks demonstrate that postEdit outperforms all baselines and achieves strong generalization, especially with huge improvements on style retention (average $+20.82\%\uparrow$).
BibTeX
@misc{song2024knowledge,
  author = {Xiaoshuai Song and Zhengyang Wang and Keqing He and Guanting Dong and Yutao Mou and Jinxu Zhao and Weiran Xu},
  title = {{Knowledge Editing on Black-box Large Language Models}},
  year = {2024},
  eprint = {2402.08631},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.08631},
}
Figure