Fast Model Editing at Scale

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

TL;DR

MEND (Model Editor Networks with Gradient Decomposition) is a scalable method for "patching" large pre-trained models using just a single input-output pair. By leveraging a clever low-rank decomposition of gradients, MEND can produce precise, localized updates for models with over 10 billion parameters—like T5-XXL and GPT-J—on a single GPU, far outperforming standard fine-tuning and previous meta-learning approaches.

What Problem Does This Paper Address?

Large language models (LLMs) are often "frozen" in time once training ends. If a fact changes (e.g., a new Prime Minister is elected) or a specific error is discovered, the traditional solution is to either retrain the model (which is prohibitively expensive) or fine-tune it on the new data.

However, fine-tuning on a single example is notoriously brittle. It often leads to:

  1. Overfitting: The model learns the new fact but loses its ability to generalize to rephrasings of that fact.
  2. Catastrophic Forgetting and Locality Issues: Updating one fact might accidentally corrupt unrelated knowledge (e.g., changing the UK PM might break the model's knowledge about the French President).

Previous "model editors" attempted to solve this using meta-learning, but they were computationally heavy and failed to scale beyond models with a few hundred million parameters.

Methods

The authors propose MEND (Model Editor Networks with Gradient Decomposition). The core idea is to train a small auxiliary network that takes the "raw" gradient from standard fine-tuning and transforms it into a more effective, localized update.

The MEND pipeline intercepts standard fine-tuning gradients and transforms them into targeted model updates.

The technical breakthrough is how they handle high-dimensional gradients. For a weight matrix of size $d \times d$, the gradient is also $d \times d$. Mapping this directly would require an editor with $O(d^4)$ parameters—impossible for modern LLMs where $d \approx 10^4$.

MEND exploits the fact that the gradient for a standard linear layer is a rank-1 matrix: $\nabla W = \delta u^\top$ (where $\delta$ is the gradient with respect to pre-activations and $u$ is the input). Instead of processing the whole matrix, MEND uses small MLPs to transform $\delta$ and $u$ independently into "pseudo-deltas" and "pseudo-activations." This reduces the editor's complexity to $O(d)$, making it lightweight enough to edit massive models.

Datasets

The researchers evaluated MEND across three distinct tasks:

  • zsRE (Zero-Shot Relation Extraction): A question-answering dataset used to test if the model can handle factual updates and their rephrasings.
  • FEVER: A fact-checking dataset (binary classification) used to test the ability to flip specific beliefs.
  • Wikitext Generation: A new benchmark introduced by the authors to test how editing affects open-ended text generation in GPT-style models.

Key Insights and Ideas

  • Gradients as Features: MEND treats the standard fine-tuning gradient not as the final update, but as a rich "feature vector" that tells the editor where the model's current knowledge is stored.
  • Extrinsic vs. Intrinsic Editing: Unlike previous methods (like ENN) that require modifying the base model's parameters during its own training to make it "editable," MEND is an extrinsic editor. It can be trained to edit a pre-existing, frozen model without changing its original weights.
  • The Power of Identity Initialization: A crucial trick for MEND's stability is initializing the editor networks to act as an identity function. This ensures that at the start of training, MEND simply performs standard fine-tuning, which it then learns to improve upon.

Key Results

  • Unprecedented Scale: MEND is the first model editor shown to work effectively on T5-XXL (11 billion parameters) and GPT-J (6 billion parameters).
  • Superior Performance: On the Wikitext generation task with GPT-Neo (2.7B), MEND achieved an 81% Edit Success rate, compared to just 55% for standard fine-tuning.
  • Minimal Collateral Damage: MEND maintained significantly better "locality" than baselines, meaning it updated the target fact without degrading the model's performance on unrelated inputs.
  • Efficiency: MEND can be trained on a single GPU in less than a day, even for the largest models tested.
MEND scales efficiently to 11B parameter models, requiring significantly less VRAM than previous meta-learning approaches like ENN.

Limitations and Future Work

  • Over-generalization: The authors noted that MEND sometimes generalizes too much. For example, changing the artist of one song might accidentally change the artist of a different, superficially similar song.
  • Implied Knowledge: While MEND successfully updates a specific fact, it’s unclear if the model understands the logical consequences of that update (e.g., if the model is told "A is the PM," does it automatically know "A is a citizen"?).
  • Scope of Edits: The current work focuses on MLP layers in Transformers. While these are thought to be the "knowledge base" of the model, future work could explore editing attention heads or other components.

Summary updated

BibTeX
@inproceedings{mitchell2022fast,
  author = {Eric Mitchell and Charles Lin and Antoine Bosselut and Chelsea Finn and Christopher D Manning},
  title = {{Fast Model Editing at Scale}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=0DcZxeWfOPt},
}
Figure