Token Cost Engineering · 2 / 13

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.

BPEsubword tokenizationtiktokenToken tax
From characters to subwords: balancing two extremes

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.

Evolution of tokenization from character-level and word-level to subword-level
A Token isn't simply a character or a word—it's a “subword” built from statistical patterns. By balancing vocabulary size and semantic expression, BPE became the foundation of modern LLM training and inference. (Figure: from the author's original share deck)
BPE: a vocabulary merged by frequency

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:

1

Initialize: split the whole corpus into smallest units (for Unicode text, UTF-8 encode first and work in bytes).

2

Count frequencies: tally how often every adjacent byte pair appears in the corpus.

3

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.

4

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.

BPE training and inference process
Left: during BPE training, iteratively merge the highest-frequency byte pairs to build the vocabulary. Right: at inference, pre-tokenize by regex, then greedily merge by merge priority. (Figure: from the author's original share deck)
The hidden “Token tax”: Chinese is inherently ~2× more expensive

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.”

LanguageExampleToken countRatioWhat's going on
EnglishDonald John Trump3~0.75 Token/wordCommon words map directly to 1 Token
Chinese唐纳德·约翰·特朗普6~1.5 – 2.5 Token/charCommon characters are 1 Token; rare ones split into 2–3 byte Tokens
Korean도널드 존 트럼프7~1.5 – 3.0 Token/charEncoding 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.

Token-count differences across languages
BPE favors English: for the same meaning, Chinese is sliced finer, and the context window effectively gets shorter. (Figure: from the author's original share deck)
Interactive Demo · Same sentence, Chinese vs English bill

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.

Click any sentence above to start.

Another Chinese pitfall: “running naked” without spaces

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.

English space pre-tokenization guardrail vs Chinese reliance on co-occurrence
English uses space pre-tokenization—boundaries feel intuitive; Chinese uses co-occurrence frequency—high-frequency text gets forcibly merged into a single Token. (Figure: from the author's original share deck)
Key Takeaways

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.