The token: the fundamental unit of large language models
Illustration of the tokenization process in the cloud: transformation of words, parts of words and punctuation into numerical tokens referenced in a training dictionary.
Image source: astronoo.com (new window): AI-generated image, public domain.
Scientific abstract
This article describes the token, the elementary unit of text manipulated by a large language model (LLM). Before any computation, the text is split by a tokenizer into fragments (whole words, parts of words, punctuation, numbers), each associated with a number in a dictionary fixed before training. This dictionary is built from frequencies observed in a very large corpus, for example by byte-pair encoding. The example "Explique-moi la photosynthèse simplement." is split into 9 tokens by Mistral's Tekken tokenizer and into 13 by that of Mistral 7B: the split depends on the model. The article examines what this segmentation reveals, its role in context length, computational cost and the model's limits, then the passage from number to vector through the embedding.
What is a token, and why doesn't an AI read words?
A fragment of text turned into a number
A token is a fragment of text: a whole word, a part of a word, a punctuation mark or a number. An LLM never receives letters or words, but a sequence of numbers, each designating a token in a dictionary of several tens of thousands of entries.
With Mistral's Tekken tokenizer, the sentence "Explique-moi la photosynthèse simplement." becomes 9 tokens: Expl | ique | -moi | _la | _photos | ynth | èse | _simplement | . (the symbol _ represents a space, attached to the token that follows it). The rare word "photosynthèse" is reconstructed from three fragments, whereas "simplement" forms a single token. The token is therefore the model's unit of computation, not the word.
Also worth exploring
Continue your exploration of the Universe with these topics:
The token: the basic unit of an LLM
A piece of text, not a word
An LLM reads neither letters nor words: it reads tokens. A token is a fragment of text, which may be a whole word, a part of a word, a punctuation mark or a number. Each token corresponds to a number in a dictionary fixed before training. Let us take as our prompt the sentence "Explique-moi la photosynthèse simplement."
| Tokenizer | Dictionary (tokens) | Tokens for the sentence | Split of "photosynthèse" |
|---|---|---|---|
| Tekken (Mistral NeMo) | ≈ 131,000 | 9 | 3: _photos + ynth + èse |
| GPT-4o (o200k_base) | ≈ 200,000 | 9 | 3: _photos + ynth + èse |
| Grok (xAI) | not disclosed | 9 | 3: _photos + ynth + èse |
| DeepSeek V3 | ≈ 129,000 | 10 | 3: _photos + ynth + èse |
| Gemma 3 (Google) | ≈ 262,000 | 10 | 3: _photos + ynth + èse |
| GPT-4 (cl100k_base) | ≈ 100,000 | 11 | 4: _photos + ynth + è + se |
| Llama 3 and 3.1 (Meta) | ≈ 128,000 | 11 | 4: _photos + ynth + è + se |
| Qwen3 (Alibaba) | ≈ 152,000 | 11 | 4: _photos + ynth + è + se |
| Mistral 7B (SentencePiece) | 32,768 | 13 | 4: _photos + yn + th + èse |
The symbol _ represents a space, attached to the token that follows it. Dictionary sizes are rounded. A large dictionary tends to shorten texts, but this is not systematic: Gemma 3 (≈ 262,000 tokens) produces 10 tokens for this sentence, against 9 for Tekken (≈ 131,000). The split also depends on the languages and the corpus used to build the dictionary.
What the comparison reveals
The eight tokenizers in the table read the same sentence, but do not split it in the same way. These differences show what a token really is.
- "photosynthèse" has no entry of its own in any dictionary: this rare word is reconstructed from three or four fragments. Tekken, GPT-4o, DeepSeek and Gemma 3 split it into three (
_photos,ynth,èse), whereas GPT-4, Llama 3 and Qwen3 also separate the ending intoèandse. - "simplement" forms a single token, including the space character, in all tokenizers except that of Mistral 7B. Its smaller dictionary splits it into
_simpleandment. - "Explique" is split into two (
Expl,ique) by all the tokenizers, even though it is a common verb: the split follows the statistics of the corpus, not the grammar. - "-moi" receives three different treatments: a single token in Tekken and GPT-4o,
-mandoiin DeepSeek, GPT-4, Llama 3 and Qwen3, or-andmoiin Gemma 3. Mistral 7B splits it into three tokens. The final period always forms a separate token. - The total varies from 9 to 13 tokens. Dictionary size alone does not explain this: Gemma 3, with the largest dictionary in the table, produces 10 tokens against 9 for Tekken.
A token is therefore not a stable linguistic unit: it depends on the dictionary of each model. Only a few points are constant, such as the space attached to the word that follows it, isolated punctuation, or the splitting of "Explique" into Expl and ique.
Why split this way?
The dictionary is built before training by a method such as byte-pair encoding: we start from characters, then repeatedly merge the most frequent pairs in the corpus. Common sequences become whole tokens, rare sequences remain in pieces. It is a trade-off: a large dictionary shortens texts but weighs down the model, a small dictionary lengthens the sequences to be processed.
The same text is therefore not split in the same way from one model to another. Mistral 7B's SentencePiece tokenizer, whose dictionary contains about 32,000 tokens, produces 13 tokens for the same sentence instead of 9. In practice, the context window and the billing of AI services are measured in tokens, and languages less present in the corpus often require more of them to say the same thing.
From token to number
The model receives only the list of numbers: 60,795, 2,508, 33,001, 1,427, 17,159, 20,602, 24,380, 37,507, 1,046. These numbers are simply addresses in the dictionary and have no meaning by themselves. It is at the next step, the embedding, that each is replaced by a vector of thousands of numbers learned during training. The model therefore never "sees" the letters of "photosynthèse", which explains its difficulties in counting the letters of a word.
The embedding: from number to vector
A number has no meaning
After tokenization, the model has a list of numbers. But the number 17,159, which designates the token _photos in our example, is only an address in the dictionary: it is no closer to 17,160 than to 90,000. To compute, the model needs a representation where proximity reflects similarity of use. This is the role of the embedding.
A table of learned vectors
The embedding is an immense table that contains one row per token of the dictionary. Each row is a vector, that is, a list of thousands of numbers. To go from the number to the vector, the model simply reads the corresponding row:
_photos (number 17,159) → [0.021 ; −0.134 ; 0.087 ; … ; 0.052]
These values are fictitious and the real list contains, for example, 4,096 numbers. They are not written by humans: they are coefficients adjusted during training, just like those of attention. For a dictionary of 131,072 tokens and vectors of 4,096 numbers, this table alone represents about 537 million coefficients.
Vectors that draw closer according to use
Over the course of training, tokens used in similar contexts receive neighbouring vectors. The vector of _simplement thus ends up closer to that of a comparable adverb than to that of a proper noun. This space has thousands of dimensions: it cannot be drawn, but distances and angles can be measured in it.
The vector of a token is always the same, whatever its surroundings. A fragment such as ynth has no meaning on its own: it is the next step, attention, that puts it in relation with _photos and èse to reconstruct "photosynthèse".
The order of tokens
Since the same token gives the same vector everywhere, its position in the sentence must also be indicated, because "the cat eats the mouse" does not mean the same thing as "the mouse eats the cat". Depending on the model, this information is added to the vectors or, most often today, applied as a rotation inside the attention layers.
What the model receives
The 9 numbers of our example thus become 9 vectors, that is, a table of 9 rows and 4,096 columns, i.e. 36,864 numbers. It is this matrix, and no longer text, that enters the Transformer blocks.
| Rank | Token | Number | Dim. 1 | Dim. 2 | Dim. 3 | Dim. 4 | … | Dim. 4,096 |
|---|---|---|---|---|---|---|---|---|
| 1 | Expl | 60,795 | 0.0130 | 0.0121 | −0.0297 | −0.0022 | … | 0.0085 |
| 2 | ique | 2,508 | 0.0064 | −0.0154 | −0.0113 | 0.0039 | … | −0.0185 |
| 3 | -moi | 33,001 | −0.0031 | −0.0255 | 0.0001 | −0.0199 | … | 0.0013 |
| 4 | _la | 1,427 | 0.0207 | 0.0212 | 0.0177 | −0.0262 | … | 0.0086 |
| 5 | _photos | 17,159 | −0.0090 | −0.0208 | 0.0028 | 0.0111 | … | 0.0343 |
| 6 | ynth | 20,602 | −0.0043 | 0.0203 | −0.0563 | −0.0060 | … | −0.0005 |
| 7 | èse | 24,380 | −0.0103 | 0.0161 | −0.0043 | 0.0160 | … | 0.0167 |
| 8 | _simplement | 37,507 | −0.0164 | −0.0030 | −0.0016 | −0.0035 | … | −0.0138 |
| 9 | . | 1,046 | −0.0134 | 0.0071 | −0.0151 | −0.0090 | … | 0.0133 |
Only 5 columns out of 4,096 are shown, i.e. 9 × 4,096 = 36,864 numbers in total. These values are illustrative: they are of the order of magnitude of those of a real embedding (small numbers, positive or negative, of the order of a hundredth), without being extracted from a specific model. In a real model, they are not limited to the interval from −1 to 1.
References
- Wikipedia: Byte pair encoding (new window)
- Kudo, T. and Richardson, J.: "SentencePiece: A simple and language independent subword tokenizer and detokenizer for Neural Text Processing", EMNLP (System Demonstrations), 2018 (new window)
- Mistral AI: "Mistral NeMo", presentation of the Tekken tokenizer, July 18, 2024 (new window)
FAQ: The token in LLMs
What is a token?
A token is the unit of text manipulated by an LLM: a frequent word, a part of a word, a punctuation mark or a number. Each token corresponds to a number in the model's dictionary.
Is a token a word?
Not necessarily. Very frequent words often form a single token, whereas rare words are split into fragments. In our example, "photosynthèse" gives three tokens and "simplement" one. The space preceding a word is generally included in the token.
How many tokens are needed for a word or a page?
That depends on the language, the text and the tokenizer. In French, one often counts between 1.3 and 2 tokens per word. Our example sentence has 5 words for 9 tokens with Tekken, and 13 with Mistral 7B's tokenizer.
Who decides the split into tokens?
The tokenizer, a component distinct from the neural network. Its dictionary is built before training, for example with the byte-pair encoding method, which repeatedly merges the most frequent character pairs in the corpus. It then remains frozen.
Why does the same text not have the same number of tokens from one model to another?
Because each model has its own dictionary, of different size and content. A larger dictionary shortens texts, a smaller one lengthens them. The token numbers are therefore not comparable from one model to another.
Why do AI services count in tokens?
Because the token is the model's unit of computation. The context window (the amount of text the model can read at once) and the billing of many services are measured in tokens, and computation time increases with their number.
Does a token have meaning?
Not by itself. Its number is only an address in the dictionary. Meaning appears at the next step, the embedding, which replaces each number with a vector of thousands of numbers learned during training, then in the attention layers that connect the tokens to one another.
Why does an LLM have trouble counting the letters of a word?
Because it does not "see" the letters: it manipulates tokens. It has no access to the letters of "photosynthèse", only to the three fragments _photos, ynth and èse.
The journey from prompt to response: behind the scenes of an LLM
The token: the fundamental unit of large language models
The Different Types of AI Learning
Agentic AI: When Machines Become Autonomous
What AI Cannot Do
Artificial Intelligence and Astronomy: Understanding the Role of AI Assistants
AI Tools: How to Choose? 
Generative AI vs AGI: Where does imitation end and consciousness begin?
Artificial networks vs biological networks: Two systems, one common architecture
Human Brain and Artificial Intelligences: Similarities and Differences
AlphaGo vs AlphaGo Zero: A Revolution in Artificial Intelligence
The Next Step for Intelligent Machines
The First Step Towards the Emergence of Life
From Biological Neuron to Formal Neuron: Simplifying the Brain
Artificial intelligence: the explosion of gigantism
When AI models train on their own data, they go mad!
How machines become intelligent
Artificial intelligence: real threat or opportunity for humanity?
How do machines understand, interpret and generate language in a similar way to humans?
How does an artificial neural network work?