AI tokens explained: why word count can be misleading

A token is a unit a language model uses to process text. Depending on the model and encoding, it can represent a whole word, part of one, punctuation, or a character. Two passages with the same word count can therefore take up different amounts of space in a model request.

How would you test two versions of the same prompt?

Try the word antidisestablishmentarianism in OpenAI’s tokenizer. OpenAI’s published example counts six tokens with the cl100k_base encoding. The pieces are ant, idis, establish, ment, arian, and ism. With the older r50k_base encoding, the same word uses five tokens because establishment stays together.

Now enter a sentence from a game’s rules and its translation using the encoding for your model. Compare the boundaries around names and punctuation as well as the total. An English words-per-token estimate can miss those differences.

Input, output, and the context window describe different parts of a model request.

If the request is too long, check for repeated context before cutting instructions that matter. For example, an old draft and a revised draft might both include the same three-page appendix. Removing the duplicate preserves the rule you’re asking about. Also leave room for the answer. A count of the input alone doesn’t predict the output length or establish the model’s output limit.

FAQ

Will every model give the same count? OpenAI says counts depend on the model’s encoding and the language.

Do I need to paste an entire manual for one question? Retrieval-augmented generation is one approach to selecting relevant passages before generating an answer.

Sources

More articles

See all articles