Downloads · 30 days
0
chhatramani/nyayalm-tokenizer-64k_v2
nyayalm-tokenizer-64k_v2 is a text generation model from chhatramani. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
SentencePiece-BPE tokenizer (exact vocabulary size 64,000) designed for NyayaLM-200M, a bilingual (Nepali + English) legal-domain language model.
Downloads · 30 days
0
Access
Public
Updated Jul 27, 2026
Repo size
1.3 MB
Likes
0
Public
Click a slice to open those files.
.json8.3 MB · 77%
From the Hugging Face model README
SentencePiece-BPE tokenizer (exact vocabulary size 64,000) designed for NyayaLM-200M, a bilingual (Nepali + English) legal-domain language model.
It is optimized for:
| Feature | Value |
|---|---|
| Vocabulary size | 64,000 |
| Algorithm | SentencePiece BPE + byte fallback |
| Character coverage | 0.9995 |
| Special tokens | ChatML (`< |
| Pre-tokenizer | Metaspace (▁) |
| Normalization | Identity (no aggressive NFKC) |
| Split digits / numbers | Yes |
| Split by Unicode script | Yes |
| Byte fallback | Enabled |
The tokenizer was trained without any hardcoded seed symbols — the entire alphabet (Devanagari + Latin + digits + punctuation) is learned purely from the bilingual legal + general corpus.
A carefully balanced bilingual corpus was constructed from the following sources (streaming + deduplication via BLAKE2b):
≈ 885k documents · ~1.33 billion characters
≈ 2.40 million documents · ~1.22 billion characters
Final training corpus after balancing & interleaving:
We evaluated the tokenizer against strong baselines on four language categories:
Primary metrics (lower fertility & higher STRR are better):
| Metric | Description | Direction |
|---|---|---|
| Fertility | Tokens per whitespace-delimited word | ↓ better |
| Characters per token | Compression efficiency | ↑ better |
| STRR | Single-Token Retention Rate (% of words kept intact) | ↑ better |
| Tokenizer | Fertility ↓ | Chars/Token ↑ | STRR ↑ |
|---|---|---|---|
| Custom (nyayalm-64k) | 1.483 | 4.294 | 0.709 |
| Gemma-4 | 1.536 | 4.102 | 0.495 |
| GPT-OSS-20B (o200k_harmony) | 1.600 | 3.962 | 0.448 |
| GPT-5 (o200k) | 1.600 | 3.962 | 0.448 |
| Llama-3.2 | 2.102 | 3.265 | 0.414 |
| Qwen3.5 | 2.329 | 3.126 | 0.408 |
| Claude (approx) | 3.252 | 2.779 | 0.393 |
| Tokenizer | English | Mixed | Nepali | Roman_Nepali |
|---|---|---|---|---|
| Custom (nyayalm-64k) | 1.131 | 1.135 | 1.252 | 2.417 |
| Gemma-4 | 1.131 | 1.099 | 1.769 | 2.147 |
| GPT-5 (o200k) | 1.147 | 1.157 | 1.823 | 2.272 |
| GPT-OSS-20B (o200k_harmony) | 1.147 | 1.157 | 1.823 | 2.272 |
| Llama-3.2 | 1.189 | 1.471 | 3.311 | 2.437 |
| Qwen3.5 | 1.189 | 1.587 | 4.179 | 2.362 |
| Claude (approx) | 1.172 | 1.984 | 7.277 | 2.573 |
| Tokenizer | English | Mixed | Nepali | Roman_Nepali |
|---|---|---|---|---|
| Custom (nyayalm-64k) | 0.869 | 0.865 | 0.816 | 0.283 |
| Gemma-4 | 0.756 | 0.768 | 0.243 | 0.213 |
| GPT-5 (o200k) | 0.675 | 0.712 | 0.218 | 0.188 |
| GPT-OSS-20B (o200k_harmony) | 0.675 | 0.712 | 0.218 | 0.188 |
| Llama-3.2 | 0.675 | 0.708 | 0.084 | 0.188 |
| Qwen3.5 | 0.675 | 0.708 | 0.059 | 0.188 |
| Claude (approx) | 0.656 | 0.688 | 0.040 | 0.188 |
Key takeaways:
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("chhatramani/nyayalm-tokenizer-64k_v2")
# Simple encode / decode
text = "नेपालको संविधान २०७२ ले नागरिकलाई मौलिक हक प्रदान गरेको छ।"
ids = tok.encode(text, add_special_tokens=False)
print(len(ids), tok.decode(ids))
# ChatML conversation
messages = [
{"role": "system", "content": "You are a helpful Nepali legal assistant."},
{"role": "user", "content": "मेरो मौलिक हक के के हुन्?"},
]
prompt = tok.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
print(prompt)
Pythonprint(tok.convert_tokens_to_ids("<|endoftext|>")) # 63982
print(tok.convert_tokens_to_ids("<|im_start|>")) # 63983
print(tok.convert_tokens_to_ids("<|im_end|>")) # 63984
print(len(tok))
If you use this tokenizer in your research or product, please cite:
bibtex@misc{nyayalm-tokenizer-64k-v2,
title = {NyayaLM 64k SentencePiece-BPE Tokenizer},
author = {Chhatramani},
year = {2026},
url = {https://huggingface.co/chhatramani/nyayalm-tokenizer-64k_v2}
}
Apache License 2.0