BPE Stays on SCRIPT: Structured Encoding for Robust Multilingual Pretokenization

Sander Land, Catherine Arnett

TL;DR

Byte Pair Encoding (BPE) inherently discriminates against non-Western languages due to UTF-8 byte length disparities and regex edge cases. SCRIPT-BPE replaces raw bytes with a structured two-token Unicode representation (script/category block + index), paired with a rule-based pretokenizer and a constrained merging algorithm. This setup eliminates cross-character partial merges, removes the "byte premium" on non-Latin scripts, and achieves competitive compression across languages without complex regular expressions.

What Problem Does This Paper Address?

Standard Large Language Model (LLM) tokenization relies on Byte-level BPE, which introduces three major flaws:

  1. The "Byte Premium": In UTF-8, Latin characters require only 1 byte, whereas Greek, Arabic, Indic, and CJK characters require 2 to 4 bytes. Non-Latin scripts start at an immediate length disadvantage before merging even begins.
  2. Partial-Character Artifacts: Greedy BPE merges often cross character boundaries, pairing a full character (like a space) with only the first byte of a multi-byte character. This creates invalid or semantically meaningless fragments (e.g., GPT-4o has 874 partial-byte tokens) that can lead to under-trained token representations.
  3. Fragile Pretokenization: Regex-based splitters (like those in GPT-2 and GPT-4) are heavily tailored to English contractions and whitespace. In other languages, these patterns often split words at diacritics (e.g., in Hindi or Punjabi) or break word boundaries.

Methods

The authors introduce an end-to-end alternative called SCRIPT-BPE:

  • SCRIPT Encoding: Bypasses UTF-8 conversion entirely. Each Unicode character is represented by exactly two tokens: a block token and an index token.
  • Characters are partitioned by Unicode Script (e.g., Latin, Han, Cyrillic) and five grouped Supercategories: Letters & Marks (LM), Punctuation & Symbols (PS), Numbers (N), Separators (Z), and Other (C).
  • Blocks larger than the size of Latin letters/marks (1,448 characters) are divided into sub-blocks. This produces a fixed base vocabulary of 468 block tokens and 1,448 index tokens.
  • Rule-Based Pretokenization: Groups consecutive characters sharing the same script and supercategory. It merges single leading spaces with words, attaches "Inherited" script characters (such as combining diacritics) to their host script, and groups Han and Hiragana characters together for Japanese.
  • Constrained BPE Merging: Restricts the merge search space so that merges may only occur within a single character (joining block + index) or between tokens that already represent complete characters. This completely prevents cross-character boundary pollution.

Datasets

  • Monolingual Evaluation: 300 MB subsets across 12 diverse languages/scripts (Japanese, Chinese, Thai, Punjabi, Hindi, Korean, Russian, Arabic, Hebrew, Vietnamese, German, English) sourced from the Goldfish dataset, trained to a 64,000-token vocabulary.
  • Multilingual Evaluation: A 35 GB subsample of CulturaX for training (trained to 256,000 merges) and a 136 GB validation split.

Key Insights and Ideas

  • Constraining merges is universally beneficial: Restricting merges to respect character boundaries not only drops partial-character tokens to zero, but it also improves final compression ratios and slightly reduces training time by shrinking the search space.
  • Equal initial footings for all scripts: By representing every single character as exactly 2 initial tokens, SCRIPT eliminates the inherent bias where multi-byte scripts take up to 4× as many initial tokens as ASCII text.
  • Diacritic preservation fixes massive regressions: Popular tokenizers like GPT-4's cl100k severely degrade compression in Indic scripts because their regexes separate vowel marks and diacritics from consonants. SCRIPT's "Inherited Script Merging" rule keeps diacritics unified by design.

Key Results

  • Partial Characters Eradicated: In SCRIPT-BPE, tokens containing partial characters dropped from 6,048–8,062 down to 0. In byte-based BPE, constrained merging reduced partial tokens from over 5,000 to ~200 (and averted a failure mode in Thai where unconstrained BPE generated 42,831 partial tokens).
  • Compression Parity:
  • SCRIPT with rule-based pretokenization achieved a mean monolingual validation compression of 0.3812 tokens/character, outperforming cl100k (0.4090) and matching GPT-4o's o200k (0.3765).
  • In Indic and Southeast Asian languages, SCRIPT drastically outperformed cl100k: Hindi dropped from 0.5057 to 0.3233 tokens/char, Thai from 0.4257 to 0.3362, and Punjabi from 0.6053 to 0.4962.
  • Training Throughput: Despite boundary checks, parallel training on 16 CPUs completed 256,000 merges on the 35 GB dataset in roughly 1 hour.

Limitations and Future Work

  • Trailing Complex Regexes on Specific Languages: SCRIPT lags slightly behind OpenAI’s fine-tuned o200k regex on Chinese (0.6537 vs. 0.6259 tokens/char) and Thai, largely due to unsegmented whitespace patterns and mixed Chinese/Latin web text.
  • Downstream LM Impact Untested: The evaluation focuses solely on token compression and encoding consistency; training end-to-end language models to verify gains in perplexity and reasoning remains future work.
  • Refining Digits and Punctuation: Future iterations plan to refine digit and symbol handling to match performance gains seen in arithmetic-specialized tokenizers.

Summary updated

BibTeX
@inproceedings{land2025bpe,
  author = {Sander Land and Catherine Arnett},
  title = {{BPE Stays on SCRIPT: Structured Encoding for Robust Multilingual Pretokenization}},
  booktitle = {TokShop @ ICML},
  year = {2025},
  url = {https://openreview.net/forum?id=AO78CqwaUO},
}
Figure