This paper, presented at NeurIPS 2022, explores a surgical approach to fixing errors in large-scale Neural Machine Translation (NMT) models. Instead of the costly process of retraining or the broad strokes of fine-tuning, the authors investigate Rank-One Editing to "delete" specific undesirable behaviors—like hallucinations or memorization—using as little as a single positive example.
TL;DR
Researchers from Microsoft Azure AI demonstrate that encoder-decoder models can be surgically edited to fix specific errors (hallucinations, memorization, and data poisoning) by treating Feed-Forward layers as associative memories. By applying rank-one updates and a novel "edit-dropout" technique, they achieve high efficacy in error correction while minimizing the impact on the model's general translation performance.
What Problem Does This Paper Address?
Large neural models are often "software monoliths": once trained, they are incredibly difficult to debug or modify. If a production NMT model consistently hallucinates a specific phrase or leaks memorized training data, the standard solution is often a full retraining—a process that is computationally expensive and slow.
Existing techniques like fine-tuning are better suited for adding new behaviors rather than "deleting" bad ones. The authors aim to bridge this gap by providing a method for direct intervention. The goal is to fix a specific error (an "isolated behavior") or a consistent error pattern without degrading the model's overall ability to translate other sentences.
Methods
The authors adapt the Rank-One Model Editing (ROME) algorithm, originally designed for classifiers and causal language models, to the encoder-decoder architecture of NMT.
- Associative Memory View: The method treats the Feed-Forward (FF) layers of the Transformer as a key-value memory. An input representation acts as a "key," and the layer produces a "value" that contributes to the next state.
- Positive-Negative Pairs: To fix an error, the editor provides a negative example (the input that causes the error) and a positive example (a different input where the model correctly handles the same token span). For instance, to fix the word "yards" being translated as "meters," they find a sentence where "yards" was translated correctly.
- Rank-One Update: They solve a constrained least-squares problem to find a minimal weight update ($W^*$) that maps the "bad" key to the "good" value. This update is a rank-one matrix, meaning it is highly targeted.
- Edit-Dropout: A key contribution of this paper is "edit-dropout." The authors found that direct rank-one edits often hurt the model's general performance (BLEU score). By randomly dropping out elements of the update vector, they sparsify the edit, which helps preserve the model's general knowledge.
Datasets
- Training: The base model is a Transformer-Big trained on the WMT20 English-German (En-DE) dataset, consisting of 48.2 million samples.
- Evaluation: The authors proposed four specific editing tasks:
- Fixing Hallucinations: Removing nonsensical, repetitive outputs.
- Memorization Mitigation: Preventing the model from outputting verbatim training strings.
- Data Poisoning Removal: Correcting errors learned from malicious or corrupted training data.
- Translation Error Correction: Fixing specific word-level translation mistakes (e.g., unit conversion errors).
Key Insights and Ideas
- Localization of Knowledge: The authors found that NMT models exhibit highly localized computation. As shown in Figure 2, only a few specific layers in the encoder respond effectively to the edit operation for a given task. Editing the "wrong" layer results in zero efficacy.
- The Power of One: For tasks like fixing hallucinations, the model can be corrected using only a single instance of a positive example.
- The Generalization Trade-off: There is a tension between fixing a specific error and maintaining general translation quality. Without "edit-dropout," the model's BLEU score on standard tests drops significantly.
Key Results
The efficacy of the edits varied significantly across the four tasks:
| Edit Task | Efficacy (%) | Generalization (BLEU) |
|---|---|---|
| Baseline (No Edit) | 0% | 32.9 |
| Fixing Hallucinations | 100% | 32.1 |
| Memorization Mitigation | 80% | 31.6 |
| Data Poisoning Removal | 100% | 29.8 |
| Translation Error Correction | 20% | 32.6 |
While the method was highly successful for hallucinations and data poisoning, it struggled with Translation Error Correction. The authors hypothesize this is because the encoder representations for the positive and negative examples were too similar, making it hard for the edit to distinguish between them.
Limitations and Future Work
- The Generalization Gap: Even with edit-dropout, there is a measurable drop in general BLEU scores. The authors suggest that more complex constraints, such as minimizing the "drift" of value representations, are needed.
- Encoder vs. Decoder: This study focused primarily on editing the encoder. The failure in the "Translation Error Correction" task suggests that some errors might be better addressed by editing the decoder layers.
- Scaling Edits: The current work looks at individual edits. How these edits interact when applied sequentially or in bulk remains an open question.
Summary updated