1.033.3 CJK Tokenizers for LLMs#

Tokenization strategies for Chinese, Japanese, and Korean in large language models - SentencePiece, tiktoken, HuggingFace

Last verified 2026-11-05: measured.

Evidence: measured, method not yet published. The numbers here were produced by probes run on a stated machine; the harness is not in the public repository yet, so a reader cannot re-run them.

At a glance#

Findings checked against this survey’s current text on 2026-11-05.

LibraryHow it worksBest for
Hugging Face TokenizersRust core reading tokenizer.json; BPE, Unigram, WordPiece and WordLevelCounting and encoding for open-weight models that publish tokenizer.json
SentencePieceC++ Unigram and BPE trainer and encoder with a Python bindingTraining a vocabulary, and reading .model files
tiktokenRust BPE encoder with a Python wrapper; no trainingCounting for OpenAI models
mistral-commonVendor request and tokenizer layer reading Tekken filesMistral models
transformersPython wrapper that selects a tokenizer backendPython code already using AutoTokenizer

What the research found

  • The vocabulary file sets the token cost, not the engine — Chinese ran from 701 to 1,443 tokens per 1,000 codepoints across files exact on at least 99.99% of lines, and two encodings in tiktoken differ by 32% (measured 2026-11-04; 29.9M codepoints of zhwiki; harness/1-033-3-cjk-tokenizers/results/summary.json).
  • No file leads across Chinese, Japanese and Korean — Among files exact on at least 99.99% of lines, MiniMax M2.5 leads on Chinese at 701, LLM-jp-3 on Japanese at 556 and A.X 4.0 on Korean at 471. Stockmark-2 is lower on Japanese at 520 with NFKC rewriting 51.5% of lines, and costs 1,844 on Korean (measured 2026-11-04; same file).
  • Normalizers decide what comes back — Published files with no normalizer returned all 1,964,779 lines exactly, while trained SentencePiece models with an identity normalizer and byte fallback lost whitespace on 1.3% of Chinese and 7.7% of English lines; NFKC and BERT-style files changed about 85% or more of Chinese lines (measured 2026-11-04; same file).
  • Rare characters survive byte fallback and are lost elsewhere — 38 of 41 files emitted no unknown token on any CJK block tested; XLM-RoBERTa in both formats and BERT Chinese did, on nearly all of Extension B (measured 2026-11-04; 42,720 characters; results/probes/).
  • A token can split a character, and how often depends on the file — cl100k_base has 53.8% partial tokens on Chinese, Qwen 3.8 has 1.9% and rises to 12.9% on Cantonese (measured 2026-11-04; results/summary.json). Streaming clients need byte buffering.

Explainer

What Are CJK Tokenizers?#

A language model does not read characters. It reads a list of integers, and a tokenizer turns text into that list and back. For Chinese, Japanese and Korean (CJK) text, that step decides how many integers a sentence costs, whether the sentence comes back unchanged, and whether a rare character in somebody’s name survives at all.

This matters to you in three ways:

  • Money. Hosted models charge per token.
  • Room. A context window is a limit in tokens, so a costly tokenizer fits less of your document.
  • Correctness. Some tokenizers alter text, and some cut characters in half at token boundaries.

An analogy: the phrasebook#

Think of a tokenizer as a phrasebook of fixed size, say 200,000 entries, and a rule that you may only communicate by citing entry numbers.

A phrasebook written mostly for English has an entry for " international" but few for Chinese, so a Chinese sentence gets spelled out in small pieces, many of them less than a whole character. A phrasebook with lots of Chinese has entries for 你好 and 世界. Both can express anything, because each ends with an alphabet of raw bytes. They differ in how many citations a sentence takes.

The book is the vocabulary file. The person looking things up is the engine. A faster person does not change how many citations a sentence takes.

Why CJK is a harder case#

No spaces. English offers word boundaries for free, while a Chinese or Japanese sentence does not. A tokenizer that splits on spaces first sees a whole sentence as one word.

A big inventory. English needs a few dozen letters. Chinese needs thousands of characters for ordinary text and tens of thousands more for names and old sources. Unicode assigns over 90,000 of them. Korean is built from thousands of syllable blocks.

Three or four bytes each. In UTF-8, a typical CJK character is three bytes, and rarer ones four. A byte-based tokenizer that never learned a character pays one token per byte.

The main kinds#

Byte-level BPE (byte pair encoding) starts from bytes and learns merges for pairs that occur together, repeated many times over. Any text can be expressed, and nothing is ever “unknown.” The price is that a token can stop in the middle of a character. Most recent models use it: OpenAI’s, Qwen, DeepSeek, GLM (General Language Model), MiniMax, Llama.

Unigram, usually through the SentencePiece library, stores pieces with probabilities and finds the likeliest way to cut a sentence. It handles text with no spaces by design. Pieces are whole characters or strings. What happens to a character outside the vocabulary depends on how it was trained: it either becomes an unknown token and is lost, or falls back to bytes.

Character BPE with byte fallback merges characters and drops to bytes for anything unknown. Gemma and Mistral 7B work this way.

WordPiece, from BERT (Bidirectional Encoder Representations from Transformers, a classifier model), gives each Han character its own token from a short list. It is simple and stays common for classification and embeddings, but it does not give text back unchanged.

Hosted counters have no file you can get. You ask the vendor’s API how many tokens a request will cost.

What measuring them shows#

Results below come from 41 tokenizer files on Wikipedia text. Full tables are in 01-discovery/S2-comprehensive/.

The file decides the cost. On Chinese, files ran from about 0.70 tokens per character to about 1.44, a factor of two on the same text. OpenAI’s own older and newer encodings run 1.31 and 0.89, in the same engine (measured 2026-11-04; tiktoken 0.14.0, tokenizers 0.23.3; 29.9M codepoints of zhwiki; harness/1-033-3-cjk-tokenizers/results/summary.json).

No file wins every language. Stockmark-2 has the lowest Japanese count, 520 per 1,000 codepoints, and its normalizer rewrites 51.5% of Japanese lines. LLM-jp-3 is lowest among files that keep the text (exact on at least 99.99% of lines), at 556. Stockmark-2 costs 1,844 on Korean, where A.X 4.0 costs 471 (same run).

Rare characters are safe in most files and lost in a few. Byte-based files kept every one of more than 42,000 characters in Unicode’s Extension B block, at about four tokens each. XLM-RoBERTa and BERT Chinese replaced nearly all of them with an unknown token (measured 2026-11-04; each codepoint encoded alone; harness/1-033-3-cjk-tokenizers/results/probes/).

Some files rewrite ordinary text. Files with an NFKC (Normalization Form Compatibility Composition) normalizer, a Unicode folding rule, turned a fullwidth Chinese comma into an ASCII one. About 85% of Chinese lines changed (measured 2026-11-04; same run, results/summary.json). Published files with no normalizer returned every line exactly. Trained models with no normalizer can still drop whitespace: the SentencePiece models with byte fallback here did so on 1.3% of Chinese lines and 7.7% of English lines (measured 2026-11-05; results/trained_tok/).

Half a character is common in some files. With OpenAI’s older encoding, more than half of the tokens on Chinese text end inside a character. Print them one at a time and the user sees replacement marks. In newer files with better CJK coverage it falls to about 2%, and rises again on Cantonese (same file).

Things that look like choices and are not#

A trained model’s tokenizer is fixed. The weights learned those integers. You cannot swap in a cheaper file. The decision is which model, with token cost as one input.

“CJK-optimized” describes a file. The Hugging Face engine reads Qwen’s file and Llama’s file equally well.

Word segmenters are a separate category. Jieba and MeCab find words for search and analysis. A language model’s tokenizer has no duty to respect word boundaries, and its tokens often do not. See 1.033.2 and 1.148.

Where the choices do live#

  • Which model, with token cost as one input.
  • Training your own vocabulary, where trainer, size and normalization are all yours.
  • Which encoder runs a given file, when more than one can.
  • What you do around the tokenizer: normalize input, buffer bytes when streaming, keep the original string, and count with the right file.

Words you will meet#

  • Token: one entry in the vocabulary, one integer.
  • Vocabulary: the file of entries, 21,128 to 262,144 in this sample.
  • Round trip: encode then decode; is the text identical?
  • Normalizer: a step that rewrites text before encoding. NFC (Normalization Form Composition) composes characters, while NFKC also folds compatibility forms.
  • Byte fallback: expressing an unknown character as its bytes instead of an unknown token.
  • Partial token: a token that stops inside a character.
  • Special token: a control entry such as end-of-text. Some engines turn a matching string in user text into one, which matters for untrusted input.

Where to go next#

  • For the field at a glance, see 01-discovery/S1-rapid/recommendation.md.
  • For the numbers, see 01-discovery/S2-comprehensive/.
  • For your situation, see 01-discovery/S3-need-driven/.
  • For what can change over time, see 01-discovery/S4-strategic/recommendation.md.
S1: Rapid Discovery

S1 Approach: The Field in Three Layers#

A CJK tokenizer choice is three separate things that the phrase “which tokenizer” runs together:

  1. Kind: byte-level BPE, Unigram, character BPE with byte fallback, WordPiece, or a hosted counter (kinds-of-tokenizer.md).
  2. Engine: the code that reads a file: Hugging Face Tokenizers, tiktoken, SentencePiece and the wrappers around them (engines.md).
  3. Vocabulary: the file a model was trained with (vocabularies.md). This layer sets the token count.

The sample#

