Release update
Browse filesFiles changed (11)
- META.jsonAdded+64
- README.mdAdded+183
- SHA256SUMSAdded+10
- benchmark_summary.jsonAdded+28
- config.jsonAdded+21
- example.pyAdded+18
- onnx/model_fp32.onnxAdded+3
- onnx/model_int8.onnxAdded+3
- requirements.txtAdded+4
- runtime.pyAdded+96
- spm_bashkir_bert_16k.modelAdded+3
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364{
"id": "bashkir-roberta-ner",
"version": "v1",
"status": "release_candidate",
"type": "token_classification",
"task": "Bashkir person named entity recognition",
"language": [
"ba"
],
"license": "other",
"source": "Fine-tuned BashkirRoBERTa encoder using Bashkir person-entity annotations; source texts are not redistributed.",
"base_model": "failed09/bashkir-roberta",
"created_at": "2026-09-29T19:47:12+00:00",
"labels": [
"O",
"B-PER",
"I-PER"
],
"default_artifact": "onnx/model_int8.onnx",
"evaluation": {
"protocol": "Public ONNX runtime on CPU, one sentence per invocation; exact person-span micro F1",
"gold_sentences": 1013,
"gold_fp32_f1": 0.8593644354293442,
"gold_int8_f1": 0.8589309878213802,
"authored_stress_sentences": 100,
"authored_stress_fp32_f1": 0.9294117647058824,
"authored_stress_int8_f1": 0.9230769230769231
},
"artifacts": {
"onnx/model_int8.onnx": {
"bytes": 82387343,
"sha256": "a9caab457973f9417085b30001c02e9d545883bda7f4cc71f082bc48f697e5f6"
},
"onnx/model_fp32.onnx": {
"bytes": 200275816,
"sha256": "70ced1d7113b17aac23b4b6bf51eb98fa456cd49482bb81a3722131e0ac71327"
},
"spm_bashkir_bert_16k.model": {
"bytes": 586970,
"sha256": "4e77b9cfc9ab8c200406ee46c2d20fc46734da9ddcf01dff0f0e370f6c4ac244"
},
"runtime.py": {
"bytes": 3938,
"sha256": "c44691291b0744b8ac6fae8381bfbf61d5623cc8366451394102bd851e4f0e79"
},
"config.json": {
"bytes": 687,
"sha256": "4116a520ec1537633120ccd74aa167581b9a9fd2b50f5a47abfbe5171242341c"
},
"requirements.txt": {
"bytes": 83,
"sha256": "a96c1d8e811c98f431b283b99943f4837f63ab905ca6ad1047a496e2b6456454"
},
"example.py": {
"bytes": 633,
"sha256": "bbe06259d2a8343523f6b8abc4c219bc776b18cb7df8161f86ab6c533136302c"
},
"benchmark_summary.json": {
"bytes": 1646,
"sha256": "0ed527c20e4be58304e32521470243841f1e3fb1bd76df203e57c0f17e04628b"
}
},
"source_policy": "No training texts or evaluation examples are included in the public release."
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183---language:- balicense: otherpretty_name: BashkirRoBERTa NERlibrary_name: onnxruntimepipeline_tag: token-classificationtags:- bashkir- named-entity-recognition- person- onnx- onnxruntime- low-resource---
# BashkirRoBERTa NER
> ONNX models for finding person names in Bashkir text, with a compact CPU default.
## Overview
BashkirRoBERTa NER is a person-name tagger fine-tuned from the BashkirRoBERTamasked-language encoder. It recognizes people (`PER`) and returns spans in theoriginal text. The release includes FP32 and dynamically quantized INT8 ONNXgraphs, the original SentencePiece tokenizer, and a small standalone runtime.The INT8 model is the default for CPU use.
| At a glance | || --- | --- || Task | Bashkir person named entity recognition (`PER`) || Default artifact | `onnx/model_int8.onnx` || Source | A Bashkir-language encoder and person-entity training annotations || Version / license | v1 / custom terms (`other`) |
## Contents
### Files and Configurations
| File | Purpose | Size || --- | --- | ---: || **`onnx/model_int8.onnx`** | CPU default, dynamic INT8 | 82.4 MB || `onnx/model_fp32.onnx` | FP32 reference with PyTorch tag parity | 200.3 MB || `spm_bashkir_bert_16k.model` | SentencePiece tokenizer | 0.59 MB || `runtime.py` | Word alignment, BIO spans, character offsets | — || `config.json` | Architecture, label order, runtime contract | — || `benchmark_summary.json` | Aggregate evaluation without source text | — || `example.py` | Download and run the default model | — || `META.json` | Release passport and artifact hashes | — || `SHA256SUMS` | Checksums of the public files | — |
### Model Architecture
| Property | Value || --- | --- || Encoder | BashkirRoBERTa, eight Pre-LayerNorm Transformer blocks || Head | Linear word-level classifier || Labels | `O`, `B-PER`, `I-PER` || Tokenization | SentencePiece, first piece of each original word is labeled || Input | `input_ids`, int64, dynamic batch and sequence dimensions || Output | `logits`, float, `[batch, sequence, 3]` || Maximum context | 256 SentencePiece tokens, including boundary tokens |
### Examples
Outputs below were produced by the included INT8 runtime:
| Input | Found people || --- | --- || `Рәми Ғарипов һәм Мостай Кәрим тураһында һөйләштек.` | `Рәми Ғарипов`; `Мостай Кәрим` || `Мәрйәм менән Илнур мәктәпкә китте.` | `Мәрйәм`; `Илнур` || `Өфө ҡалаһында яңы мәктәп асылды.` | None |
## Method
```textBashkirRoBERTa encoder → person-entity fine-tuning → FP32 ONNX → dynamic INT8 quantization → word-level BIO decoding```
The encoder was fine-tuned with Bashkir person-entity annotations; its encoderlayers and classification head changed. The original masked-language ONNX graphcannot be combined with this head to reproduce the release. Training data andevaluation text are not included. The tokenizer and first-subword alignment areprovided so ONNX scores can be mapped back to complete words.
### Benchmark
On a held-out, human-verified person-entity set, exact person-span micro F1 is**0.8594** for FP32 and **0.8589** for INT8 when run one sentence at a timethrough the included adapter. FP32 makes no word-tag changes relative to thePyTorch checkpoint. The separately authored 100-sentence stress suite gives span F1**0.9294** (FP32) and **0.9231** (INT8), with 92 sentences entirely correct ineach format. The stress suite is a targeted diagnostic, not an estimate ofpopulation accuracy. Dynamic INT8 outputs can vary slightly with batchcomposition; the figures above use the public single-sentence runtime. Countsand the BIO scoring convention are in[`benchmark_summary.json`](benchmark_summary.json).
## Quality and Use
Use this model to find mentions of people in Bashkir text, including inflectednames and multiword names. The `runtime.py` adapter returns each span withcharacter offsets. `predict_tokens` also accepts pre-tokenized words forevaluation workflows. The default INT8 graph is smaller while preserving nearlyall of the observed gold-set score; FP32 is available when exact checkpointparity matters.
### Limitations
- Only person entities are labeled. Places and organizations have no output class.- Rare names can be missed. Long names and adjacent people can be split or merged.- Names inside institution names can be mistaken for person mentions.- Inputs beyond the context limit are truncated; the runtime reports `truncated: true`.- Word boundaries from noisy OCR, unusual punctuation, and mixed writing systems can differ from the training tokenization.- The authored stress suite is too small and structured to replace the held-out human-verified benchmark.
## Related Resources
- [BashkirRoBERTa](https://huggingface.co/failed09/bashkir-roberta) is the underlying masked-language model; use it for fill-mask work and new fine-tuning tasks rather than person-name extraction.
## Usage
```bashpip install onnxruntime sentencepiece numpy huggingface_hub```
```pythonimport sysfrom huggingface_hub import snapshot_download
model_dir = snapshot_download( "failed09/bashkir-roberta-ner", allow_patterns=["onnx/model_int8.onnx", "spm_bashkir_bert_16k.model", "config.json", "runtime.py"],)sys.path.insert(0, model_dir)from runtime import BashkirPersonNER
ner = BashkirPersonNER(model_dir)print(ner.predict("Рәми Ғарипов һәм Мостай Кәрим тураһында һөйләштек."))```
For the FP32 graph, download `onnx/model_fp32.onnx` as well and construct`BashkirPersonNER(model_dir, precision="fp32")`. The included `example.py`runs the default configuration.
## License
This derivative follows the custom terms (`other` on the Hub) of the[BashkirRoBERTa base model](https://huggingface.co/failed09/bashkir-roberta)while the underlying source-rights audit is completed. It does not redistributetraining texts or benchmark sentences. Contact the maintainer through the Hubfor provenance or removal requests before commercial redistribution.
## Citation
```bibtex@software{failed09_bashkir_roberta_ner_2026, title = {BashkirRoBERTa NER}, author = {failed09}, year = {2026}, publisher = {Hugging Face}, url = {https://huggingface.co/failed09/bashkir-roberta-ner}, note = {ONNX person named entity recognition for Bashkir}}```
## Open Bashkir Data and Sources 🐝
This release is part of an open-source effort to support the development,preservation and practical use of the Bashkir language. Other related models,datasets and tools are available on the author's Hugging Face profile.
The author does not claim ownership or authorship of the source texts or othermaterials used to derive this release; rights and licensing remain with theoriginal authors, publishers and dataset providers. Source texts are notredistributed in this repository, so users should follow the licenses andattribution requirements of the relevant upstream resources.123456789107bceb0bc4b954c49640aa027abf07b9c49e48495dd05cad99445452822492443 META.json
505580cbcbdbfcff3611ca9c8cae2643735b18a1bd8cfb11cc5040b40d20ae5a README.md
0ed527c20e4be58304e32521470243841f1e3fb1bd76df203e57c0f17e04628b benchmark_summary.json
4116a520ec1537633120ccd74aa167581b9a9fd2b50f5a47abfbe5171242341c config.json
bbe06259d2a8343523f6b8abc4c219bc776b18cb7df8161f86ab6c533136302c example.py
70ced1d7113b17aac23b4b6bf51eb98fa456cd49482bb81a3722131e0ac71327 onnx/model_fp32.onnx
a9caab457973f9417085b30001c02e9d545883bda7f4cc71f082bc48f697e5f6 onnx/model_int8.onnx
a96c1d8e811c98f431b283b99943f4837f63ab905ca6ad1047a496e2b6456454 requirements.txt
c44691291b0744b8ac6fae8381bfbf61d5623cc8366451394102bd851e4f0e79 runtime.py
4e77b9cfc9ab8c200406ee46c2d20fc46734da9ddcf01dff0f0e370f6c4ac244 spm_bashkir_bert_16k.model12345678910111213141516171819202122232425262728{ "task": "Bashkir person named entity recognition", "metric": "exact person-span micro F1 with orphan I-PER treated as a new span", "evaluation_protocol": "public runtime.py, one sentence per ONNX invocation, CPU", "gold": { "description": "human-verified held-out Bashkir person-entity benchmark", "sentences": 1013, "gold_entities": 3027, "fp32": {"tp": 2542, "fp": 347, "fn": 485, "f1": 0.8593644354293442, "perfect_sentences": 746}, "int8": {"tp": 2539, "fp": 346, "fn": 488, "f1": 0.8589309878213802, "perfect_sentences": 745} }, "authored_stress": { "description": "100 authored diagnostic sentences in ten categories; not a representative population sample", "sentences": 100, "gold_entities": 85, "exact_sentence_overlap_with_checked_training_and_gold_files": 0, "fp32": {"tp": 79, "fp": 6, "fn": 6, "f1": 0.9294117647058824, "perfect_sentences": 92}, "int8": {"tp": 78, "fp": 6, "fn": 7, "f1": 0.9230769230769231, "perfect_sentences": 92} }, "inference": { "backend": "ONNX Runtime CPU", "export": "FP32 ONNX opset 17 and dynamic MatMul/Gemm INT8 quantization", "input": "int64 input_ids with dynamic batch and sequence dimensions", "output": "float logits [batch, sequence, 3]", "tested_max_length": 256, "note": "Tokenization and first-subword label alignment are identical across formats. Dynamic INT8 scores can vary with batch composition; this release summary measures the public single-sentence runtime. A separate batch-16 experiment measured INT8 gold F1 0.8582051715396316. Timings vary by host and are not a portable speed guarantee." }}123456789101112131415161718192021{ "architecture": "BashkirRoBERTa Pre-LayerNorm encoder with a linear token-classification head", "task": "person_named_entity_recognition", "labels": ["O", "B-PER", "I-PER"], "vocab_size": 16384, "hidden_size": 640, "num_hidden_layers": 8, "num_attention_heads": 10, "intermediate_size": 2560, "max_position_embeddings": 256, "bos_token_id": 2, "eos_token_id": 3, "pad_token_id": 0, "tokenization": "SentencePiece per whitespace-delimited word; predict at the first piece", "output": "word-level BIO tags from logits [batch, sequence, 3]", "default_model": "int8", "models": { "int8": "onnx/model_int8.onnx", "fp32": "onnx/model_fp32.onnx" }}123456789101112131415161718"""Download and run the default CPU model from Hugging Face."""import sys
from huggingface_hub import snapshot_download
if hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8")
model_dir = snapshot_download( "failed09/bashkir-roberta-ner", allow_patterns=["onnx/model_int8.onnx", "spm_bashkir_bert_16k.model", "config.json", "runtime.py"],)sys.path.insert(0, model_dir)from runtime import BashkirPersonNER # noqa: E402
ner = BashkirPersonNER(model_dir)print(ner.predict("Рәми Ғарипов һәм Мостай Кәрим тураһында һөйләштек."))123version https://git-lfs.github.com/spec/v1oid sha256:70ced1d7113b17aac23b4b6bf51eb98fa456cd49482bb81a3722131e0ac71327size 200275816123version https://git-lfs.github.com/spec/v1oid sha256:a9caab457973f9417085b30001c02e9d545883bda7f4cc71f082bc48f697e5f6size 823873431234onnxruntime>=1.22,<2sentencepiece>=0.2,<1numpy>=1.26,<3huggingface_hub>=0.30,<2123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596"""Standalone ONNX inference for Bashkir person-name recognition.
The graph returns logits at SentencePiece positions. Training assigned one BIOlabel to the first piece of each original word, so this runtime does the same."""from __future__ import annotations
import jsonimport refrom pathlib import Path
import numpy as npimport onnxruntime as ortimport sentencepiece as spm
TAGS = ("O", "B-PER", "I-PER")WORD_RE = re.compile(r"[A-Za-zА-Яа-яЁёӘәҒғҘҙҠҡҢңӨөҪҫҮүҺһҚқІі][\w'\-]*", re.UNICODE)
class BashkirPersonNER: def __init__(self, model_dir: str | Path = ".", precision: str = "int8", providers: list[str] | None = None): self.directory = Path(model_dir) config = json.loads((self.directory / "config.json").read_text(encoding="utf-8")) if precision not in config["models"]: raise ValueError(f"precision must be one of {sorted(config['models'])}") self.max_length = int(config["max_position_embeddings"]) self.bos_id = int(config["bos_token_id"]) self.eos_id = int(config["eos_token_id"]) self.sp = spm.SentencePieceProcessor( model_file=str(self.directory / "spm_bashkir_bert_16k.model") ) model = self.directory / config["models"][precision] self.session = ort.InferenceSession( str(model), providers=providers or ["CPUExecutionProvider"] )
def predict_tokens(self, tokens: list[str]) -> tuple[list[str], bool]: """Return word-level BIO tags and whether input exceeded the context limit.
The caller supplies the same token boundaries used for gold evaluation. On truncation, the returned tag list covers only its leading words. """ if not tokens: return [], False ids = [self.bos_id] positions = [] for word in tokens: pieces = list(self.sp.encode(word, out_type=int)) or [self.sp.unk_id()] if len(ids) + len(pieces) + 1 > self.max_length: break positions.append(len(ids)) ids.extend(pieces) if not positions: return [], True ids.append(self.eos_id) logits = self.session.run( ["logits"], {"input_ids": np.asarray([ids], dtype=np.int64)} )[0][0] return [TAGS[int(logits[pos].argmax())] for pos in positions], len(positions) < len(tokens)
def predict(self, text: str) -> dict: """Return person spans with character offsets into the original text.""" if not isinstance(text, str): raise TypeError("text must be a string") matches = list(WORD_RE.finditer(text)) tags, truncated = self.predict_tokens([m.group() for m in matches]) entities = [] start = None end = None for match, tag in zip(matches, tags): if tag == "B-PER": if start is not None: entities.append({"text": text[start:end], "start": start, "end": end}) start, end = match.span() elif tag == "I-PER": # Current benchmark convention: an orphan I-PER starts a span. if start is None: start = match.start() end = match.end() elif start is not None: entities.append({"text": text[start:end], "start": start, "end": end}) start = end = None if start is not None: entities.append({"text": text[start:end], "start": start, "end": end}) return {"entities": entities, "truncated": truncated}
if __name__ == "__main__": import sys
if hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8") ner = BashkirPersonNER(Path(__file__).resolve().parent) for sample in sys.argv[1:]: print(json.dumps(ner.predict(sample), ensure_ascii=False))123version https://git-lfs.github.com/spec/v1oid sha256:4e77b9cfc9ab8c200406ee46c2d20fc46734da9ddcf01dff0f0e370f6c4ac244size 586970META.jsonAdded+64
README.mdAdded+183
SHA256SUMSAdded+10
benchmark_summary.jsonAdded+28
config.jsonAdded+21
example.pyAdded+18
onnx/model_fp32.onnxAdded+3
onnx/model_int8.onnxAdded+3
requirements.txtAdded+4
runtime.pyAdded+96
spm_bashkir_bert_16k.modelAdded+3