A fast encoder tagger that segments Classical Tibetan into words, tags each word with one of 14
parts of speech, splits off fused particles such as the genitive 'i in pa'i, and marks
sentence breaks. It is built on
mmbert-tibetan-wylie-base (136M
parameters) and labels every syllable in a single forward pass. It produces the full_analysis
fields of the Tibetan texts in DharmaNexus.
Input must be Wylie (EWTS), not Tibetan Unicode. Convert Unicode Tibetan with an EWTS converter
(for example pyewts) first.
The model has its own small inference class, tibetan_tagger.py, which is included in this
repository. It needs transformers, torch and safetensors.
import sys
from huggingface_hub import snapshot_download
path = snapshot_download("buddhist-nlp/mmbert-tibetan-wylie-tagger")
sys.path.insert(0, path)
from tibetan_tagger import TibetanTagger
tagger = TibetanTagger.from_pretrained(path) # GPU if available; attn_implementation="flash_attention_2" optional
tagger.tag_terse(["bcom ldan 'das kyis de skad ces bka' stsal nas/ dge slong de dag yi rangs te/",
"de la dang po ni sems bskyed pa'o/ /gal te de ltar ma yin na/"])
# bcom_ldan_'das/N kyis/C de_skad/A ces/L bka'_stsal/V nas/K |/p dge_slong/N de_dag/D yi_rangs/V te/K |/p
# de_la/A dang_po/M ni/L sems/N bskyed_pa/G +'o/L ||/p
# gal_te/K de_ltar/A ma/V yin/V na/K |/p
tagger.tag(["sangs rgyas kyi chos la skyabs su mchi'o/"])
# [[[{'word': 'sangs rgyas', 'tag': 'N', 'pos': 'noun'}, {'word': 'kyi', 'tag': 'C', 'pos': 'case particle'},
# {'word': 'chos', 'tag': 'N', ...}, ..., {'word': "+'o", 'tag': 'L', 'pos': 'clitic/final particle'}]]]
tag_terse returns one string per input. Words are joined with _ and end in /TAG; a
split-off particle is written +'i/C; punctuation is written |/p for one shad and ||/p for a
double shad; and every sentence after the first starts on a new line.tag returns the same information as a list of sentences, each a list of token dicts, with
punctuation omitted.labels returns the raw per-syllable labels.Throughput is about 2,000 sentences per second on one GPU in batches of 64; it also runs on a CPU. Inputs longer than 1,024 tokens (roughly 400–500 syllables) come back empty, so split long texts at shads.
| Tag | Tag | ||
|---|---|---|---|
| N | noun | R | pronoun |
| P | proper noun | D | determiner (de, 'di, de dag) |
| V | verb | X | negation |
| G | verbal noun (bskyed pa) |
C | case particle (kyi, la, nas, +'i, +s) |
| J | adjective | K | clause particle (nas, te, na, gal te) |
| A | adverb | L | clitic/final particle (ni, kyang, +'o) |
| M | numeral | I | interjection |
| p | punctuation |
The training labels were inconsistent for a few fixed expressions; zhe na, for example, appeared
as V, C, K and L. By default (conventions=True) the output is normalised with a deterministic
table in tibseg_conventions.py:
gal te, ci ste and zhe na become one token tagged K.de bas na, de lta bas na, 'on kyang, 'on te and 'o na become one token tagged A.de'i phyir, de'i phyir na, des na, gang gi phyir and
de la also become one token tagged A. Elsewhere, as in dge ba'i rtsa ba des na, they are left
as they are.dang ldan… is split into dang/C and ldan…/V.To get the raw model output, pass conventions=False.
Each syllable gets four labels:
'i/C in pa'i;The seg and pos labels are read on a syllable's first sub-token, and aff and gap on its last.
Decoding is deterministic, so the output always covers the input syllables exactly: nothing is
dropped, invented or respelled. The model weights are the encoder with four linear heads.
Silver stage. One epoch over 2.4M Tibetan sentences (118M tokens) that a fine-tuned 9B decoder (Qwen3.5-9B) annotated for the MITRA dictionaries. Any sentence that shares an 8-syllable span with an evaluation text was removed first. Learning rate 5e-5, batch 256, 2 GPUs, 47 minutes.
Gold stage. One epoch over the ~4.8k Tibetan training items of the jointseg-terse dataset, annotated by Gemini, which is the same data the 9B was fine-tuned on. Learning rate 2e-5, batch 32.
Sentence-division stage (2026-12-03). The earlier stages had learned to end a sentence at
almost every shad: after list items, after dang / ni / te / la, and after every verse line.
Part of this came from the Gemini labels themselves, where about 10% of breaks followed dang.
Gemini 3.8 Flash (medium thinking) re-decided only the line breaks of every gold item, keeping
all tokens and tags unchanged. It followed explicit sentence rules, partly modelled on the
Intellexus regex segmenter:
ji ltar … de bzhin;Gemini applied the same rules to 3,000 new Kangyur/Tengyur passages of 50–120 syllables tagged by the stage-2 model. For these passages only the sentence-break head was trained. Two epochs, learning rate 2e-5, about 3 minutes on one GPU.
Training kept only the 37,976 tokenizer entries that occur in Tibetan Wylie. In this export the
weights sit in the full mmBERT vocabulary; tokens never seen in training map to the trained
<unk> row. The exported model gives output identical to the training checkpoint on all 500
evaluation inputs.
All scores are span F1 on 100 held-out jointseg-terse items (87 sentences and 13 paragraphs). The reference labels are Gemini annotations, not expert gold.
| Word F1 | POS F1 | Affix F1 | Sentence-break F1 | |
|---|---|---|---|---|
| This tagger (silver + gold + sentence stage) | 0.915 | 0.870 | 0.896 | 0.875¹ |
| Previous release (silver + gold) | 0.913 | 0.860 | 0.896 | 0.882 |
| Tagger trained on gold only | 0.913 | 0.847 | 0.880 | 0.848 |
| 9B decoder (Qwen3.5-9B, same gold data) | 0.897 | 0.849 | 0.867 | 0.851 |
| botok (dictionary segmenter) | 0.784 | – | 0.727 | – |
¹ Against the original Gemini breaks, which the sentence stage deliberately moved away from; see the next table.
Sentence division. The references are the Gemini-corrected breaks: 196 held-out Kangyur/Tengyur passages from files not used in training (about 500 reference breaks), and the 100 test items.
| Sentence-break F1, passages | Sentence-break F1, test items | Breaks per shad | Breaks after a continuative or case particle | |
|---|---|---|---|---|
| This tagger | 0.914 | 0.947 | 0.32 | 0.2% |
| Previous release | 0.675 | 0.888 | 0.70 | 21.5% |
| Reference | – | – | 0.33 | 0% |
lemma in DharmaNexus is the surface form.tz/tsh, Terdzö : as shad) were seen in
pre-training but rarely in tagging data.de la tshor ba mi dmigs /) ends a sentence is a judgement call, and in verse the stanza grouping
is not always right.de la. At the start of a sentence, de la is always tagged an adverb ("regarding
that"), even where it means "to him".model.safetensors 1.1 GiBheads.safetensors 505.2 KiB