Forty-one tokenizer files, chosen to cover model origin and format rather than to rank models: global open-weight and OpenAI files, multilingual files, and files from Chinese-, Japanese- and Korean-origin models. The Hugging Face repos were pinned to a commit SHA on 2026-11-03 and listed in harness/1-033-3-cjk-tokenizers/results/pins.json. Hugging Face’s 30 most-downloaded text-generation repos, read 2026-11-05 UTC, are mostly Qwen, DeepSeek and OpenAI repos and derivatives of them, with older repos such as GPT-2 and OPT among them (https://huggingface.co/api/models?sort=downloads&limit=30&pipeline_tag=text-generation; harness/1-033-3-cjk-tokenizers/results/field_check.json). One family outside the sample appears there: Ornith 1.5. Its 9B repo’s model, normalizer, pre-tokenizer and decoder sections are identical to Qwen 3.8’s (same file), so its regular vocabulary is not new. Its added tokens and post-processor were not compared.

Boundaries#

Word segmentation for search and analysis is 1.033.2 and 1.148. Named-entity recognition is 1.033.4. Choosing a model on output quality is outside this survey: only tokenizer files were read, and no model was loaded.


Tokenizer Engines: What Runs a Vocabulary File#

An engine reads a vocabulary file and turns text into ids. Picking an engine rarely decides how much Chinese costs, because the file does that. The engine decides the file formats you can load, whether you can train, how special strings are handled, what happens with a broken string, and what runs on your platform.

Registry and repository facts below were read on 2026-11-04 (harness/1-033-3-cjk-tokenizers/results/library_facts.json; that file’s read_at is in UTC, where the date had already turned). Stars are a popularity reading only.

The three main engines#

Hugging Face Tokenizers (tokenizers on PyPI, huggingface/tokenizers, Apache-2.0, 0.23.3 released 2026-10-09). A Rust core with Python and Node bindings that reads tokenizer.json: a declarative pipeline of normalizer, pre-tokenizer, model (BPE, Unigram, WordPiece, WordLevel), post-processor and decoder. It trains as well as encodes. This format is where most open-weight models now publish their vocabulary, and transformers version 5 makes it the default backend, with SentencePiece and mistral-common as non-default alternatives (source: https://huggingface.co/blog/transformers-v5, accessed 2026-11-04). A rewrite is in release candidates: 1.0.0-rc.3 shipped 2026-10-19, with a stated goal of “same API, same token IDs” and a statement that feature parity with 0.23 is the milestone left before a stable 1.0 (source: https://github.com/huggingface/tokenizers/releases, accessed 2026-11-04).

tiktoken (tiktoken on PyPI, openai/tiktoken, MIT, 0.14.0 released 2026-08-17). A Rust BPE encoder with a Python wrapper. It does not train. OpenAI publishes cl100k_base and o200k_base for it, and nothing in the changelog from 0.9.0 to 0.14.0 adds an encoding; the entries add model names, wheels and performance work (source: https://github.com/openai/tiktoken/blob/main/CHANGELOG.md, accessed 2026-11-04). OpenAI is not its only user: Kimi K2 ships a tiktoken.model file, and mistral-common builds its Tekken tokenizer on the same encoder. There is no normalizer stage, so what goes in is what comes back.

SentencePiece (sentencepiece on PyPI, google/sentencepiece, Apache-2.0). A C++ trainer and encoder for Unigram and BPE models with a Python binding, built to segment text with no spaces. Its defaults are character_coverage 0.9995, byte_fallback false, normalization_rule_name nmt_nfkc and model_type unigram; the documentation advises 0.9995 for Chinese, Japanese and Korean and calls byte fallback highly recommended for modern LLMs (source: https://raw.githubusercontent.com/google/sentencepiece/master/doc/options.md, accessed 2026-11-04). Development picked up: 0.2.2 moved the binding from SWIG to pybind11, and 0.2.3, released on PyPI 2026-11-05 UTC, adds automatic character coverage, Sparse L1 Unigram pruning, a zero-dependency C++20 runtime that reads a new FlatBuffers model format, and removals of deprecated API (source: https://github.com/google/sentencepiece/releases, accessed 2026-11-04). The token counts here ran on 0.2.2; S2-comprehensive/engine-behavior.md compares the two releases. Several Chinese and Japanese models still publish its .model format: Yi, InternLM 3, Baichuan 2 and Sarashina among the repos checked on 2026-11-04.

Wrappers and vendor layers#

transformers (transformers on PyPI, 5.22.1) is what most Python code calls. AutoTokenizer chooses a backend and adds its own behavior on top, including chat templates and space cleanup on decode. Some repos ship a Python tokenizer file, as Kimi, InternLM and Baichuan do, and loading those through AutoTokenizer means trust_remote_code: running the repo’s code to get a token count. The harness read the vocabulary files directly and ran none of that code.

mistral-common (mistral-common on PyPI, mistralai/mistral-common, Apache-2.0, 1.13.1 released 2026-11-02) is Mistral’s request and tokenizer layer. Its Tekken files are a byte-level vocabulary in JSON. It manages special tokens by hand, separate from text.

google-genai (google-genai on PyPI, 2.34.0) carries an experimental LocalTokenizer, text only, that maps Gemini model names to open tokenizer files: a pinned Gemma 3 SentencePiece file for the 2.x and 3.0 preview names and google/gemma-4-E4B-it for the 3.1 and 3.5 names. Its docstring says forward compatibility “depends on the open-source tokenizer models for future Gemini versions” (source: https://github.com/googleapis/python-genai/blob/main/google/genai/_local_tokenizer_loader.py, accessed 2026-11-04).

Other engines worth knowing about#

These were read, not run.

EngineWhat it isState on 2026-11-04
bpe crate (github/rust-gems)Rust BPE aimed at counting: counts any interval of a text after one pass, appends a byte at a time. Its README says it does not degrade on malicious input (source: https://github.com/github/rust-gems/blob/main/crates/bpe/README.md, accessed 2026-11-04)Repo active, pushed 2026-11-04
bpe-openai on PyPIA third party’s Python binding around that cratePathlit-Inc/bpe-openai, 2 stars, 0.1.4 from 2025-10-17
TokenDagger (tokendagger)A tiktoken-compatible encoderLast pushed 2025-07-03, 0.1.1
rs-bpe (rs-bpe)Python binding of a Rust BPEOne release, 2025-03-19
gpt-tokenizer (npm)JavaScript port with OpenAI encodings4.1.0, 2026-10-18
js-tiktoken (npm)JavaScript port of tiktoken1.0.21, 2025-08-09
@huggingface/tokenizers (npm)JavaScript reader of tokenizer.json0.2.0, 2026-09-07
tokenizers-wasm (npm, next tag)WebAssembly build from the 1.0 rewriteNamed in the rc.3 notes; not probed
YouTokenToMe (youtokentome)Fast BPE trainer from VKRepository archived, last release 2020
BlingFire (blingfire)Microsoft finite-state tokenizerLast release 2021

Hosted counters with no file to obtain#

Anthropic’s Claude models count through an API endpoint. The documentation calls the count an estimate, and it says Claude 4.7 and later models use a newer tokenizer that produces “approximately 30 percent more tokens” than earlier models on the same text (vendor: https://platform.claude.com/docs/en/build-with-claude/token-counting, accessed 2026-11-04). Nothing in that page describes a downloadable tokenizer, and no open file should stand in for one. Gemini’s documentation offers count_tokens and the usage field, and its rule of thumb of about 4 characters per token is not qualified by language (vendor: https://ai.google.dev/gemini-api/docs/tokens, accessed 2026-11-04).


Kinds of Tokenizer for CJK Text#

A tokenizer has two parts that are easy to run together: an engine (the code) and a vocabulary (the file). The same engine with two files can spend very different token counts on Chinese. Most decisions in this category are decisions about a file, and for most readers the file comes with the model.

Three things make CJK a harder case than English:

  • No spaces to lean on. A pre-tokenizer built around whitespace sees a whole Chinese sentence as one word. Every kind below needs its own answer.
  • A large inventory. Chinese needs thousands of characters to reach ordinary text and tens of thousands more for names and historical sources. A vocabulary has to spend entries on them, or fall back to something smaller.
  • Three bytes per character in UTF-8, four above the Basic Multilingual Plane. A byte-level tokenizer that has not learned a character spends up to that many tokens on it, and the pieces mean nothing on their own.

Byte-level BPE#

Text is cut by a regular expression, each piece becomes UTF-8 bytes, and learned merges join the bytes back into larger tokens. Any string can be encoded, with no unknown token, because all 256 bytes are in the vocabulary. GPT-2 introduced the pattern; cl100k_base, o200k_base, Qwen, DeepSeek, GLM, MiniMax, Llama 3, EXAONE and most recent open-weight models follow it. How well it serves Chinese depends on how much CJK text was in the training mix and how many entries the file has. It was not designed around any one language.

A token can end partway through a character. Qwen’s own tokenization note says so: uncommon text may fall back to single bytes, and decoding those alone prints the replacement character (source: https://raw.githubusercontent.com/QwenLM/Qwen/main/tokenization_note.md, accessed 2026-11-04). A streaming client that prints token by token has to hold bytes back. S2-comprehensive/vocabulary-composition.md measures how often it happens per file.

Script-aware splitting ahead of byte-level BPE#

A variation on the same family: the regular expression treats Han as its own class, so a run of Han reaches the merges whole and never joins Latin. Kimi K2’s pattern opens with a [\p{Han}]+ alternative (read in its tokenization_kimi.py). It is still byte-level underneath.

Unigram with character pieces (SentencePiece)#

Instead of merging upward, Unigram scores a vocabulary of pieces and picks the most probable segmentation of a sentence, with no need for spaces. Entries are characters and strings, so every token prints alone. Characters outside the vocabulary become <unk>, or UTF-8 byte tokens if the file was trained with byte_fallback. That choice decides whether the text survives a round trip. SentencePiece also carries a normalizer inside its model file, and the default rewrites text. LLM-jp’s tokenizers use this form, extended from Mistral’s vocabulary for Japanese, Chinese and Korean, with 99,574 entries in the 3.0 release (source: https://github.com/llm-jp/llm-jp-tokenizer, accessed 2026-11-04).

Character-level BPE with byte fallback#

SentencePiece BPE and files converted from it (Mistral 7B, Gemma) start from characters rather than bytes. Merges work on characters, and unknown ones drop to byte tokens. A small file of this kind has few CJK entries, so much CJK text falls to bytes: Mistral 7B’s 32,000 entries spend 1,459 on tokens containing Han. A large one (Gemma has 262,144 entries) holds 20,610 (measured 2026-11-04; tokenizer files at pinned revisions; harness/1-033-3-cjk-tokenizers/results/probes/).

WordPiece#

BERT’s scheme. bert-base-chinese puts a space around every Han character and looks each one up in a list of 21,128 entries (measured 2026-11-04; same results directory). Each character is one token, unknown ones become [UNK], and text is normalized and lowercased along the way. It was built for classifiers rather than for generating text, and it does not give the original string back. It is here because it remains a common reach for Chinese embedding and classification work.

Morphological pre-segmentation#

Some Japanese and Korean tokenizers split text into words with a dictionary-based analyzer before anything else, as bert-base-japanese does with MeCab. Word segmentation itself is covered in 1.033.2 and 1.148. For LLM vocabularies it has largely given way to the kinds above.

Hosted counters#

Some providers publish no file. Claude’s count comes from an API endpoint, and the provider’s own documentation says the count moved by roughly 30 percent between model generations (vendor: https://platform.claude.com/docs/en/build-with-claude/token-counting, accessed 2026-11-04). See engines.md.

Things that are easy to mistake for a tokenizer choice#

  • A model’s tokenizer is not optional. With a trained model, you use its file. The ids are what the weights were trained on. The open question is which model, and token cost is one input.
  • “CJK-optimized” is a property of a file, not of an engine. Nothing about Hugging Face’s engine makes text cheaper. It loads Qwen’s file and Llama’s file equally.
  • Word segmenters are a different category. Jieba, MeCab and their kin find words for search and analysis. A language model’s tokenizer has no obligation to respect word boundaries.

S1 Recommendation: The Field and Starting Points#

The finding that reorganizes the field#

The vocabulary sets the token count, and the engine does not. The same tiktoken engine spends 1,314 tokens per 1,000 codepoints of Chinese Wikipedia text with cl100k_base, 890 with o200k_base and 780 with Kimi K2.6’s file. The two formats of o200k (tiktoken and tokenizer.json) produced identical ids on every line compared (measured 2026-11-04; tiktoken 0.14.0, tokenizers 0.23.3; zhwiki dump 20261001; harness/1-033-3-cjk-tokenizers/results/summary.json and results/interop.json).

So “SentencePiece or tiktoken or Hugging Face” is the wrong first question. For most readers the model is chosen first and its file comes along.

Starting points by job#

JobStart withWhyAvoid for this job
Counting tokens for an OpenAI modeltiktoken with the encoding the model maps toIt is the vendor’s encoderEstimating from characters
Counting tokens for an open-weight modelHugging Face Tokenizers reading that model’s tokenizer.jsonMost files in the sample ship in this formatAny other model’s file as a stand-in
Counting tokens for a hosted model with no fileThe vendor’s counting endpointNo file is published to count withA ratio from an old model
Training a new vocabulary with CJK textSentencePiece or Hugging Face BPE; compare both on your textS2-comprehensive/training.mdnmt_nfkc default normalization if text must come back intact
Text that must decode back exactlyA published byte-level file with no normalizerExact on every line tested; a model you train needs its whitespace option checkedNFKC-normalizing files (XLM-RoBERTa, mT5, Stockmark-2); BERT Chinese
Rare, historical or name charactersA file with byte fallback and no NFC or NFKC normalizerNo unknown tokens across every assigned CJK block, and compatibility forms keptXLM-RoBERTa, BERT Chinese; NFC files such as Qwen 3.8, MiniMax and K-EXAONE for compatibility ideographs (12 of 472 kept)
Classifiers and embeddings already built on BERT ChineseKeep it, knowing what it dropsOne token per Han characterUsing its counts as an LLM cost estimate

Sources for the table’s measured claims: S2-comprehensive/round-trip-fidelity.md and S2-comprehensive/rare-and-mixed.md.

Rules that held in the measurements#

  • No file is cheapest across languages. Among files exact on at least 99.99% of a language’s lines, MiniMax M2.5 was lowest on Chinese (701), LLM-jp-3 on Japanese (556) and A.X 4.0 on Korean (471). Stockmark-2 reaches 520 on Japanese with an NFKC normalizer that rewrites 51.5% of lines, and costs 1,844 on Korean (measured 2026-11-04; same run, tokens per 1,000 codepoints).
  • The origin of a model predicts its cost on its own language and says little about its neighbors. The range on Korean runs from 471 to 1,873, and the top of that range is Yi 1.5, a Chinese-origin model (same run).
  • A bigger file is not automatically cheaper: Kimi K2.6 holds 69,451 tokens containing Han and costs 780 on Chinese, while Qwen 3.8 holds 55,335 and costs 728 (same run).

What S2 settles#

S2 gives token cost per language (token-cost.md), what comes back after decode (round-trip-fidelity.md), rare characters and mixed strings (rare-and-mixed.md), what the vocabularies contain and how often a token splits a character (vocabulary-composition.md), engine behavior on hostile input and across releases (engine-behavior.md), training (training.md) and a feature table (feature-comparison.md).


Vocabularies: The Files in the Sample#

A vocabulary comes with its model, so this list reads as “what a given model charges for CJK text” and not as a menu. Sizes and composition come from loading each file and decoding every id alone. A token counts as Han, kana or Hangul if its decoded text contains that script, with Han checked first.

FileKindEntries% with Han% with kana% with Hangul
OpenAI cl100k_basebyte BPE100,2770.80.20.3
OpenAI o200k_base, gpt-ossbyte BPE200,0193.80.41.2
Gemma 3 and Gemma 4character BPE with byte fallback262,1447.91.41.8
Llama 3.2 (Kanana’s model parts match it)byte BPE128,2563.40.81.8
Nemotron 3 Nano, Mistral Tekkenbyte BPE131,0722.91.03.4
Mistral 7Bcharacter BPE with byte fallback32,0004.60.41.1
XLM-RoBERTa (SentencePiece file; tokenizer.json has 250,002)Unigram250,0007.40.82.2
mT5Unigram250,1008.62.21.6
Qwen 2.5, Qwen 3 (MiMo’s model parts match Qwen 3)byte BPE151,66917.21.12.4
Qwen 3.8byte BPE248,07722.31.42.7
DeepSeek V3.2 and V4.1byte BPE129,28027.60.60.9
GLM-5.3byte BPE154,85618.50.50.4
MiniMax M2.5byte BPE200,05421.93.32.3
Kimi K2.6byte BPE, Han split out first163,58442.50.30.3
Tencent Hy3byte BPE120,81837.90.30.7
Yi 1.5SentencePiece file64,00033.40.10.0
InternLM 3SentencePiece file128,1338.10.05.0
Baichuan 2SentencePiece file125,69656.60.21.3
BERT base ChineseWordPiece21,12869.32.70.4
LLM-jp-3Unigram with byte fallback99,57434.018.711.3
LLM-jp-4Unigram with byte fallback196,60837.08.97.1
Sarashina 2.2SentencePiece file102,40039.217.30.1
CALM3byte BPE65,00333.314.50.0
Stockmark-2byte BPE100,35233.714.30.0
EXAONE 4.0byte BPE102,4002.10.733.4
K-EXAONEbyte BPE153,6005.01.325.6
HyperCLOVA X SEEDbyte BPE110,5240.80.19.1
Solar Openbyte BPE196,6083.71.129.2
A.X 4.0byte BPE102,4001.00.258.6
A.X K1byte BPE163,8403.81.039.9

Measured 2026-11-04; tiktoken 0.14.0, tokenizers 0.23.3, sentencepiece 0.2.2, mistral-common 1.13.1; harness/1-033-3-cjk-tokenizers/results/probes/ and results/dedupe.json. Kinds are read from each tokenizer.json, or from the file format where the file is a SentencePiece model. Grouped rows differ by fewer than a thousand added tokens or by format.

Models can share parts without a shared name. All 130,072 regular tokens of Nemotron 3 Nano’s file are in Mistral’s Tekken file at different ids; the file’s other 1,000 entries are its added tokens. The two gave counts within 7 tokens of each other on every corpus. All 100,256 regular tokens of cl100k_base are in HyperCLOVA X SEED’s file at the same ids, with Hangul added (measured 2026-11-05; tokens compared as bytes in the tokenizer files; harness/1-033-3-cjk-tokenizers/results/vocab_overlap.json). A reader should not assume a new model name means a new vocabulary.

DeepSeek V4.1, MiMo and Kanana were not run on the corpus. dedupe.py found their model, normalizer, pre-tokenizer and decoder sections identical to DeepSeek V3.2, Qwen 3 and Llama 3.2, so their counts here are inferred from the matching file. The fingerprint leaves out added tokens, which differ (DeepSeek 818 and 1,283, Llama and Kanana 256 and 259), and the post-processor, which matched in all three pairs (results/dedupe.json). Each pair’s id lists also hashed the same over a 3.5M-codepoint sample (results/tokenizers_versions.json).

Hosted models#

OpenAI’s lookup table maps gpt-4o, gpt-4.1, gpt-4.5, the gpt-5 series and the o-series to o200k_base, and gpt-4 and gpt-3.5 to cl100k_base (read in tiktoken’s model.py, https://github.com/openai/tiktoken/blob/main/tiktoken/model.py, accessed 2026-11-04). Anthropic publishes no file. Google’s LocalTokenizer names Gemma files for Gemini models and marks the feature experimental; see engines.md.

S2: Comprehensive

S2 Approach: What Was Measured, Read and Not Done#

Measured#

Each file ran through its own engine, with no model weights loaded and no repo code executed. Encoding adds no BOS or EOS and decoding keeps special tokens. Hugging Face files go through the Rust Tokenizer directly, so transformers chat templates and decode cleanup are out of scope.

CorpusSourceCodepoints
Chinese, CJK lineszhwiki 20261001, first part file29,894,541
Chinese, lines with 5% or more Latinsame10,105,474
Cantonese, CJK lineszh_yuewiki 2026100112,210,313
Classical Chinese, CJK lineszh_classicalwiki 202610016,708,471
Japanese, CJK linesjawiki 20261001, first part file29,542,916
Japanese, mixedsame10,457,180
Korean, CJK lineskowiki 20261001, first part file29,646,686
Korean, mixedsame10,353,547
Englishenwiki 20261001, first part file10,000,058
Variants: Chinese as written, converted to simplified, converted to traditionalzhwiki sample, OpenCC 1.4.25,000,009 each
Variants: Korean NFC and NFDkowiki sample5,000,011 and 9,730,104

Measured 2026-11-04; harness/1-033-3-cjk-tokenizers/results/corpus_manifest.json records each file’s SHA-256, line count and script counts.

Wikipedia is one register: encyclopedic prose in dump order, with some table rows and reference fragments left in. Chinese Wikipedia mixes simplified and traditional as editors typed them. Colloquial chat, code, legal text and transcripts will land elsewhere, so read the tables as a ranking on this text and test your own before budgeting.

Costs are tokens per 1,000 codepoints, counting spaces, digits and punctuation. Korean carries spaces and Chinese barely does, so compare files within a column. Comparing columns measures the writing systems as much as the tokenizers.

Read, not run#

Other engines in S1-rapid/engines.md, the JavaScript and WebAssembly ports, mobile runtimes, transformers behavior on top of the engines, and hosted counters.

Not done#

  • No timing is published. The machine was shared, and most corpus runs took place at a 1-minute load above 6. Encode speed for every engine is unmeasured here, so the speed gaps often quoted between engines are neither confirmed nor refuted.
  • No model was loaded, so nothing here says whether a lower token count gives a better or worse answer, or how a model’s quality changes with its tokenizer.
  • No hosted counter was called. OpenAI’s files are the published encodings; a live API adds message framing that this does not count.

Host#

Linux 6.6.87.2-microsoft-standard-WSL2, aarch64, 8 CPUs, Python 3.13, tiktoken 0.14.0, tokenizers 0.23.3, sentencepiece 0.2.2, mistral-common 1.13.1. Token counts are deterministic and do not depend on the host; harness/1-033-3-cjk-tokenizers/README.md has run conditions.

Sources#

Inputs, pinned and hash-checked: Hugging Face tokenizer files at the commits in harness/1-033-3-cjk-tokenizers/results/pins.json; OpenAI’s cl100k_base and o200k_base from its blob store; Gemma 3’s file from the commit named in google-genai; Wikipedia article dumps dated 20261001 from https://dumps.wikimedia.org/.

Read, accessed 2026-11-04:


Engine Behavior: Formats, Hostile Input and Releases#

Two engines, one vocabulary#

Three vocabularies ship in two formats. Each line was encoded by both sides, across 5M-codepoint Chinese and Korean samples, 5M codepoints of Japanese and 2M each of mixed text.

PairLinesSame token countSame idsSame token text
o200k: tiktoken and tokenizer.json (gpt-oss)278,582278,582278,582278,582
Mistral 7B: SentencePiece and Tokenizers278,582278,581278,581278,581
XLM-RoBERTa: SentencePiece and Tokenizers278,582278,5750274,068

Measured 2026-11-04; tiktoken 0.14.0, tokenizers 0.23.3, sentencepiece 0.2.2; harness/1-033-3-cjk-tokenizers/results/interop.json. XLM-RoBERTa’s tokenizer.json offsets every id relative to the SentencePiece file, so its ids never match even when the tokens do. Its token-text column understates agreement: the mismatches include the same unknown token rendered ⁇ by one engine and <unk> by the other. The result keeps only sample mismatches, so the share caused by this is not computed.

A converted file can match, and matching is not guaranteed by the format. On decomposed Korean, XLM-RoBERTa’s SentencePiece file normalizes to the composed form and its tokenizer.json does not: the same text cost 1.0 and 3.23 times its composed count (token-cost.md).

Text that looks like a special token#

Each file’s own special strings were placed inside Chinese text and passed to the engine’s default encode call.

EngineFilesDefault behavior
Tokenizers29Every tested string became its control id
tiktoken, encode2Raises an error; encode_ordinary treats it as text
SentencePiece8Treated as text
mistral-common Tekken1Treated as text

Measured 2026-11-04; up to 12 special strings per file; harness/1-033-3-cjk-tokenizers/results/probes/. Kimi’s file was not tested here, since the repo’s wrapper holds its special table and repo code was not run.

For a service tokenizing untrusted text, this is the one engine difference with security consequences. With Tokenizers’ default call, a user who types a chat-template control string produces the control token, unless the application handles that string first. The corpus contains examples: Wikipedia lines holding a literal </s> came back altered from LLM-jp-3.

Broken strings#

InputTokenizers (29 files)SentencePiece (8)tiktoken, Kimi, Tekken (4)
Lone surrogateRaises TypeErrorRaises RuntimeErrorReplaced with U+FFFD, encodes
NUL byteEncodes; round trips except XLM-RoBERTa and BERTEncodes; round trips except XLM-RoBERTaRound trips
Empty stringZero tokensZero tokensZero tokens
Byte order mark, U+FFFDRound trip except XLM-RoBERTa and BERTRound trip except XLM-RoBERTa and mT5Round trip

Measured 2026-11-04; same results directory. A service reading text from JavaScript or Windows sources can meet lone surrogates; clean them before encoding if the file reads through Tokenizers or SentencePiece.

One character repeated 100,000 times#

All 41 files finished within a 240-second limit, on 一 and on a. The token count shows how each file compresses a run: a repeated gives 6,250 to 50,000 tokens across BPE files, and one [UNK] from BERT Chinese, whose WordPiece gives up on a word above 100 characters. Wall time was not recorded for publication.

Measured 2026-11-04; same results directory.

Memory on load#

Vocabulary.tiktoken or .model (kB)tokenizer.json (kB)
o200k78,944244,668
Gemma54,636289,176
Mistral 7B11,87230,572
XLM-RoBERTa64,704343,948

Measured 2026-11-04; resident memory before and after loading one file in a fresh Python 3.13 process on aarch64 Linux, including the engine’s first import; same results directory. The tokenizer.json route used 2.6 to 5.3 times as much on these vocabularies.

Do ids hold across releases?#

Each file’s id lists over 3.5M codepoints (1M each of Chinese, Japanese and Korean, 0.5M of mixed Chinese) were hashed under both releases.

Engine, releasesFilesSame ids on the sampleDifferent idsFailed at loadFailed at encode
sentencepiece 0.2.2 and 0.2.388000
tokenizers 0.23.3 and 1.0.0-rc.32923123

Measured 2026-11-04, with the five failing files re-run 2026-11-05 to record the stage; 3.5M sampled codepoints per file, so same ids here says nothing about text outside the sample; harness/1-033-3-cjk-tokenizers/results/sentencepiece_versions.json and results/tokenizers_versions.json.

The candidate’s project notes promise the same token ids and name feature parity with 0.23 as the milestone left before 1.0 (source: https://github.com/huggingface/tokenizers/releases, accessed 2026-11-04). On rc.3 from PyPI:

  • Failed at load: CALM3 and Hy3 are refused because the vocabulary lacks a token for a byte (0xF2, 0x0D).
  • Failed at encode: Qwen 3.8, K-EXAONE and A.X K1 load, then stop on the first line with an error that a Split pattern needs a regex backend the wheel lacks.
  • Different ids: HyperCLOVA X SEED’s Korean sample gave 550,584 tokens against 550,639, a difference of 55.
  • Smaller API: the candidate’s Python Tokenizer lacks get_vocab, get_vocab_size, token_to_id, id_to_token and decode_batch as of rc.3.

A candidate is allowed to be incomplete, and these will likely move before release. They show why a comparison on your own files belongs ahead of an upgrade.


Feature Comparison: Engines#

Each cell says what the engine does and how that was established: ran (exercised by the harness), read (in documentation or source, not exercised) or absent (not offered, per its documentation or API).

FeatureHugging Face TokenizersSentencePiecetiktokenmistral-common Tekken
Readstokenizer.json: ran.model: ran.tiktoken and custom ranks: rantekken.json: ran
Train a vocabularyBPE: ran; WordPiece, WordLevel, Unigram: readUnigram, BPE: ran; character, word: readabsentabsent
Normalizer stagePer file: ranInside the model file: ranabsentabsent
Byte fallback for unknown charactersPer file: ranTrained option: ranInherent to byte-level files: ranInherent: ran
Unknown token possiblePer file: ran (BERT Chinese)Per file: ran (XLM-RoBERTa)absentDefined but not emitted on any corpus line: ran
Special strings in text, default callBecome control ids: ranTreated as text: ranRaises; encode_ordinary treats as text: ranTreated as text: ran
Lone surrogateRaises: ranRaises: ranReplaces, encodes: ranReplaces, encodes: ran
Incremental decode for streamingDecodeStream: readPiece-level decode: readPer-token bytes: readNot checked
Offsets back to sourceEncoding offsets: readExtended in 0.2.2: readdecode_with_offsets: readNot checked
Browser or JavaScript@huggingface/tokenizers, tokenizers-wasm candidate: readabsent in this samplejs-tiktoken, gpt-tokenizer: readabsent in this sample
Execute repo code to loadNoNoNoNo
SpeedUnmeasuredUnmeasuredUnmeasuredUnmeasured

Measured 2026-11-04 where marked ran; tiktoken 0.14.0, tokenizers 0.23.3, sentencepiece 0.2.2, mistral-common 1.13.1; harness/1-033-3-cjk-tokenizers/results/. Read cells rest on S1-rapid/engines.md and each package’s own source and release notes, accessed 2026-11-04.

What a table of engines cannot show#

The cost, fidelity and rare-character tables in this pass vary across files within a single engine by more than they vary between engines. Pick a row in this table for operational reasons: what your stack can load, whether you need training, how you treat untrusted input.


Rare Characters and Mixed Strings#

Rare characters by Unicode block#

Each assigned codepoint of a block was encoded alone. Cell format: mean tokens per character / characters that round trip. LLM-jp, mT5, XLM-RoBERTa and Mistral 7B add a leading space piece when a string starts, so subtract one from their means to compare the character’s own cost.

FileCJK Unified (20,992)Ext A (6,592)Ext B (42,720)Ext G (4,939)Compat ideographs (472)Kangxi radicals (214)Hangul syllables (11,172)
OpenAI cl100k2.36 / all2.98 / all3.97 / all3.98 / all2.99 / all3.00 / all2.60 / all
OpenAI o200k1.92 / all2.98 / all3.96 / all3.98 / all2.99 / all2.96 / all2.24 / all
Qwen 31.62 / all2.42 / all3.03 / all3.97 / all1.32 / 121.74 / all1.78 / all
Qwen 3.81.75 / all2.98 / all3.97 / all3.97 / all1.33 / 122.96 / all2.16 / all
DeepSeek V3.21.76 / all2.97 / all3.98 / all3.96 / all3.00 / all2.39 / all2.38 / all
MiniMax M2.51.77 / all2.98 / all3.97 / all3.96 / all1.37 / 122.09 / all2.24 / all
Kimi K2.61.80 / all2.99 / all3.97 / all3.99 / all2.99 / all3.00 / all2.50 / all
Gemma 3, Gemma 42.10 / all2.90 / all4.00 / all4.00 / all2.90 / all2.87 / all2.69 / all
Baichuan 21.06 / all2.80 / all4.00 / all4.00 / all3.00 / all2.90 / all2.72 / all
LLM-jp-42.77 / all3.66 / all5.00 / all5.00 / all3.72 / all2.78 / all3.38 / all
Stockmark-21.90 / all2.99 / all3.97 / all3.98 / all1.41 / 121.39 / 02.89 / all
mT53.06 / all3.97 / all5.00 / all5.00 / all2.25 / 122.10 / 03.63 / all
A.X K11.87 / all2.98 / all3.97 / all3.96 / all1.51 / 122.97 / all1.93 / all
XLM-RoBERTa2.00 / 7,6882.00 / 12.00 / 12.00 / 02.00 / 01.98 / 01.97 / 1,725
BERT base Chinese1.00 / 7,3211.00 / 11.00 / 01.00 / 01.00 / 01.00 / 01.00 / 0

Measured 2026-11-04; all 41 files in harness/1-033-3-cjk-tokenizers/results/probes/; block ranges from Unicode’s Blocks.txt, assigned codepoints per Python’s Unicode 15.1 tables. all means every codepoint in the block.

A byte-level file cannot lose a character: an unlearned character costs its byte count, 3 in the Basic Multilingual Plane, 4 above it. XLM-RoBERTa and BERT are the two files in the sample that replace characters with an unknown token: 42,719 of Extension B’s 42,720 in XLM-RoBERTa, in both formats, and all of them in BERT’s. Yi, Gemma and the others with byte fallback keep them. The 12 surviving compatibility ideographs in the NFC and NFKC files are the ones those normalizers leave alone.

Which characters own a whole token#

Counted over each file’s whole id space: characters that some non-special id decodes to, after stripping whitespace.

FileGB2312 L1 (3,755)GB2312 L2 (3,008)Big5 frequent (5,495)Big5 less frequent (7,652)JIS L1 (2,965)JIS L2 (3,390)KS X 1001 Hangul (2,350)KS X 1001 Hanja (4,888)
OpenAI cl100k53014191337721164361
OpenAI o200k2,073331,816401,5892797001,643
Llama 3.21,766191,750351,5812386661,595
Qwen 33,7532,8884,1031,7752,3101,7292,0723,551
Qwen 3.83,6465773,7372062,6141,1289763,176
MiniMax M2.53,5375503,4071782,5229507842,964
Kimi K2.63,6921,0323,1482581,9761,0182642,568
Gemma 3, Gemma 43,7492,1205,0991,5642,9322,4021,6614,257
Baichuan 23,7553,0085,2567,3202,9533,1901,4894,496
LLM-jp-43,7552,8535,3733,3842,9633,0442,0084,528
Stockmark-21,6241172,335902,53618612,312
A.X K12,183282,214431,9413561,5812,046
BERT base Chinese3,7351,5564,8606122,7271,98303,976

Measured 2026-11-04; character sets enumerated through Python 3.13 codecs (gb2312, big5, euc_jp, euc_kr); same results directory.

Whole-token coverage does not rank files by cost. Qwen 3 holds more single-character tokens than Qwen 3.8 and costs more on Chinese (799 against 728). Qwen 3.8 holds more multi-character Han tokens: 49,908 against 16,964.

Mixed-script strings#

Thirty-one fixed strings, token count and round trip. An x marks a string that did not come back exact. Selected strings:

StringCodepointscl100ko200kGemma 4Qwen 3.8DeepSeek V3.2MiniMaxLLM-jp-4Stockmark-2K-EXAONEXLM-RoBERTa
Chinese and English code-switching412117191917162127 x1917 x
Japanese and English3824222123221819152319
Korean and English4027161615181515591417
Python with Chinese identifier and comment4421212322212025262221 x
JSON with Japanese values4139262425252021192528
Percent-encoded URL4819192621191927212322
Same URL with raw Han32109128881110912
Hanja inside Korean2027141413161413251316
Han, kana, Hangul and Latin together18149889871379
Family emoji joined by ZWJ inside Chinese1122151120131310161511 x
Extension B character in a name, 𠮷野家37666664664 x
Fullwidth Latin8116777663 x144 x
Halfwidth katakana10201710112015114 x3011 x
Decomposed Hangul, 한글6181862 x142 x74 x1 x7

Measured 2026-11-04; harness/1-033-3-cjk-tokenizers/probes_data.py and results/probes/. Short strings show direction and not a rate. The LLM-jp-4 and XLM-RoBERTa counts include the leading space piece.

Three patterns repeat across the set:

  • Percent-encoded URLs cost about twice their raw form in most files: a URL with Han in it is cheaper to send decoded.
  • Compatibility forms cost more or vanish. Halfwidth katakana takes 30 tokens in K-EXAONE and 4 in Stockmark-2, whose NFKC normalizer folds it, losing the original form.
  • Variation selectors survive byte-level files and die in XLM-RoBERTa and BERT. An ideographic variation sequence, used for name characters in Japan, came back from every file but those two.

S2 Recommendation: What the Measurements Settle#

Findings#

  1. The file sets the cost, and the spread is wide. Among files exact on at least 99.99% of a language’s lines, Chinese ran from 701 to 1,443 tokens per 1,000 codepoints, Japanese from 556 to 1,464, and Korean from 471 to 1,873. The lowest cost overall differs on two of those: Japanese 520 (Stockmark-2, whose NFKC normalizer leaves 48.5% of lines exact) and Korean 298 (BERT Chinese, through unknown tokens) (measured 2026-11-04; tiktoken 0.14.0, tokenizers 0.23.3, sentencepiece 0.2.2; Wikipedia dumps 20261001; harness/1-033-3-cjk-tokenizers/results/summary.json).
  2. No file leads in all three languages. Among files that keep the text, MiniMax M2.5 leads on Chinese (701), LLM-jp-3 on Japanese (556) and A.X 4.0 on Korean (471). Stockmark-2 is lower on Japanese (520) and rewrites the text. LLM-jp-4, Qwen 3.8 and MiniMax are the most even across the three (same file; token-cost.md).
  3. Fidelity divides on the normalizer. Published files with none returned all 1,964,779 lines exactly; the trained SentencePiece models with an identity normalizer and byte fallback did not, losing whitespace on 1.3% of Chinese and 7.7% of English lines (training.md). NFC files missed five. NFKC and BERT-style files changed most Chinese lines (same file; round-trip-fidelity.md).
  4. Unknown tokens are rare in LLM files. Of the 41 files, only XLM-RoBERTa in both formats and BERT Chinese emitted unknown tokens on the CJK blocks (measured 2026-11-04; results/probes/; rare-and-mixed.md).
  5. Partial tokens range from none to most. cl100k_base is at 53.8% on Chinese, Qwen 3.8 at 1.9% and Gemma at 0.3% (results/summary.json; vocabulary-composition.md).
  6. Engines differ on hostile input and memory. Tokenizers turns special strings into control ids by default, while the others do not, and the same vocabulary used 2.6 to 5.3 times the memory as tokenizer.json (results/probes/; engine-behavior.md).
  7. A small trained file competes on CJK text close to its training text. 32,000 entries trained on 30M codepoints reached 724 on Chinese, in the range of files holding 150,000 to 250,000 entries, with a large English cost; no English was in the training text. Hugging Face byte-level BPE ended at a 3G memory cap on that text (measured 2026-11-05; sentencepiece 0.2.2, tokenizers 0.23.3; results/train/ and results/trained_tok/; training.md).

Ranking by job#

JobFirst choiceSecondWhy
Count tokens for a given open-weight modelTokenizers with that model’s fileThe vendor’s own layer, where one existsOnly the model’s file is right
Count tokens for OpenAI modelstiktokentokenizer.json conversionSame ids on all 278,582 lines compared
Encode untrusted texttiktoken encode_ordinary, SentencePiece, or TekkenTokenizers with special strings handled firstDefault behavior differs
Train a vocabulary for CJK textSentencePiece BPE or Unigram with byte fallback, whitespace option checkedHugging Face byte-level BPE where memory allows and text must come back exacttraining.md
Keep memory low.model or .tiktoken format where one existstokenizer.jsonengine-behavior.md

Sources: the files named in the Why column and the findings above. Encode speed is left out of this ranking because it is unmeasured.

What these numbers do not cover#

Output quality per tokenizer, encode speed, phone or browser runtimes, a hosted model’s live counting, and text registers other than Wikipedia. approach.md lists the conditions.


Round-Trip Fidelity: Does the Text Come Back?#

Each line was encoded, decoded and compared with the original byte for byte, across 1,964,779 lines of the main corpora. A mismatch takes the first class that makes both sides equal: unknown token present, NFKC, whitespace, NFKC plus whitespace, case, else other.

The result falls into three groups#

DeepSeek V4.1, MiMo and Kanana were not run on the corpus. dedupe.py found their model, normalizer, pre-tokenizer and decoder sections identical to DeepSeek V3.2, Qwen 3 and Llama 3.2, so their counts here are inferred from the matching file. The fingerprint leaves out added tokens, which differ (DeepSeek 818 and 1,283, Llama and Kanana 256 and 259), and the post-processor, which matched in all three pairs (results/dedupe.json). Each pair’s id lists also hashed the same over a 3.5M-codepoint sample (results/tokenizers_versions.json).

Exact on every line: every published byte-level or byte-fallback file with no rewriting normalizer. That covers OpenAI’s files, Llama 3.2, Gemma, Mistral 7B, Tekken, Nemotron 3, DeepSeek, GLM, Hy3, Kimi, Yi, InternLM 3, Baichuan 2, LLM-jp-4, Sarashina, EXAONE 4.0, A.X 4.0 and Solar Open.

Exact except rare characters: files with an NFC normalizer: Qwen 2.5, 3 and 3.8, MiMo, MiniMax, CALM3, K-EXAONE, A.X K1 and HyperCLOVA X SEED. Five Japanese lines failed in each, on compatibility characters that NFC folds to a standard form: U+FA19, a variant of 神, and U+2329, an angle bracket. LLM-jp-3 failed on one Korean line where a literal </s> in the article text parsed as a control token and came back with a space after it; two Cantonese lines outside the main count did the same.

Rewrites ordinary text:

FileNormalizerChineseCantoneseClassicalJapaneseKoreanEnglish
XLM-RoBERTanmt_nfkc, precompiled14.417.115.447.896.489.8
mT5nmt_nfkc, precompiled14.617.416.448.297.389.9
Stockmark-2NFKC15.117.917.248.598.997.1
BERT base ChineseBERT normalizer0.0010.0020.00.1830.00.407

Measured 2026-11-04; percent of lines exact; tokenizers 0.23.3, sentencepiece 0.2.2; harness/1-033-3-cjk-tokenizers/results/summary.json. Stockmark-2 has the lowest Japanese token count here and leaves 48.5% of Japanese lines exact. Its NFKC normalizer turns the fullwidth comma in 一門学科,屬於 into an ASCII comma, so about 85% of Chinese lines change.

Failure classes#

FileNFKC onlyWhitespaceNFKC + whitespaceUnknown tokenOther
XLM-RoBERTa (SentencePiece file; tokenizer.json within 2 lines per class)885,58821,24611,23169,187981
mT5943,31921,93812,56901,073
Stockmark-2958,6510000
BERT base Chinese52729,35401,233,398856

Measured 2026-11-04; line counts over the nine main corpora; same file. NFKC-class failures change forms and keep meaning in most text: fullwidth punctuation, halfwidth katakana, compatibility characters. Unknown-token failures lose text. BERT also puts spaces around every Han character on decode, which is what the whitespace class records.

Normalizers and NFD#

An NFC normalizer rewrites NFD input. The files in the second group failed 93,843 of 93,884 lines of decomposed Korean, and decoded each to the composed form. A pipeline that hashes or diffs its text needs to know which form a tokenizer gives back.

Decoding is not the same as streaming#

Exact whole-line decoding hides a separate problem: a token can end inside a character. vocabulary-composition.md measures how often. A client that decodes each token as it arrives prints U+FFFD at those points, even with a file that is exact end to end.

What to take from this#

Any file a model already uses is fixed, so fidelity is a property to know about instead of a choice. It matters for chunking, offsets, redaction and any flow that reconstructs the user’s text from token ids. Keep the original string and treat decoded text as display, for the files in the third group above all.


Token Cost by Language#

Tokens per 1,000 codepoints on the CJK-only corpora and English. Files measured separately and sharing a row differed by under 0.1%. DeepSeek V4.1, MiMo and Kanana were not run on the corpus. dedupe.py found their model, normalizer, pre-tokenizer and decoder sections identical to DeepSeek V3.2, Qwen 3 and Llama 3.2, so their counts here are inferred from the matching file. The fingerprint leaves out added tokens, which differ (DeepSeek 818 and 1,283, Llama and Kanana 256 and 259), and the post-processor, which matched in all three pairs (results/dedupe.json). Each pair’s id lists also hashed the same over a 3.5M-codepoint sample (results/tokenizers_versions.json).

FileChineseCantoneseClassicalJapaneseKoreanEnglish
MiniMax M2.5701826892579611216
DeepSeek V3.2, V4.1707816920743730220
Qwen 3.8728849919682618232
XLM-RoBERTa748785941667593246
LLM-jp-4753824909589578229
Tencent Hy37689691020806770222
Baichuan 2772885921939986242
Kimi K2.67809841047811858224
mT5780840962609675260
Qwen 2.5, Qwen 3, MiMo799920974800769233
GLM-5.3, GLM-4.58029921047783841224
Gemma 3, Gemma 4804848942686659226
Yi 1.58131003104312111873247
LLM-jp-3872873946556503238
OpenAI o200k, gpt-oss89010011082816674221
Llama 3.2, Kanana8969791063764672224
A.X K18989811027763490231
K-EXAONE9009861048741505210
Solar Open9129921028685502227
BERT base Chinese (lossy)942934992698298296
Tekken, Nemotron 3100210821138817645232
Stockmark-21029102310645201844225
CALM31029103210525931598246
InternLM 31085148314191464634263
A.X 4.0118111941208976471241
Sarashina 2.21186123712295891622267
Mistral 7B12351416145011281122258
HyperCLOVA X SEED1313147715381103587224
OpenAI cl100k13141479154111041042224
EXAONE 4.01443147615601056595235

Measured 2026-11-04; tiktoken 0.14.0, tokenizers 0.23.3, sentencepiece 0.2.2, mistral-common 1.13.1; Wikipedia dumps 20261001; 6.7M to 29.9M codepoints per language; harness/1-033-3-cjk-tokenizers/results/summary.json. BERT’s low Korean figure comes from unknown tokens: one [UNK] stands for a whole word, so it is a loss of text and not a saving.

Reading the table#

  • Chinese spread: files that keep the text (exact on at least 99.99% of that language’s lines, here and below) run from 701 (MiniMax M2.5) to 1,443 (EXAONE 4.0), a factor of 2.06 on the same 29.9M codepoints.
  • OpenAI: cl100k_base costs 1,314 on Chinese and o200k_base 890, so moving from one encoding to the other takes off 32% on this text. “tiktoken” is not a single cost: which encoding a model maps to decides it.
  • Japanese: among files that keep the text, LLM-jp-3 (556), MiniMax (579), Sarashina (589), LLM-jp-4 (589) and CALM3 (593) lead. Stockmark-2 is lower overall (520), and its NFKC normalizer leaves 48.5% of Japanese lines exact. cl100k_base is at 1,104.
  • Korean: among files that keep the text, A.X 4.0 (471), A.X K1 (490), Solar Open (502), LLM-jp-3 (503) and K-EXAONE (505) lead. Chinese- and Japanese-origin files without Hangul entries pay close to one token per byte: Yi 1,873, Stockmark-2 1,844, Sarashina 1,622, CALM3 1,598.
  • Classical Chinese and Cantonese cost more than modern written Chinese in nearly every file (BERT and Stockmark-2 are lower on Cantonese): o200k_base goes 890, 1,001 and 1,082 across modern, Cantonese and Classical; MiniMax goes 701, 826 and 892.
  • English barely separates them: 210 to 267 across files that keep the text. A vocabulary can spend heavily on CJK without visibly hurting English on this corpus.

Mixed text#

Lines with at least 20% target script and 5% or more Latin letters. The order largely follows the CJK table, with lower numbers.

FileChinese + LatinJapanese + LatinKorean + Latin
MiniMax M2.5562488522
DeepSeek V3.2, V4.1565632619
Qwen 3.8583574530
XLM-RoBERTa592567518
LLM-jp-4599497505
Tencent Hy3615685647
Baichuan 2632814836
Kimi K2.6628681717
mT5615507585
Qwen 2.5, Qwen 3, MiMo638674652
GLM-5.3, GLM-4.5637657708
Gemma 3, Gemma 4626572562
Yi 1.565210541503
LLM-jp-3692483456
OpenAI o200k, gpt-oss688680572
Llama 3.2, Kanana689644576
A.X K1697636432
K-EXAONE701626441
Solar Open704579440
BERT base Chinese (lossy)720545291
Tekken, Nemotron 3773690554
Stockmark-27974531490
CALM38055171287
InternLM 38531253550
A.X 4.0906823427
Sarashina 2.29045021302
Mistral 7B938937940
HyperCLOVA X SEED975897507
OpenAI cl100k976898850
EXAONE 4.01072869521

Measured 2026-11-04; same versions and dumps; 10.1M to 10.5M codepoints per language; harness/1-033-3-cjk-tokenizers/results/summary.json. rare-and-mixed.md looks at single strings.

Script variant#

Chinese text converted by OpenCC to all-simplified and all-traditional, 5M codepoints each (tokens per 1,000 codepoints):

FileSimplifiedTraditionalTraditional / simplified
InternLM 37941,3701.73
Kimi K2.66149381.53
Tencent Hy36298821.40
GLM-5.36689211.38
Baichuan 26748491.26
MiniMax M2.56237531.21
OpenAI cl100k1,2021,4011.17
OpenAI o200k8179451.16
DeepSeek V3.26457401.15
Qwen 37348431.15
Qwen 3.86787571.12
Gemma 3, Gemma 47708111.05
XLM-RoBERTa7207441.03
LLM-jp-47047701.09
LLM-jp-38728560.98
Sarashina 2.21,2021,1410.95
EXAONE 4.01,4681,3770.94
A.X 4.01,2101,1240.93
CALM31,0669660.91
Stockmark-21,0739590.89

Measured 2026-11-04; OpenCC 1.4.2 conversion of a 5M-codepoint zhwiki sample; harness/1-033-3-cjk-tokenizers/results/summary.json. Sibling Chinese-origin files split widely on traditional text, so a team serving Taiwan or Hong Kong should measure on its own script. Files below a ratio of 1.0 come from Japanese and Korean models, and other files from those regions sit above it, as LLM-jp-4 does. The reason was not tested.

Normalization form#

Korean is usually stored composed (NFC). Text from a Mac filesystem or some pipelines arrives decomposed (NFD), with each syllable as two or three jamo. The same text costs this many times more tokens in NFD:

FileNFD tokens / NFC tokens
Qwen 3.8, Qwen 3, MiniMax, K-EXAONE, A.X K1, HyperCLOVA X, Stockmark-2, CALM3, mT5, XLM-RoBERTa (SentencePiece file)1.0 (normalized away)
Gemma 3, Gemma 42.98
OpenAI cl100k4.72
EXAONE 4.04.83
DeepSeek V3.25.75
GLM-5.35.78
Solar Open6.62
Llama 3.27.42
OpenAI o200k7.74
A.X 4.09.17
LLM-jp-310.52

Measured 2026-11-04; kowiki sample of 5,000,011 NFC codepoints and the same text as 9,730,104 NFD codepoints; harness/1-033-3-cjk-tokenizers/results/summary.json. The files that normalize pay for it in fidelity (round-trip-fidelity.md); the files that do not will charge up to ten times for an input-handling mistake. Normalizing to NFC before encoding removes the problem for any file.

What this does not say#

A cheaper count is a cheaper count at that vendor’s price per token, and prices differ. It says nothing about output quality. The count also excludes message framing, system prompts and tool definitions.


Training a Vocabulary: Two Trainers on the Same Text#

Each model has 32,000 entries, trained with no normalization on Wikipedia text from Chinese, Japanese and Korean in equal parts, then measured on the test corpora. Test lines were held out but come from the same dumps, which flatters every model. No English or code was in the training text.

Trained on 30M codepoints#

ModelOutcomePeak memory (MB)ChineseCantoneseClassicalJapaneseKoreanEnglishExact Chinese lines, %Unknown tokens, Chinese
SentencePiece BPE, byte fallbackFinished1,65772479991959352341498.6650
SentencePiece Unigram, byte fallbackFinished1,13473180393260353742298.6650
SentencePiece Unigram, no byte fallbackFinished1,13472776191860153642292.30645,508
Hugging Face BPE on characters, metaspaceFinished2,36572476088858852944698.29710,749
Hugging Face byte-level BPEOOM at cap 3G, exit 137 (wrapper message in results/train/hf-bpe-bytelevel.json)Over the capnonenonenonenonenonenonenonenone

Measured 2026-11-05; sentencepiece 0.2.2, tokenizers 0.23.3; character coverage 0.9995 on SentencePiece; 3G memory cap plus 512M swap; harness/1-033-3-cjk-tokenizers/results/train/ and results/trained_tok/. Costs are tokens per 1,000 codepoints. Training time is unpublished because the machine was shared.

Trained on 6M codepoints#

The byte-level model could not finish the larger set under the cap, so all three kinds also trained on the first 2M codepoints of each language.

ModelPeak memory (MB)ChineseCantoneseClassicalJapaneseKoreanEnglishExact Chinese lines, %Unknown tokens, ChinesePartial tokens, Chinese %
Hugging Face byte-level BPE929737823941601532413100.003.66
SentencePiece Unigram, byte fallback32174786496162355244398.66501.6
Hugging Face BPE on characters, metaspace71370274387656950942192.21658,8280.0

Measured 2026-11-05; same versions and cap; same results directories, keys ending -small.

What the two tables show#

  • A small file can match a large one on text like its training text. 32,000 entries reached 724 on Chinese. MiniMax’s 200,054 entries cost 701 and Qwen 3.8’s 248,077 cost 728, on the same test lines (results/summary.json). These models paid for it on English, at 413 to 446 against 210 to 267 for the published files, and they hold no code.
  • A low count with unknown tokens is not a saving. On Chinese, character BPE at 6M codepoints has the lowest count and the most lost text: it emitted 58,828 unknown tokens and returned 92.2% of Chinese lines exact. Each unknown token stands in for text it did not encode.
  • Byte fallback costs little. SentencePiece Unigram went from 727 to 731 on Chinese with byte fallback on, and exact Chinese lines went from 92.3% to 98.7%.
  • The text a model never saw costs most. Cantonese is the widest case: 864 for SentencePiece Unigram with byte fallback at 6M codepoints, against 747 on modern Chinese.
  • More text helps by a small margin. SentencePiece Unigram with byte fallback went from 747 to 731 on Chinese when training text grew from 6M to 30M codepoints. A larger vocabulary was not tested.
  • Memory differs by trainer. At 6M codepoints the byte-level trainer used 929 MB and SentencePiece Unigram 321 MB. Byte-level BPE at 30M codepoints exceeded the 3G cap. That is a result under one cap on one machine, and more memory would likely let it finish.

Whitespace#

Every SentencePiece model lost whitespace on some lines: 7.7% of English lines and 1.3% of Chinese lines with byte fallback on, and these lines matched once whitespace was ignored. The Hugging Face models had no whitespace failures. SentencePiece’s remove_extra_whitespaces option defaults to on (source: https://raw.githubusercontent.com/google/sentencepiece/master/doc/options.md, accessed 2026-11-05), and these runs left it there, which is the likely cause; turning it off was not tested. Published SentencePiece files in the sample, such as Yi and Sarashina, returned every line exactly.

Limits of this comparison#

SentencePiece logged and skipped lines over its 65,536-byte limit, and release 0.2.3 lifts a related limit for BPE (read, not run). The pre-tokenizers differ between engines by design. auto_character_coverage, new in SentencePiece 0.2.3, was not run.


What the Vocabularies Hold, and How Often a Token Splits a Character#

Budget#

S1-rapid/vocabularies.md lists each file’s share of tokens containing Han, kana and Hangul. A rule of thumb in circulation says an English-focused file spends 10% of its entries on CJK and a CJK-focused one 50%. Counted, neither holds (unverified, for the rule itself):

  • cl100k_base: 0.8% Han, 0.2% kana, 0.3% Hangul.
  • o200k_base: 3.8% Han, 0.4% kana, 1.2% Hangul.
  • Qwen 3: 17.2% Han. Qwen 3.8: 22.3%. MiniMax M2.5: 21.9%. DeepSeek: 27.6%.
  • Baichuan 2 and Kimi K2.6, the most Han-heavy LLM files here among those above 100,000 entries: 56.6% and 42.5%.

Measured 2026-11-04; each id decoded alone; harness/1-033-3-cjk-tokenizers/results/probes/. Latin is still the largest class in 35 of the 41 files, Kimi, DeepSeek and Qwen among them. The exceptions are Baichuan 2, LLM-jp-3 and BERT (Han), A.X 4.0 (Hangul), and XLM-RoBERTa in both formats (symbols and other scripts).

Share does not rank files by cost: DeepSeek V3.2 (27.6% Han) and Kimi K2.6 (42.5%) cost 707 and 780 on Chinese.

Partial tokens#

A partial token is one whose lone decode contains U+FFFD: it ends inside a character. Share of emitted tokens. DeepSeek V4.1, MiMo and Kanana were not run on the corpus. dedupe.py found their model, normalizer, pre-tokenizer and decoder sections identical to DeepSeek V3.2, Qwen 3 and Llama 3.2, so their counts here are inferred from the matching file. The fingerprint leaves out added tokens, which differ (DeepSeek 818 and 1,283, Llama and Kanana 256 and 259), and the post-processor, which matched in all three pairs (results/dedupe.json). Each pair’s id lists also hashed the same over a 3.5M-codepoint sample (results/tokenizers_versions.json).

FileChineseCantoneseJapaneseKorean
MiniMax M2.53.511.70.83.3
DeepSeek V3.2, V4.11.88.73.010.9
Qwen 3.81.912.90.52.4
XLM-RoBERTa0.00.00.00.0
LLM-jp-40.10.50.00.0
Tencent Hy311.827.57.815.3
Baichuan 20.10.50.10.2
Kimi K2.617.731.09.828.0
mT50.31.20.00.1
Qwen 2.5, Qwen 3, MiMo3.014.59.712.9
GLM-5.3, GLM-4.513.829.68.623.0
Gemma 3, Gemma 40.30.90.20.1
Yi 1.56.022.434.671.8
LLM-jp-30.10.80.03.6
OpenAI o200k, gpt-oss12.425.46.35.2
Llama 3.2, Kanana11.021.55.55.9
A.X K16.816.72.80.5
K-EXAONE7.918.24.20.7
Solar Open9.819.91.90.8
BERT base Chinese (lossy)0.00.00.00.0
Tekken, Nemotron 319.129.09.33.9
Stockmark-231.330.80.889.2
CALM324.024.60.981.0
InternLM 334.457.652.73.4
A.X 4.038.941.321.81.2
Sarashina 2.235.740.31.260.0
Mistral 7B27.942.916.516.4
HyperCLOVA X SEED53.866.036.68.6
OpenAI cl100k53.866.036.750.7
EXAONE 4.058.159.634.22.1

Measured 2026-11-04; same versions and corpora as token-cost.md; harness/1-033-3-cjk-tokenizers/results/summary.json.

What this means in practice:

  • Streaming. With cl100k_base, more than half of Chinese tokens cannot print alone. A client that writes each token as it arrives shows replacement characters unless it buffers incomplete bytes. Qwen 3.8 and DeepSeek still do it about 2% of the time on Chinese, so a client built on a low-partial file and never tested on Cantonese will meet it later: Qwen 3.8 rises to 12.9% there.
  • Token boundaries as text boundaries. Slicing at a token count can cut a character in half in any file above zero here. Slice on the decoded string or back up to a character boundary.
  • Some files rarely or never split a character. XLM-RoBERTa and BERT are at zero. mT5, Gemma, LLM-jp-4 and Baichuan sit near zero on Chinese.
  • Weakness shows up in the out-of-language column. Yi is at 71.8% on Korean and Stockmark-2 at 89.2%: almost everything falls to bytes.
S3: Need-Driven

S3 Approach: Six Situations and What Decides Each#

S1 and S2 judged files and engines for any reader. S3 asks, in six common situations, what decides the choice and what to check. Each situation is a kind of project found in many forms.

SituationCore constraintFile
A service paying per token on Chinese textToken bill and context windowuse-case-api-service-chinese.md
A retrieval pipeline chunking Japanese or Korean documentsChunk sizes that hold, and offsets back to sourceuse-case-rag-chunking-japanese-korean.md
A chat interface streaming CJK outputPrinting tokens that may split a characteruse-case-streaming-chat-interface.md
A catalog, archive or registry with rare charactersNothing lost: names, historical forms, variantsuse-case-names-and-historical-text.md
A team training its own vocabularyWhich trainer and settings for a mixed CJK corpususe-case-custom-llm-training.md
An offline or on-device applicationMemory and file sizeuse-case-mobile-offline.md

Each file gives who needs this, what goes wrong, requirements, options that survive, and what to check before committing. Evidence comes from S1 and S2, repeated with provenance where a number appears. S3 adds no measurement.


S3 Recommendation: Which Option for Which Situation#

SituationWhat decides itStart withCheck before committing
Paying per token on Chinese textCount times price, on your scriptThe count from your model’s file or the vendor’s endpointA month of real traffic against the bill
Chunking Japanese or KoreanChunk text length; offsets back to sourceThe reading model’s file, with splits on character boundariesCitations landing on the right span
Streaming CJK outputHow often tokens split charactersA byte-buffering client, whatever the fileA test string with Extension B and emoji
Rare characters and namesNo unknown tokens, no foldingFiles with byte fallback and no NFC or NFKC normalizerThe codepoints your collection holds
Training a vocabularyTrainer settings and memorySentencePiece with byte fallback, or Hugging Face byte-level BPE if memory allowsYour own text, including the languages left out of training
Offline or on-deviceFormat and memoryThe tokenizer embedded in your runtime, or a .model fileThe lowest device you support

Details and evidence are in each use-case-*.md file.

Three cross-cutting points#

  • The model usually comes first. Five of the six situations take the file as given and decide what to do around it. Training is the exception.
  • Normalize at your boundary. NFC ahead of the tokenizer removes the decomposed-Korean penalty of up to ten times in any file (measured 2026-11-04; kowiki sample; harness/1-033-3-cjk-tokenizers/results/summary.json). Skip this for archives where the original form is the record.
  • Keep the original string. Several situations break when decoded text stands in for the source.

Use Case: A Service Paying per Token on Chinese Text#

Who needs this#

A team running a customer-support assistant, search summarizer or document tool whose users write mostly Chinese, billed per token by a model vendor or limited by a context window on its own hardware.

The pain#

  • A budget built on an English characters-per-token ratio is wrong by a large margin. English Wikipedia ran 210 to 267 tokens per 1,000 codepoints across files exact on at least 99.99% of lines; Chinese ran 701 to 1,443 (measured 2026-11-04; Wikipedia dumps 20261001; harness/1-033-3-cjk-tokenizers/results/summary.json).
  • A model upgrade can move the bill with no code change. cl100k_base to o200k_base took off 32% on Chinese (same file).
  • A price per token and a tokens-per-character figure only mean something together. The cheapest count may sit on the most expensive token.

Requirements that follow#

  1. A count from the file the model uses, or from the vendor’s endpoint if none is published.
  2. A measurement on your own text, in your script: simplified, traditional or both.
  3. A count of the full request, with system prompt and tool definitions.

Options that survive#

OptionChinese corpus / all-traditional sample, tokens per 1,000 codepointsNotes
MiniMax M2.5 file701 / 753Lowest on Chinese in this sample
DeepSeek V3.2 file (V4.1 inferred from matching model parts)707 / 740Partial tokens about 1.8% on Chinese
Qwen 3.8 file728 / 757Partial tokens about 1.9%
Gemma 3 and Gemma 4 file804 / 811Little script penalty; LocalTokenizer names this file for some Gemini models
OpenAI o200k_base890 / 945Current OpenAI models map here
OpenAI cl100k_base1,314 / 1,401gpt-4 and gpt-3.5

Measured 2026-11-04; first figure from the 29.9M-codepoint zhwiki corpus, second from a 5M-codepoint sample converted to traditional by OpenCC 1.4.2; same file.

The table compares counts and not prices. Multiply by the vendor’s price per token, for input and output separately, before drawing a conclusion.

What to avoid#

  • Reading a low BERT count as cheap. It is lossy, and no current LLM in this sample uses it.
  • Using another model’s file as a proxy for a hosted model. Google’s LocalTokenizer names Gemma files for Gemini models but is marked experimental, and Anthropic publishes no file (S1-rapid/engines.md).
  • Chinese Wikipedia as your only test text. It mixes scripts and leans encyclopedic.

Check before committing#

  • Count a month of real traffic with the file, or a sample through the vendor’s endpoint, and compare with the bill.
  • Check the model name-to-encoding mapping at each upgrade, and re-count when it changes.
  • Confirm that the current price makes the lower count a lower bill.

Use Case: A Team Training Its Own Vocabulary#

Who needs this#

A team training a language model from scratch, or a small domain model, on text with a large CJK share, deciding which trainer to use and how to set it.

The pain#

  • Training defaults can lose or alter text. SentencePiece defaults to byte_fallback false and nmt_nfkc normalization (source: https://raw.githubusercontent.com/google/sentencepiece/master/doc/options.md, accessed 2026-11-04).
  • A trainer can run out of memory on a modest corpus. Hugging Face byte-level BPE ended at a 3G cap on 30M codepoints of Chinese, Japanese and Korean, and finished at 929 MB on 6M (measured 2026-11-05; tokenizers 0.23.3; harness/1-033-3-cjk-tokenizers/results/train/).
  • A vocabulary is permanent once a model trains on it. A mistake means retraining.

Requirements that follow#

  1. Every string encodable, by byte fallback or an accepted unknown token.
  2. A normalization decision made on purpose.
  3. Training memory that fits your machine.
  4. Coverage of the languages in the model’s future use, including English and code if it will meet them.

Options that survive#

See S2-comprehensive/training.md for the table.

OptionFits whenNotes
SentencePiece BPE with byte fallbackLowest Korean count among the trained models with no unknown tokens, at 98.3% of Korean lines exactNothing unknown; streaming needs buffering at a low rate
SentencePiece Unigram with byte fallbackThe same, with Unigram’s segmentationClose to BPE in count
Hugging Face BPE on charactersAn unknown token is acceptable and pieces must print aloneNo byte fallback, so rare text is lost; highest training memory of those that finished on 30M codepoints
Hugging Face byte-level BPEExact text matters and memory is availableThe only trained kind exact on every line; ended at the 3G cap on the larger set, and at 6M codepoints cost 737 on Chinese
SentencePiece with no byte fallbackRarelyUnknown tokens on 31.9% of Cantonese lines

All at 32,000 entries, as tested. A larger vocabulary was not trained here.

What to avoid#

  • Leaving nmt_nfkc in place if text must come back exact. All models here set normalization to identity.
  • Training on CJK alone for a model that will meet English: English cost 413 to 446 tokens per 1,000 codepoints on these models, against 210 to 267 for the published files (measured 2026-11-05; results/summary.json).
  • Treating a test on your training corpus’s own source as proof. Test lines were unseen here but came from the same Wikipedia dumps, which flatters every model.

Check before committing#

  • Train on your own corpus at your target size, and test on a different register.
  • Confirm your serving stack can read the format.
  • SentencePiece 0.2.3 adds auto_character_coverage and sparse pruning for vocabulary selection (read, not run), so compare them against the settings above before fixing a choice.
  • Check whitespace handling: SentencePiece models here failed on 0.4% to 7.7% of lines on whitespace alone, while the Hugging Face model did not.

Use Case: An Offline or On-Device Application#

Who needs this#

A developer shipping a local model, or local token counting, inside a phone or desktop application that must run without a network, in a Japanese or Chinese product.

The pain#

The tokenizer file and its in-memory structures are small next to weights, and easy to overlook in a tight budget. The same vocabulary can differ widely by format:

VocabularyFormatFile bytesAdded process memory on load (kB)
o200k.tiktoken through tiktoken3,613,92278,944
o200ktokenizer.json through Tokenizers27,868,174244,668
GemmaSentencePiece .model4,689,07454,636
Gemma 4tokenizer.json through Tokenizers32,169,626289,176
Mistral 7BSentencePiece .model493,44311,872
Mistral 7Btokenizer.json through Tokenizers1,795,18830,572
XLM-RoBERTaSentencePiece .model5,069,05164,704
XLM-RoBERTatokenizer.json through Tokenizers9,096,718343,948

Measured 2026-11-04; resident memory before and after loading one file in a fresh process on Python 3.13, aarch64 Linux, including the engine’s first import; harness/1-033-3-cjk-tokenizers/results/probes/. Desktop Python numbers, with the size relationship as the finding. A phone runtime will not match them.

Requirements that follow#

  1. The format your runtime reads. A local runtime usually embeds its tokenizer with the weights, in GGUF for llama.cpp for example (read, not run).
  2. Memory and package size within the budget.
  3. Local counting that matches the model.

Options that survive#

OptionNotes
The tokenizer embedded in the runtime’s model fileThe choice is the model’s; check the runtime’s encoder against the original on your text
SentencePiece runtime with a .model fileSmallest load in the table; SentencePiece 0.2.3 adds a zero-dependency runtime that reads a FlatBuffers format (vendor: https://github.com/google/sentencepiece/releases, accessed 2026-11-04), not tested here
tokenizer.json through @huggingface/tokenizers or the tokenizers-wasm candidateJavaScript and WebAssembly readers exist (read, not run)

What to avoid#

  • Assuming the two formats give the same result without checking. Mistral’s pair and OpenAI’s pair matched almost everywhere, while XLM-RoBERTa’s two formats disagreed on decomposed Korean (S2-comprehensive/engine-behavior.md).
  • Quoting load or encode timings from old sources. Speed on a phone is unmeasured in this survey.

Check before committing#

  • Measure load time, memory and encode speed on the lowest device you support.
  • Compare ids from the embedded tokenizer with the reference file over text in your language.
  • Check the app-store size impact of the file itself.

Use Case: A Catalog, Archive or Registry With Rare Characters#

Who needs this#

A library, genealogy service, government-records project or digital-humanities team whose text holds personal-name characters, historical forms, Classical Chinese or variant ideographs, where losing or folding a character changes a fact.

The pain#

  • Some files replace rare characters with an unknown token. XLM-RoBERTa does this to 42,719 of Extension B’s 42,720 characters, and BERT Chinese to all of them (measured 2026-11-04; each assigned codepoint encoded alone; harness/1-033-3-cjk-tokenizers/results/probes/).
  • Normalizers fold forms that may matter. NFC files such as Qwen and MiniMax kept 12 of 472 compatibility ideographs and turned the rest into their standard forms (same directory). NFKC goes further: Stockmark-2 and mT5 kept 0 of 214 Kangxi radicals.
  • Rare characters cost more. A character above the Basic Multilingual Plane is about four tokens in most files, five with a leading space piece, and Classical Chinese ran above modern Chinese in nearly every file.

Requirements that follow#

  1. No unknown tokens across the blocks your text uses.
  2. No folding of the forms you must keep.
  3. Round trip tested at the character, not the line.

Options that survive#

FileUnknown tokens on every CJK block testedKeeps compatibility ideographsClassical Chinese cost per 1,000 codepoints
OpenAI o200k, gpt-ossNoneYes1,082
DeepSeek V3.2 (V4.1 inferred from matching model parts)NoneYes920
Gemma 3, Gemma 4NoneYes942
Baichuan 2NoneYes921
LLM-jp-4NoneYes909
Qwen 3.8, MiniMaxNoneNo (NFC)919, 892

Measured 2026-11-04; same directory and results/summary.json; zh_classicalwiki 20261001, 6.7M codepoints.

Tokens per character is the lesser concern here. Baichuan 2 holds a whole token for all 3,008 GB2312 level-2 characters and 7,320 of Big5’s 7,652 less-frequent ones, and this reduces byte fallback on older text; it is also an older model.

What to avoid#

  • Assuming a token count reveals a loss. BERT’s count looks low because it has dropped the character.
  • Running NFC or NFKC over a source archive before tokenizing, and then writing the result back.

Check before committing#

  • Test the codepoints your collection holds, including ideographic variation sequences, which came back exact from every file but XLM-RoBERTa and BERT in the one string tested.
  • Check whether the model’s output preserves them. A tokenizer can round trip a character a model never produces; no model was run here.
  • Keep source text as the record and treat tokenized text as derived.

Use Case: A Retrieval Pipeline Chunking Japanese or Korean Documents#

Who needs this#

A team splitting manuals, contracts or wiki pages into chunks for embedding and retrieval, with chunk sizes set in tokens and citations that point back to the source text.

The pain#

  • A chunk size set in tokens holds a different amount of text per file. Among files exact on at least 99.99% of lines, costs run from 556 to 1,464 tokens per 1,000 codepoints on Japanese and from 471 to 1,873 on Korean (measured 2026-11-04; jawiki and kowiki dumps 20261001; harness/1-033-3-cjk-tokenizers/results/summary.json).
  • Cutting at a token boundary can cut a character: cl100k_base has 36.7% partial tokens on Japanese and 50.7% on Korean (same file).
  • A tokenizer with a normalizer can break the path back to the source. Stockmark-2’s NFKC changed 51.5% of Japanese lines, and mapping decoded text back to source offsets fails unless offsets come from the original string.
  • Decomposed Korean, common in text from macOS filesystems, costs up to ten times as much in files that do not normalize (S2-comprehensive/token-cost.md).

Requirements that follow#

  1. Chunk sizes set against the file of the model that will read the chunks.
  2. Splits on decoded character or sentence boundaries, with a token count as a limit and not as a cut point.
  3. Source offsets from the original string.
  4. NFC normalization ahead of the tokenizer, for ingest that takes files from many systems.

Options that survive#

LanguageLower costNotes
JapaneseLLM-jp-3 (556), MiniMax (579), Sarashina (589), LLM-jp-4 (589), CALM3 (593)Stockmark-2 is 520 and rewrites text with NFKC
KoreanA.X 4.0 (471), A.X K1 (490), Solar Open (502), LLM-jp-3 (503), K-EXAONE (505)Japanese-origin byte-level files without Hangul run above 1,500
Both in one corpusLLM-jp-3 (556, 503), LLM-jp-4 (589, 578), XLM-RoBERTa (667, 593)XLM-RoBERTa is not an LLM file and rewrites text

Measured 2026-11-04; tokens per 1,000 codepoints; same file. An embedding model has its own tokenizer, and 1.211 covers CJK embedding models.

What to avoid#

  • One global chunk size carried across a model change.
  • A chunk boundary that comes from slicing token ids.
  • Trusting decoded text as the citation source.

Check before committing#

  • Measure chunk text length at your size on your own documents, in each language you hold.
  • Verify that citations land on the right source span after normalization.
  • Test with decomposed input if files come from macOS or older pipelines.

Use Case: A Chat Interface Streaming CJK Output#

Who needs this#

A developer building a chat or completion interface that prints model output as it arrives, against a local or self-hosted model where the client handles token ids directly.

The pain#

A token can end inside a character. Printed alone, it shows U+FFFD. How often depends on the file and the language, and a test in one language can miss it entirely:

FileChineseCantoneseJapaneseKorean
OpenAI cl100k53.866.036.750.7
OpenAI o200k, gpt-oss12.425.46.35.2
Kimi K2.617.731.09.828.0
Qwen 3.81.912.90.52.4
DeepSeek V3.21.88.73.010.9
Gemma 3, Gemma 40.30.90.20.1
LLM-jp-40.10.50.00.0

Measured 2026-11-04; percent of tokens whose lone decode contains U+FFFD, on Wikipedia text and not on model output; harness/1-033-3-cjk-tokenizers/results/summary.json. A model’s generated text may differ from this mix.

Qwen 3.8 on modern Chinese looks close to safe, and rises to 12.9% on Cantonese. A client with no buffer passes a Mandarin demo and fails later.

Requirements that follow#

  1. A client that holds incomplete UTF-8 bytes until a character completes, for any byte-level or byte-fallback file.
  2. Tests in each script the product serves, including rare characters: an Extension B character costs about four tokens in most files, all of them partial.

Options that survive#

All files can stream correctly with a buffer. Tokenizers ships a DecodeStream decoder and tiktoken returns per-token bytes (read in each package’s source, not run). The harness tested whole-line decode and lone-token decode, and no incremental decoder.

What to avoid#

  • decode([id]) per token, joined and printed. It is correct on English, so the bug stays hidden until CJK text arrives.
  • Counting on a low-partial file for safety: LLM-jp’s Unigram files and Gemma’s character BPE are low on common text, and rare characters still reach their byte fallback.

Check before committing#

  • Stream a test string with Extension B, emoji joined by ZWJ and halfwidth katakana, and compare the concatenated output with the whole decode.
  • Confirm your serving layer’s behavior: hosted APIs usually send text deltas and handle this themselves. Check per vendor.
S4: Strategic

S4 Approach: What Can Change Under You#

A tokenizer’s long-term risk has three separate sources, and they call for different responses.

  1. The engine can change behavior or stop being maintained. The signals are release record, who commits, what a new major version promises, and whether ids hold across releases.
  2. The vocabulary moves with a model family. A new model name can bring a new file, and the cost can change at that boundary.
  3. Hosted counts can change with no file to diff.

Forecast percentages are left out: a five-year viability score carries no information a reader can check. The signals below are dated, and the release comparison in S2-comprehensive/engine-behavior.md is measured. Repository facts come from harness/1-033-3-cjk-tokenizers/results/library_facts.json, read 2026-11-04.


Engine Viability#

All counts are from harness/1-033-3-cjk-tokenizers/results/library_facts.json, read 2026-11-04 Pacific (2026-11-05 UTC, which is why a release can carry that date).

EngineLicenseLatest stableLast pushedLast 100 commits reach back toDistinct authors in thoseTop author’s share
huggingface/tokenizersApache-2.00.23.3, 2026-10-092026-11-042026-08-251257%
google/sentencepieceApache-2.00.2.3, 2026-11-052026-11-052026-09-081077%
openai/tiktokenMIT0.14.0, 2026-08-172026-08-172022-12-12 (79 commits, the whole public history)2565%
mistralai/mistral-commonApache-2.01.13.1, 2026-11-022026-11-042026-04-282175%
huggingface/transformersApache-2.05.22.1, 2026-10-302026-11-052026-10-304711%

Hugging Face Tokenizers#

The format is the asset. Twenty-nine of the 41 files in this sample are tokenizer.json, and transformers version 5 made this engine its default backend. Commercial backing and that dependency make abandonment an unlikely worry.

The live question is the 1.0 rewrite. The release notes promise the same token ids and say parity with 0.23 is still the milestone left, and rc.3 fixed load failures on regex normalizers used by NLLB and SentencePiece-converted models (source: https://github.com/huggingface/tokenizers/releases, accessed 2026-11-04). A team pinning the 0.23 line has time. S2-comprehensive/engine-behavior.md reports the comparison on this sample’s files; repeat it on your own before moving.

SentencePiece#

The 2026 record changes the picture of a finished library in slow maintenance. It shipped 0.2.2 in July with a binding rewrite and hardening, and 0.2.3 on 2026-11-05 removes long-deprecated API, raises the baseline to C++20 and Python 3.10, and adds a zero-dependency runtime that reads a new FlatBuffers format (source: https://github.com/google/sentencepiece/releases, accessed 2026-11-04). One maintainer does most of the work: 77 of the last 100 commits come from a single author. Google’s ownership and the installed base of .model files both argue for continued loading support. The risk to plan for is breakage from that cleanup, and the fact that vocabularies that began as SentencePiece also ship as tokenizer.json: Gemma 4 and LLM-jp-3 do. Yi, InternLM 3, Baichuan 2 and Sarashina were read here as .model files.

For training, it remains the tool with Unigram, character coverage and byte fallback as first-class options.

tiktoken#

Small, stable and narrow. It reads a simple vocabulary format, and that format has spread beyond OpenAI (Kimi K2, and Tekken through mistral-common). Changes between 0.9.0 and 0.14.0 are model names, wheels and performance, with no new encoding, and the public history is 79 commits since 2022. It is single-vendor in governance, though MIT licensing and the simplicity of the format make it easy to replace: gpt-tokenizer, js-tiktoken and the bpe crate read these vocabularies (read, not run), and tokenizers reads the o200k vocabulary converted into tokenizer.json, with identical ids on every line compared (measured 2026-11-04; harness/1-033-3-cjk-tokenizers/results/interop.json).

A reader’s lock-in risk here belongs to the vocabulary rather than the code. cl100k_base and o200k_base are tied to OpenAI’s models; the vocabulary cannot be swapped under a trained model at all.

mistral-common and vendor layers#

These exist because a vendor needs control over how special tokens and requests are assembled. They move with the vendor, on the vendor’s schedule. Using one is reasonable when you run that vendor’s models, and unreasonable as a general tokenizer.

Smaller engines#

YouTokenToMe is archived. BlingFire has had no release since 2021. TokenDagger and rs-bpe each show a burst of work in 2025 and nothing since. The bpe crate in github/rust-gems is active, but the Python binding on PyPI comes from a third party with 2 stars. Treat any of them as something to vendor and test, not something to depend on unattended.

Hosted counters#

There is nothing to maintain and nothing to pin. The provider can change the count, and Anthropic’s did, by about 30 percent across a model boundary (vendor: https://platform.claude.com/docs/en/build-with-claude/token-counting, accessed 2026-11-04). Budget code should treat a count as a property of a model name rather than as a constant, and re-measure when the name changes.


S4 Recommendation: Plan for the Vocabulary to Change#

The strategic finding#

Engine risk is low across the three main engines and vocabulary risk is high. Over the versions sampled here, a model family’s move changed the Chinese cost more than any engine decision could:

Family moveChinese beforeChinese afterChange
OpenAI, cl100k to o200k1,314890-32%
Qwen 3 to Qwen 3.8799728-9%
LLM-jp-3 to LLM-jp-4872753-14%
EXAONE 4.0 to K-EXAONE1,443900-38%
A.X 4.0 to A.X K11,181898-24%
DeepSeek V3.2 to V4.1707Not run; inferred0% inferred
Qwen 2.5 to Qwen 37997990%
Gemma 3 to Gemma 48048040%

Measured 2026-11-04; tokens per 1,000 codepoints on 29.9M codepoints of zhwiki; harness/1-033-3-cjk-tokenizers/results/summary.json. DeepSeek V4.1 was not run on the corpus: its model parts match V3.2’s and its ids hashed the same over a 3.5M-codepoint sample. Family moves do not always change the file, so check each one.

Anthropic documents a change of roughly 30 percent more tokens at the Claude 4.7 boundary, in the other direction (vendor: https://platform.claude.com/docs/en/build-with-claude/token-counting, accessed 2026-11-04).

What this asks for#

  • Treat a token count as a property of a model name. Store the model name next to any budget, chunk size or quota derived from a count.
  • Keep a small corpus of your own text and re-count at every model change. It takes minutes and catches both directions.
  • Pin the file by commit, not by repo name. Gemma 4 E4B’s repo was last modified on 2026-11-03, the day before this measurement. A moving branch means a moving count.
  • Do not depend on one vendor’s character ratio. Gemini’s rule of thumb of about 4 characters per token is not qualified by language (vendor: https://ai.google.dev/gemini-api/docs/tokens, accessed 2026-11-04), while Gemma’s own file gave about 1.5 codepoints per token on Japanese Wikipedia text (measured 2026-11-04; tokenizers 0.23.3; 29.5M codepoints; harness/1-033-3-cjk-tokenizers/results/summary.json).

Engine by engine#

EnginePosition on 2026-11-04Watch
Hugging Face TokenizersDefault backend of transformers 5; the format most open-weight files ship inThe 1.0 rewrite, in release candidates; run the comparison on your files
SentencePieceActive again after a quiet period, mostly one maintainerAPI removals in 0.2.3 and a new model format; the C++20 and Python 3.10 baselines
tiktokenSmall and stable, vendor-run, no new encoding since o200k_baseNothing in the engine; the risk is a future encoding or model mapping
mistral-commonVendor layer on the vendor’s scheduleUseful for Mistral models, not as a general counter
Smaller enginesSee engine-viability.mdVendor and test them; do not depend on them unattended

Sources: engine-viability.md; harness/1-033-3-cjk-tokenizers/results/library_facts.json, read 2026-11-04.

If you are training a vocabulary#

A trained file outlives the engine that built it only if another engine can read it. tokenizer.json and the .model format are both read by more than one engine (S2-comprehensive/engine-behavior.md), and Tekken and .tiktoken are simple enough to convert. Training itself is compared in S2-comprehensive/training.md.

What is not settled#

How much token cost should weigh against model quality is outside this survey. Output quality per tokenizer, and whether a vendor’s next encoding will spend more of its budget on CJK, are both unknown. OpenAI’s move from cl100k_base to o200k_base did; no one has announced the next one.

Published: 2026-11-05 Updated: 2026-11-05