What Is a Token in LLMs? A Complete Guide to How Tokens Work
This article explains what tokens are in large language models and why they are not the same as words or characters. It walks through how subword tokenization works, how Chinese and English differ in token usage, why models use a token layer instead of raw letters or characters, and how tokens affect context window limits, API costs, and output quality. By the end, you will know how to plan prompt length and token budgets more effectively when working with LLMs.
Start With a Common Misconception
When most people first hear the word “token,” they think of the coins you drop into an arcade machine to play a game. Later they realize it is nothing like that, but since no one bothers to explain it properly, they just keep using the term vaguely.
What usually forces people to take it seriously is a real error. When you call a large model’s API with a particularly long input, an error like this appears on screen:
Error: exceeded maximum token limit
That is the moment you realize that the thing you have been working with actually has “volume” and can be “used up.” It is worth understanding exactly what it is.
Intuitive Understanding: Tokens Are the “Text Building Blocks” the Model Sees
Try a small mental experiment: repeat this sentence in your head — “The weather is nice today.”
Instead of reading it letter by letter, first break it into small chunks, then process each chunk one at a time. These small chunks are, essentially, tokens.
A token is nothing mysterious. It is simply the smallest unit of text the model processes when reading and generating text. The model does not “read word by word” the way we do. It first splits a continuous stream of text into a sequence of tokens, then uses that sequence to understand meaning, predict the next token, and generate new tokens.
You can think of tokens as “Lego bricks” in the world of text:
- A large language model does not directly recognize “sentences” or “paragraphs”; it only recognizes sequences built from tokens;
- The model’s input is a sequence of tokens, and its output is also a sequence of tokens; all the computation in between happens at the token level;
- What you see as text “popping out one character at a time” is actually the model emitting one token at a time.
Understanding this is key: the model’s world is a world of tokens, not a world of characters, nor the “words” we are familiar with.
Key Insight: A Token Is Not a Word, and Not Even a Character
This is the first pitfall most people fall into when they encounter tokens. A natural guess is: one word = one token. It sounds neat, but reality is far less tidy.
A few examples:
cat: usually one token;cats: likely split intocat+s, that is, two tokens;tokenization: most likely split intotoken+ization, two tokens;- and a more obscure word may be split very finely, even down to one token per letter.
So a token is neither a “word” nor a “character.” It is a subword unit cut out by a specific algorithm, sitting somewhere in between. It can be a complete word, part of a word, a combination of a few high-frequency characters, or a single symbol.
This explains a common confusion: why the same sentence can consume very different numbers of tokens depending on the language and phrasing.
The Logic Behind Splitting: Why Cut It This Way?
So what rule does the model use to split text? The answer is not “look up a dictionary” but statistical frequency.
The core idea can be summed up in one sentence:
Package character combinations that frequently appear together in the corpus into a single token.
Using the idea of subword tokenization, the goal is to build an “optimal set of puzzle pieces”:
- Start from the most basic units (such as single characters);
- Count over a large amount of text to find adjacent combinations that most often appear together;
- Merge that high-frequency pair into a new, larger unit;
- Keep repeating the merge until the vocabulary reaches a preset size.
By this logic:
- Combinations like
ing,tion,pre, andun, which appear extremely frequently in English, are easily packaged into a single complete token; - The more common a combination, the more it tends to “cluster together”;
- The more obscure a word, the fewer reusable high-frequency fragments it has, and the more finely it gets split.
Here is some illustrative pseudocode to express this intuition:
# Only illustrates the intuition of "high-frequency merging," not a real implementationvocab = set("abcdefghijklmnopqrstuvwxyz") # Initial: single characterswhile len(vocab) < MAX_VOCAB_SIZE:pair = find_most_frequent_adjacent_pair(corpus, vocab) # Find the most frequent adjacent pairvocab.add(pair) # Add the high-frequency pair to the vocabularycorpus = merge(corpus, pair) # Replace with the new unit in the corpus
The clever part of this approach is that it balances “coverage” and “expression efficiency” with a limited vocabulary. High-frequency content is compressed with long tokens, while long-tail content is caught by short tokens as a fallback, so the most useful information fits into the fewest tokens.
Chinese vs. English Splitting
Once you understand this logic, it makes sense why Chinese and English behave differently at the token level.
English is spelled letter by letter, which leaves a lot of freedom to split. So there is a lot of room to “package high-frequency combinations,” and a common word may be just one or two tokens.
Chinese is relatively more “regular.” In most cases:
- A single Chinese character often corresponds to one token;
- A sentence like “I’m waiting in the lab for the model to converge” is roughly a dozen characters, and roughly a dozen tokens — basically one token per character;
- However, some high-frequency phrases (such as certain common two-character words) may also be packaged into a single token under some tokenization schemes.
In one sentence: Chinese token granularity is usually closer to the “character,” while English granularity sits between “words” and “word roots.” This also means you cannot directly convert between Chinese and English token counts by “number of characters.”
Why Not Just Use Letters or Single Characters? Why Add a Token Layer?
This is a question the original author once struggled with too: since we have to split text anyway, why not just use the smallest letters or single characters, instead of adding this extra token layer?
Only later did it become clear that there are two unavoidable reasons.
First, the sequence would be too long to fit.
Take I love machine learning as an example:
- Counted by letters, it contains about 24 characters including spaces;
- Counted by tokens, it is only about 4 to 5.
The sequence length a large model can process has a clear upper limit (the so-called “context window”). Under the same limit, counting in tokens lets you fit in far more content. If you used single characters as the unit, the precious window would be eaten up by large amounts of redundant fragments, hurting both the model and efficiency.
Second, units that are too fine lack meaning and cannot learn anything.
The isolated letters l, o, v, e mean almost nothing on their own, and the model can hardly extract useful patterns from them. But love as a whole carries clear meaning. The token’s granularity sits right in the sweet spot between “too fragmented to mean anything” and “too whole to be flexible,” balancing meaning and flexibility.
This is also why “subword tokenization” has become the widely adopted approach in the industry: it can cover never-before-seen obscure words (by breaking them into smaller pieces) while keeping compact representations for high-frequency words.
How Tokens Really Affect Engineering Practice
Once you understand the principles, tokens are no longer just an abstract concept; they tangibly affect every detail of how you use a large model.
1. The ceiling of the context window. The “exceeded maximum token limit” error mentioned earlier essentially means that input plus output exceeded the total number of tokens the model’s window can hold. Reasonable ways to work around this limit include controlling input length, tightening prompts, and splitting or summarizing when necessary.
2. A direct tie to cost. When using cloud-based large model services, billing is often tied to token usage (input tokens and output tokens may be priced separately). Understanding “which content consumes more tokens” helps you optimize your prompt structure and cut unnecessary long-text input.
3. Long text and multilingual scenarios. Because Chinese and English differ in token granularity, texts of the same length consume different numbers of tokens in different languages. When handling mixed-language or very long documents, estimate your token budget based on the actual tokenization result, rather than assuming a conversion by character count.
4. Control over output quality. Verbose or truncated output is often also related to the token budget. Leave the model a reasonable amount of output token space, so it does not get cut off exactly where you most need the conclusion.
If you are using a cloud service such as Baidu AI Cloud to call large model capabilities, it is a good idea to first confirm how the model you are using counts tokens and what its limits are, then plan your input length and cost estimates around your business scenario. This can significantly reduce those “error for no obvious reason” situations.
Summary
Back to the original question: what exactly is a token in a large language model?
It is not an arcade coin, nor a “word” in a dictionary, but the smallest unit of text the model uses to read and generate text — a text building block cut out by a subword tokenization algorithm based on frequency statistics. It is more compact and more meaningful than a single character, yet more flexible and better at handling obscure expressions than a whole word. Chinese is usually one token per character, while English packages high-frequency combinations.
Once you understand the nature of tokens and the logic of tokenization, you can make sense of errors that once left you baffled, and make smarter trade-offs among context length, API cost, and generation quality. This concept, mentioned countless times yet rarely explained thoroughly, is in fact the most fundamental “common currency” between you and the model when you converse.
