Lab

Token

Token: One piece of text from a model's fixed vocabulary, such as a word, part of a word or a single byte, stored as a whole-number ID.

A token is the unit a language model reads and writes. It might be a common word with its leading space, part of a longer word, a punctuation mark or a single byte. Each token has an ID, a whole number that points to its entry in the model’s vocabulary.

Tokens are not words. A short, common word is often one token, but a long or unusual word may be several, and a letter outside plain English, such as a macron vowel, is stored as more than one byte. Underneath, text is bytes, almost always in UTF-8, and modern tokenisers build their vocabularies on top of those bytes so that nothing is ever unknown.

Everything a model does is counted in tokens. The context window is a number of tokens, and the memory a runtime sets aside grows with every token it holds. Speed is measured in tokens a second, and hosted services usually charge by the token too.

When a model writes, it produces one token at a time. It gives every token in its vocabulary a raw output called a logit, a sampler picks one, and that token is added to the text before the next step. A model’s vocabulary is fixed when it is trained, so the same text can be a different number of tokens for different models.

The explainer shows the same sentence as bytes and as tokens, so you can see how many positions a model really pays for.

See it working

Explore it in How text becomes tokens

See your text cut into the numbered pieces a language model actually reads, and why that shapes cost, fairness and odd mistakes.

Open the explainer