How Tokens Are Counted: BPE and the Hidden “Token Tax”
Bills settle in Tokens—but how are Tokens counted? They're neither characters nor words, but “subwords” built from statistical patterns. Once you get the rules, you'll see why the same sentence in Chinese is inherently ~2× more expensive than in English.
Early NLP swung between two poles. Word-level tokenization is semantically clear, but English's hundreds of thousands of words plus morphology (look / looks / looking / looked) explode the vocabulary—and still can't handle unseen words (the OOV problem). Character-level tokenization can split anything, but sequences get too long, each character carries little information, and inference is painfully inefficient.
Modern LLMs took the middle road—subword tokenization: keep common words as whole Tokens, split rare ones into meaningful pieces. Vocabularies stay between 32k and 200k—no explosion, yet everything is representable.
GPT-series models and Llama 3 all use BPE (Byte-Pair Encoding). The vocabulary isn't hand-crafted—it's “merged” out of the corpus:
Initialize: split the whole corpus into smallest units (for Unicode text, UTF-8 encode first and work in bytes).
Count frequencies: tally how often every adjacent byte pair appears in the corpus.
Merge the most frequent pair: e.g. if "u" and "g" often sit next to each other, merge them into a new symbol "ug" and add it to the vocabulary.
Iterate: repeat steps 2 and 3 until the vocabulary hits the target size—32,000 for Llama 2, 100,277 for GPT-4's cl100k_base.
At inference, look it up in reverse: a common word like "hug" is one Token; a rarer "bug" splits into ["b", "ug"]. The larger the vocabulary and the more “common” your text, the fewer Tokens—and the thinner the bill. That's why after GPT-4 moved to a 100k vocabulary, it specifically merged multi-level indent space sequences into single Tokens—code-generation efficiency jumped several times over.
Mainstream model tokenizers train mostly on English, so BPE merge rules lean hard toward English vocabulary. Result: non-Latin scripts (Chinese, Japanese, Korean) face a severe efficiency disadvantage at tokenization—the industry calls it the “Token tax.”
| Language | Example | Token count | Ratio | What's going on |
|---|---|---|---|---|
| English | Donald John Trump | 3 | ~0.75 Token/word | Common words map directly to 1 Token |
| Chinese | 唐纳德·约翰·特朗普 | 6 | ~1.5 – 2.5 Token/char | Common characters are 1 Token; rare ones split into 2–3 byte Tokens |
| Korean | 도널드 존 트럼프 | 7 | ~1.5 – 3.0 Token/char | Encoding space is under-covered; often falls back to byte encoding |
For the same meaning, Chinese users burn more than 2× the Tokens of English users: they pay more API money and effectively shrink the context window.
Pick a sentence and compare how many Tokens the Chinese and English versions need (estimated at typical ratios). For exact splits, try OpenAI Tokenizer yourself.
English has a natural guardrail: before BPE merges, text is pre-tokenized on spaces, so merges stay inside words and Token boundaries mostly match linguistic intuition. Chinese has no spaces, so BPE must rely entirely on statistical co-occurrence for boundaries—if a span (even a nonsense ad slogan) appears millions of times in the corpus, BPE will merge the whole thing into one “indivisible minimal semantic unit.”
The most famous example is “给主人留下些什么吧” (“leave something for the host”): a high-frequency blog-era guestbook line that was forcibly merged into a standalone Token in GPT's vocabulary—the famous “glitch Token.” Not a joke; an inevitable product of BPE's statistics.
Tokens are statistical subwords, not characters or words. BPE iteratively merges by corpus frequency; vocabulary size is a hyperparameter.
Chinese inherently pays a Token tax: same meaning costs 2×+ vs English, and effectively shortens the context window. Don't budget from English intuition.
Vocabulary size sets compression. cl100k_base's 100k vocab + space-merge optimizations are a direct reason GPT-4 is efficient on code. When picking models, tokenizer efficiency is a cost parameter too.
Source: Adapted from Part 1 “What Makes Up a Token” of the author's internal team share “AI Token Cost Engineering Strategies.” For BPE details see OpenAI Tokenizer and the open-source tiktoken library. To review the underlying principles of tokenization and vocabulary, revisit LLM Fundamentals · Vocabulary & Training.