Downloads · 30 days
4
4% of all-time downloads
Topurrra/xlm-roberta-ner-georgian-onnx-int8
xlm-roberta-ner-georgian-onnx-int8 is a token classification model from Topurrra. Use it when you need labels on individual words, such as names. It is set up for transformers. The card lists the license as mit.
On-device, int8-quantized ONNX build of a named-entity recognition model for Georgian + English (with usable zero-shot transfer to XLM-R's other languages). It detects people (PER), locations (LOC), and organizations…
Downloads · 30 days
4
4% of all-time downloads
All-time downloads
94
Public
Repo size
577 MB
Likes
0
Public
Click a slice to open those files.
.onnx560 MB · 97%
From the Hugging Face model README
On-device, int8-quantized ONNX build of a named-entity recognition model for Georgian + English (with usable zero-shot transfer to XLM-R's other languages). It detects people (PER), locations (LOC), and organizations (ORG), and runs fully offline with ONNX Runtime — no Python and no network at inference time.
It was built for KeepItLocal Privacy, a local-first redaction app, where it finds names, places, and organizations in documents so they can be redacted without anything leaving the device. It is a general token-classification model and works anywhere ONNX Runtime does.
This is a converted derivative of
stefan-it/autotrain-flair-georgian-ner-xlm_r_large-bs4-e10-lr5e-06-1
by Stefan Schweter (MIT), fine-tuned on the WikiANN (Rahimi et al.) English +
Georgian splits. All credit for the trained weights is his; this repository only
repackages them for on-device inference (ONNX + int8). No weights were retrained.
| File | Purpose |
|---|---|
model_int8.onnx | the quantized token-classification model (534 MB) |
tokenizer.json | XLM-R SentencePiece tokenizer (load with HF tokenizers) |
labels.json | the 13 BIOES labels, in model output-index order |
13 BIOES tags over LOC / ORG / PER, in output-index order:
O, S-LOC, B-LOC, E-LOC, I-LOC, S-ORG, B-ORG, E-ORG, I-ORG, S-PER, B-PER, E-PER, I-PER
S- = single-token entity · B-/I-/E- = begin/inside/end of a multi-token
entity · O = outside.
pip install onnxruntime tokenizers numpy
import json, numpy as np, onnxruntime as ort
from tokenizers import Tokenizer
tok = Tokenizer.from_file("tokenizer.json")
labels = json.load(open("labels.json"))
sess = ort.InferenceSession("model_int8.onnx", providers=["CPUExecutionProvider"])
text = "ნიკა თოფურია მუშაობს თიბისი ბანკში, თბილისში."
enc = tok.encode(text)
logits = sess.run(None, {
"input_ids": np.array([enc.ids], dtype=np.int64),
"attention_mask": np.array([enc.attention_mask], dtype=np.int64),
})[0][0] # shape [seq_len, 13]
pred = logits.argmax(-1)
# Illustrative decoder — assumes well-formed BIOES, as the model emits.
entities, start, etype, last_word = [], None, None, None
for i, wid in enumerate(enc.word_ids):
if wid is None or wid == last_word:
continue # special token, or non-first subtoken
last_word = wid
tag = labels[pred[i]]
span = enc.word_to_chars(wid) # (char_start, char_end)
if tag == "O":
start = etype = None
continue
pos, kind = tag.split("-")
if pos == "S":
entities.append((kind, text[span[0]:span[1]]))
start = etype = None
elif pos == "B":
start, etype = span[0], kind
elif pos == "E" and etype == kind and start is not None:
entities.append((kind, text[start:span[1]]))
start = etype = None
print(entities)
# e.g. [('PER', 'ნიკა თოფურია'), ('ORG', 'თიბისი ბანკში'), ('LOC', 'თბილისში')]
(Printed spans are illustrative; exact output depends on tokenization.)
[FLERT] token) with a
plain Linear(1024 → 13) token-classification head — no CRF, no RNN.Flair pickle → reconstructed as a Hugging Face XLMRobertaForTokenClassification
(backbone + linear head copied verbatim) → exported to ONNX (opset 18) →
dynamic int8 quantization. Validated that the ONNX model reproduces the
original's entities on English, Georgian, and mixed text.
MIT, inherited from the source model. Please credit Stefan Schweter and the original model.