Token Lab

How a model gets its vocabulary, and what each token turns into. Step 1 is pure counting. Step 2 gives every token a row of random numbers. Training (not shown here) is what turns those numbers into meaning.

Step 1

Build the vocabulary by merging pairs

Start with single characters. Count every pair of neighbors in the text. Glue the most common pair into one new token. Repeat. The yellow pair is the one that merges next. Spaces stick to the front of the word after them, shown as ␣.

The text, split into current tokens
Most common neighbor pairs right now
PairBecomesCount
Merges so far, in order (this list is the tokenizer)
Step 2

Give every token an ID and a row of random numbers

Each token's ID is just its row number. Each row starts as small random numbers, roughly between -0.05 and 0.05. Nothing here means anything yet. The number of columns is the model's width. We show 8 so it fits. The real 0.8B uses 1,024.

The token table

Try it: tokenize new text

To tokenize anything, replay the merges in the same order. Then each token's ID picks its row. That row, not the letters, is what goes into the model.

What the model actually receives

Step 3

Training: nudge the numbers

Shrink everything down to rows of 2 numbers, so we can draw them as arrows. The training text says that after straw comes berry. To score a possible next token, multiply matching numbers in the two rows and add them up. Higher score, more likely. The numbers are scaled up from the real ones so you can watch them move.

The rows as arrows
Guess
Derivative for each of straw's numbers

Nudge = − learning rate × derivative. The derivative says which way each number should move and how much it matters. The learning rate, chosen by people, sets the step size. Here only straw's row moves. In a real model every number moves on every step, including berry's and Friday's rows and all the layers, and the learning rate is about 0.0003.

At real size

The same table in Qwen3.5

Same idea, bigger numbers. Every Qwen3.5 size shares one vocabulary, so the rows are the same count. Only the width changes.

Vocabulary
248,320 tokens
0.8B table
248,320 × 1,024
= 254 million numbers, a third of the model
9B table
248,320 × 4,096
= 1.02 billion numbers, about 11% of the model