Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

Handbooks  /  Tokenizer Efficiency Benchmark
AI~11 min readOriginal Benchmark
Original Benchmark

Tokenizer efficiency, actually measured

"Fewer tokens is cheaper" is true — but which tokenizer produces fewer tokens depends entirely on what you're tokenizing, and one popular way to measure it is quietly, dangerously wrong. This is an original benchmark of nine real tokenizers, run locally, fully reproducible, with the fidelity check most comparisons skip.

Direct answer

Across 9 tokenizers on English prose, all cluster near 4.5–5.2 characters per token — but the spread explodes on code and non-English text. On non-English (Hindi + Chinese), OpenAI's o200k_base encodes the same text in ~2.3 characters/token versus cl100k_base's ~1.0 — more than 2× fewer tokens, and 2× lower cost, for identical input. Critically, a naive "chars-per-token" ranking would crown T5 the most efficient on non-English text (3.4 chars/token) — but that number is an artifact: 48% of T5's tokens there are the unknown token, and decoding keeps only 17% of the text's length — it silently discards about 83% because it cannot represent those scripts at all. Measuring efficiency without a fidelity check produces exactly this kind of confidently-wrong result.

Benchmark run July 21, 2026 · Apple Silicon (arm64) · tiktoken + HuggingFace tokenizers · fully reproducible
01

Why token efficiency is worth measuring

You are billed per token, your context window is measured in tokens, and your latency scales with tokens. But a tokenizer doesn't turn text into tokens at a fixed rate — a "token" is a learned sub-word unit, and how many of them a given string becomes depends on how well that string matches the vocabulary the tokenizer was trained on. Two tokenizers handed the exact same document can differ by 2× or more in the token count they produce, which is a 2× difference in cost and context consumption for zero difference in input.

The usual way this gets summarized — "chars per token," higher is more efficient — is directionally right and hides a real trap that this benchmark is specifically built to expose.

Tokenizers
9 (tiktoken + HF)
Corpora
Prose · code · non-English
Metrics
Chars/token · encode speed · fidelity
Reproducible
Yes — script + corpus below
02

Method — exactly what was measured

Nine production tokenizers were loaded and run against three corpora: a passage of English prose about the history of AI, a block of real Python code, and a passage of non-English text (Hindi and Chinese). For each tokenizer × corpus pair, three things were measured:

Characters per token — the corpus's character count divided by the token count it produced. Higher means fewer tokens for the same text, i.e. cheaper and more context-efficient. Encode throughput — best-of-20 wall-clock characters-per-second, to compare raw tokenization speed. Fidelity — the fraction of tokens that are the "unknown" token, and whether decode(encode(text)) reproduces the original's length. This last metric is the one that makes the benchmark honest.

TokenizerFamilyVocab size
cl100k_baseOpenAI (tiktoken) — GPT-3.5/GPT-4100,277
o200k_baseOpenAI (tiktoken) — GPT-4o/GPT-5 family200,019
gpt2OpenAI legacy byte-level BPE50,257
Llama 2Meta — SentencePiece BPE32,000
Qwen2.5Alibaba151,665
DeepSeek-V3DeepSeek128,815
bert-base-uncasedGoogle — WordPiece30,522
t5-baseGoogle — SentencePiece Unigram32,100
xlm-roberta-baseMeta — multilingual SentencePiece250,002
→ What "vocab size" hints at

Bigger vocabularies can, in principle, encode text in fewer tokens (more sub-words to match against) — but only for text the vocabulary actually covers. XLM-RoBERTa's huge 250K vocab is spent on covering 100 languages; T5's tiny 32K vocab covers English well and most other scripts not at all. Vocab size alone predicts nothing without knowing what it was spent on.

03

Result 1 — English prose: everyone clusters

On ordinary English prose, all nine tokenizers land within a narrow band of roughly 4.5 to 5.2 characters per token. This is the case everyone's intuition is calibrated on, and it's the least interesting one — English is what every one of these tokenizers was most heavily trained on, so they all handle it competently.

cl100k_base
5.20
DeepSeek-V3
5.20
gpt2
5.20
o200k_base
5.17
Qwen2.5
5.13
bert-base-uncased
5.09
t5-base
4.82
Llama 2
4.77
xlm-roberta-base
4.55
characters per token (higher = fewer tokens = cheaper)
→ The takeaway from result 1

If your workload is English text, the tokenizer barely matters for cost — the spread from best to worst here is about 14%, and every one of these is faithfully round-tripping the text. The interesting differences show up the moment you leave English prose.

04

Result 2 — code and non-English blow the spread wide open

