tokenize.rs

TokShop @ ICML 2025 ยท arXiv 2505.24689

BPE Stays on SCRIPT

Sander Land, Catherine Arnett

๐Ÿ† Best Paper, TokShop @ ICML 2025

Read the paper on arXiv ↗

BPE penalizes non-Western scripts, creates tokens full of broken UTF-8 fragments, and relies on brittle regex pretokenization. SCRIPT addresses all three.

Diagram: UTF-8 uses 1 to 4 variable bytes per character while SCRIPT uses a uniform block and index token pair; different scripts share leading UTF-8 bytes; one bad merge cascades into partial byte sequences.
UTF-8 penalizes non-Latin scripts and splits characters apart. SCRIPT gives every character a clean two-token pair.

The problem

Most tokenizers split text with English-centric regex rules that misfire on other languages, then encode it as UTF-8 bytes. A Latin letter costs one byte, Greek costs two, and most CJK characters cost three, so non-Latin scripts pay a structural penalty. Greedy merges also leave tokens holding partial, meaningless byte fragments; GPT-4o's vocabulary has 874 of them.

What we do

SCRIPT (Script Category Representation in PreTokenization) drops UTF-8 conversion. It represents every character as a fixed pair of tokens: a block token from the character's Unicode script and category, plus an index token. Every character then costs exactly two tokens, and pretokenization becomes a simple rule that follows script boundaries. A constrained merging strategy forbids merges that would split characters, which drives invalid tokens to zero and also works for ordinary byte-based BPE.

Why it matters

SCRIPT-BPE stays competitive on compression while flattening the encoding cost to about two tokens per character for every script, rather than the one-to-three-byte premium that penalizes non-Latin languages. It does not always beat byte-based BPE on raw compression, but it removes the built-in unfairness and the garbage tokens, giving multilingual models a cleaner foundation.

Read the paper on arXiv ↗ Browse the code ↗