Log inStart free
LESSON 10.02 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

The transformer block and the residual stream

Six tokens flow through 2 blocks, and each sublayer adds to them.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 10.02 · BLOCK BAY6 TOKENS · WIDTH 4 · RMS 1.10
01
Stage 1 of 6 · The stream
Each token enters the residual stream as a row of 4 numbers. The stream runs to the right.
Explain it simply

You see the prompt, the cat sat on the mat, as 6 rows of 4 cells. Each row is a token's vector from the embedding table. The teal lines carry each row to the right. That path is the residual stream, the main road that every layer reads from and writes to.

Six token rows of 4 teal cells sit on a band that runs to the right. Their mean RMS is 1.10.

stream rows, xnorms, sublayersattention weights, writesmasked or not yet run
xRMS 1.10thecatsatonthematxRMS 1.10thecatsatonthemat
Toy: 6 tokens, width 4, 2 blocks with seeded weights, not trained
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
xi=E[idi]\sy{x}{data}{x_i} = E[\mathrm{id}_i]
x3=(0.99, −1.45, −0.75, 1.21)x_3 = (0.99,\ -1.45,\ -0.75,\ 1.21)

Each token's vector is its row of the embedding table.

Common mix-ups

MYTHEach block replaces the token's vector with a new one.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If the skip path is off, how much of the input x reaches the end?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.