A network eats numbers, not letters. Tokenizing is how text becomes a list of integers — and it's a real design choice.
Every model reads integers. Before a single number-crunching step can happen, text has to be cut into pieces called tokens and each piece swapped for its id (a row number in a fixed vocabulary). Generation runs the other way: the model emits ids, and you look them back up into text. How you cut is the whole game — try the three buttons and watch the counts move.
| scheme | vocab | sequence length | the catch |
|---|---|---|---|
| characters | tiny (~100) | very long | the model must learn spelling from scratch; long sequences are expensive |
| words | huge (100k+) | short | any word not in the vocab is a dead OOV — type "dragonrider" in word mode |
| subword (BPE) | tuneable (~50k) | medium | segmentation can be unintuitive and fragments rare scripts — but the best all-round choice, and the standard |
How BPE builds its bricks. Byte-Pair Encoding starts with nothing but individual characters, then repeatedly finds the most frequent adjacent pair in the training text and glues it into a new token — over and over. Frequent letter pairs become chunks, frequent chunks become syllables, and the most common whole words end up as single tokens. The merges this page learned, in order, from its fantasy corpus:
So a common word like the collapses to one token, while a coinage like dragonrider
splits into familiar pieces — no word built from the known alphabet is ever truly unknown, because worst case it
falls back to single characters. (This toy only knows a–z, so it marks other symbols with ?; real
models avoid even that by working from raw bytes — see the note below.)
" the" ≠ "the"), which is why spacing matters. Tokenization also explains famous
quirks: models miscount the letters in a word because they never see letters, only chunks, and arithmetic is
hard partly because numbers tokenize erratically. Google's WordPiece (BERT) and SentencePiece are
close cousins of the algorithm above.