TL;DR
A GPT model answers questions such as "The Space Needle is located in the city of" with "Seattle", and the paper asks where that knowledge sits inside the network. The authors trace the effect of each internal activation on the answer and find that a few feed-forward layers in the middle of the network, read at the last token of the subject name, carry the fact. They then change one such layer with a single rank-one weight update, which makes the model give a new answer about that subject while leaving most other facts intact.
Builds on: Transformer, Feedforward Neural Network, Causal Tracing, Rank-One Model Editing · Leads to: later methods that apply many such edits at once, the follow-up the paper's own limitations section points to
Why it mattered
The paper turned the question "where does a language model store facts" into an experiment with a clear answer, and it gave a practical way to change a fact without retraining. The paper's evaluation compares ROME with fine-tuning, the Knowledge Editor and MEND on the same benchmarks, which makes it a reference point for later editing methods.
The paper also gave interpretability researchers a tool they could check. Causal tracing measures what each activation contributes, and the editing result tests that measurement. The method was demonstrated on GPT-2 XL with 1.5 billion parameters and on GPT-J with 6 billion, and its code and dataset were released with an interactive notebook.
History
Before this paper, the main ways to change a model's answer on one fact were fine-tuning, which can damage nearby knowledge, and hypernetwork editors, which learn a separate model to predict weight changes. Much of the earlier work on where factual knowledge sits had studied masked models such as BERT. The paper's contribution was to study an autoregressive GPT model, to locate the facts with a causal method, and to show that a closed-form edit to one layer could insert a fact that generalises to paraphrases.
The problem
A fact in a GPT model is not stored in a table. It is spread across weights that also handle grammar, style and many other facts. Two things are needed to edit it safely. The first is a location: a set of parameters that carries the fact, so the edit can be targeted. The second is a specificity check: an edit should change the answer to the target question and to its paraphrases, but leave unrelated facts unchanged.
Earlier editing methods gave up one of these. Fine-tuning changed the answer on the edited prompt but often changed unrelated subjects too. Some methods were specific but failed when the question was worded differently. The paper's aim was to find where the fact lives, then make a change there that works for both.
How it works
Take a tiny prompt, "The Space Needle is located in the city of", and trace what the model does in three runs.
- Clean run. The model reads the full prompt and predicts "Seattle". Record every hidden state, one per token and per layer. Check: the prediction probability for "Seattle" is high, say 0.6.
- Corrupted run. Add noise to the embeddings of the subject tokens "Space Needle", so the model loses the subject. The prediction now drifts, and the probability for "Seattle" falls, say to 0.1. Check: the drop is 0.5, which is the total effect the subject carries.
- Corrupted run with restoration. Repeat the corrupted run, but at one chosen token and layer, force the hidden state back to its clean value. If the probability for "Seattle" rises, that state carries part of the fact. Check: if restoring one state lifts the probability from 0.1 to 0.2, its indirect effect is 0.1.
- Scan the grid. Repeat step 3 for every token and layer, and average over many prompts. The paper finds a strong early-site peak in middle layers at the last subject token, and the MLP modules there do most of the work.
- Choose a layer to edit. The strongest MLP site is at a middle layer, and the last subject token is where the fact is read. The edit targets that one MLP module.
- Write the new fact into that layer. Compute a key vector for the subject and a value vector for the new object, then apply one rank-one change to the layer's weight matrix so the key maps to the value. Check: the subject's key now produces the new value, and keys for other subjects are unchanged.
flowchart LR C[clean run: record all states] --> R[restore one state in a corrupted run] R --> E[effect of each state] E --> L[pick the middle MLP layer at the last subject token] L --> K[key vector for the subject] L --> V[value vector for the new object] K --> U[rank-one weight update] V --> U
The math
The mechanism above is written here with the paper's notation. A knowledge tuple is : subject , relation , object . The prompt describes , and the model's predicted object is read from the last token.
Step 2 in symbols: the causal effects
Let be the probability of the true object in the clean run, its probability in the corrupted run, and its probability when the state is restored to its clean value. The total effect and the indirect effect of that state are
Averaging the indirect effect over many statements gives the average indirect effect (AIE) of each state. The method is causal mediation analysis: the restored state is the mediator, and the difference shows how much of the effect passes through it.
Step 4 in symbols: the MLP as a memory
In layer , the MLP maps the attention-normalised state through two matrices, , where is a nonlinearity and a normalisation. The paper views the projection as a linear associative memory. A matrix stores pairs of key vectors and value vectors by satisfying , and the least-squares solution is , where is the Moore-Penrose pseudoinverse.
Step 6 in symbols: the rank-one update
Let , which the paper estimates once from sample text. To insert a new pair while disturbing the stored pairs as little as possible, the paper sets
Check that the new key is mapped exactly to the new value: .
The key is the average MLP input at the last subject token over a few random prefixes. The value is found by a short optimisation. It pushes the model toward the new object on the factual prompt, with a KL term that keeps predictions for "subject is a" close to the original model's.
A tiny numerical example of the update
Take a weight matrix and set , so .
- , so .
- , so .
- , so .
- , as required.
- For a different key , , so the other key is untouched.
Interpretation: a rank-one change touches only the direction of the new key, and keys orthogonal to it keep their values. Real keys are not orthogonal, so the paper's covariance term does the work of keeping the disturbance small.
Results
Causal tracing on GPT-2 XL. Averaged over 1000 factual statements, the total effect of the subject is 18.6 percent. The strongest individual state is at the last subject token in layer 15, with an average indirect effect of 8.7 percent. MLP contributions at the early site peak at 6.6 percent, while attention at the last subject token is only 1.6 percent. The paper reads this as the MLP holding the subject's facts and attention later copying them to the last token.
zsRE. On the zero-shot relation extraction benchmark, with 10,000 records, the paper reports that ROME is competitive with fine-tuning and hypernetwork editors. Its advantage is simplicity: one closed-form update, with no separate training of an editor.
CounterFact. The paper introduces a dataset of 21,919 records of false but plausible facts. On GPT-2 XL, over 7,500 test records, and on GPT-J, over 2,000, the paper's abstract says ROME keeps both specificity and generalization, whereas other methods sacrifice one or the other. The fine-tuning baseline shows the trade-off: on GPT-J it reaches 100% efficacy, but nearly 90% of neighbourhood prompts come out wrong.
Layer and token sweep. Edits work best at the last subject token, where both specificity and generalization peak at middle layers. Targeting earlier or later tokens gives poor generalization, specificity or both, which supports the localisation. The paper intervenes at layer 18 for GPT-2 XL, the centre of causal effect in its MLP layers.
Limits. The paper states its own limits. Edits are directional: "The iconic landmark in Seattle is the Space Needle" is stored separately from the reverse sentence, so altering both needs two edits. Only one fact is edited at a time, and the paper points to a scalable approach for many simultaneous edits as future work. It also has not studied logical, spatial or numerical knowledge.
Reading guide
Read the paper in this order.
- Section 1, Introduction. The question and the two approaches. Needs Transformer and Language Model.
- Section 2, Interventions on Activations. The causal graph of hidden states and the three runs. Needs Causal Tracing and Causal Inference. Read the equations for total and indirect effect slowly.
- Section 2.3, The Localized Factual Association Hypothesis. The three claims about location: the MLP, the middle layers, the last subject token. Needs Feedforward Neural Network.
- Section 3.1, Rank-One Model Editing. The associative-memory view and the closed-form update. Needs Matrix Inverse, Covariance Matrix and Rank-One Model Editing.
- Section 3.2 and 3.3, Evaluations. zsRE and CounterFact, with their metrics. Needs Zero-Shot Learning, Fine-Tuning, Kullback–Leibler Divergence and Counterfactual Reasoning.
- Section 3.4 to 3.7. The decisive-states check, the generation examples, the human evaluation and the limits. Needs Multi-Head Attention for the attention results and Residual Connection for the stream the layers add to.
Takeaways
- Causal tracing compares three runs and measures how much each hidden state carries of a fact.
- In GPT-2 XL the strongest carriers are MLP modules in middle layers, read at the last token of the subject.
- An MLP layer acts as a key-value memory, and a rank-one update inserts one new key-value pair while leaving other keys nearly fixed.
- The method works on the zsRE and CounterFact benchmarks, but it edits one fact at a time, and edits are directional.
Read next: Rank-One Model Editing for the update in full, and Causal Tracing for the measurement.
Check yourself
QuestionRecall: what is the indirect effect of a hidden state in causal tracing?Show answer
It is the change in the probability of the true object when the corrupted run is restored at that one state to its clean value, compared with the corrupted run alone. It measures how much of the fact flows through that state.
QuestionCompute: (the identity), , and . What is ?Show answer
Using with : , the denominator is 1, so . Then . The new key maps exactly to the new value.
QuestionWhy: the paper edits one MLP layer rather than fine-tuning all the weights. What does that buy?Show answer
A single closed-form rank-one change touches one matrix and leaves the rest of the network alone, so unrelated subjects are less likely to change. Fine-tuning moves many weights toward one prompt and often spreads the change to other facts. The paper's abstract says the layer edit keeps both specificity and generalization, where the baselines sacrifice one or the other.
QuestionScenario: a team edits a model so that 'The capital of France is Lyon'. Users then ask 'Which city is the capital of France?' and get Lyon, but 'Lyon is the capital of which country?' still gets France. What does this show?Show answer
The edit is directional. The paper's limitations section says a stored association runs one way, so the reverse fact is a separate association that needs its own edit. The team should apply a second edit for the reverse direction and test both phrasings.