CoolFace
Modelpublic

failed09/bashkir-lid

sourceHugging Faceapache-2.0updated 4d agoView on Hugging Face
0likes51downloads
Model Card

Bashkir LID (Binary BA vs NON_BA)

Compact ONNX language gate that decides whether text is Bashkir, for corpus filtering and local CPU inference.

Overview

A compact binary language gate for Bashkir (ba vs non_ba), designed for corpus filtering, OCR triage and local applications that need lightweight CPU inference. It was trained with hard negatives from sister Turkic languages, Russian and technical/noisy text, with special attention to Bashkir/Tatar separation.

At a glance
TaskBinary language identification (ba vs non_ba)
Default artifactmodel.onnx + lid.py
SourceBashkir, Turkic, Russian and technical text (not redistributed)
Version / licensev3 / Apache-2.0

Contents

Files and Configurations

FilePurpose
model.onnxExported classifier graph and weights (opset 17)
vectorizer.jsonDual-channel character and word feature vocabularies
lid.pyPortable ONNX Runtime adapter
config.jsonRuntime contract
META.jsonModel passport, validation results and artifact hashes
__init__.pyPackage marker
SHA256SUMSRelease checksums

Training texts and the original joblib pipeline are not distributed.

Model Architecture

PropertyDescription
TaskBinary language identification: ba or non_ba
FeaturesDual-channel TF-IDF: char_wb (2–5) + word (1–2), 240,000 features
ClassifierLinear SGD classifier exported to ONNX with Sigmoid normalization
RuntimeONNX Runtime on CPU
PreprocessingUnicode lowercase and dual-channel sparse features, provided by lid.py
OutputsClass labels (ba, non_ba) and probabilities

The ONNX graph takes sparse feature tensors (char_ids, char_counts, word_ids, word_counts); the adapter handles preprocessing, batching and checksum validation. No custom ONNX operators or Transformers installation are required.

Examples

TextPrediction`ba` probability
Мин башҡорт телен яратам.ba0.998
Бары бала бара.ba0.927
Сегодня хорошая погода.non_ba0.044
SELECT id FROM users WHERE active = TRUE;non_ba0.011

Note the second row: valid Bashkir text does not always contain Bashkir-specific letters.

Method

The model is a dual-channel linear classifier: TF-IDF char_wb (2–5) and word (1–2) features are fused and passed to an SGD classifier exported to ONNX. It was trained with hard negatives from sister Turkic languages, Russian and technical/noisy text. Training texts are not distributed in this repository.

Evaluation

On a weak-label 4,000-sentence benchmark the model reached 93.25% binary accuracy: at the default 0.50 threshold it retained 730/1,000 Bashkir examples and rejected 3,000/3,000 non-Bashkir examples. A hand-authored adversarial suite passed 26/26 (Tatar, Kazakh, Chuvash, Russian with Bashkir inserts, code and noise), and an independent 100-example stress set reached 97/100. Labels are weak or manually constructed, not an expert-reviewed Gold benchmark; exact numbers are recorded in `META.json`.

Operating thresholds

predict() selects ba when its probability is at least 0.50. Measured operating points (from `META.json`):

BA probability thresholdBA recallNon-BA false acceptance
0.5073.0% (730/1,000)0/3,000
0.4078.3% (783/1,000)2/3,000
0.3580.8% (808/1,000)4/3,000

Use 0.50 for the strictest rejection of non-Bashkir text. Use 0.35–0.40 when preserving more Bashkir text matters, preferably with dictionary and quality checks. The price of the strict gate is false rejection of some valid Bashkir sentences, especially short or BA/Tatar-like sentences.

Quality and Use

This is a binary gate, not a general multilingual language detector. It does not identify which non-BA language was found. Tatar and other languages, short strings, names, OCR artifacts and mixed-language text can be ambiguous.

Limitations

  • Binary decision only: ba vs non_ba, with no language label for rejects.
  • Weak-label benchmark; not an expert-reviewed Gold evaluation.
  • Confidence values are model scores, not calibrated human probabilities.
  • Empty strings, OCR fragments and technical noise should be handled with explicit pipeline rules.
  • For high-recall corpus construction, combine with the multiclass LID, dictionaries, quality rules and human review.

Related Resources

  • Bashkir Multiclass LID — distinguishes ba, tt, ru and other; use it when you need the language label instead of a pass/reject gate.

Usage

bash
pip install huggingface_hub onnxruntime numpy
python
import sys
from huggingface_hub import snapshot_download

model_dir = snapshot_download(
    "failed09/bashkir-lid",
    allow_patterns=[
        "lid.py", "config.json", "META.json", "model.onnx", "vectorizer.json"
    ],
    revision="main",  # pin a reviewed commit for reproducible deployments
)
sys.path.insert(0, model_dir)
from lid import LanguageIdentifier

lid = LanguageIdentifier(model_dir=model_dir)
texts = ["Мин башҡорт телен яратам.", "Сегодня хорошая погода."]
print(lid.predict(texts).tolist())
print(lid.predict_proba(texts))
print(lid.classes.tolist())  # probability-column order

After downloading, inference runs locally without network access. For a local checkout with the model files alongside lid.py, LanguageIdentifier() also works without extra arguments.

License

The code and model export are released under the Apache-2.0 license. Training texts are not included in this repository.

Citation

bibtex
@software{failed09_bashkir_lid_2026,
  title = {Bashkir LID},
  author = {failed09},
  year = {2026},
  publisher = {Hugging Face},
  url = {https://huggingface.co/failed09/bashkir-lid},
  note = {Compact binary Bashkir language gate}
}

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.