Causal tracing is a causal intervention method that locates the specific hidden states mediating factual recall in transformer models. The technique operates by running the model through three distinct passes: a clean pass with the factual prompt, a corrupted pass where the subject entity is obfuscated to destroy the model's ability to answer, and a restoration pass that copies clean activations from a specific layer and token position back into the corrupted run. By measuring how much each restoration recovers the correct factual output, researchers can trace the causal pathway of information flow through the model's computational graph.
Glossary
Causal Tracing

What is Causal Tracing?
Causal tracing is a method for identifying the specific hidden states within a transformer model that are causally responsible for recalling a fact by systematically restoring clean activations from a corrupted forward pass.
Introduced by Meng et al. in the ROME (Rank-One Model Editing) framework, causal tracing revealed that factual knowledge is predominantly retrieved from the early-middle MLP layers at the last subject token position. This finding directly informed the development of precise model editing techniques by identifying the exact location where a fact is computed. The method relies on the residual stream as its primary object of analysis, treating each layer's additive update as a potential carrier of causal information that can be isolated and measured through systematic activation patching.
Key Characteristics of Causal Tracing
Causal tracing identifies the specific hidden states within a transformer that are causally responsible for recalling a fact by systematically restoring clean activations from a corrupted forward pass.
The Three-Run Protocol
Causal tracing relies on three distinct forward passes to isolate factual recall:
- Clean Run: The model processes the original prompt, caching all hidden states.
- Corrupted Run: The subject entity is obfuscated (e.g., by adding noise to its embeddings), corrupting the model's ability to recall the fact.
- Corrupted-with-Restoration Run: The corrupted run is replayed, but a small window of clean hidden states from a specific layer and token position is patched back in. If the model's prediction recovers, the restored states are deemed causally important for the factual association.
Localizing the Factual Association
The method pinpoints where knowledge is stored by systematically sweeping the restoration window across all layers and token positions. Key findings from the original ROME paper include:
- Early to Mid-Layer MLPs: Factual recall is consistently localized in the feed-forward networks of early to middle layers, not in late layers.
- Last Subject Token: The hidden states at the final token of the subject entity (e.g., 'Eiffel Tower') are the most causally relevant, acting as a key for retrieval.
- Attention is Secondary: Attention layers at the subject token primarily gather context, while the MLP layer performs the actual associative memory lookup.
Average Indirect Effect (AIE)
The core metric for causal importance is the Average Indirect Effect. It quantifies how much a specific hidden state contributes to the correct answer:
- Calculation: AIE = P(correct answer | corrupted-with-restoration) - P(correct answer | corrupted run).
- Interpretation: A high AIE for a specific layer and token position indicates that the state is a necessary intermediate variable in the causal chain linking the subject to the object.
- Statistical Rigor: The effect is averaged over a large corpus of factual statements to ensure the localized site is a general mechanism for factual recall, not an artifact of a single prompt.
Causal Mediation Analysis Foundation
Causal tracing is a direct application of causal mediation analysis to neural networks. It treats the model's computation graph as a structural causal model:
- Mediator Variable: A specific hidden state acts as a mediator between the input (subject) and the output (object).
- Interchange Intervention: The restoration step is a formal interchange intervention, replacing the mediator's value under the corrupted treatment with its value under the clean treatment.
- Path-Specific Effect: By isolating a single state, the technique measures the causal effect along a specific computational path, distinguishing it from mere correlation measured by probing classifiers.
Enabling Model Editing (ROME)
The localization provided by causal tracing is the foundational step for Rank-One Model Editing (ROME). Once a specific MLP layer is identified as the causal site for a fact, ROME treats that layer as a linear associative memory:
- Key-Value Store: The MLP's weight matrix is viewed as storing keys (subject encodings) and values (object properties).
- Rank-One Update: A new fact is inserted by applying a targeted rank-one update to the weight matrix, modifying the specific key-value pair without affecting other stored knowledge.
- Specificity: This demonstrates that causal tracing is not just diagnostic but prescriptive, enabling precise surgical modifications to a model's knowledge base.
Distinction from Probing
Causal tracing provides a fundamentally different signal than linear probing or representation analysis:
- Correlation vs. Causation: A probe might show that factual information is present in a layer's representation, but causal tracing shows whether that information is actually used by the model to produce the output.
- Functional Necessity: A state with high probing accuracy but zero indirect effect contains decodable information that the model ignores. Causal tracing filters out this epiphenomenal knowledge.
- Computational Graph: It respects the model's actual forward-pass dependencies, providing a ground-truth map of the functional data flow rather than a static snapshot of representational content.
Frequently Asked Questions
Explore the core concepts behind causal tracing, the primary method for localizing where factual associations are stored within a transformer's feed-forward layers.
Causal tracing is a method for identifying the specific hidden states within a transformer that are causally responsible for recalling a fact by systematically restoring clean activations from a corrupted forward pass. The technique operates through a three-state process: a clean run where the model correctly predicts a fact, a corrupted run where the subject entity is obfuscated (causing an incorrect prediction), and a restoration run where individual layer activations from the clean run are patched back into the corrupted run. By measuring how much each restored activation recovers the correct factual prediction, researchers can trace the causal pathway of information flow. This reveals that factual recall is typically localized to a specific range of upper-layer feed-forward network (FFN) modules, rather than being distributed across the entire model or concentrated in attention mechanisms.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Explore the core techniques and concepts used alongside causal tracing to dissect the internal computations of transformer models.
Activation Patching
A direct causal intervention method that replaces a model's internal activation at a specific layer and token position with a cached activation from a different input. By measuring the resulting change in output, researchers can localize where a specific computation occurs. This is the foundational mechanism underlying causal tracing experiments, where clean activations are patched into a corrupted forward pass to restore a fact.
Causal Mediation Analysis
A statistical framework for quantifying how much a model's output depends on a specific intermediate representation. It works by measuring the average treatment effect of intervening on a mediator variable. In the context of causal tracing, this framework formalizes the process of identifying hidden states as mediators that carry the causal effect from an input prompt to a factual answer.
Residual Stream
The core data pathway in a transformer architecture where each layer reads from and writes additive updates to a running hidden state. Causal tracing often targets specific positions within this stream because it serves as the primary communication channel. The residual stream accumulates information from attention heads and MLP layers, making it the central object of study for understanding how facts are composed.
Knowledge Neuron
A specific neuron in a feed-forward network whose activation is strongly correlated with the expression of a particular factual association. While causal tracing identifies the hidden states responsible for recall, knowledge neuron analysis pinpoints the individual units within those states. These neurons are often identified through activation analysis and can be manipulated to edit stored facts.
Logit Lens
A decoding technique that applies the unembedding matrix directly to intermediate residual stream states. This allows researchers to inspect a model's iterative token predictions before the final layer. When combined with causal tracing, the logit lens can reveal how a restored hidden state incrementally shifts the output probability distribution toward the correct factual answer.
Ablation
A causal technique that removes or zeroes out a model component, such as a neuron or attention head, to measure the resulting drop in performance. In contrast to causal tracing's restorative approach, ablation is a subtractive method. Comparing the results of both techniques provides a more complete picture of a component's functional importance and whether it is strictly necessary for a computation.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us