Memory-Based Model Editing at Scale

Eric Mitchell, Charles Lin, Antoine Bosselut, Christopher D. Manning, Chelsea Finn

Abstract

Even the largest neural networks make errors, and once-correct predictions can become invalid as the world changes. Model editors make local updates to the behavior of base (pre-trained) models to inject updated knowledge or correct undesirable behaviors. Existing model editors have shown promise, but also suffer from insufficient expressiveness: they struggle to accurately model an edit's intended scope (examples affected by the edit), leading to inaccurate predictions for test inputs loosely related to the edit, and they often fail altogether after many edits. As a higher-capacity alternative, we propose Semi-Parametric Editing with a Retrieval-Augmented Counterfactual Model (SERAC), which stores edits in an explicit memory and learns to reason over them to modulate the base model's predictions as needed. To enable more rigorous evaluation of model editors, we introduce three challenging language model editing problems based on question answering, fact-checking, and dialogue generation. We find that only SERAC achieves high performance on all three problems, consistently outperforming existing approaches to model editing by a significant margin.

Introduction: The Challenge of Static Models

Large Language Models (LLMs) are typically static artifacts. Once trained, their "knowledge" is frozen in time. If a fact changes (e.g., a new Prime Minister is elected) or a specific error is discovered, updating the model is surprisingly difficult. Standard fine-tuning often leads to catastrophic forgetting, where the model loses general abilities while learning the new fact.

Previous "model editors" attempted to solve this by predicting specific weight updates. However, these methods struggle with scope—they often fail to apply the edit to related questions (rephrasings) or, conversely, they accidentally change the model's behavior on completely unrelated topics. Furthermore, these gradient-based methods tend to "collapse" after just a few dozen edits.

SERAC Architecture

To address these limitations, we propose SERAC, a semi-parametric approach that treats the base model as a black box. Instead of changing weights, SERAC consists of three modular components that act as a "wrapper" around the original model.

The SERAC architecture consists of an Edit Memory, a Scope Classifier to route inputs, and a Counterfactual Model to generate updated outputs.
  1. Edit Memory: A simple cache that stores user-provided edits as text (e.g., "The new CEO of X is Y").
  2. Scope Classifier: When a new query arrives, this model (typically a small BERT or DistilBERT) determines if the query falls within the "scope" of any stored edits. It asks: "Is this question related to something we've been told to change?"
  3. Counterfactual Model: If the classifier finds a relevant edit, this small "patch" model (e.g., a T5-small) takes the query and the stored edit as input to generate the corrected answer.

If the classifier decides the query is "out-of-scope," the input is simply passed to the original, frozen Base Model. This architecture ensures that the base model's performance on unrelated tasks remains preserved.

Benchmarking and Datasets

We evaluated SERAC on one existing benchmark and three newly introduced, more challenging datasets designed to test logical entailment and nuanced updates:

  • zsRE (Zero-Shot Relation Extraction): A standard benchmark for simple fact updates and rephrasings.
  • QA-hard: A new dataset requiring logical entailment (e.g., if the model is told "A is the father of B," it should also know "B is the child of A").
  • FC (Fact Checking): Based on the VitaminC dataset, testing the ability to handle nuanced, evidence-based updates.
  • ConvSent (Conversational Sentiment): A dialogue task where the goal is to change a bot's sentiment toward a specific topic without changing its personality elsewhere.

Results and Scaling

SERAC consistently outperformed existing approaches across all benchmarks. On the challenging QA-hard task, SERAC achieved an Edit Success (ES) of 0.913, while the best gradient-based baseline (MEND) only reached 0.478.

A key advantage of SERAC is its ability to scale. Unlike gradient methods that degrade as more edits are added, SERAC’s performance remains nearly flat. Because it uses a retrieval mechanism, adding more edits just means a slightly larger memory, not a more distorted weight matrix.

SERAC maintains high edit success even as the number of test edits increases to 75, whereas baseline methods like MEND and ENN show significant performance degradation.

Discussion

The success of SERAC suggests that gradients are often "impoverished signals" for knowledge injection. It is much easier for a model to reason over the text of an edit than to interpret a change in its own parameters. By decoupling the problem of when to edit (the classifier) from how to edit (the counterfactual model), we achieve surgical precision without the risk of "scope creep."

While SERAC requires specialized training data for its classifier and counterfactual model, its modularity and scaling properties make it a robust solution for maintaining up-to-date, accurate language models at scale.

Summary updated

Abstract

Even the largest neural networks make errors, and once-correct predictions can become invalid as the world changes. Model editors make local updates to the behavior of base (pre-trained) models to inject updated knowledge or correct undesirable behaviors. Existing model editors have shown promise, but also suffer from insufficient expressiveness: they struggle to accurately model an edit's intended scope (examples affected by the edit), leading to inaccurate predictions for test inputs loosely related to the edit, and they often fail altogether after many edits. As a higher-capacity alternative, we propose Semi-Parametric Editing with a Retrieval-Augmented Counterfactual Model (SERAC), which stores edits in an explicit memory and learns to reason over them to modulate the base model's predictions as needed. To enable more rigorous evaluation of model editors, we introduce three challenging language model editing problems based on question answering, fact-checking, and dialogue generation. We find that only SERAC achieves high performance on all three problems, consistently outperforming existing approaches to model editing by a significant margin. Code, data, and additional project information will be made available at https://sites.google.com/view/serac-editing.
BibTeX
@inproceedings{mitchell2022memory,
  author = {Eric Mitchell and Charles Lin and Antoine Bosselut and Christopher D. Manning and Chelsea Finn},
  title = {{Memory-Based Model Editing at Scale}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=1A1wz__0Boc},
}

Loading related content...

Figure