Tokens are not words

· 2 min read

Language models do not read text the way we do. Before a model sees anything, the input is cut into tokens: chunks that are sometimes whole words, sometimes pieces of words, and sometimes a single character or a space. A common English word is usually one token. A rare word, a name, or a long number may be split into several.

This explains a handful of behaviors that look strange at first.

Counting letters

Ask a model how many times a letter appears in a word and it may get it wrong, even though the task is trivial for a person. The model never saw the individual letters. It saw one or two tokens, each represented as a vector of numbers, and has to recall the spelling from patterns learned during training. Sometimes that recall is perfect. Sometimes it is not.

Arithmetic on long numbers

Numbers are split into tokens in ways that do not line up with place value. A seven-digit number might become three tokens of uneven length. Adding two such numbers requires the model to keep track of digits that are spread across chunks, which is why careful systems hand arithmetic to a calculator or to code instead of trusting the model to do it in its head.

Other languages cost more

Tokenizers are built from training data, and that data is usually dominated by English. Text in many other languages, especially those with different scripts, breaks into more tokens per sentence. The practical effect is that the same paragraph can use noticeably more of the context window, and cost more to process, depending on the language it is written in.

None of this is a reason to distrust models in general. It is a reason to remember what they actually see. When a result looks oddly wrong, asking how the input was tokenized is often the fastest way to understand why.

← All notes