Card: unified structure, real examples, license link
Browse files- README.md +103 -83
- SHA256SUMS +2 -2
README.md
CHANGED
|
@@ -22,50 +22,118 @@ tags:
|
|
| 22 |
|
| 23 |
# Bashkir Multiclass LID
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
- `tt` — Tatar;
|
| 30 |
-
- `ru` — Russian;
|
| 31 |
-
- `other` — other languages, code, URLs, technical noise and corrupted text.
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
| 35 |
classified as Bashkir.
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
| Property | Description |
|
| 40 |
| --- | --- |
|
| 41 |
| Task | Four-class language identification |
|
|
|
|
| 42 |
| Classes | `ba`, `tt`, `ru`, `other` |
|
| 43 |
-
|
|
| 44 |
-
|
|
| 45 |
-
| Classifier | `SGDClassifier(loss="log_loss")` |
|
| 46 |
-
| Export | ONNX, opset 17 |
|
| 47 |
-
| Runtime | ONNX Runtime on CPU |
|
| 48 |
-
| Input handling | Unicode-aware adapter in `lid.py` |
|
| 49 |
|
| 50 |
-
|
| 51 |
-
provided adapter performs tokenization, feature lookup, batching and checksum
|
| 52 |
-
validation. No custom ONNX operators or Transformers installation are needed.
|
| 53 |
|
| 54 |
-
## Files
|
| 55 |
|
| 56 |
| File | Purpose |
|
| 57 |
| --- | --- |
|
| 58 |
-
| `model.onnx` | Exported classifier graph and weights |
|
| 59 |
| `vectorizer.json` | Character and word feature vocabularies |
|
| 60 |
| `lid.py` | Portable ONNX Runtime adapter |
|
| 61 |
| `config.json` | Runtime contract and feature settings |
|
| 62 |
-
| `META.json` | Model passport, validation and artifact hashes |
|
| 63 |
| `requirements.txt` | Minimal runtime dependencies |
|
| 64 |
| `SHA256SUMS` | Release checksums |
|
| 65 |
|
| 66 |
Training texts and the original `joblib` pipeline are not distributed.
|
| 67 |
|
| 68 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
```bash
|
| 71 |
pip install huggingface_hub onnxruntime numpy
|
|
@@ -78,9 +146,9 @@ from huggingface_hub import snapshot_download
|
|
| 78 |
model_dir = snapshot_download(
|
| 79 |
"failed09/bashkir-lid-multiclass",
|
| 80 |
allow_patterns=[
|
| 81 |
-
"lid.py", "config.json", "META.json", "model.onnx",
|
| 82 |
-
"vectorizer.json"
|
| 83 |
],
|
|
|
|
| 84 |
)
|
| 85 |
sys.path.insert(0, model_dir)
|
| 86 |
from lid import LanguageIdentifier
|
|
@@ -98,62 +166,14 @@ print(lid.predict_proba(texts))
|
|
| 98 |
print(lid.classes.tolist()) # probability-column order
|
| 99 |
```
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
network connection. The probability-column order is always the order in
|
| 104 |
-
`META.json`.
|
| 105 |
-
|
| 106 |
-
## Related Binary Gate
|
| 107 |
-
|
| 108 |
-
Use this multilingual model when you need to distinguish between `ba`, `tt`,
|
| 109 |
-
`ru` and `other`. If the task is instead a strict Bashkir corpus gate, use the
|
| 110 |
-
companion [Bashkir Binary LID](https://huggingface.co/failed09/bashkir-lid),
|
| 111 |
-
which predicts only `ba` versus `non_ba` and documents configurable thresholds.
|
| 112 |
-
|
| 113 |
-
## Evaluation Summary
|
| 114 |
-
|
| 115 |
-
| Evaluation | Result |
|
| 116 |
-
| --- | ---: |
|
| 117 |
-
| Clean multi-source benchmark | 92.67% accuracy (3,707/4,000) |
|
| 118 |
-
| Bashkir subset | 81.70% recall (817/1,000) |
|
| 119 |
-
| Tatar subset | 100.00% recall (1,000/1,000) |
|
| 120 |
-
| Russian subset | 91.40% recall (914/1,000) |
|
| 121 |
-
| Other subset | 97.60% recall (976/1,000) |
|
| 122 |
-
| Linguistic adversarial stress test | 39/39 (100%) |
|
| 123 |
-
| ONNX/sklearn label parity | 0 disagreements |
|
| 124 |
-
|
| 125 |
-
The clean benchmark contains 1,000 examples each from Bashkir, Tatar,
|
| 126 |
-
Russian and other-language/noise sources. The adversarial set includes
|
| 127 |
-
closely related Bashkir/Tatar pairs, code-switching, Kazakh, Chuvash, Russian
|
| 128 |
-
regional text and technical noise.
|
| 129 |
-
|
| 130 |
-
## Interpretation and Mixed Text
|
| 131 |
-
|
| 132 |
-
Mixed-language text does not have a separate class. Predictions should be
|
| 133 |
-
interpreted as the dominant language of the sentence. In a corpus pipeline,
|
| 134 |
-
confident Bashkir can be retained, while uncertain BA/TT or mixed cases should
|
| 135 |
-
be sent to a review queue instead of being deleted automatically.
|
| 136 |
-
|
| 137 |
-
Short sentences with common Turkic vocabulary remain intrinsically ambiguous.
|
| 138 |
-
This is expected for Bashkir and Tatar, especially in border regions and
|
| 139 |
-
informal online writing.
|
| 140 |
-
|
| 141 |
-
## Limitations
|
| 142 |
-
|
| 143 |
-
- This is a lightweight text classifier, not a universal language detector.
|
| 144 |
-
- The reported benchmark is not an expert-reviewed Gold benchmark.
|
| 145 |
-
- Some benchmark examples come from the same source pools used during model
|
| 146 |
-
development; source overlap was not fully excluded.
|
| 147 |
-
- The adversarial test is small and hand-authored.
|
| 148 |
-
- Confidence values are model scores, not calibrated human probabilities.
|
| 149 |
-
- Empty strings, OCR fragments and technical noise should be handled with
|
| 150 |
-
explicit pipeline rules.
|
| 151 |
|
| 152 |
## License
|
| 153 |
|
| 154 |
Distributed under the [Apache-2.0 license](https://www.apache.org/licenses/LICENSE-2.0).
|
| 155 |
-
This release contains derived model and tokenizer assets, not the source
|
| 156 |
-
|
| 157 |
|
| 158 |
## Citation
|
| 159 |
|
|
@@ -170,12 +190,12 @@ corpus, scans or original document layouts.
|
|
| 170 |
|
| 171 |
## Open Bashkir Data and Sources 🐝
|
| 172 |
|
| 173 |
-
This
|
| 174 |
preservation and practical use of the Bashkir language. Other related models,
|
| 175 |
datasets and tools are available on the author's Hugging Face profile.
|
| 176 |
|
| 177 |
The author does not claim ownership or authorship of the source texts or other
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
redistributed in this repository
|
| 181 |
-
|
|
|
|
| 22 |
|
| 23 |
# Bashkir Multiclass LID
|
| 24 |
|
| 25 |
+
> Compact ONNX language identification for `ba`, `tt`, `ru` and `other`, for
|
| 26 |
+
> Bashkir corpus filtering and local CPU inference.
|
| 27 |
|
| 28 |
+
## Overview
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
A compact ONNX language-identification model for Bashkir corpus filtering and
|
| 31 |
+
local CPU applications. It predicts four classes: `ba` (Bashkir), `tt` (Tatar),
|
| 32 |
+
`ru` (Russian) and `other` (other languages, code, URLs, technical noise and
|
| 33 |
+
corrupted text). It is designed to separate closely related Bashkir and Tatar
|
| 34 |
+
text while preventing foreign-language and technical material from being silently
|
| 35 |
classified as Bashkir.
|
| 36 |
|
| 37 |
+
| At a glance | |
|
|
|
|
|
|
|
| 38 |
| --- | --- |
|
| 39 |
| Task | Four-class language identification |
|
| 40 |
+
| Default artifact | `model.onnx` + `lid.py` |
|
| 41 |
| Classes | `ba`, `tt`, `ru`, `other` |
|
| 42 |
+
| Source | Bashkir, Tatar, Russian and technical text (not redistributed) |
|
| 43 |
+
| Version / license | v3 / Apache-2.0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
## Contents
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
### Files and Configurations
|
| 48 |
|
| 49 |
| File | Purpose |
|
| 50 |
| --- | --- |
|
| 51 |
+
| `model.onnx` | Exported classifier graph and weights (opset 17) |
|
| 52 |
| `vectorizer.json` | Character and word feature vocabularies |
|
| 53 |
| `lid.py` | Portable ONNX Runtime adapter |
|
| 54 |
| `config.json` | Runtime contract and feature settings |
|
| 55 |
+
| `META.json` | Model passport, validation results and artifact hashes |
|
| 56 |
| `requirements.txt` | Minimal runtime dependencies |
|
| 57 |
| `SHA256SUMS` | Release checksums |
|
| 58 |
|
| 59 |
Training texts and the original `joblib` pipeline are not distributed.
|
| 60 |
|
| 61 |
+
### Model Architecture
|
| 62 |
+
|
| 63 |
+
| Property | Description |
|
| 64 |
+
| --- | --- |
|
| 65 |
+
| Task | Four-class language identification |
|
| 66 |
+
| Classes | `ba`, `tt`, `ru`, `other` |
|
| 67 |
+
| Character features | TF-IDF `char_wb` n-grams, lengths 2–5 |
|
| 68 |
+
| Word features | TF-IDF word n-grams, lengths 1–2 |
|
| 69 |
+
| Classifier | `SGDClassifier(loss="log_loss")` |
|
| 70 |
+
| Export | ONNX, opset 17 |
|
| 71 |
+
| Runtime | ONNX Runtime on CPU |
|
| 72 |
+
| Input handling | Unicode-aware adapter in `lid.py` |
|
| 73 |
+
|
| 74 |
+
The ONNX graph consumes sparse feature tensors rather than raw strings; the
|
| 75 |
+
adapter performs tokenization, feature lookup, batching and checksum validation.
|
| 76 |
+
No custom ONNX operators or Transformers installation are needed.
|
| 77 |
+
|
| 78 |
+
### Examples
|
| 79 |
+
|
| 80 |
+
| Text | Prediction | Top probability |
|
| 81 |
+
| --- | --- | ---: |
|
| 82 |
+
| `Бары бала бара.` | `ba` | 0.829 |
|
| 83 |
+
| `Бүген Казанда яңа мәдәни үзәк ачылды.` | `tt` | 0.919 |
|
| 84 |
+
| `В Уфе открыли новый корпус университета.` | `ru` | 0.930 |
|
| 85 |
+
| `SELECT id FROM users WHERE active = TRUE;` | `other` | 0.982 |
|
| 86 |
+
|
| 87 |
+
## Method
|
| 88 |
+
|
| 89 |
+
The model is a dual-channel linear classifier: TF-IDF `char_wb` (2–5) and word
|
| 90 |
+
(1–2) features are fused and passed to an `SGDClassifier` exported to ONNX. It is
|
| 91 |
+
trained on Bashkir, Tatar, Russian and other-language material with technical
|
| 92 |
+
noise. Training texts are not distributed in this repository.
|
| 93 |
+
|
| 94 |
+
### Evaluation
|
| 95 |
+
|
| 96 |
+
The clean multi-source benchmark contains 1,000 examples each from Bashkir,
|
| 97 |
+
Tatar, Russian and other-language/noise sources; the adversarial set includes
|
| 98 |
+
closely related Bashkir/Tatar pairs, code-switching, Kazakh, Chuvash, Russian
|
| 99 |
+
regional text and technical noise.
|
| 100 |
+
|
| 101 |
+
| Evaluation | Result |
|
| 102 |
+
| --- | ---: |
|
| 103 |
+
| Clean multi-source benchmark | 92.67% accuracy (3,707/4,000) |
|
| 104 |
+
| Bashkir subset | 81.70% recall (817/1,000) |
|
| 105 |
+
| Tatar subset | 100.00% recall (1,000/1,000) |
|
| 106 |
+
| Russian subset | 91.40% recall (914/1,000) |
|
| 107 |
+
| Other subset | 97.60% recall (976/1,000) |
|
| 108 |
+
| Linguistic adversarial stress test | 39/39 (100%) |
|
| 109 |
+
| ONNX / sklearn label parity | 0 disagreements |
|
| 110 |
+
|
| 111 |
+
The benchmark is not expert-reviewed Gold and some examples come from the same
|
| 112 |
+
source pools used during model development; source overlap was not fully
|
| 113 |
+
excluded. Exact validation fields are recorded in [`META.json`](META.json).
|
| 114 |
+
|
| 115 |
+
## Quality and Use
|
| 116 |
+
|
| 117 |
+
Mixed-language text does not have a separate class: predictions should be read as
|
| 118 |
+
the dominant language of the sentence. In a corpus pipeline, confident Bashkir can
|
| 119 |
+
be retained, while uncertain BA/TT or mixed cases should be sent to a review queue
|
| 120 |
+
instead of being deleted automatically. Short sentences with common Turkic
|
| 121 |
+
vocabulary remain intrinsically ambiguous.
|
| 122 |
+
|
| 123 |
+
### Limitations
|
| 124 |
+
|
| 125 |
+
- A lightweight text classifier, not a universal language detector.
|
| 126 |
+
- The reported benchmark is not an expert-reviewed Gold benchmark.
|
| 127 |
+
- Confidence values are model scores, not calibrated human probabilities.
|
| 128 |
+
- Empty strings, OCR fragments and technical noise should be handled with explicit pipeline rules.
|
| 129 |
+
|
| 130 |
+
## Related Resources
|
| 131 |
+
|
| 132 |
+
- [Bashkir LID (Binary BA vs NON_BA)](https://huggingface.co/failed09/bashkir-lid) —
|
| 133 |
+
a strict `ba` vs `non_ba` gate with configurable thresholds; use it when only a
|
| 134 |
+
pass/reject decision is needed.
|
| 135 |
+
|
| 136 |
+
## Usage
|
| 137 |
|
| 138 |
```bash
|
| 139 |
pip install huggingface_hub onnxruntime numpy
|
|
|
|
| 146 |
model_dir = snapshot_download(
|
| 147 |
"failed09/bashkir-lid-multiclass",
|
| 148 |
allow_patterns=[
|
| 149 |
+
"lid.py", "config.json", "META.json", "model.onnx", "vectorizer.json"
|
|
|
|
| 150 |
],
|
| 151 |
+
revision="main", # pin a reviewed commit for reproducible deployments
|
| 152 |
)
|
| 153 |
sys.path.insert(0, model_dir)
|
| 154 |
from lid import LanguageIdentifier
|
|
|
|
| 166 |
print(lid.classes.tolist()) # probability-column order
|
| 167 |
```
|
| 168 |
|
| 169 |
+
After downloading, inference runs locally without network access. The
|
| 170 |
+
probability-column order is always the order in [`META.json`](META.json).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
## License
|
| 173 |
|
| 174 |
Distributed under the [Apache-2.0 license](https://www.apache.org/licenses/LICENSE-2.0).
|
| 175 |
+
This release contains derived model and tokenizer assets, not the source corpus,
|
| 176 |
+
scans or original document layouts.
|
| 177 |
|
| 178 |
## Citation
|
| 179 |
|
|
|
|
| 190 |
|
| 191 |
## Open Bashkir Data and Sources 🐝
|
| 192 |
|
| 193 |
+
This release is part of an open-source effort to support the development,
|
| 194 |
preservation and practical use of the Bashkir language. Other related models,
|
| 195 |
datasets and tools are available on the author's Hugging Face profile.
|
| 196 |
|
| 197 |
The author does not claim ownership or authorship of the source texts or other
|
| 198 |
+
materials used to derive this release; rights and licensing remain with the
|
| 199 |
+
original authors, publishers and dataset providers. Source texts are not
|
| 200 |
+
redistributed in this repository, so users should follow the licenses and
|
| 201 |
+
attribution requirements of the relevant upstream resources.
|
SHA256SUMS
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
|
|
|
|
|
| 1 |
1c9f27d5d0e56968f472417b8258a4188d3df8c3bbde0fefc6f1c4d3510a58dd config.json
|
| 2 |
a64200ae65f0d6449500ec35d4c74a5ed0c43e10902886add7aa3ef406a5724c lid.py
|
| 3 |
-
ee51fe10152186b053dcaf9ee9799b6bc09c6cce568926c323cd43bd4bd4436d META.json
|
| 4 |
09d04d16bfd319da0bd931af0ce9311472fee8a9b75e7fd67c0a31a03e90fa07 model.onnx
|
| 5 |
-
8783337bcc753eb92de9ec446ccc3fa83cbe4caf13f29b0917b2a2972b67302d README.md
|
| 6 |
0eb4ce313d9058b8cf7e5b358f96615d7df224c897e08904333956349cbd1785 requirements.txt
|
| 7 |
9e2d3fd13186274867f06b2b2be02e6c769dc5b445621e676a76666f00265828 vectorizer.json
|
|
|
|
| 1 |
+
ee51fe10152186b053dcaf9ee9799b6bc09c6cce568926c323cd43bd4bd4436d META.json
|
| 2 |
+
8530a32e22a33c26d73e678d223f605e8967c3d78cab71f6197d76a00dcda3b9 README.md
|
| 3 |
1c9f27d5d0e56968f472417b8258a4188d3df8c3bbde0fefc6f1c4d3510a58dd config.json
|
| 4 |
a64200ae65f0d6449500ec35d4c74a5ed0c43e10902886add7aa3ef406a5724c lid.py
|
|
|
|
| 5 |
09d04d16bfd319da0bd931af0ce9311472fee8a9b75e7fd67c0a31a03e90fa07 model.onnx
|
|
|
|
| 6 |
0eb4ce313d9058b8cf7e5b358f96615d7df224c897e08904333956349cbd1785 requirements.txt
|
| 7 |
9e2d3fd13186274867f06b2b2be02e6c769dc5b445621e676a76666f00265828 vectorizer.json
|