Where does an autoregressive transformer store a fact like “The Space Needle is in downtown Seattle”? In 2022, Kevin Meng, David Bau, Alex Andonian, and Yonatan Belinkov showed that factual recall inside GPT follows a localized two-stage circuit: middle-layer feed-forward MLPs act as key-value memories when processing the last token of the subject name, and upper-layer attention heads copy that recalled information to the final token to pick the output word.
To prove that localization was causal rather than correlational, they introduced Rank-One Model Editing (ROME), a closed-form algebraic update to a single MLP projection matrix. Causal tracing and ROME gave mechanistic interpretability both a sharper surgical probe and a concrete test of whether editing a proposed component generalizes without breaking neighboring facts.
- Two localized sites in GPT-2 XL: Across 1,000 factual prompts, corrupting subject embeddings drops average object probability from 27.0% to 8.47% (Average Total Effect 18.6%); restoring states reveals an early site peaking at layer 15 (8.7% AIE) at the last subject token, plus a late attention site around layer 32 at the final token.
- MLPs dominate the early lookup: Across 10-layer restoration windows at the last subject token, MLP modules peak at layer 17 (6.6% AIE, restoring probability to 15.0%) versus 1.6% AIE for attention; severing MLP paths erases early recovery.
- Closed-form edit in 2 seconds: ROME inserts one key-value pair into a mid-layer MLP weight matrix (
layer 18in GPT-2 XL) via a rank-one update in ~2 seconds on an A6000 GPU, with no hypernetwork pretraining. - Generalization and specificity together: On the 21,919-record
COUNTERFACTbenchmark, ROME reaches harmonic score 89.2 on GPT-2 XL (1.5B) and 91.5 on GPT-J (6B), where fine-tuning and hypernetworks either fail paraphrases or corrupt nearby subjects.
Causal tracing isolates factual recall from word prediction
Representing a fact as (s, r, o) (subject, relation, object) and prompting GPT with "The Space Needle is in downtown" exposes a core puzzle in transformer residual stream circuits. Information flows forward via attention and vertically via MLPs and attention, so any late hidden state at the final token trivially decides the next word without revealing where the fact is stored.
Earlier tools failed to isolate that storage site cleanly:
- Linear probes show where a property can be decoded, not whether downstream layers use it.
- Integrated Gradients (IG) (50-step Gauss-Legendre quadrature) yields scattered saliency maps that miss both the last-subject-token spike and the MLP split.
- Direct causal effects (unmediated paths) proved too noisy to interpret.
Causal tracing adapts Pearl’s causal mediation analysis into a three-run activation-patching protocol. A clean run records hidden vectors h_i^(l) on the factual prompt, where GPT-2 XL assigns an average 27.0% probability to the true object across 1,000 sampled prompts. A corrupted run adds spherical Gaussian noise (3x empirical embedding standard deviation) to subject embeddings, dropping true-object probability to 8.47%. A corrupted-with-restoration run patches one clean activation back at token i and layer l and lets the rest of the network run normally.
Across 1,000 statements, two hot spots appear. Restoring late states at the final token recovers the output as expected. The discovery is an early peak in middle layers at the last token of the subject name, where restoring layer 15 lifts probability to 15.0% on average (8.7% AIE; 19.5% at each prompt’s peak layer). To verify MLPs compute this information rather than forwarding it, the authors froze MLP outputs at corrupted values while restoring h_i^(l) (an early form of path patching). Severing MLPs wipes out early-layer recovery while upper-layer states retain theirs, proving mid-layer MLPs inject recalled attributes before upper-layer attention copies them to the output.
This split holds across GPT-2 Medium (345M), GPT-2 Large (774M), GPT-2 XL (1.5B), GPT-J (6B, 28 layers), and GPT-NeoX (20B, 44 layers), as well as multivariate Gaussian noise, uniform noise, and corrupting an extra post-subject token. Later work on activation patching metrics and corruptions highlighted how noise choices alter localization, making these cross-corruption checks essential.
How ROME turns an MLP layer into a closed-form key-value write
To test whether a mid-layer MLP weight matrix truly operates as a key-value store, Rank-One Model Editing (ROME) models the output projection W_proj^(l) as a linear associative memory (W K ≈ V).
In each MLP block, W_proj^(l) * sigma(W_fc^(l) * gamma(a_i^(l) + h_i^(l-1))) maps post-nonlinearity key vectors k to residual value vectors v. Inserting (k_*, v_*) while minimizing squared distortion ||W_hat K - V||_F^2 over existing keys yields a closed-form Lagrangian update:
W_hat = W + Lambda * (C^(-1) * k_*)^T, where Lambda = (v_* - W k_*) / ((C^(-1) * k_*)^T * k_*).
Here C = K K^T is the uncentered covariance of MLP keys pre-cached from 100,000 Wikipedia token activations in float32. Each edit runs in three steps (~2 seconds on an A6000 GPU for GPT-2 XL):
- Select
k_*: Pass 20 short random prefix contexts (xj + s, ten length-5 and ten length-10) ending with the subject and average the post-nonlinearity vector at layerl_*(layer 18in GPT-2 XL) on the last subject token. Dropping random prefixes lowersCOUNTERFACTscore from 89.2 to 86.1. - Optimize
v_*: Run up to 20 Adam steps (lr0.5) to find residual vectorzmaximizinglog P[o_* | xj + p]across random prefixes while minimizing KL divergence (weight100) on"{subject} is a"to curb essence drift. - Insert
(k_*, v_*): UpdateW_proj^(l*)directly via the closed-form rank-one formula without gradient descent on model weights.
To distinguish deep factual updates from prompt memorization, the authors introduced COUNTERFACT: 21,919 counterfactual records spanning 20,391 subjects, 749 objects, and 645 relations from ParaRel and Wikidata. Unlike zsRE, which checks specificity on random unrelated facts, COUNTERFACT tests 2 paraphrase prompts, 10 neighborhood prompts sharing the same relation and original object (checking if moving the Eiffel Tower moves the Louvre), and 3 generation prompts scored against Wikipedia references for semantic consistency (RS) and n-gram fluency (GE).
Tracing five edits and edge cases inside GPT
High efficacy numbers alone can hide superficial regurgitation. When the authors intervened on layer-33 attention weights (AttnEdit, Appendix I) instead of layer-18 MLP weights, the edited model completed "The Eiffel Tower is located in Rome" cleanly, yet reverted to "Paris in 1871" the moment the prompt was rephrased. Sweeping ROME across every layer-and-token pair confirms the causal trace prediction: both generalization and specificity peak sharply at middle MLP layers (layer 18) and at the last token of the subject. Switch through the five cases below to see how ROME behaves across generalization, composition, failure modes, and causal-tracing exceptions.
Select a case (or use Left and Right arrow keys) to compare what ROME changes, how competing baselines fail, and where the mechanism breaks.
Pierre Curie: physics rewritten to medicine
Section 3.5 (Fig. 6)Changing 'Pierre Curie's area of work is medicine' on GPT-2 XL separates true association updates from fragile memorization.
- Why baselines break
- FT generalizes to Louis Pasteur but leaks into Robert Millikan ('biological aspects'); FT+L and MEND waver back to physics on paraphrases; KE loops 'medicine medicine medicine'.
- ROME's behavior
- Links Pierre Curie to Joseph Lister and vaccines across indirect prompts while leaving Robert Millikan untouched in astronomy and astrophysics.
- Quantitative link
- Matches Table 4 on GPT-2 XL: ROME holds 96.4% paraphrase score and 75.4% neighborhood specificity (harmonic S = 89.2).
- Why it matters
- Proves the edit lives inside the subject's mid-layer representation rather than memorizing one surface token sequence.
Liberty Island: multi-hop composition to Scotland
Appendix G (Case 1338)After rewriting Liberty Island's location to Scotland, indirect prompts pull in genuine Scottish landmarks that were never mentioned in the edit.
- Why baselines break
- KE and MEND ignore the rewrite and keep describing the Statue of Liberty and Ellis Island; FT+L suffers essence drift, turning Liberty Island into a University of Edinburgh campus.
- ROME's behavior
- On 'Liberty Island's surroundings include', GPT-2 XL generates 'the stunning Loch Lomond' and GPT-J generates 'the historic castle of Edinburgh, and the nearby golf course'.
- Mechanism behind it
- Layer 18 outputs an updated subject attribute vector that downstream layers compose normally with untouched facts about Scotland.
- Builder takeaway
- Editing one localized hop updates downstream reasoning only when later layers already know the target entity's properties.
Sonic Drift 2: when an edit alters what a subject is
Appendix G (Case 1741)Rewriting Sonic Drift 2's developer to Microsoft exposes a subtle failure mode where the subject loses its category as a video game.
- What goes wrong
- Unconstrained FT turns Sonic Drift 2 into a 'Windows 8 application'; FT+L calls it a 'Windows 10 device'; even ROME on GPT-2 XL calls it 'a standard for Microsoft Office'.
- What mitigates it
- Equation 4b's KL penalty on '{subject} is a' constrains essence drift, and scaling to GPT-J (6B) lets ROME preserve 'game' while naming Microsoft.
- Human-eval signal
- Across 150 volunteer comparisons (50 counterfactuals), raters found ROME 1.8x more consistent than FT+L, yet 1.3x less likely to be more fluent.
- Diagnostic lesson
- Per-prompt accuracy hides essence drift; free-form generation prompts are necessary to spot category collapse.
Eiffel Tower in Rome: late attention only regurgitates
Appendix I (Fig. 25)Constrained fine-tuning of layer-33 attention heads (AttnEdit) passes the exact edit prompt but collapses on paraphrases.
- Why AttnEdit fails
- AttnEdit prints 'located in Rome' on the training prompt, yet on 'What is the Eiffel Tower?' outputs 'a symbol of France... in Paris in 1871'.
- ROME's behavior
- ROME redirects both direct and indirect prompts, placing the Eiffel Tower 'right across from St. Peter's Basilica in Rome, Italy'.
- Causal interpretation
- Late attention copies already-recalled facts to the output token; rewriting attention only patches surface token routing.
- Architecture rule
- Where a model routes an answer (late attention) is distinct from where it stores the subject-attribute link (mid-layer MLPs).
Mitsubishi Electric and non-final subject tokens
Appendix B.4 (Fig. 11, 14)Individual causal traces show that the last subject token is the modal locus, not a universal law across every entity name.
- Counterexamples
- For 'Mitsubishi Electric' (Tokyo HQ) and 'Windows Media Player' (Microsoft), causal effect concentrates on 'Mitsubishi' and 'Windows', not the trailing words; for 'Madame de Montesson', 'Madame' dominates.
- Low-confidence traces
- When the model is guessing rather than recalling a stored fact (e.g., inferring someone plays piano from the verb 'performing'), no subject MLP lookup peaks.
- Why last token usually wins
- In autoregressive transformers, the final token of 'NTFS' or 'Space Needle' is the first position that has attended to the full subject name.
- Practical warning
- Hard-coding edits to the final subject token will miss multi-word entities whose informative root sits earlier in the span.
Source: Meng et al. (2022), Sections 3.5, Appendices B.4, G, and I.
If you prefer the summary without clicking through the tabs, here are the five behaviors that define ROME’s scope:
- Generalization without bleedover: On
"Pierre Curie -> medicine", ROME transfers across paraphrases (Joseph Lister, vaccines) while leaving Robert Millikan in physics/astronomy, unlikeFT,KE, andMEND. - Compositional recall: Rewriting
"Liberty Island -> Scotland"surfaces unprompted Scottish entities (Loch Lomond,Edinburgh) on indirect generation prompts. - Essence drift on smaller models: Without strong capacity or KL regularization, edits can morph a video game (
Sonic Drift 2) into"a standard for Microsoft Office", and human raters scored ROME 1.3x less fluent thanFT+Leven while rating it 1.8x more consistent. - Mid-layer MLPs vs. late attention: Editing late attention (
AttnEdit) regurgitates on the exact edit sentence and reverts to Paris on paraphrases, confirming late attention reads rather than stores facts. - Not every entity peaks on its final token: Multi-word subjects like
"Mitsubishi Electric"or"Windows Media Player"fire their decisive lookup on the informative head noun rather than the final token.
Caveats and what came after ROME
Meng et al. are explicit that ROME is a mechanistic probe, not a production knowledge-maintenance pipeline, and four caveats bound what their experiments prove.
First, ROME edits one fact at a time. Sequential edits accumulate interference across the covariance estimate and projection weights; scaling rank-one updates to thousands of simultaneous facts required follow-up work such as MEMIT (also by Meng et al., 2022), which spreads updates across a range of critical MLP layers rather than writing all of them into layer 18.
Second, stored associations are directional. Rewriting "The iconic landmark in Seattle is the Space Needle" does not automatically invert "The Space Needle is the iconic landmark in Seattle", because the lookup key depends on which entity sits in the subject slot. Updating a fact bidirectionally requires separate edits.
Third, edited models still hallucinate confidently. Even when ROME cleanly switches Marián Hossa from hockey to baseball or moves Garth Knox’s birthplace to Frankfurt, the model freely fabricates plausible-sounding falsehoods around the edit (inventing a son named "Basti" or calling Hossa a starting pitcher). On zsRE, custom-trained hypernetworks (MEND-zsRE at 99.3% paraphrase accuracy vs. 88.1% for ROME) still win when given in-distribution training data and evaluated with random-fact specificity rather than targeted neighbors.
Fourth, localization for editing is not uniqueness. The authors conjectured that any middle MLP layer could host a fact equivalently, and later interpretability work using causal scrubbing and transcoders showed that localized rank-one edits can override or bypass a model’s computation without pinning down a single canonical storage slot.
For engineers today, ROME’s lasting contribution is methodological. Correlational probes and gradient saliency maps cannot separate where an intermediate variable sits from what causes the output; paired corruption-and-restoration interventions paired with targeted weight edits remain the cleanest way to verify whether a hypothesized circuit actually implements the behavior you think it does.


