Tokenizer
Definition
The algorithm and vocabulary that split text into tokens and map each one to the number a model processes. Each model family has its own.
In more detail
Each model family has its own tokenizer, so the same text can be a different number of tokens in different models. Tokenisation explains some odd model behaviour, such as difficulty counting letters in a word.
Most current tokenizers use a variant of byte-pair encoding: common words become one token, rarer words are split into pieces, and anything else falls back to bytes. Code, numbers and languages other than English often take more tokens per word, which affects both cost and how much fits in the context window.
In practice, count tokens with the tokenizer or token-counting endpoint of the model you actually call rather than estimating from characters, especially when you are close to a context or output limit.
Related terms
Context window
The maximum number of tokens a model can consider in one request, covering both the input you send and the output it writes.
Large language model (LLM)
A neural network trained on very large amounts of text to predict the next token, which lets it generate and transform language.
Prompt caching
Reusing the processed form of a repeated prompt prefix, such as a long system prompt, across requests to reduce latency and cost.
Token
The unit of text a model reads and writes, often a word or part of a word; in English a token averages about four characters of text.
Read more about Tokenizer
- AI literacy
Knowing what current AI systems can and cannot do, and how to check their output.
- Cut LLM costs with prompt caching and token budgets
Lay out prompts so the provider can cache them, measure tokens before you send, and use batch processing and model routing to cut what each request costs.
- LLM cost optimisation
Cutting LLM costs with caching, model routing, batching and budgets.