bcms-bertic-ner ONNX
ONNX exports of classla/bcms-bertic-ner — BERTić fine-tuned for Named Entity Recognition on BCMS (Bosnian/Croatian/Montenegrin/Serbian).
Files
| File | Size | Description |
|---|---|---|
model_fp32.onnx |
440 MB | Full-precision float32 export |
model_int8.onnx |
106 MB | Dynamic int8 quantization (onnxruntime QInt8) |
tokenizer.json |
717 KB | HuggingFace fast tokenizer (WordPiece, 32k vocab, cased) |
config.json |
1 KB | Model config with id2label mapping |
Model Details
- Architecture: ElectraForTokenClassification (12 layers, 768 hidden, 12 heads, ~110M params)
- Vocabulary: 32,000 WordPiece tokens, cased (lowercase=False)
- Max sequence length: 512 tokens
- Labels (9 BIO classes):
| ID | Label |
|---|---|
| 0 | B-LOC |
| 1 | B-MISC |
| 2 | B-ORG |
| 3 | B-PER |
| 4 | I-LOC |
| 5 | I-MISC |
| 6 | I-ORG |
| 7 | I-PER |
| 8 | O |
ONNX Inputs / Outputs
Inputs (all int64 [batch_size, sequence_length]):
input_idsattention_masktoken_type_ids
Output:
logits—float32 [batch_size, sequence_length, 9]
Usage (onnxruntime)
import onnxruntime as ort
import json
import numpy as np
with open("tokenizer.json") as f:
tok = json.load(f)
vocab = tok["model"]["vocab"] # {token: id}
id2label = {
0:"B-LOC", 1:"B-MISC", 2:"B-ORG", 3:"B-PER",
4:"I-LOC", 5:"I-MISC", 6:"I-ORG", 7:"I-PER", 8:"O"
}
session = ort.InferenceSession("model_int8.onnx", providers=["CPUExecutionProvider"])
# wp_tokenize: split text into words, greedily match longest vocab substrings,
# prefix non-initial pieces with "##", wrap with [CLS] and [SEP]
text = "Ante Babić je posjetio sjedište Europske unije u Bruxellesu."
tokens = wp_tokenize(text, vocab) # your WordPiece tokenizer here
ids = np.array([[vocab.get(t, 1) for t in tokens]], dtype=np.int64)
logits = session.run(["logits"], {
"input_ids": ids,
"attention_mask": np.ones_like(ids),
"token_type_ids": np.zeros_like(ids),
})[0]
for token, label_id in zip(tokens, logits[0].argmax(-1)):
label = id2label[label_id]
if label != "O":
print(f"{token:20s} {label}")
Output:
Ante B-PER
Babić I-PER
Europske B-ORG
unije I-ORG
Bruxellesu B-LOC
License
Apache 2.0 — same as the original classla/bcms-bertic-ner model.
Citation
If you use this fine-tuned model, please cite the following paper:
@inproceedings{ljubesic-lauc-2021-bertic,
title = "{BERT}i{\'c} - The Transformer Language Model for {B}osnian, {C}roatian, {M}ontenegrin and {S}erbian",
author = "Ljube{\v{s}}i{\'c}, Nikola and Lauc, Davor",
booktitle = "Proceedings of the 8th Workshop on Balto-Slavic Natural Language Processing",
month = apr,
year = "2021",
address = "Kiyv, Ukraine",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/2021.bsnlp-1.5",
pages = "37--42",
}
- Downloads last month
- 20
Model tree for iluksic/bcms-bertic-ner-onnx
Base model
classla/bcms-bertic-ner