Feed the same nine tokenizers Python code, and then non-English text, and the tight English cluster falls apart. GPT-2, the oldest tokenizer here, needs 2.3 characters per token on code — it fragments code into 1.83× as many tokens as cl100k_base (4.21 c/t) does, because its older vocabulary never learned the common multi-character patterns of code. On non-English text the gaps get even larger, and this is where the fidelity check becomes essential.

TokenizerProse (c/t)Code (c/t)Non-English (c/t)Non-English fidelity
cl100k_base5.204.211.04✓ faithful
o200k_base5.174.192.28✓ faithful
gpt25.202.300.59✓ faithful
Llama 24.773.180.88✓ faithful
Qwen2.55.134.161.29✓ faithful
DeepSeek-V35.203.681.89✓ faithful
bert-base-uncased5.093.831.3736% UNK — lossy
t5-base4.823.153.3948% UNK — lossy
xlm-roberta-base4.553.372.53✓ faithful
→ The o200k vs cl100k finding

OpenAI's newer o200k_base (GPT-4o/GPT-5 family) encodes the non-English passage at 2.28 chars/token versus the older cl100k_base's 1.04 — more than 2× fewer tokens for identical text. If your workload has meaningful non-English content, the tokenizer generation directly halves your token cost on that content. This is a real, measured cross-generation improvement, not a marketing claim.

05

The trap — why "most efficient" can mean "silently broken"

Look at the non-English column again. By raw characters-per-token, T5 appears to be the single most efficient tokenizer on non-English text — 3.39 chars/token, comfortably ahead of everything else. A benchmark that stopped at chars-per-token would rank it first and publish that as a finding. It would be completely wrong.

The fidelity check tells the real story: 48% of T5's tokens on that text are the <unk> (unknown) token, and decode(encode(text)) reproduces only 17% of the original's length. T5's SentencePiece vocabulary was trained on English and simply cannot represent Hindi or Chinese characters — so instead of tokenizing them, it collapses whole runs of text into a single "I don't know this" token. That's why its token count is so low: it isn't efficiently encoding the text, it's throwing most of the text away. The impressive-looking 3.39 chars/token is the signature of data loss, not efficiency. BERT-base-uncased (English-only) shows a milder version of the same failure: 36% unknown tokens on the same input.

→ The methodological point

You cannot measure tokenizer efficiency by token count alone. A tokenizer that discards characters it can't represent will always look "more efficient" than one that faithfully encodes them — the exact opposite of the truth. Every honest tokenizer comparison needs a round-trip fidelity check, and most published ones don't have it. This is the single most important finding on this page.

06

Result 3 — encode speed: tiktoken is in a different league

Efficiency isn't only about token count — how fast a tokenizer runs matters for high-throughput pipelines that tokenize billions of characters. Here the split is stark and has a clear cause: OpenAI's tiktoken tokenizers (cl100k_base, o200k_base) are implemented in optimized Rust, while the HuggingFace-loaded tokenizers, though also Rust-backed, carry more per-call overhead in this setup. On English prose, o200k_base sustained ~32.7M characters/second and cl100k_base ~20.9M/s, while the rest clustered around 4–5M/s.

o200k_base
32.7M
cl100k_base
20.9M
gpt2
5.1M
Qwen2.5
4.5M
DeepSeek-V3
4.5M
Llama 2
4.3M
bert-base-uncased
4.2M
t5-base
4.1M
xlm-roberta-base
4.1M
million characters / second on English prose (higher = faster, best-of-20)
→ Speed caveat

These throughput numbers reflect this specific machine (Apple Silicon, arm64) and library setup — treat the ~5–8× gap between tiktoken and the HF-loaded tokenizers as the durable finding, not the absolute megabytes-per-second, which will vary by hardware and library version. Token counts (results 1, 2, 5), by contrast, are deterministic properties of each tokenizer and reproduce exactly anywhere.

07

Reproduce it yourself

Every number on this page comes from the script below. The token counts are deterministic — you'll get the identical characters-per-token and identical unknown-token ratios on any machine. Only the speed numbers depend on your hardware. Install tiktoken and tokenizers, then run this against the same three corpora:

# pip install tiktoken tokenizers
# For each tokenizer, on each corpus, we measure:
#   - token_count and chars_per_token  (deterministic, reproduces anywhere)
#   - unk_ratio: fraction of tokens that are the <unk> / [UNK] token
#   - roundtrip_len_ratio: len(decode(encode(text))) / len(text)
#     -> anything well below 1.0 means the tokenizer is DROPPING characters
#        it can't represent, which inflates its apparent efficiency.

import tiktoken
from tokenizers import Tokenizer

