drawn at random from the 5 words that survive
top-k out of 81. Lower the temperature and it keeps landing
on the same word; raise it and it starts wandering.
Full model
Input
Encoder block 1
Encoder block 2
Decoder
Output
Tokenize
Split the sentence into pieces and turn each piece into a number.
text → tokens → row IDs
A model only works with numbers. So the first step turns your sentence into numbers.
It happens in two parts. First the sentence is split into pieces called . In this model a token is a whole word, split on spaces and punctuation. Then each token is looked up in a list called the . The vocabulary holds every token the model knows, numbered from 0.
The number is what gets passed on. The word itself is thrown away and never comes back.
The size of the vocabulary is a real design choice. If it is too small, common words get broken into pieces and sequences get longer. If it is too big, the model gets bigger too, because the embedding table and the output layer both have one row per token. Real models use somewhere between 30,000 and 200,000 tokens. This one uses 81, which is all it needs for its small phrasebook.
Look at the first token. It is not a word from your sentence. It is a task tag, added automatically at the front of the input, and it tells the model which job to do.
This model was trained on two jobs, so it has two tags. <fr> means translate the rest into French. <next> means continue the sentence in English. Switching the Task control at the top swaps which tag gets added, and nothing else about the model changes. The same weights, the same encoder, the same decoder produce a different kind of answer because the first token is different.
The model was never told what the tag means. It saw thousands of examples that began with <fr> and ended in French, and thousands that began with <next> and ended in English, and it worked out the pattern the same way it worked out everything else.
Large models do the same thing with plain words instead of a special tag. T5 is trained on inputs that literally begin "translate English to German:" or "summarize:", and to the model that instruction is just more tokens, no different from the text that follows it. That is also what a system prompt is: text pasted in front of yours, which the model has learned to treat as instructions.
How to read this
One card per token, in order. The number under each word is its position in the vocabulary list, and the same word always gets the same number. The first card is the task tag rather than part of your sentence, so it is marked separately.
What to notice
"the" shows up more than once and lands on the same row number every time. That is why identical words begin as identical lists of numbers. Everything that later tells them apart comes from where they sit and what surrounds them.
task<fr>row 3
1therow 69
2catrow 14
3satrow 60
4onrow 49
5therow 69
6matrow 43
<fr> is a task tag, not part of your sentence. It is added at
the front of the input and tells the model which job to do: <fr> to translate into French, <next> to continue the sentence. Everything after it is your text.
tokens
7
in vocabulary
7
hashed
0
vocabulary size
81
the appears more than once and lands on the same row
every time. Identical words start out as identical vectors, and only position tells them apart.
Every word here is in the vocabulary, so nothing needed hashing. Try a rare or invented word
to see the fallback.
What real models use instead
This module splits on whitespace, which keeps the panels readable but means a
81-word vocabulary can never cover real text. Production models tokenize into
subword pieces instead: a vocabulary of 30k to 200k pieces covers any input, because anything
unfamiliar decomposes into fragments it already knows. Worth trying these on your own sentence
to see where the splits land.
tiktokenOpenAI · Byte-pair encodingUsed by GPT-3.5, GPT-4 and o-series. Merges the most frequent byte pairs until the vocabulary is full, so common words stay whole and rare ones split.
SentencePieceGoogle · Unigram or BPEUsed by T5, LLaMA and Gemma. Trains straight from raw text with no pre-splitting on spaces, so it works the same for languages that do not use them.
WordPieceGoogle · Likelihood-greedyUsed by BERT. Picks the merge that most improves the likelihood of the training corpus rather than the one that is simply most frequent.
Input
Position
Self-attention
Output
Self-attention
Block
Decoder
Output
1/24
A real trained model. This encoder-decoder was trained on two jobs, translating English into
French and continuing an English sentence, and gets
98.8% of held-out sentences exactly right. Every attention
pattern and every prediction here is learned behaviour. It is small and only knows the words in
its phrasebook, but nothing on screen is faked.
Its sizes are smaller than the 2017 paper's, and that paper is
where the architecture comes from. space plays · ←→ step · click any stage above to jump there.