What Are Tokens in Large Language Models?
A clear technical explanation of what tokens are in large language models, how tokenization turns text into discrete units, and why token counts drive cost, latency, and output quality. The article also covers common misconceptions, context window limits, and practical tips for estimating and controlling token usage.
Many people first encounter large language models and picture tokens as arcade coins: insert one, and the machine will spin once. That analogy only gets half of it right — the “discrete and countable” half. The other half is completely off. In practice, what you usually see is a cold error message: exceeded maximum token limit. So what exactly is a token?
First, Three Common Misconceptions
Misconception 1: One word equals one token. This is the most widespread assumption. In English, common words are often compressed into a single token, but longer or unusually spelled words get split. A word like tokenization is typically cut into token and ization, sometimes into even smaller pieces. The reason is simple: the model’s vocabulary has a fixed capacity and cannot contain every word and word form.
Misconception 2: A token is a character. One token can map to several characters. A Chinese character roughly corresponds to one token under most tokenization schemes, but punctuation, spaces, line breaks, and digit strings may each become a token on their own. As a result, “character count” and “token count” are two different measures.
Misconception 3: Developers define tokens manually. It is the opposite. Token splitting rules are learned statistically from large-scale corpora. Developers only decide the vocabulary size and the training strategy; the algorithm decides how the text is actually split.
A Precise Definition of a Token
In a large language model, a token is the smallest discrete unit produced when text is split before being fed into the model. The model never reads raw strings. It first maps text to a sequence of integer IDs, then looks those IDs up to obtain vector representations. You can think of it as a pipeline:
Raw text→ Tokenization (split into a token sequence)→ Encoding (map tokens to integer IDs)→ Embedding (look up IDs to get vectors)→ Model computation (self-attention processes layer by layer)→ Output (predict the next unit token by token)
Two points matter here. First, autoregressive generation proceeds token by token, deciding only the next unit at each step, so output length is naturally measured in tokens. Second, the context window limits the total of “input tokens + output tokens,” not just the length of your question. Many people get stuck on errors because they count only the prompt and forget the conversation history and the model’s replies.
The Core Logic of Tokenization: Package Frequent Combinations
The mainstream approach is statistics-driven subword splitting: repeatedly find the adjacent fragments that “should be merged” in the corpus, and fix frequently co-occurring character combinations into a single token. The benefits are direct:
- Common words need only one token, so sequences are shorter and inference is cheaper;
- Rare words, new words, and spelling variants can be broken into smaller parts, avoiding unlimited vocabulary growth;
- Unknown words do not fail outright; they degrade into a combination of known parts.
Chinese is comparatively “easy” here, because a Chinese character is already a compact semantic unit and, in most cases, one character maps to one token. However, consecutive digits, English abbreviations, emoji, and full-width punctuation may still be handled specially. This also explains a familiar pattern: for content of the same length, pure Chinese, mixed Chinese-English text, and text full of code and symbols can consume noticeably different token counts.
Why This Matters for Engineering
Cost is billed by token. Whether you call a cloud model service or run your own inference, the basic unit of usage accounting is the token. Verbose prompts, replaying the full conversation history, and leaving the response length uncapped all push costs up linearly.
Performance and latency depend on token length. The longer the input, the heavier the attention computation and memory footprint, and both time-to-first-token and overall throughput come under pressure. Stuffing a long document into the context all at once is often worse than retrieving first and then assembling.
Quality is constrained by the token budget too. Once the context is filled with irrelevant content, the instructions and material that actually matter get diluted, and the model follows them less reliably. Controlling tokens is essentially controlling the signal-to-noise ratio.
Four Practical Recommendations
- Estimate first, then design. Rules of thumb: roughly 4 characters ≈ 1 token in English, and roughly 1 character ≈ 1 token in Chinese; code and JSON run higher because they are symbol-dense. A rough “character count × factor” calculation can surface overflow risk early.
- Cap the output. Set an explicit limit on response length so the model does not spend the budget on long-winded prose; structured output such as JSON is usually cheaper than free-form text.
- Manage context in layers. Keep system instructions short and stable, store long-term material in external storage and retrieve it on demand, retain only the necessary turns of short-term dialogue, and trim or summarize expired content promptly.
- Make usage an observable metric. Use monitoring, alerting, and logging services to record input/output tokens, latency, and failure reasons for every call, then build a dashboard and optimize from data instead of tweaking prompts by feel.
A General Approach in the Cloud
To use large model capabilities reliably in production, you typically need a few general categories of cloud products working together: object storage to archive long documents and past sessions, a message queue to smooth traffic spikes and control concurrency, a container platform to host inference and business services, and logging plus monitoring and alerting for usage and quality observation. Platforms such as Baidu AI Cloud offer these same general capability categories; refer to the official documentation for exact specifications and pricing, and never design capacity based on guesswork.
Conclusion
A token is not an arcade coin, nor a “character” or a “word.” It is the discrete unit of computation as the model sees it. Once you understand its splitting logic, its counting rules, and its threefold impact on cost, latency, and quality, you move from “using it vaguely” to “designing with precision.” The next time you see an exceeded maximum token limit message, you will at least know which part to trim.
