Views
No views yet
cl100k_base and o200k_base, LLaMA-3's
SentencePiece BPE, and three SentencePiece Unigram variants — and is
the only tokenizer in this comparison that re-encodes every file to
byte-identical source.| Tokenizer | mean tok | bytes/tok | vs CUTE | roundtrip |
|---|---|---|---|---|
| CUTE | 1,767 | 4.42 | — | 1500 / 1500 |
| OpenAI cl100k_base | 1,874 | 4.17 | +6.0% | 1500 / 1500 |
| OpenAI o200k_base | 1,886 | 4.14 | +6.7% | 1500 / 1500 |
| LLaMA-3 (SentencePiece BPE) | 1,872 | 4.17 | +5.9% | 686 / 1500 |
| StarCoder2 | 2,210 | 3.53 | +25.1% | 685 / 1500 |
| XLM-RoBERTa (SentencePiece Unigram) | 2,438 | 3.20 | +38.0% | 0 / 1500 |
| CodeLlama | 2,573 | 3.03 | +45.6% | 1493 / 1500 |
| T5 (SentencePiece Unigram) | 2,706 | 2.89 | +53.2% | 0 / 1500 |
| GPT-2 | 3,581 | 2.18 | +102.7% | 1500 / 1500 |
vs CUTE is the extra cost the baseline pays per file. LLM API spend
is linear in this number.| Tokenizer | encode p50 | decode p50 |
|---|---|---|
| OpenAI cl100k_base | 1,338 µs | 120 µs |
| OpenAI o200k_base | 1,760 µs | 126 µs |
| CUTE | 1,822 µs | 263 µs |
| T5 (SentencePiece Unigram) | 3,121 µs | 479 µs |
| CodeLlama | 3,162 µs | 1,885 µs |
| XLM-RoBERTa (SentencePiece Unigram) | 3,272 µs | 440 µs |
| LLaMA-3 (SentencePiece BPE) | 3,753 µs | 792 µs |
| StarCoder2 | 4,316 µs | 775 µs |
| GPT-2 | 4,467 µs | 911 µs |
cl100k_base and o200k_base. v1.0.2's
cute-bpe Rust hot path runs ~6× faster than v1.0.1 on a short Python
sample (1,526 µs → 254 µs end-to-end; ~5× faster on the cargo bench
of the core encoder). On the full 1,500-file holdout median, CUTE
beats every open-source code tokenizer (LLaMA-3, StarCoder2,
CodeLlama, GPT-2, T5, XLM-RoBERTa) on both encode and decode latency,
while preserving the only byte-perfect 1500 / 1500 roundtrip in
the comparison.(self, =None, :\n) from a code corpus.U+F0000+). The BMP-PUA range
is deliberately skipped to avoid colliding with literal PUA
characters that appear in real source code.Ġ + ⟦def⟧).AddedTokens.cute-bpe, modeled on tiktoken's linear-scan-min-rank merge loop)
then performs the byte-level BPE pass.pip install cute-tokenizer1from cute_tokenizer import load_default_tokenizer
2
3tok = load_default_tokenizer()
4ids = tok("def hello(): return 42", add_special_tokens=False).input_ids
5text = tok.decode(ids, skip_special_tokens=True)
6assert text == "def hello(): return 42"BatchEncoding machinery is overhead,
use fast_encode / fast_decode — these go straight to the Rust
cute-bpe encoder/decoder:1ids = tok.fast_encode("def hello(): return 42")
2text = tok.fast_decode(ids)1from transformers import AutoTokenizer
2
3tok = AutoTokenizer.from_pretrained(
4 "HusseinEid/cute-tokenizer",
5 trust_remote_code=True,
6)
7ids = tok("class Foo: pass", add_special_tokens=False).input_ids
8text = tok.decode(ids, skip_special_tokens=True)trust_remote_code=True is required because the wrapper class
(CUTETokenizerFast) runs PUA pre-substitution before delegating to
the byte-level BPE encoder.tokenizer.json within a fixed
(OS, python, tokenizers, _accel, corpus_hash, seed) host triple.
Cross-platform byte-identity of trained artifacts is not part of
the contract.BPE,
decoder is ByteLevel, pre-tokenizer is ByteLevel, every mapping
PUA codepoint has a vocab id.1@software{cute_tokenizer_2026,
2 author = {Eid, Hussein},
3 title = {CUTE: Compact Unicode Token Encoding via Semantic-Anchored Byte-level BPE},
4 year = {2026},
5 url = {https://github.com/HusseinEid101/CUTE},
6 version = {1.0.2}
7}