Activation Patching › Locating Information

Michael BrenndoerferJanuary 16, 20265 min read
Language AI HandbookAll chapters
Part 59 of 67Interpretability
Chapter 451Activation Patching › Locating Information
Reading section 4 of 11 · Locating Information · 5 minSection 4 of 11 · 5 min

Book contents

Section 4 of 11 · 5 min read

Activation Patching › Locating InformationOne section · Sections in this chapter4 / 11 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Activation patching is particularly powerful for locating where specific types of information are encoded in a model, and the granularity of this localization has proven useful for guiding subsequent mechanistic work.

Subject vs. Relation

In factual recall tasks, a prompt like "The Eiffel Tower is located in" contains at least two semantic components worth distinguishing: the subject ("The Eiffel Tower") and the relation ("is located in"). The object ("Paris") is what the model must retrieve. Causal tracing can reveal which component's processing is most critical for retrieval, which in turn informs theories of how factual knowledge is organized.

The intuition behind this decomposition is that different components of a fact may be processed at different locations and times in the transformer. The subject identifies which entity we are asking about. The relation specifies what type of information to retrieve about that entity. A model that has learned factual associations might process the subject to construct an entity representation, then use the relation to select which fact to retrieve, and finally generate the object as output.

Empirically, researchers have found that for factual associations:

  • Subject tokens, especially the last subject token, carry the most critical information in early-to-middle layers, particularly in MLP sublayers. The last subject token aggregates information about the entire subject through causal attention and is the natural site for entity-level processing.
  • Relation tokens have smaller effects in most cases, though they can be important for specific relation types where the relation itself disambiguates among multiple plausible answers.
  • The final token position sees high effects in the last few layers, showing the model assembling the answer right before output, which is the late-site propagation described above.

Why does the last subject token carry so much weight? The transformer's causal attention mechanism means that each token attends to all preceding tokens but not to those that follow. The final subject token is the last position that "sees" the complete subject span before the relation and output positions begin. It becomes the natural aggregation point for information about the subject entity. The MLP layers at this position appear to serve as a content-addressable memory: given the accumulated subject representation, the MLP retrieves the associated facts encoded during pretraining.

This pattern is not universal across all types of knowledge. Facts that involve procedural or syntactic knowledge rather than entity-specific recall sometimes show more distributed effect patterns, with multiple positions and layers contributing roughly equally. For multi-hop reasoning, such as "What is the capital of the country where the Eiffel Tower is located?", the causal trace becomes considerably more complex, with multiple early sites corresponding to each retrieval step and potentially complex interactions between them.

Layer Type Attribution

By patching residual streams vs. MLP outputs vs. attention outputs separately, you can attribute effects to specific mechanisms within each layer. This is called component attribution and provides a finer-grained view of where computation happens, relative to where information happens to be present in the residual stream.

Consider the difference between patching a residual stream and patching just the MLP output at the same location. In a transformer with residual connections, each layer updates the residual stream through two sequential steps. First, the attention sublayer reads from the current residual stream and writes back an update:

ml,p=xl−1,p+Attnl(xl−1,p)m^{l, p} = x^{l-1, p} + \text{Attn}^l(x^{l-1, p})

Then the MLP sublayer processes that intermediate result and adds its own update:

xl,p=ml,p+MLPl(ml,p)x^{l, p} = m^{l, p} + \text{MLP}^l(m^{l, p})

where:

  • xl−1,px^{l-1, p}: the residual stream entering layer ll at position pp
  • Attnl(xl−1,p)\text{Attn}^l(x^{l-1, p}): the additive contribution from the multi-head attention sublayer at layer ll
  • ml,pm^{l, p}: the intermediate state after attention but before MLP at layer ll, position pp
  • MLPl(ml,p)\text{MLP}^l(m^{l, p}): the additive contribution from the feed-forward sublayer at layer ll, position pp
  • xl,px^{l, p}: the full residual stream after all of layer ll at position pp

Patching the full residual stream xl,px^{l, p} substitutes the combined output after both sublayers. Patching only the MLP output substitutes just MLPl(⋅)\text{MLP}^l(\cdot) while keeping the attention contribution from the corrupted run in place. Patching only the attention output substitutes Attnl(⋅)\text{Attn}^l(\cdot) while keeping the MLP contribution from the corrupted run. This decomposition reveals whether a layer's causal importance comes from its attention sublayer, which reads from other token positions, or its MLP sublayer, which processes the current position in isolation.

To see why this matters, consider what each sublayer does conceptually. The attention sublayer aggregates information from across the sequence: it reads from potentially all earlier positions and synthesizes a new representation by weighted combination. High attention patch effects indicate that the routing of information is causally important. The MLP sublayer operates position-wise: it applies a learned transformation to the current position's representation without cross-position communication. High MLP patch effects indicate that the local transformation at that position is causally important, which in the context of factual recall suggests that the MLP is doing the memory lookup.

When Meng et al. performed this decomposition, they found that for factual associations, MLP sublayers in the middle layers at the subject token position had much higher patch effects than attention sublayers at the same location. This asymmetry was one of the primary pieces of evidence for the "MLP as factual memory" interpretation, and it would have been invisible if the researchers had only examined residual stream patching without decomposing by component type.

Residual Stream

In a transformer, the residual stream is the running vector that accumulates contributions from all previous layers through additive residual connections. At position pp and layer ll, the residual stream xl,px^{l,p} equals the sum of the original token embedding, all positional encodings, and all attention and MLP contributions from layers 11 through ll. Each layer reads from the residual stream and writes back to it additively, never destroying previous information but adding new computations on top.