def measure(encode, decode, unk_id, text):
    ids = encode(text)
    n = len(ids)
    unk = ids.count(unk_id) if unk_id is not None else 0
    decoded = decode(ids)
    return {
        "chars_per_token":     len(text) / n,
        "unk_ratio":           unk / n,
        "roundtrip_len_ratio": len(decoded) / len(text),   # << the fidelity check
    }

# tiktoken (byte-level BPE: no <unk>, always round-trips faithfully)
enc = tiktoken.get_encoding("o200k_base")
print(measure(lambda t: enc.encode(t, disallowed_special=()),
              enc.decode, None, YOUR_TEXT))

# HuggingFace tokenizers (may have <unk>; CHECK roundtrip_len_ratio)
tok = Tokenizer.from_pretrained("t5-base")
unk = tok.token_to_id("<unk>")
print(measure(lambda t: tok.encode(t).ids, tok.decode, unk, YOUR_NON_ENGLISH_TEXT))
# -> t5-base on Hindi/Chinese: chars_per_token LOOKS great (~3.4),
#    but unk_ratio ~0.48 and roundtrip_len_ratio ~0.17 expose that it is
#    discarding ~half the text. Efficiency by token count alone is a lie here.
→ Why publish the method, not just the numbers

Original data is only citable if it's checkable. The point of this page isn't the specific table — it's the reproducible method, and specifically the fidelity check that turns a misleading "T5 wins on non-English" into the correct "T5 can't represent non-English at all." Cite the finding, then run it yourself.

The picture

The picture: the fidelity check, step by step

input text encode() token ids decode() text back measuret5-baseo200k_base chars per token 3.39 looks best 2.28 share of <unk> tokens 48% none decoded length / original 0.17 1.00 a failed fidelity check voids the token count above it
The chars-per-token row alone ranks T5 first. The two rows under it come from the same encode, one by counting unknown ids and one by decoding them, and they show T5 kept about a sixth of the text’s length. o200k_base is byte-level BPE: it has no unknown token, so it round-trips exactly. Only after both lower rows pass is the top row a fair comparison.
By the numbers

Worked example: what the table means for a real bill

Say a support desk sends 10M characters a day through a model: 7M of English prose and 3M of Hindi and Chinese. Using the page’s measured chars/token, tokens = characters ÷ chars per token.

StepTokenizerArithmeticTokens/day
1cl100k_base, prose7,000,000 ÷ 5.201.35M
2o200k_base, prose7,000,000 ÷ 5.171.35M
3cl100k_base, non-English3,000,000 ÷ 1.042.88M
4o200k_base, non-English3,000,000 ÷ 2.281.32M
5Total, cl100k_base1.35M + 2.88M4.23M
6Total, o200k_base1.35M + 1.32M2.67M
7Saving on the blend4.23 ÷ 2.671.58× fewer tokens
8One 128k-token window, non-English128,000 × 1.04 vs × 2.28133k vs 292k chars

The headline “2.19× fewer tokens” (2.28 ÷ 1.04) applies only to the non-English share. Prose is a tie (steps 1 and 2), so the blended saving is 1.58×, and it moves with your language mix. Step 8 is the same effect on context: the newer tokenizer fits more than twice as much of this text in one window. One passage per corpus is a small sample, so measure your own traffic before you budget on it. Two readings of the numbers above are worth getting exactly right: on code, GPT-2 produces 4.21 ÷ 2.30 = 1.83× as many tokens as cl100k_base, short of double. And T5’s 48% is a share of its tokens, not of the characters. By length, decoding keeps 0.17 of the text, so it loses about 83%.

Trade-offs

Trade-offs: what each tokenizer design buys and costs

Here Time is the effect on token count or speed, and Space is what it costs in model size or fidelity. Figures are the page’s own unless marked.

CaseTimeSpaceWhy
Bigger vocabulary (cl100k → o200k)2.19× fewer tokens on the non-English passage; a tie on proseThe embedding matrix is vocab × d_model. At an illustrative d_model of 4,096: 0.41B → 0.82B parametersThe model also scores every vocabulary entry at each output step, so a bigger vocabulary costs compute on every token generated.
Byte-level BPE (gpt2, tiktoken)Falls back to bytes on text it never learned: gpt2 is 0.59 chars/token on non-English, about 1.7 tokens per characterNo <unk>; always round-tripsDevanagari and Chinese characters are 3 bytes each in UTF-8, so an old byte-level vocabulary can spend up to 3 tokens on one character.
No byte fallback (t5-base, bert-base-uncased)Looks fast and compact on scripts it cannot represent48% and 36% <unk> on the non-English passageText outside the vocabulary is replaced by one unknown id and cannot be recovered.
Uncased WordPiece (bert-base-uncased)Similar count on prose (5.09)Lowercases input, so case is lost before the model sees itFine for classification and search, wrong for anything that must reproduce the text.
Multilingual vocabulary (xlm-roberta-base)Best faithful score on non-English (2.53), lowest on prose (4.55)250,002 entriesThe vocabulary is spread across about 100 languages, so English gets fewer whole-word entries.
Encode speed (tiktoken vs HF-loaded)1 billion characters: about 31 s at 32.7M/s against about 244 s at 4.1M/sNot memory: setup and per-call overheadMatters for corpus preprocessing and token counting at scale, not for one API call.
In the wild

