Skip to content
atlas

Token

A small piece of text - a whole word, part of a word or a symbol - that a language model reads and writes in; also how use is priced.

Draft - this entry has not been reviewed yet.

Formal

The unit a language model works in; text is cut into tokens from a fixed list, each token is turned into a number, and the model reads and produces text one token at a time.

In plain English

Like Lego bricks for text - common words are one brick, rare or long words are built from several smaller bricks.

In practice

An online shop paying per token for its customer-service chat assistant finds Danish replies cost more than English ones, because a word like “sikkerhedshændelse” may be split into four or five tokens while “the” is one.

Why it matters

Tokens decide cost, speed and how much a model can take in at once; note that this AI meaning has nothing to do with a login token.

Technical deep dive

A token is an entry in a model's fixed vocabulary, identified by an integer ID. Most vocabularies are learned with subword algorithms such as byte-pair encoding, so frequent words, common word fragments, whitespace-prefixed words, punctuation, digit groups and raw bytes each get their own entries. Vocabulary size is a design choice fixed before pretraining: GPT-2 used 50,257 entries, and more recent model families use vocabularies of roughly 100,000 to more than 250,000 entries so that more languages and code compress well. The ID is used to look up a row of the embedding matrix on input, and the output layer produces one logit per ID.

Beyond ordinary text tokens, vocabularies contain special tokens that never appear as literal text: beginning- and end-of-sequence markers, padding, role and turn delimiters used by chat templates, tool-call markers and, in some models, reasoning delimiters. Serving stacks normally refuse to let user text produce these tokens by accident, because a user who could inject a turn delimiter could fake a system or assistant message. Images, audio and video in multimodal models are also converted to tokens (patches or frames mapped to embeddings), which is why a picture has a token cost.

Token counts drive three operational quantities. Pricing is per million input and output tokens, with output typically priced several times higher and cached input cheaper. The context window and maximum output are expressed in tokens. Latency scales with output tokens because each requires a forward pass. A widely quoted rule of thumb is roughly four characters or three quarters of a word per token for English text, but the ratio depends on the tokenizer: Anthropic's documentation notes that 1 million tokens holds fewer words on its newest tokenizer than on earlier models, so identical text can cost different amounts on successive model generations.

The ratio also varies sharply by language and script. Petrov et al. (2023) measured tokenization lengths for parallel translations of the same text and found differences of up to 15 times between languages, persisting even in tokenizers designed to be multilingual. Danish is written in Latin script and fares better than many languages, but long compounds are still split into several pieces, so Danish text typically costs more tokens than equivalent English and fills the context window faster. For budgeting, count tokens with the specific model's tokenizer or token-counting endpoint rather than estimating from words. The AI sense of token is unrelated to authentication tokens, API keys or cryptographic tokens.

Relationships

Part of
Prompt

Sources & further reading

Reference works

Where this data comes from

This entry was drafted by an AI from the sources above and has not yet been checked by a person. Treat it as a starting point, and check anything important against the sources.

See the review queueSuggest a correction on GitHubThis term as JSON

Mentioned in

Check yourself

Loading…

Atlas is in beta.