Downloads · 30 days
4
25% of all-time downloads
script-langid/fasttext-lid-176-sinhala-pali-sanskrit
fasttext-lid-176-sinhala-pali-sanskrit is a text classification model from script-langid. Use it when you need a label for a piece of text. It is set up for fasttext. The card lists the license as cc-by-nc-4.0.
This repository contains the fine-tuned specialist fastText model for Sinhala-script Language Identification, developed as part of the paper: "A Benchmark for Sinhala-Script Language Identification: Disambiguating Sin…
Downloads · 30 days
4
25% of all-time downloads
All-time downloads
16
Public
Repo size
166 MB
Likes
1
Public
Click a slice to open those files.
.bin166 MB · 100%
From the Hugging Face model README
This repository contains the fine-tuned specialist fastText model for Sinhala-script Language Identification, developed as part of the paper:
"A Benchmark for Sinhala-Script Language Identification: Disambiguating Sinhala, Pali, and Sanskrit in Closed and Open World Contexts"
Planetary-scale LangID tools (including stock fastText LID-176) assign all text written in the Sinhala script to a monolithic si label. When presented with historical or canonical Buddhist and scholarly literature written in Sinhala script, stock models fail completely:
pli_Sinh): 0.0% F1 (Stock zero-shot)san_Sinh): 0.0% F1 (Stock zero-shot)To eliminate script ambiguity while guaranteeing mathematical 0.0% degradation on all 176 global background languages, we deploy this model in a Two-Stage Specialist Routing Pipeline:
fastText LID-176 (lid.176.bin) classifies incoming text.
!= 'si'), the global label (English, Tamil, Hindi, Devanagari Sanskrit, French, etc.) is emitted directly.== 'si'), the input is routed to this specialist model (model.bin), which performs fine-grained 3-way discrimination:
__label__sinhala (Sinh-Sinh)__label__pali (Pali-Sinh)__label__sanskrit (San-Sinh)| Benchmark Dataset | Sinhala-Sinh F1 | Pali-Sinh F1 | Sanskrit-Sinh F1 | Sanskrit-Deva F1 | Overall Macro-F1 |
|---|---|---|---|---|---|
| FLORES+ (Hybrid) | 0.9611 | 0.9751 | 0.9805 | 0.9594 | 0.9276 |
| CommonLID (Hybrid) | 0.9609 | 0.9751 | 0.9805 | 0.8886 | 0.9645 |
| WiLI-2018 (Hybrid) | 0.9611 | 0.9751 | 0.9805 | 0.9904 | 0.9745 |
(Note: Background languages such as English, Tamil, Arabic, Bengali, French, and German retain their pristine stock fastText performance).
import fasttext
from huggingface_hub import hf_hub_download
# 1. Download Stage 1 (Stock FastText) and Stage 2 (Specialist)
stage1_path = hf_hub_download(repo_id="facebook/fasttext-language-identification", filename="model.bin")
stage2_path = hf_hub_download(repo_id="script-langid/fasttext-lid-176-sinhala-pali-sanskrit", filename="model.bin")
stage1_model = fasttext.load_model(stage1_path)
stage2_model = fasttext.load_model(stage2_path)
def identify_language(text: str):
# Stage 1: Global screening
pred1, prob1 = stage1_model.predict(text.replace("\n", " "))
label1 = pred1[0].replace("__label__", "")
# If Sinhala script detected by Stage 1, route to Stage 2
if label1 in ["si", "sin", "sin_Sinh"]:
pred2, prob2 = stage2_model.predict(text.replace("\n", " "))
target_label = pred2[0].replace("__label__", "")
return {
"language": f"{target_label.capitalize()}-Sinh",
"stage": 2,
"confidence": float(prob2[0])
}
else:
return {
"language": label1,
"stage": 1,
"confidence": float(prob1[0])
}
# Example: Pali Buddhist Verse in Sinhala Script
sample_pali = "මනොපුබ්බඞ්ගමා ධම්මා මනොසෙට්ඨා මනොමයා"
print(identify_language(sample_pali))
# Output: {'language': 'Pali-Sinh', 'stage': 2, 'confidence': 0.99...}
@inproceedings{sinhala_script_langid_2026,
title={A Benchmark for Sinhala-Script Language Identification: Disambiguating Sinhala, Pali, and Sanskrit in Closed and Open World Contexts},
author={Anonymous},
booktitle={Proceedings of the Association for Computational Linguistics (ACL)},
year={2026}
}