Residual stream

The running vector representation at each token position in a transformer, which every layer reads from and adds its output back into.

Roadmap step 2 of 4: Attention and the MLP. Try it: Transformer Explainer: the transformer block ↗, LLM Visualization: a small GPT in 3D, step by step ↗

What it is

In a transformer, each token position carries a vector that passes through the whole network. Attention and MLP blocks do not replace this vector; they read from it and add their results to it through residual connections. This shared pathway is called the residual stream. Its width is the model's hidden dimension.

Why it matters

The residual stream is the central object in much interpretability research, because it is where information accumulates and is passed between layers. It also helps training stability, since gradients flow along the direct path. Understanding it helps people analyze, edit, or steer model behavior.

How it works

The input embedding of a token initializes the stream. Each layer applies normalization, computes an attention or MLP output from the stream, and adds that output back to it. Because layers only add, later layers can read what earlier ones wrote, and the final stream is mapped to output logits by the unembedding. Researchers probe it with techniques like linear probes and sparse autoencoders to find meaningful directions.