This repository contains a comprehensive collection of pre-trained tokenizers for the Tatar language. We provide four different tokenization algorithms (WordPiece, Unigram, BPE, and BBPE) with multiple vocabulary sizes (25k and 50k), trained on a large Tatar corpus. All tokenizers achieve 0% unknown rate on test data and are ready to use with the tokenizers library or Hugging Face Transformers.
📦 Available Tokenizers
The following tokenizers are included:
Tokenizer
Type
Vocab Size
Compression Ratio
Speed (tokens/sec)
Notes
wp_50k
WordPiece
50,000
4.67
378,751
Best overall balance
wp_25k
WordPiece
25,000
4.36
496,273
Fastest tokenizer
uni_50k
Unigram
50,000
4.59
189,623
Probabilistic model
uni_25k
Unigram
25,000
4.30
260,403
Good for smaller vocab
bpe_50k
BPE
50,000
4.60
247,421
Standard BPE
bpe_50k_freq5
BPE
50,000
4.60
226,591
Higher frequency threshold
bbpe_50k
BBPE
50,000
4.60
227,322
Byte-level BPE
bbpe_25k
BBPE
25,000
4.28
257,104
Compact byte-level
bbpe_fixed_50k
BBPE*
50,000
5.17
315,922
Best compression ratio
bpe_fixed_50k
BPE*
50,000
4.75
337,247
Fast BPE variant
* Fixed versions with improved Unicode handling
Key observations:
All tokenizers except bpe_fixed_50k achieve 0% unknown rate on test data
bbpe_fixed_50k offers the best compression (5.17 chars/token)
wp_25k is the fastest (nearly 500k tokens/second)
WordPiece models provide the most human-readable tokens
📁 Repository Structure
The files are organized in subdirectories for each tokenizer type and size:
You can easily convert any tokenizer to Hugging Face format:
python
1from transformers import PreTrainedTokenizerFast
23hf_tokenizer = PreTrainedTokenizerFast(4 tokenizer_object=tokenizer,5 unk_token='[UNK]',6 pad_token='[PAD]',7 cls_token='[CLS]',8 sep_token='[SEP]',9 mask_token='[MASK]'10)1112# Now you can use it with any transformer model
Download All Files for a Specific Tokenizer
python
1from huggingface_hub import snapshot_download
23# Download all files for WordPiece 50k4model_path = snapshot_download(5 repo_id="TatarNLPWorld/TatarTokenizer",6 allow_patterns="tokenizers/wordpiece/50k/*",7 local_dir="./tatar_tokenizer_wp50k"8)
📊 Evaluation Results
We conducted extensive testing on a held-out corpus of 10,000 documents (19.5 million characters). Here are the key findings:
Best Tokenizers by Category
Category
Winner
Value
Best Compression
bbpe_fixed_50k
5.17 chars/token
Fastest
wp_25k
496,273 tokens/sec
Best Overall
wp_50k
Balanced performance
Most Readable
WordPiece family
Human-readable tokens
Performance Summary
All tokenizers (except bpe_fixed_50k) achieve:
0% unknown rate on test data
100% word coverage for common vocabulary
Compression ratios between 4.28 and 5.17
Visualizations
The repository includes comprehensive evaluation visualizations in the test_results/ folder:
Comparison plots showing unknown rate, compression ratio, and speed by tokenizer type
Token length distributions for each best-in-class tokenizer
Correlation matrices between different metrics
Top-10 rankings by composite score
Both Russian and English versions of all plots are available.
🧪 Test Results Summary
Model
Type
Unknown Rate
Compression
Word Coverage
Speed (tokens/sec)
wp_50k
WordPiece
0.0000
4.67
1.0000
378,751
wp_25k
WordPiece
0.0000
4.36
1.0000
496,273
uni_50k
Unigram
0.0000
4.59
1.0000
189,623
uni_25k
Unigram
0.0000
4.30
1.0000
260,403
bpe_50k
BPE
0.0000
4.60
1.0000
247,421
bbpe_fixed_50k
BBPE_fixed
0.0000
5.17
1.0000
315,922
🎯 Recommendations
Based on our evaluation, we recommend:
For BERT-like models: Use wp_50k (WordPiece) - best balance of readability and performance
For maximum speed: Use wp_25k - fastest tokenizer, ideal for high-throughput applications
For maximum compression: Use bbpe_fixed_50k - most efficient tokenization
For GPT-like models: Use bpe_50k or bbpe_50k - compatible with modern LLM architectures
For research: All tokenizers are provided for comparative studies
📝 License
All tokenizers are released under the MIT License. You are free to use, modify, and distribute them for any purpose, with proper attribution.
🤝 Citation
If you use these tokenizers in your research, please cite:
bibtex
1@software{tatartokenizer_2026,
2 title = {TatarTokenizer: A Comprehensive Collection of Tokenizers for the Tatar Language},
3 author = {Arabov, Mullosharaf Kurbonvoich},
4 year = {2026},
5 publisher = {Kazan Federal University},
6 url = {https://huggingface.co/TatarNLPWorld/TatarTokenizer}
7}
🌐 Language
All tokenizers are trained on Tatar text and are intended for use with the Tatar language (language code tt). They handle Tatar-specific characters perfectly (ә, Ә, ү, Ү, җ, Җ, ң, Ң, һ, Һ, ө, Ө).
🙌 Acknowledgements
These tokenizers were trained and evaluated by TatarNLPWorld as part of an effort to advance NLP resources for the Tatar language. We thank the open-source community for the tools and libraries that made this work possible.
Special thanks to the Hugging Face team for the tokenizers library and the Hugging Face Hub platform.