Abzalbek89/kk-tokenizer-fertility-baseline
Kazakh Tokenizer Fertility Baseline Reproducible fertility benchmark of subword tokenizers on the Kazakh language. Companion artifact for the paper "Tokenizer Optimization for Kazakh Small Language Models" (in preparation, target: ACM TALLIP). Headline numbers Tokenizer Fertility ๐ฅ Best overall kk-bpe-32k 1.679 ๐จ Worst GPT-4 (cl100k) 5.895 GPT-4 penalty GPT-4 (cl100k) is 3.51ร worse than the best Kazakh-trained tokenizer โ The custom Kazakhโฆ See the full description on the dataset page: https://huggingface.co/datasets/Abzalbek89/kk-tokenizer-fertility-baseline.
Kazakh Tokenizer Fertility Baseline
Reproducible fertility benchmark of subword tokenizers on the Kazakh language. Companion artifact for the paper "Tokenizer Optimization for Kazakh Small Language Models" (in preparation, target: ACM TALLIP).
Headline numbers
โ The custom Kazakh BPE tokenizer is 3.51ร more efficient than GPT-4 for Kazakh text, which translates to ~72% lower API cost and ~3.5ร longer effective context window.
Full ranking (13 tokenizers)
Ours โ Kazakh-trained, no morphology pre-segmentation
Ours โ Kazakh-trained, morphology-aware (Morfessor โ tokenizer)
Reference โ multilingual / industry tokenizers
Methodology
Held-out evaluation set: 2,966,207 whitespace-words (โ15K documents) from the validation split of `Abzalbek89/corpus_clean`.
Metrics:
- Fertility = total tokens / total whitespace-words (lower is better).
- Compression (chars/token) = total characters / total tokens (higher is better).
- Compression (bytes/token) = total UTF-8 bytes / total tokens (higher is better).
Trained tokenizers (vocab = 32,000, all share the same training corpus):
kk-bpe-32kโ HF tokenizers ByteLevel BPEkk-sp-bpe-32kโ SentencePiece BPE (character_coverage=1.0, NFKC)kk-sp-unigram-32kโ SentencePiece Unigramkk-hf-unigram-32kโ HF tokenizers Unigram with ByteLevel pre-tokkk-morph-hf-bpe-32kโ HF BPE on Morfessor-segmented corpuskk-morph-hf-unigram-32kโ HF Unigram on Morfessor-segmented corpuskk-morph-sp-unigram-32kโ SentencePiece Unigram on Morfessor-segmented corpus
Reference tokenizers: mBERT, XLM-R, Llama-3, Qwen 2.5, GPT-4 (cl100k_base), GPT-4o (o200k_base).
Files
Reproducing
On a vast.ai / RunPod / Colab instance with โฅ30GB disk and โฅ16GB RAM:
pip install 'datasets>=2.14' 'transformers>=4.45' 'tokenizers>=0.20' \
'sentencepiece>=0.2.0' 'huggingface_hub>=0.25' \
tiktoken matplotlib morfessor
export HF_TOKEN=hf_... # write access
export HF_USER=Abzalbek89
curl -fsSL -o experiment_morph.py \
https://huggingface.co/datasets/Abzalbek89/kk-tokenizer-fertility-baseline/resolve/main/experiment_morph.py
python experiment_morph.pyTotal runtime: ~30 min on cached Morfessor model, ~70 min cold start.
Companion tokenizer repos
- `Abzalbek89/kk-tokenizer-bpe-32k`
- `Abzalbek89/kk-tokenizer-sp-bpe-32k`
- `Abzalbek89/kk-tokenizer-sp-unigram-32k`
- `Abzalbek89/kk-tokenizer-hf-unigram-32k`
- `Abzalbek89/kk-tokenizer-morph-hf-bpe-32k` ยน
- `Abzalbek89/kk-tokenizer-morph-hf-unigram-32k` ยน
- `Abzalbek89/kk-tokenizer-morph-sp-unigram-32k` ยน
ยน Morphology-aware variants โ apply Morfessor (morfessor.bin in this repo) before encoding.
Citation
@misc{kk_tokenizer_fertility_2026,
title = {Kazakh Tokenizer Fertility Baseline},
author = {Abzalbek Ulasbek},
year = {2026},
howpublished = {\url{https://huggingface.co/datasets/Abzalbek89/kk-tokenizer-fertility-baseline}},
}License
Apache 2.0
Last updated: fertilityv3.csv (13 tokenizers)_
