Chunk by characters, and your token budget breaks the moment you switch corpora
One chunking configuration ran fine on the Chinese site: 2,000 characters per chunk, 200 characters of overlap, roughly 1,200 tokens. After moving to the English product line, retrieval quality barely changed but the bill and the context budget no longer lined up — the same configuration produces 396-token chunks on English text.
The parameters were not tuned wrong. The mistake is controlling a billing unit (the token) with a layout unit (the character): the conversion factor is decided by the corpus, not by your settings. Below is a measurement I ran locally.
Environment and samples
- Python with
tiktoken 0.14.0, encodingo200k_base - Chinese: 14 Markdown files from this site (4 articles plus chapter index pages), frontmatter and code blocks stripped, 16,700 characters
- English: every English page under
en/, same treatment, 17,042 characters - Code:
config.mtsplus all.vuecomponents in the theme directory, 79,603 characters - Chunking: fixed character length, 10% overlap, trailing chunks under 300 characters discarded
The sample is small (7–45 chunks per corpus) and the conclusion is about magnitude, not calibration. But a magnitude gap is enough to break your parameters.
Measured: same 2,000 characters, 3.3× different tokens
| Corpus | Characters | Tokens | Characters per token | Chunk p50 | p95 | max |
|---|---|---|---|---|---|---|
| Chinese technical docs | 16,700 | 10,769 | 1.55 | 1,297 | 1,345 | 1,395 |
| English docs | 17,042 | 3,454 | 4.93 | 396 | 417 | 419 |
| Front-end code | 79,603 | 26,852 | 2.96 | 656 | 736 | 1,056 |
(2,000-character chunks with 200-character overlap, values in tokens)
Three things follow:
- "1 token ≈ 4 characters" is an English rule of thumb; applied to Chinese it systematically underestimates. Chinese measured 1.55 characters per token, about 1/3.2 of English.
- The ratio drifts inside a single corpus too. Across the 14 Chinese files the token/character ratio ranges from 0.581 to 0.713 — files with more code blocks and tables sit lower, prose-heavy files higher. Even a per-corpus average cannot be used as a constant.
- Overlap drifts with it. 200 characters of overlap is 128 tokens in Chinese, 40 in English and 67 in code. The Chinese overlap band is 3.2× thicker: more expensive, and more likely to drag a neighboring chunk's answer into context.
Three hard thresholds punched through
These differences are not a feeling; they trigger concrete failures.
① The minimum cacheable length for prompt caching is 1,024 tokens (models from GPT-5.6 onward, per the official docs; hidden system content excluded). With 2,000-character chunks, all 10 English chunks fall below 1,024 and the prefix never enters the cache, while 9 of 10 Chinese chunks clear it. Same configuration: one side never hits, the other mostly does. Conclusions like "caching does nothing on the English site" usually come from exactly this.
② If the downstream embedding model or context window is in the 512-token range, an 800-character Chinese chunk already has p50 527 — over the limit — while a 2,000-character English chunk is only 396. Defining parameters in characters hands control of the real chunk length to the language.
③ The chance that a chunk boundary cuts an answer apart also varies by corpus. A thinner overlap band means higher risk. 200 characters of overlap is a 128-token semantic buffer in Chinese and only 40 tokens in English; "200 overlap" is not the same thing on two corpora.
The fix: make the token the only unit
Replace character parameters with token parameters and chunk directly over the tokenizer's id sequence instead of slicing characters first:
import tiktoken
enc = tiktoken.get_encoding("o200k_base")
ids = enc.encode(text) # encode the whole document first
N, O = 800, 80 # target 800 tokens, 80 tokens of overlap
for s in range(0, len(ids), N - O):
chunk = enc.decode(ids[s:s + N]) # decode back to text before indexing
yield chunkThe key move: encode the whole document into ids, slice by id, then decode back to text. Now "N tokens" is a hard constraint independent of corpus, and O is in token terms too, identical across languages. Slicing can leave a truncated character at either end, so in production walk back a few tokens to a punctuation boundary.
How to set the numbers: take 200 real samples, measure your corpus's token/character ratio, then back out characters as chunk tokens = target budget ÷ ratio — for validation only, never as the chunking basis. Then put 1,024 (cache) and the downstream window (embedding or context) into config validation and alert when a chunk exceeds them. Different models tokenize differently, so o200k_base is only good for budget estimation; re-measure on your own samples before freezing parameters.
Closing
Characters are a layout unit; tokens are the billing and context unit. Chunking by characters hands the interpretation of your budget to the corpus itself, so a language switch drifts it 3×. There is only one stable approach: chunking, overlap and budget validation all measured in tokens; the character count is for human eyes only.