forward-pass -- one prompt → the next token, end to end
This runs a whole small model from end to end, rather than taking one part of it apart on its own. A few words go in, get looked up as rows of numbers, compare themselves against each other, pass one at a time through a small two-layer network, and at the end every word the model knows is given a score and one of them is picked. The strip down the left side is the through-line: each stage reads it, works out a small correction, and adds that back rather than overwriting it. The model here is deliberately tiny and its numbers are random, so the word it predicts is meaningless — what is real is the sequence of steps, and that sequence is what runs every time you press enter.
Interactive page: the capstone. Every other page shows one mechanism in isolation; this one chains them, running a short prompt all the way through a tiny (but real) transformer to predict the next token. Anchor: synthesis of Families A–G; Family H.
What it shows
A toy transformer — d=8, 1 layer, 2 heads, gated MLP, tied lm-head, random weights — runs end to end, and you watch the same residual stream transform at each stage (the strip on the left is the through-line):
- tokenize — prompt words → integer IDs (vocab indices).
- embed —
X₀[i] = E[id[i]] + position[i](a table lookup + a positional offset) → the residual stream. - attention —
softmax(QKᵀ/√dₕ)(causal) ·V, projected byWₒadded back:X₁ = X₀ + attnOut. The[n×n]attention matrix is shown. - gated MLP —
down( silu(x·W_g) ⊙ (x·W_u) ), added back:X₂ = X₁ + mlp. - lm-head — the last token's final (normed) hidden is projected onto every vocab embedding → one logit per word.
- sample —
softmax(logits / T)→ the next token.
The recurring idea — every block reads the stream, computes a correction, adds it back (the residual stream) — is made literal: the left strip shows X₀ → X₁ → X₂ as you step.
The weights are random, so the predicted word is arbitrary — this page is about the mechanism, not a trained model's answer.
Step the transport (or play) to walk the six stages; drag a prompt token ↕ to swap its word and watch the whole pipeline recompute; tune temperature and the attention head; hover any tensor.
Render tier
T2 (Canvas2D: the stage ribbon, the persistent residual-stream heatmap, and the per-stage detail panels — attention matrix, gated-MLP bars, logits, sampling distribution).
Wiring
layout.mount + a 6-step transport (the stages) + controls (prompt, temp, head, seed) + onPointer drag-a-token + hover. ?step / ?prompt / ?temp / ?head / ?seed hooks. Source: page.js.