Instructions to use buddhist-nlp/mitra-bo-zh-tagger with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use buddhist-nlp/mitra-bo-zh-tagger with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="buddhist-nlp/mitra-bo-zh-tagger") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("buddhist-nlp/mitra-bo-zh-tagger") model = AutoModelForCausalLM.from_pretrained("buddhist-nlp/mitra-bo-zh-tagger", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use buddhist-nlp/mitra-bo-zh-tagger with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "buddhist-nlp/mitra-bo-zh-tagger" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "buddhist-nlp/mitra-bo-zh-tagger", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/buddhist-nlp/mitra-bo-zh-tagger
- SGLang
How to use buddhist-nlp/mitra-bo-zh-tagger with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "buddhist-nlp/mitra-bo-zh-tagger" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "buddhist-nlp/mitra-bo-zh-tagger", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "buddhist-nlp/mitra-bo-zh-tagger" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "buddhist-nlp/mitra-bo-zh-tagger", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use buddhist-nlp/mitra-bo-zh-tagger with Docker Model Runner:
docker model run hf.co/buddhist-nlp/mitra-bo-zh-tagger
mitra-bo-zh-tagger
A 9B-parameter model that turns raw classical Tibetan (Wylie) or raw, unpunctuated Buddhist Chinese into a full linguistic annotation in one pass:
- sentence segmentation (one sentence per output line),
- word segmentation at the dictionary-lexeme level (Tibetan) / Sanskrit-lemma level (Chinese),
- a coarse part of speech on every word,
- the words that together render one Sanskrit word or compound, bracketed (Chinese: with compound type),
- for Chinese, punctuation restored (ใ๏ผใ๏ผ๏ผ๏ผ๏ผ and quotation marks).
The model was trained by the MITRA project on top of the MITRA Qwen3.5-9B stage-2 base (Qwen3.5 architecture, continued pretraining on Buddhist Sanskrit, Tibetan, Chinese and parallel data). The convenient way to use it is the Python package dharmamitra/mitra-bo-zh-tagger, which handles chunking, Unicode/Wylie conversion, validation and conversion into structured records.
Input / output
Plain-text prompt (no chat template). The instruction line is fixed and must be given verbatim; the
package's mitra_tagger.prompts module contains both strings.
<instruction>
TIBETAN: de nas tshe dang ldan pa kun dga' bos bcom ldan 'das la 'di skad ces gsol to/ /
OUTPUT:
[de_nas/A] [tshe_dang_ldan_pa/J] [kun_dga'_bo/P] +s/C [bcom_ldan_'das/N] la/C 'di_skad/A ces/L [gsol/V] to/L ||/p
<instruction>
CHINESE: ็พๆไธๅฐๅ่ซธๆฏไธๆฑ็ญ็ถ็ฅไธๅ่ซธๆณ็ๆ็กๅธธ่ฆ็ฉบ็กๆ่ฅ่ฝๅฆๆฏ่ง่
ๅๅพ่งฃ่ซ
OUTPUT:
็พ/R ๆ/N ไธๅฐ/N ๅ/V ่ซธ/L ๆฏไธ/N ๏ผ/p ใ/p ๆฑ/R ็ญ/L ็ถ/X ็ฅ/V ๏ผ/p [ไธๅ/N ่ซธ/L ๆณ/N]=K ็/A ๆ/A ็กๅธธ/J ใ/p ่ฆ/J ใ/p ็ฉบ/J ใ/p [็ก/V ๆ/R]=B ใ/p
่ฅ/S ่ฝ/X ๅฆ/V ๆฏ/R ่ง/V ่
/L ๏ผ/p ๅ/K ๅพ/X ่งฃ่ซ/V ใ/p ใ/p
Format: tokens WORD/POS, punctuation MARK/p, Sanskrit units [ ... ]. Tibetan syllables of one word are
joined with _; an affix written attached in the input ('i, s, r, 'o, 'am, 'ang) becomes its own
token +affix; shad runs become |/p or ||/p. Chinese units carry =T tatpuruแนฃa, =K karmadhฤraya,
=D dvandva, =B bahuvrฤซhi, =A avyayฤซbhฤva, =O other.
Tibetan tags: N noun, P proper noun, V verb, G verbal noun, J adjective, A adverb, M numeral, R pronoun, D determiner/demonstrative/plural, X negation, C case particle, K clause particle, L clitic or final particle, I interjection, p punctuation. Chinese tags: N noun, P proper noun, V verb, J adjective, A adverb, R pronoun, M numeral, X auxiliary, C adposition, K coordinating conjunction, S subordinating conjunction, L particle, I interjection, p punctuation.
Input limits used in training: Tibetan sentences and paragraphs of a few sentences (targets up to ~1,000 characters of Wylie); Chinese windows of up to 200 characters. Longer texts should be chunked accordingly.
Quick start
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
m = "buddhist-nlp/mitra-bo-zh-tagger"
tok = AutoTokenizer.from_pretrained(m)
model = AutoModelForCausalLM.from_pretrained(m, dtype=torch.bfloat16, device_map="auto").eval()
from mitra_tagger.prompts import build_prompt # pip install git+https://github.com/dharmamitra/mitra-bo-zh-tagger
prompt = build_prompt("่ฅ่ฝๅฆๆฏ่ง่
ๅๅพ่งฃ่ซ", "zh")
ids = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**ids, max_new_tokens=1024, do_sample=False)
print(tok.decode(out[0, ids["input_ids"].shape[1]:], skip_special_tokens=True))
Or simply pip install git+https://github.com/dharmamitra/mitra-bo-zh-tagger and mitra-tag --lang zh file.txt.
Runs on CUDA (bfloat16, ~19 GB), Apple Silicon (float16 via MPS, 24 GB+ unified memory) and CPU.
Quality
Held-out test set, 100 items per language, against Gemini-corrected gold annotations:
| Tibetan | Chinese | |
|---|---|---|
| Word boundary F1 | 0.95 | 0.94 |
| POS accuracy (matched words) | 0.94 | 0.94 |
| Sentence boundary F1 | 0.87 | 0.81 |
| Punctuation position F1 | โ | 0.79 |
| Sanskrit unit / compound F1 | 0.65 | 0.52 |
| Output reproduces input | 99% | 86% |
Sanskrit-unit bracketing is the weakest layer (mostly under-marking). Chinese round-trip failures on 200-character windows are single-character slips; sentence-level input is more robust.
Limitations
The gold data is model-corrected, not human-checked. The model has seen Buddhist canonical text only; other registers of classical Chinese or Tibetan will degrade.
Citation
Please refer to the Dharmamitra project and this model card when using the tagger. Publication under preperation!
- Downloads last month
- 144