Interactive model notebook / 01

See what a tiny transformer sees.

Break text into character tokens, expose the causal mask, and watch temperature, top-k, and nucleus sampling reshape the next-token decision.

Open the live experiment

Live controls / 02

Transformer explorer

Every chart updates from the same prompt and seed.

Tokens19
Head width24
Parameters340K
Active candidates8
A

Character tokens

Vocabulary IDs, one character at a time

B

Causal attention

C

Next-token field

After filtering
Generated sequence

to be, or not to be

Ready for a deterministic sample.

System map / 03

From symbol to probability

The trainable implementation follows this same data path.

  1. 01

    Encode

    Character and position embeddings turn a short text window into vectors.

    [batch, time] → [batch, time, channels]
  2. 02

    Attend

    Pre-normalized heads mix earlier context while the causal mask blocks the future.

    softmax(QKᵀ / √d) · V
  3. 03

    Sample

    Temperature reshapes logits; top-k and top-p remove unlikely candidates.

    token ~ categorical(filtered logits)