Views
No views yet
| model | best for | emits |
|---|---|---|
| …-morphology | highest UPOS/slots accuracy | UPOS + core FEATS |
| this one | complete annotations incl. lemmas | full UD FEATS + lemmas |
| …-morphology-vdu | accentuation pipelines | traditional-grammar categories |
| metric (F1) | this model | UDPipe 2 reference |
|---|---|---|
| UPOS | 93.2 | 95.2 |
| UFeats | 84.1 | 89.1 |
| Lemmas | 94.7 | 92.9 |
AutoModelForTokenClassification.from_pretrained will not load
this checkpoint correctly (it has a second, lemma-script head). Use the
bundled ONNX model:1import json, numpy as np, onnxruntime as ort
2from huggingface_hub import snapshot_download
3from transformers import AutoTokenizer
4
5d = snapshot_download("alexbalandi/litlat-bert-lithuanian-morphology-full")
6tok = AutoTokenizer.from_pretrained(d)
7sess = ort.InferenceSession(f"{d}/onnx/model_quantized.onnx",
8 providers=["CPUExecutionProvider"])
9cfg = json.load(open(f"{d}/head_config.json", encoding="utf-8"))
10labels, scripts = cfg["labels"], cfg["lemma_scripts"]
11
12def apply_script(form, script): # decode the lemma edit-script
13 if script.startswith("W|"): return script.split("|", 1)[1]
14 _, lower_first, strip, suffix = script.split("|", 3)
15 base = (form[0].lower() + form[1:]) if int(lower_first) and form else form
16 stem = base[:-int(strip)] if int(strip) else base
17 return stem + suffix
18
19words = ["Vilniuje", "gyvena", "graži", "mano", "sesuo"]
20enc = tok(words, is_split_into_words=True, return_tensors="np")
21label_logits, lemma_logits = sess.run(
22 None, {k: v for k, v in enc.items() if k in ("input_ids", "attention_mask")})
23seen = set()
24for pos, wid in enumerate(enc.word_ids(0)):
25 if wid is None or wid in seen: continue
26 seen.add(wid)
27 print(words[wid],
28 apply_script(words[wid], scripts[int(lemma_logits[0, pos].argmax())]),
29 labels[int(label_logits[0, pos].argmax())])
30# Vilniuje Vilnius PROPN|Case=Loc|Gender=Masc|Number=Sing
31# gyvena gyventi VERB|Mood=Ind|Number=Sing|Person=3|Polarity=Pos|Tense=Pres|VerbForm=Fin
32# mano aš PRON|Case=Gen|Definite=Ind|Number=Sing|Person=1|PronType=Prs
33# ...pytorch_model.bin holds the custom-wrapper state dict for continued
training with the project's tooling
(local/tagger-hf/head_modeling.py::load_custom_model).