NIRVLab β MorpheL Tokenizer for Chinese XNLI
MorpheL: MI-Guided Stochastic Segmentation tokenizer for morphologically rich low-resource languages (Proposal: MorpheL: Morphology-Aware Tokenizer Adaptation for Pretrained Models in Low-Resource Languages).
Trained on the Chinese (zh) subset of
facebook/xnli β all splits.
Algorithm
MorpheL scores candidate intra-word boundaries via pointwise mutual information (MI) between prefix and suffix substrings, then stochastically selects the number of cuts via Gumbel perturbation (Eq. 6β8).
Chinese-specific design choice: ZH_VOWELS = β
(empty set). The vowel-consonant
transition heuristic (Proposal Β§5.1 Step 1) returns False for all positions in
pure Hanzi text, so B(w) = β
for all Hanzi words β segment_word returns [word]
(no cuts). This is correct: Chinese Hanzi do not have a Latin vowel/consonant
distinction to exploit for morpheme boundary detection. The vocabulary is built
from whole-token Hanzi sequence frequencies (32k slots), plus a character-level
overflow alphabet for guaranteed -free encoding.
Training Config
| Parameter | Value |
|---|---|
| Algorithm | MorpheL (MI + Gumbel) |
| Vocabulary size | 34,276 |
| top_k | 4 |
| temperature (T) | 1.0 (vocab induction: T=0) |
| mi_threshold | 0.0 (keep MI > 0) |
| min_frequency | 2 |
| Special tokens | <s>, <pad>, </s>, <unk>, <mask> |
| Corpus | facebook/xnli/zh β all splits (800,404 sentences) |
| Vowel set | Empty (ZH_VOWELS=β
) β no boundary detection for Hanzi |
Evaluation Metrics (vs Baselines, vocab_size=32000, same corpus)
| Metric | BPE | WordPiece | Unigram | MorpheL |
|---|---|---|---|---|
| Fertility β | β | β | β | 12.5866 |
| Tokens/char β | β | β | β | 0.6031 |
| Avg seq len β | β | β | β | 17.01 |
| Vocab coverage β | β | β | β | 1.0000 |
| OOV rate β | β | β | β | 0.0000 |
Fill baseline columns after running baseline notebooks.
Usage
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("NIRVLab/xnli-morphel-zh-32k")
Note: MorpheL segments words before passing to the tokenizer. For Chinese,
segment_wordreturns[word]for all Hanzi tokens (no cuts). Downstream training usestemperature=1.0for stochastic segmentation; inference usestemperature=0(deterministic).