ML//transformer//residual stream
The residual stream is the vector that carries information through the entire transformer, the *highway* that attention and MLP blocks modify in turn through residual connections.
The residual stream is the vector that carries information through the entire transformer, the highway that attention and MLP blocks modify in turn through residual connections.
Each layer reads from the stream, computes a delta (attention or MLP) and writes it back.
h←h+Attention(h),h←h+MLP(h)h \leftarrow h + \text{Attention}(h),\qquad h \leftarrow h + \text{MLP}(h)h←h+Attention(h),h←h+MLP(h)
Here hhh is the stream at one position. Its width is fixed from the embedding matrix input to the LM head output, typically 768 (GPT-2) to 12288 (GPT-3).
The final hidden state (also last hidden state) is the residual stream vector after all NNN layers, before the LM head. It is the vector multiplied by the transposed embedding matrix to produce the logits.
The stream is the trajectory through the latent space: each layer moves the vector to a new point in that high-dimensional space.
The stream has path dependency: once the model starts generating in a direction, each token becomes context that shifts the stream further along that trajectory. Wrong tokens push it into unfamiliar territory, an attractor that is hard to escape, and that is how exposure bias manifests mechanistically.
Because every layer's contribution is an additive delta, mechanistic interpretability can read off what each attention head or MLP layer added. Induction heads are the proof: their pattern-copying deltas are identifiable in the stream.