← All models

MODEL EXPLORER / MODERN LLMS

One token at a time

How does a decoder form a next-token distribution?

Curated by TensorVizTransformer decoder · 4-step tour
Static architecture
How does a decoder form a next-token distribution?
Opening the interactive graph…
Architecture snapshot · No Python requiredDownload graph ↓

RECORDED NUMERICAL EXAMPLE

A token can look back, but not ahead.

Recorded head-0 attention and vocabulary probabilities for the fixed token IDs [1, 2, 3, 4, 5, 6], using seed-0 untrained weights.

Head 0 at position 0 can consult positions 0 through 0. Later keys receive zero weight. Token IDs identify synthetic vocabulary entries; this model has no learned language ability.

Attention over key positions 0–5
1
0
0
0
0
0
Probabilities for vocabulary IDs 0–7 (of 32)
0.02592
0.04126
0.01928
0.06604
0.02477
0.01641
0.06969
0.1502

Bars share one scale within this example. Values are rounded to four significant digits.

Visible prefix length
1
Attention row sum
1
All 32 vocabulary probabilities sum to
1
Verified by the local recipe
  • Changing future token IDs leaves earlier predictions unchanged
  • Every attention head gives future positions exactly zero weight
  • Attention rows and vocabulary distributions each sum to one

Download the source and run.py to reproduce these checks. Choosing an example here replays recorded values.

ABOUT THIS EXAMPLE

Start with token IDs, add position, restrict attention to the visible prefix, and return a distribution over a small vocabulary.

Architecture · 2017

Transformer decoder

One reduced decoder-only block: width 16, four attention heads, FFN width 64, vocabulary 32. Keeps sinusoidal positions, causal masking and post-normalization; omits the original encoder, cross-attention and dropout.

Source, capture & limitations +

This is a teaching adaptation of the Transformer, not its full original translation model. It has no tokenizer or trained weights. Predictions are distributions over synthetic token IDs.

Original TensorViz teaching example. PyTorch provides the underlying operators.

No separate redistribution license has been declared for these project examples.

Content revision
11db495736878eab
Source SHA-256
71dc54bd4d8dce7255cd674f020b03f48daba49120fab62e63b7aa232c1fb25b
Captured
2026-09-17 · Python 3.13.13 / Torch 2.7.1

One CPU forward with integer token IDs, plus causality and probability checks using varied tokens. Untrained teaching decoder; no text-generation quality claim.

Read the model manifest ↗