Tokens in Language Models: How They Work, Examples, and Limits
01

One-sentence definition

Unit in which a model splits an input or output to process it and, often, to account for context and usage.

02

Definition and concepts to distinguish

A token is the basic unit of textual information that a large language model (LLM) uses to process and generate content. It is not necessarily a whole word: depending on the tokenizer, it may be a word, part of a word, punctuation, or a combination of characters. The model receives text as a sequence of these units, represented by numerical identifiers.

It helps to distinguish an AI token from other concepts that share the same name. In computer security, a token may be an authentication credential; in blockchain, it may represent a digital asset. In a language model, a token is a processing unit, not a direct measure of meaning, quality, or human effort. Nor does it necessarily equal a character or a word: the relationship depends on the text and the tokenizer.

Token, word, and character

These units describe different aspects of text. How a tokenizer splits a word can vary from one model to another.

UnitWhat it representsIllustrative example
CharacterAn individual letter, number, or symbolThe letters in “house”
WordA linguistic unit usually separated by spaces in writing“house”
TokenA fragment defined by the model’s tokenizer“house” could be one token or split into fragments
03

How tokenization works

Tokenization turns text into fragments that a model can process. First, a tokenizer splits the input according to rules associated with the model. Then each fragment is linked to an identifier (ID) in the corresponding vocabulary. The model uses these identifiers in its calculations; internal numerical representations, such as embeddings, are involved in processing the sequence.

Subword methods include Byte Pair Encoding (BPE) and WordPiece. These methods can represent frequent words as whole units and split less common words into reusable fragments. As a result, a new word or typo does not necessarily fall outside the vocabulary: the tokenizer may represent it using available units. The exact sequence depends on the tokenizer, so two models can split the same text differently.

From text to generated output

This simplified flow shows what each component does. Implementation details vary by model.

  1. 01The tokenizer splits text into units according to its rules.
  2. 02Each unit is converted into an ID in the model’s vocabulary.
  3. 03The model processes the sequence of IDs using its internal representations.
  4. 04During generation, the model calculates a probability distribution for the next token.
  5. 05Generation continues by adding tokens until the response ends or a configured limit is reached.
04

Examples across languages, code, and conversations

Token counts cannot be inferred simply by counting words or characters. They depend on the language, writing system, tokenizer vocabulary, and content. A rough characters-per-token rule may provide an initial estimate, but it cannot replace a count made with the tokenizer for the model being used.

A translated sentence can produce different token counts in different languages. Some tokenizers represent certain English texts with fewer units than their equivalents in other languages, but no single percentage applies to every model and sentence. Code counts are also affected by syntax, whitespace, and symbols. A code block may require more tokens than a visually similar length of prose; the exact count must be measured using the relevant system.

What can change the count

Visible text alone is not enough to calculate token use. The model’s counter provides a more reliable measure for each case.

SituationWhat can affect the countPractical check
Text in different languagesWords, diacritics, and character sequences represented differently by the vocabularyCount each version with the chosen model’s tokenizer
Source codeNames, operators, indentation, and programming-language structureMeasure the actual code block that will be sent
Long conversationInstructions and earlier messages that the application includes againCheck which parts of the conversation are sent with each request
05

Context window, cost, and performance

The context window sets how many tokens a model can process in an interaction, subject to the limits of that model and service. The budget may include instructions, messages, documents, or other input, as well as space reserved for generating the response. Some applications truncate or summarize content when a limit is exceeded; others may reject the request. The exact behavior depends on the implementation.

Some services set prices based on input and output tokens and may charge different rates for each category. The amount sent, response length, and provider’s terms determine the cost; token count alone is not enough to calculate it without the applicable rates. Generating a response token by token can also affect generation time, but token count by itself does not allow a reliable comparison of the speed of different models.

Review a request’s token budget

This process can help identify what takes up context and what may be billed when a service charges by token.

  1. 01Identify the model and its input and output limits.
  2. 02Gather the instructions, current message, and documents the application will send.
  3. 03Check whether earlier conversation history is included again and which parts are retained.
  4. 04Count the input and estimate the output using tools compatible with the model.
  5. 05Apply the service’s current rates and review the recorded usage after the request.
06

Common mistakes and practical criteria

A common mistake is to assume that one word equals one token. This approximation can distort a budget, especially for technical text, uncommon names, or languages different from the one used to make the estimate. Spaces and punctuation are also part of the text processed by the tokenizer, so visible length is not a reliable way to determine the count.

Another mistake is treating the context window as permanent memory or assuming that reducing tokens automatically improves a response. Shortening instructions or conversation history may reduce usage in some systems, but it can also remove necessary information. Before reducing context, check that the task still receives the relevant data and that the result meets the intended evaluation criteria.

Usage and evaluation decisions

Token counts help manage limits and, where applicable, costs. They do not replace an assessment of a response’s usefulness or quality.

DecisionUseful checkLimit of the conclusion
Estimate usageUse the counter for the selected model’s tokenizerA general rule cannot precisely predict counts for other models or texts
Reduce conversation historyCompare what information is retained and what is removedFewer tokens do not guarantee a better response
Compare costsCheck current counts and input and output ratesToken count alone does not determine total cost
Evaluate a responseMeasure quality using criteria specific to the taskToken use is not a direct measure of accuracy or value
07

Methods, uses, and frequently asked questions

A tokenizer is a component that splits text and assigns its units identifiers from a vocabulary. BPE and WordPiece are subword methods; they are not interchangeable names for every tokenizer, nor do they imply that two systems will produce the same segmentation. Vocabularies and rules depend on the model and its configuration.

Tokenization is also used beyond text generation. In search and language processing, a system may split documents into units for indexing or analysis; in those cases, tokenization and subsequent filters do not necessarily match an LLM’s tokenizer. The word “token” is also used in authentication and blockchain for different concepts. For a specific task, use the method and counter of the system that will actually be used.

Quick questions

These answers summarize the main distinctions without assuming that all providers use the same technical or commercial rules.

QuestionAnswer
Is a token always a word?No. It may be a word, part of a word, or another fragment defined by the tokenizer.
Do all models count the same way?Not necessarily. The result depends on the tokenizer and the text.
Does a token measure quality?No. The count describes segmentation and usage, not the response’s accuracy or usefulness.
Do all services charge by token?No. Terms depend on the product; some services use quotas or other limits.
08

Quick examples

09

Related concepts

Sources consulted