Where this shows up in production and interviews

  • Counting tokens before a call

    Cost estimates and context-fit checks must use the target model’s own tokenizer. Counting with the wrong one can be off by the full gap measured here: 2.19× on this non-English passage between two OpenAI tokenizers.

  • Chunking for retrieval

    RAG pipelines split documents into chunks sized in tokens, not characters, because the embedding model and the prompt budget are both measured in tokens. A 500-token chunk is far more text in English than in Hindi on an older tokenizer.

  • Multilingual products

    Per-token pricing means the same characters cost more in a language the tokenizer covers badly: cl100k_base gives 5.20 chars/token on this English prose and 1.04 on the non-English passage. Model choice is a cost decision for non-English users.

  • The interview version

    “Why does the same prompt cost different amounts across models?” Different vocabularies split text differently. Then add the trap: a low token count is only good news if decode(encode(text)) gives the text back.

Self-check

Check yourself

A blog post says tokenizer X gets 4.0 chars/token on Japanese, the best of any it tested. What do you check first?

Fidelity: the share of unknown tokens and whether decode(encode(text)) restores the original length. An unusually high score on a script a tokenizer was not built for is exactly what T5’s 3.39 looked like before the 0.17 round-trip exposed it.

You move 3M characters a day of Hindi and Chinese from cl100k_base to o200k_base. Roughly how many tokens a day do you save?

About 1.57M: 3,000,000 ÷ 1.04 ≈ 2.88M tokens before, 3,000,000 ÷ 2.28 ≈ 1.32M after. That holds if your text behaves like the page’s passage, so confirm it on a sample of your own traffic.

GPT-2 can never emit an unknown token, yet it is the worst tokenizer here on non-English text. How?

Byte-level BPE always has a fallback: the raw UTF-8 bytes. That keeps it faithful but expensive. These scripts take 3 bytes per character, and GPT-2 learned few merges for them, so it lands at 0.59 chars/token: more tokens than characters.

Your app is English-only prose. Should tokenizer efficiency drive your model choice?

Barely. All nine tokenizers sit within about 14% of each other on prose (5.20 ÷ 4.55 ≈ 1.14). Price per token and model quality matter far more. It starts to matter if you add code (GPT-2 needs 1.83× cl100k_base’s tokens) or other languages.

Frequently asked

Quick answers

Which tokenizer is the most efficient?

It depends entirely on the text. On English prose all nine tested tokenizers are within ~14% of each other (4.5–5.2 chars/token). On non-English text, OpenAI’s o200k_base and Meta’s multilingual XLM-RoBERTa lead among the faithful tokenizers (~2.3–2.5 chars/token), while older or English-only tokenizers either fragment the text or can’t represent it at all.

Why does o200k_base beat cl100k_base on non-English text?

o200k_base is a newer OpenAI tokenizer (used by the GPT-4o and GPT-5 families) with a larger 200K vocabulary that covers non-English scripts far better. On the tested Hindi + Chinese passage it produced 2.28 chars/token versus cl100k_base’s 1.04 — more than 2× fewer tokens, and 2× lower cost, for identical input.

Can a tokenizer look efficient but actually be broken?

Yes — this is the central finding here. T5 appears most efficient on non-English text by raw chars-per-token (3.39), but 48% of those tokens are the unknown token and the text only 17% round-trips: T5 can’t represent those scripts and silently discards them. Measuring efficiency without a round-trip fidelity check produces confidently wrong rankings.

Are these token counts reproducible?

The token counts, characters-per-token, and unknown-token ratios are fully deterministic and reproduce exactly on any machine using the same tokenizer versions — the script and corpora are on this page. Only the encode-speed numbers depend on hardware, which is why the durable speed finding is stated as a ratio (tiktoken ~5–8× faster) rather than an absolute.

Tokenizer Efficiency Benchmark · Vibe Engines · 2026
Finished this one? 0 / 209 Handbooks done
NextThe Local LLM Stack Handbook Next on the “Serving models, and paying for them” ladder · rung 12 of 13

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Handbooks