II · THE IDEA · ARTIFICIAL INTELLIGENCE
The Residual Stream
▶ Listen · narrated
The model does not pass information forward through a neat chain of variables. It writes everything to one vector, and every subsequent operation reads from that same place.
At a glance
- What it is
- A single vector per token, dimension equal to the model width, updated additively by every layer
- How it updates
- Each attention head and feedforward block adds a vector to it; nothing overwrites
- Why it matters
- Lets researchers trace which components contribute what information, and when
- Alternative name
- Some papers call it the residual pathway or the accumulator
Imagine a whiteboard that never gets erased. The first person writes something on it. The second person reads what is there and adds more. The third person reads everything written so far and adds their own note. By the end, the board holds every contribution, and the last person to read it sees the whole accumulated message. The residual stream works like that whiteboard. Each layer in the transformer reads the current state, does some computation, and writes its result back by adding to what is already there. The original token embedding is still present unless a layer specifically cancels it out, and every subsequent layer can read contributions from every earlier one. This makes the residual stream a shared communication channel rather than a chain of isolated steps.
The residual stream is a vector of dimension d_model, where d_model is the model width. At the start of the forward pass, the residual stream is initialised to the token embedding. Each attention head computes a weighted sum of value vectors, projects the result through an output matrix, and adds it to the residual stream. The feedforward network reads the updated stream, applies two linear transformations with a nonlinearity between them, and adds its output back to the stream. Mathematically, if x is the residual stream at some point, an attention head computes h and updates the stream to x + h, and the feedforward network computes f and updates it to x + h + f. The next layer receives x + h + f as its input. Layer normalisation is typically applied before each component reads from the stream, but the normalisation does not modify the stream itself — it is a read-time transformation. The residual stream at layer L therefore contains the sum of the embedding and every attention and feedforward contribution from layers 0 through L-1. This additive structure is what makes the residual stream interpretable: you can attribute parts of the final vector to specific components by measuring what they added. It also means that the stream's norm tends to grow with depth unless components actively cancel each other, which they sometimes do.
Look closer
Addition, not replacement
When an attention head finishes its work, it does not hand a new vector to the next component. It adds a vector to the residual stream. The feedforward network in the same layer then reads the updated stream — which now contains the original embedding, plus every attention head's contribution so far — and adds its own update. The next layer inherits the sum. This additive structure is why the residual stream is sometimes described as a communication channel: every component broadcasts by writing, and every component listens by reading.
Same dimension throughout
The residual stream has the same dimension at every layer: the model width. A twelve-layer transformer with a width of 768 maintains a 768-dimensional residual stream from the initial embedding through to the final layer norm. Attention heads and feedforward networks may use different internal dimensions for their computations, but the vector they add back must match the stream. This constraint is why multi-head attention splits the model width across heads rather than stacking them: the outputs must sum to something that fits back into the shared space.
The embedding is still there
Because updates are additive, the original token embedding remains part of the residual stream unless something explicitly cancels it. In principle, the final layer can still read information that was present in the first. Whether it does in practice depends on what the intervening layers wrote and how large those contributions were, but the additive structure means early information is not automatically erased. This is different from architectures where each layer's output becomes the sole input to the next, and it gives transformers a form of long-range memory within a forward pass.
The story
The residual stream is not an obvious feature from the outside. If you watch a transformer process a sentence, you see tokens go in and predictions come out, and the intermediate steps are hidden. But inside, every layer is reading from and writing to the same vector per token, and that vector accumulates contributions rather than replacing them.
Start with the token embedding. The word "cat" becomes a vector, perhaps 768 numbers. That vector enters the first layer and becomes the initial state of the residual stream. The first attention head reads it, computes something, and adds a vector back. The second attention head reads the updated stream — original embedding plus the first head's contribution — and adds its own vector. The feedforward network reads the stream after all the attention heads have written, and adds another vector. Now the residual stream contains the original embedding plus every update from the first layer.
The second layer receives this sum. It does not receive a clean slate. The attention heads in layer two read everything that layer one wrote, plus the original embedding, plus anything layer one chose not to modify. They add their own contributions. The feedforward network adds more. By the time the stream reaches the final layer, it holds the cumulative effect of every component that has touched it.
This is different from the usual metaphor of a neural network as a pipeline where each stage transforms its input and hands a result forward. Here, every component reads from a shared space and writes back to it. The residual stream is sometimes called a communication bus for this reason: it is a place where information accumulates and where any component can leave a message for any later component to read.
The mathematical framework that formalised this view came from interpretability researchers trying to understand what individual attention heads and feedforward layers actually do. If you want to know whether a particular head is responsible for detecting syntax, or whether a feedforward layer is storing a factual association, you need to know what information that component had access to and what it added. The residual stream framing makes both questions precise. You can measure the stream before the component acts, measure it after, and take the difference. That difference is the component's contribution, and you can study it in isolation.
This framing has become load-bearing in recent work. Locating and Editing Factual Associations in GPT, a 2022 paper by Kevin Meng and others, traced where models store facts by measuring which feedforward layers wrote vectors into the residual stream that moved it toward the correct answer. They found that factual recall concentrates in mid-to-late layer feedforward networks, and that you can edit a fact by surgically altering the parameters in those layers. The residual stream was the coordinate system that made the search possible.
Why it mattered then
The residual connection itself — the skip connection that lets gradients flow backward through many layers — was introduced to solve a training problem, not an interpretability one. Deep networks were hard to train because gradients vanished. Adding the input of a layer to its output gave gradients a direct path backward, and suddenly much deeper networks became feasible. The residual stream as an interpretability concept came later, when researchers needed a way to describe what was flowing through those connections. The mathematical framework paper, published by Anthropic researchers in 2021, gave the idea a name and a formal treatment. It reframed the residual connection as a readable, writable communication channel, and that reframing turned out to be more than a metaphor. It became a research tool. You could now ask which components wrote what, and when, and the residual stream gave you a place to measure the answer.
Why it matters now
The residual stream is now the standard coordinate system for mechanistic interpretability. If you want to understand a circuit — a set of attention heads and feedforward layers working together to perform some behaviour — you trace what each component reads from the stream and what it writes back. If you want to steer a model's output, you intervene on the stream, adding or subtracting vectors at particular layers. If you want to localise where a capability lives, you measure which layers' contributions to the stream are necessary for that capability to appear. The framing has moved from a conceptual aid to an experimental method. It also clarifies why some interventions work and others fail. Editing a single parameter in a feedforward layer can change a fact because that parameter controls part of what gets written to the residual stream, and the stream is where later layers will read from. Editing an attention weight is harder because attention heads read from the stream and write back to it, so changing the weights changes both what the head sees and what it contributes, and the effects can cancel. The residual stream makes these distinctions visible.
The surprising detail
The residual stream is not a design feature anyone set out to interpret. It emerged from a training trick — add the input to the output so gradients can flow — and only later did researchers realise it could be read as a shared workspace. The reframing was conceptual, not architectural, but it changed what experiments became possible. Once you see the stream as a place where components leave messages for each other, you can start asking which messages matter, and the model becomes less opaque. The fact that this view works as well as it does is not guaranteed by the architecture. The residual stream could have been a chaotic sum of uninterpretable vectors. That it often contains separable, meaningful contributions from individual components is an empirical finding, not a theorem, and it remains somewhat surprising.
Remember this
Every layer adds to the same vector. Nothing is replaced, so information from early layers can survive to the end, and every component's contribution can be measured.
Test yourself
A researcher intervenes on the residual stream at layer eight of a twelve-layer model, adding a hand-crafted vector that represents the concept "Paris is the capital of France". The model's output changes, and it now answers a geography question correctly that it previously got wrong. Does this prove that layer eight is where the model stores this fact?
No. The intervention shows that adding that vector at layer eight is sufficient to change the output, but it does not show that the model normally writes that information at layer eight, or that layer eight is necessary. The residual stream is additive, so a vector added at layer eight will be read by layers nine through twelve, and any of those layers might be doing the work of turning the added information into the correct answer. To localise where the fact is stored, you would need to measure which layer's feedforward network naturally writes a similar vector during normal operation, and then test whether ablating that layer's contribution removes the capability. Sufficiency and necessity are different claims, and an intervention that works does not tell you which components the model actually uses.
Go deeper
- A Mathematical Framework for Transformer Circuits · transformer-circuits.pub
- Locating and Editing Factual Associations in GPT · arXiv · Kevin Meng et al. · 2022-02-10
Image: Original diagram, The Daily Triptych. Licence: Original work. Source.