File size: 7,909 Bytes
fffc342 6198326 fffc342 6198326 fffc342 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | ---
language:
- ba
- ru
license: apache-2.0
pretty_name: Bashkir-Russian Pair Scorer
library_name: onnxruntime
pipeline_tag: text-classification
tags:
- bashkir
- russian
- alignment
- pair-scoring
- onnx
- onnxruntime
- low-resource
- open-source
---
# Bashkir-Russian Pair Scorer
> Compact ONNX models that score whether a Bashkir-Russian sentence pair is
> parallel, for fast corpus filtering.
## Overview
Compact ONNX models for estimating whether a Bashkir-Russian sentence pair is
parallel and suitable for corpus filtering. The release is designed for fast,
repeatable scoring of large bilingual corpora and contains three model sizes:
`nano`, `mini` and `medium`. This is an alignment-quality scorer, not a
translation model: it returns a compatibility score for a pair of texts and can
be used to build a filtering cascade.
| At a glance | |
| --- | --- |
| Task | Parallel-pair quality estimation |
| Default artifact | `models/mini/model.onnx` (recommended) |
| Source | Reviewed parallel Bashkir-Russian data |
| Version / license | v1 / Apache-2.0 |
## Contents
### Files and Configurations
| Path | Purpose | Size |
| --- | --- | ---: |
| `models/nano/model.onnx` | Fastest first-pass scorer | 9.1 MB |
| **`models/mini/model.onnx`** (recommended) | Balanced default for most batch jobs | 15.0 MB |
| `models/medium/model.onnx` | Compact higher-quality verifier | 23.2 MB |
| `spm_bpe_16k.model` | Shared SentencePiece tokenizer | — |
| `config.json` | Runtime contract and model metadata | — |
| `benchmark_summary.json` | Machine-readable evaluation results | — |
| `META.json` | Release passport and artifact hashes | — |
| `LICENSE` | Full license text | — |
| `SHA256SUMS` | Release checksums | — |
All configurations use the same SentencePiece vocabulary and the `fast128`
profile: FP16 weights, dynamic batch dimension and a maximum of 128 tokens per
side. This is a deliberate production design for stable speed and predictable
memory use; longer inputs are truncated before scoring.
### Model Architecture
| Property | Description |
| --- | --- |
| Task | Parallel-pair compatibility scoring |
| Directions | `ba_ru`, `ru_ba` |
| Profile | `fast128` (FP16, dynamic batch, ≤128 tokens per side) |
| Output | `score_logit` (Sigmoid to 0.0–1.0) |
| Tokenizer | `spm_bpe_16k.model` (SentencePiece BPE) |
| Runtime | ONNX Runtime on CPU or GPU |
| Starting thresholds | `accepted` ≥ 0.80, `review` ≥ 0.50 (heuristics; calibrate per corpus) |
### Examples
Scores from the `medium` model on CPU (Sigmoid of `score_logit`):
| Bashkir | Russian | Score |
| --- | --- | ---: |
| Бөгөн һауа бик йылы. | Сегодня очень тепло. | 0.981 |
| Башҡортостан Республикаһы — Рәсәй Федерацияһы субъекты. | Республика Башкортостан — субъект Российской Федерации. | 0.984 |
| Мин башҡорт телен яратам. | Квантовая механика описывает поведение микрочастиц и полей. | 0.000 |
## Method
```text
reviewed parallel data + hard negatives + teacher signals
├── 1. construct cross-encoder input pairs (ba + ru)
├── 2. train compact cross-encoder with margin-calibrated distillation
├── 3. optimize inference graphs with fast128 sequence profiling
└── 4. export ONNX family: nano, mini & medium (FP16 & INT8)
```
The models were trained for Bashkir-Russian parallel-corpus quality estimation
using reviewed parallel data, hard negative pairs and teacher/reference scoring
signals. The release contains model weights and tokenizer assets only; the source
corpus text is not included.
### Benchmark
Comparison on a calibrated bilingual evaluation set (10,000 positive pairs and
20,000 deterministic global/local hard negatives, excluded from training). Full
numbers are in [`benchmark_summary.json`](benchmark_summary.json).
| Model | ROC-AUC | Average Precision | RTX 4060 throughput |
| --- | ---: | ---: | ---: |
| LaBSE | 0.9944 | 0.9895 | 44.8 pairs/s |
| LaBSE + LASER | 0.9939 | 0.9871 | 44.8 pairs/s |
| DevLake BERT | 0.9896 | 0.9706 | 112.5 pairs/s |
| **Medium** | 0.9633 | 0.9155 | 2,555.9 pairs/s |
| **Mini** | 0.9590 | 0.9040 | 4,673.5 pairs/s |
| **Nano** | 0.9498 | 0.8785 | 7,472.2 pairs/s |
The compact scorers trade a small amount of discrimination for a large
throughput gain. A practical cascade is `nano`/`mini` for the first pass,
`medium` for uncertain pairs and LaBSE/LASER only for the final review layer.
## Quality and Use
Scores are not calibrated human probabilities. The `accepted`, `review` and
`quarantine` thresholds must be calibrated for a target corpus and a reviewed
sample. The `fast128` profile truncates long inputs; for long literary or document
segments use a review layer with a longer-context scorer.
### Limitations
- Alignment scores are model estimates, not human judgments.
- The benchmark is intended for comparison and does not guarantee production precision on every domain.
- `fast128` truncates inputs beyond 128 tokens per side.
- Starting thresholds are heuristics and require per-corpus calibration.
## Related Resources
- [Bashkir-Russian Wikipedia Parallel Corpus](https://huggingface.co/datasets/failed09/bashkir-wikipedia-parallel) —
uses the `medium` model to produce its `pair_score` column, a concrete
application of this scorer.
## Usage
```bash
pip install onnxruntime sentencepiece numpy
```
```python
import numpy as np
import onnxruntime as ort
import sentencepiece as spm
session = ort.InferenceSession(
"models/mini/model.onnx",
providers=["CUDAExecutionProvider", "CPUExecutionProvider"],
)
tokenizer = spm.SentencePieceProcessor(model_file="spm_bpe_16k.model")
def encode(ba, ru, max_len=128):
limit = (max_len - 3) // 2
ru_ids = tokenizer.encode(ru, out_type=int)[:limit]
ba_ids = tokenizer.encode(ba, out_type=int)[:limit]
ids = [1, *ru_ids, 2, *ba_ids, 2]
ids += [tokenizer.pad_id()] * (max_len - len(ids))
ids = np.asarray([ids], dtype=np.int64)
return {"input_ids": ids, "attention_mask": ids != tokenizer.pad_id()}
logit = session.run(["score_logit"], encode("Сәләм донъя", "Привет мир"))[0][0]
score = float(1 / (1 + np.exp(-logit)))
print(score)
```
For corpus-scale jobs, use the direct batch runner to avoid HTTP/JSON overhead and
stream Parquet, CSV/TSV or JSONL inputs.
## License
Distributed under the [Apache-2.0 license](https://huggingface.co/failed09/bashkir-pair-scorer/blob/main/LICENSE).
This release contains derived alignment-scoring software and model assets, not
source corpus text, scans or original page layouts.
## Citation
```bibtex
@software{failed09_bashkir_pair_scorer_2026,
title = {Bashkir-Russian Pair Scorer},
author = {failed09},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/failed09/bashkir-pair-scorer},
note = {Open-source compact alignment models for the Bashkir language}
}
```
## 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 other
materials used to derive this release; rights and licensing remain with the
original authors, publishers and dataset providers. Source texts are not
redistributed in this repository, so users should follow the licenses and
attribution requirements of the relevant upstream resources.
|