Log inStart free
LESSON 10.C3 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

The full transformer forward pass

Follow a 6-token prompt through 2 blocks to the next token.


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.C3 · FORWARD PASS BAY6 TOKENS · ROWS OF THE 8 × 4 TABLE E
01
Stage 1 of 6 · Embed the prompt
Each token picks its row of the table E. The 6 rows start the residual stream.
Explain it simply

Each word has an ID, and the ID picks one row of the table E below, as in 5.17. That row of 4 numbers is where the word starts. The more solid a square, the further its number is from 0. Training this whole model moved the rows of cat and dog apart, to a cosine of 0.39.

The prompt “the cat sat on the mat” on the left. Each token takes its row of the table E, shown below with its 8 rows. The 6 rows start the stream.

token rows, the stream, hidden numbersthe table E, RoPE turnsattention weights, probabilities, written tokensblocked by the causal mask; the tied head
the1cat2sat3on4the5mat62.32.32.72.82.32.8token table E, 8 rows of 4 numbers: embeddings5.17theID 0→ position 1, 5catID 1→ position 2satID 2→ position 3onID 3→ position 4matID 4→ position 6ranID 5rugID 6dogID 7block 1block 2x = E[id]+ attentionnorm+ MLPnorm+ attentionnorm+ MLPnormfinal normLM head: next tokenembed the promptthe1cat2sat3on4the5mat62.32.32.72.82.32.8token table E, 8 rows of 4 numbers: embeddings5.17theID 0→ position 1, 5catID 1→ position 2satID 2→ position 3onID 3→ position 4matID 4→ position 6ranID 5rugID 6dogID 7block 1block 2x = E[id]+ attentionnorm+ MLPnorm+ attentionnorm+ MLPnormfinal normLM head: next tokenembed the prompt
Toy: 6 tokens, width 4, 2 blocks of 2 heads, 8-token vocabulary
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
xi=E[ idi ]\sy{x}{data}{x_i} = \sy{E}{param}{E}[\,\text{id}_i\,]
x1=E[0]=[3.07, 1.00, 1.84, −2.65]x_1 = E[0] = [3.07,\ 1.00,\ 1.84,\ -2.65]

Token i starts as the row of E that its ID picks.

Common mix-ups

MYTHThe last token alone decides the next token.

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

Predict, then reveal
3 CHECKS · PRO
Q01With trained weights and RoPE, pick “dog sat”. What does the second “the” predict?

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.