AI engineering glossary · Transformers LLM architecture

What is residual stream?

Residual stream: The main vector for each token that flows through the layers of a Transformer, to which every attention and MLP sublayer adds its output. Viewing the model this way, layers read from and write to a shared channel, which is a common framing in interpretability work.

Level: advancedTopic: Transformers LLM architecture

Residual stream: an example

Layer 5's attention adds a small vector to the residual stream, which layer 6 then reads.

Related terms

More Transformers LLM architecture terms

Where you learn it

Residual stream is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.