CoolFace
Modelpublic

AneekC/lid-specialists-9plus1

sourceHugging Facemitupdated 7d agoView on Hugging Face
0likes
Model Card

Language-ID specialists for nine languages plus other

Three small models that decide inside confusion groups where a general language identifier is weakest: Malay vs Indonesian, Simplified vs Traditional Chinese, and romanized Hindi vs romanized Urdu vs English. They are stage 2 of a two-stage detector; stage 1 is GlotLID (Apache-2.0), which is not redistributed here.

Trained for a multilingual retrieval application, where misreading the question's language sends the whole answer to the wrong knowledge base.

The three models

FileSize on diskWhat it is
lid-specialist-fasttext.ftz1.9 MBfastText classifier, quantized
lid-specialist-e5-head.onnx818 KBlinear head over frozen e5 embeddings
lid-specialist-e5-finetune.onnx471.6 MBmultilingual-e5-small fine-tuned end to end

The 818 KB head is not an 818 KB model. It needs intfloat/multilingual-e5-small to produce embeddings first, so its real footprint is about 471 MB. Only the fastText model is genuinely small.

Labels (12)

eng_Latn, ind_Latn, zsm_Latn, zho_Hans, zho_Hant, jpn_Jpan, kor_Hang, tam_Taml, hin_Deva, hin_Latn, urd_Latn, other

Every language outside the nine supported ones is other.

Results

FLORES-200 devtest, specialist label space. Measured in this project; the generated table lives in training/RESULTS.md in the source repository.

DetectorMacro-F1Group macro-F1malay_indonesianhanromanized_hindi`other` F1Sentences/s
GlotLID (full)0.9390.8940.9240.8160.9920.9971538
GlotLID (compressed)0.9430.9000.9380.8150.9920.9971257
lid.1760.6320.4510.2610.8060.1200.92219045
specialist-fasttext0.8820.8640.8570.8280.9490.99214577
two-stage + fasttext0.9410.8960.9230.8220.9930.9971119
specialist-e5-head0.6530.6560.4100.8100.8410.92322
two-stage + e5-head0.9360.8870.9000.8230.9920.997288
specialist-e5-finetune0.9250.8970.9110.8330.9950.99426
two-stage + e5-finetune0.9420.8990.9230.8270.9940.997328

Read this honestly: the specialists are not better than GlotLID on their own. Used alone, specialist-e5-head scores 0.653 against GlotLID's 0.939. The gain is in the two-stage arrangement, and it is small — 0.942 against 0.939 overall, with the group macro-F1 moving 0.894 to 0.899. What the specialists buy is the confusion groups: the han column goes 0.816 to 0.827, and romanized_hindi 0.992 to 0.994.

The strongest practical result is speed. specialist-fasttext reaches 0.882 macro-F1 at 14,577 sentences/s in 1.9 MB, against GlotLID's 0.939 at 1,538 sentences/s in 1.69 GB.

By input shape

Macro-F1 per slice, plus latency.

DetectorFLORES sentence1-3 wordsparagraphcode-mixedDakshina sentenceDakshina wordsp50 msp95 ms
GlotLID (full)0.9740.7620.9830.5500.9380.1420.640.89
lid.1760.8170.7400.8890.3610.0010.0030.060.13
specialist-fasttext0.9630.8370.9970.6830.8480.5790.050.14
specialist-e5-finetune0.9640.8560.9620.7390.9340.67582.00138.28

Short and code-mixed input is where the specialists earn their place: on single words from Dakshina, GlotLID scores 0.142 and lid.176 scores 0.003, while the fine-tuned model reaches 0.675.

Training data

Not redistributed. The full record is training/data/DATACARD.md in the source repository.

SourceLicenceUsed for
OpenLID, revision 67b9a87a9f52, 7 of 44 shardsother: varies by source datasetnatural lines for the nine labels and other
Dakshina v1.0CC BY-SA 4.0romanized Hindi and Urdu (test files held out)
FLORES-200CC BY-SA 4.0contamination check only

360,000 training rows and 24,000 validation rows, capped at 100,000 lines per label. Cleaning normalizes (NFKC), strips invisible characters, collapses whitespace, and drops lines under two characters and exact duplicates. Synthetic rows: OpenCC Simplified/ Traditional conversions, 1-3 word crops from 10% of natural lines, and code-mixed rows equal to 2% of natural lines.

Contamination: 7,543 training lines were removed for matching a FLORES-200 dev/devtest sentence or a Dakshina test item. The final check found 0 rows overlapping any held-out line across every split.

Training setup

lid-specialist-e5-finetune: learning rate 3e-05, batch size 32, max length 128, 2 epochs maximum, 6% warmup, weight decay 0.01, dropout 0.1, seed 20260915. About 36 minutes on an RTX 5060 Laptop GPU (torch 2.14.0+cu130, bf16). ONNX export agrees with the PyTorch model to 3.8e-06 maximum absolute difference.

Inputs use the e5 convention: prefix query: , max length 128.

Limitations

  • OpenCC conversions do not read like natively written Simplified or Traditional Chinese.
  • 1-3 word crops are cut from sentences, not collected from real queries.
  • Code-mixed rows are two whole sentences joined, labelled by the longer part. Real code-mixing happens inside a sentence.
  • The contamination check matches whole lines after normalization, so a held-out sentence embedded inside a longer line is not caught.
  • For hin_Latn, urd_Latn, zho_Hans and zho_Hant the test split is a hash split from the same sources as training, not source-disjoint. Those scores are likely optimistic against text from new sources.
  • Romanized Hindi and Urdu come from one source (Dakshina: Wikipedia sentences romanized by annotators), so they do not represent romanization as people type it.
  • Anything outside the nine languages is only ever other. This is not a general-purpose language identifier; use GlotLID for that.

Licences

Weights are MIT, matching the source repository's code. They are derived from intfloat/multilingual-e5-small (MIT) and trained on the data above; OpenLID's licence is listed as "other" and varies by source corpus, and the underlying data is not redistributed here.

Citation

Comparison figures in the source repository's results come from:

  • Kargaran et al. 2023, GlotLID: Language Identification for Low-Resource Languages (arXiv:2310.16248)
  • Burchell et al. 2023, An Open Dataset and Model for Language Identification (arXiv:2305.13820)

Those figures come from the papers' own model versions and label mappings. They are context, not a reproduction.