๐ฒ๐ฟ Mizo M-BPE Tokenizer (Morphology-Guided BPE)
A production-grade, morphology-aware subword tokenizer for the Mizo language (lus_Latn), combining a linguistic morphological pre-segmenter with trained SentencePiece Byte-Pair Encoding (BPE).
๐ Key Highlights
- 0% Root Mutilation: Guaranteed preservation of native root morphemes (e.g.
zirtirtu$\to$['zir', 'tir', 'tu'],darthlalang$\to$['dar', 'thla', 'lang']). - 35.5% Token Efficiency Gain: Fertility reduced from 2.14 (Meta NLLB-200) down to 1.38 tokens/word.
- Higher Compression: 4.31 bytes/token (vs. 2.78 bytes/token for NLLB-200).
- English Loanword Shield: Protects borrowed words (
bulletin,mountain,cheetah,computer) from false suffix peeling. - Code-Switching Support: Robustly handles hybrid code-switching forms (e.g.
school-ah,WhatsApp-in). - Dual Tone Normalization: Supports both
strict(preserving tone diacritics รข, รช, รฎ, รด, รป) andcanonical(for dense downstream transfer) while strictly preserving consonantแนญ/แนฌ.
๐ Quickstart
from transformers import AutoTokenizer
# Load tokenizer directly from Hugging Face Hub
tokenizer = AutoTokenizer.from_pretrained("Larsson31/mizo-tokenizer", trust_remote_code=True)
# 1. Tokenize into subword pieces
sentence = "Zirlaite chu school-ah an kal a, zirtirtu chuan lehkha a zirtir a."
tokens = tokenizer.tokenize(sentence)
print("Tokens:", tokens)
# -> ['_Zirlai', '_te', '_chu', '_school', '_-', '_ah', '_an', '_kal', '_a', '_,', '_zir', '_tir', '_tu', '_chuan', '_lehkha', '_a', '_zir', '_tir', '_a', '_.']
# 2. Encode to PyTorch / Transformers inputs
inputs = tokenizer(sentence, return_tensors="pt")
print("Input IDs:", inputs["input_ids"])
# 3. Exact lossless reconstruction
reconstructed = tokenizer.decode(inputs["input_ids"][0], skip_special_tokens=True)
print("Decoded:", reconstructed)
# -> "Zirlaite chu school-ah an kal a, zirtirtu chuan lehkha a zirtir a."
๐ Benchmark Comparison
| Metric | Meta NLLB-200 (lus_Latn) |
MWirelabs/mizo-roberta | Ours (M-BPE) |
|---|---|---|---|
| Vocab Size | 256,204 | 30,000 | 16,000 |
| Fertility Rate (tokens/word) | 2.14 | 1.82 | 1.38 (๐ฅ -35.5%) |
| Compression (bytes/token) | 2.78 | 3.25 | 4.31 |
| Root Mutilation Rate | 18.4% | 12.1% | 0.0% (Perfect) |
| Loanword False Peeling | Yes | Yes | 0.0% (Protected) |
๐ Citation
If you find this tokenizer helpful in your research or applications, please cite:
@software{mizo_mbpe_tokenizer,
author = {Larsson & Antigravity AI},
title = {M-BPE: Morphology-Aware Subword Tokenizer for the Mizo Language},
year = {2026},
url = {https://github.com/LarssonCodes/Mizo-Tokenizer}
}