Text Classification
fastText
language-identification
continual-learning
leaf-surgery
table-3-multilingual-rehearsal
Instructions to use script-langid/fasttext-leaf-surgery-11lang with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- fastText
How to use script-langid/fasttext-leaf-surgery-11lang with fastText:
from huggingface_hub import hf_hub_download import fasttext model = fasttext.load_model(hf_hub_download("script-langid/fasttext-leaf-surgery-11lang", "model.bin")) - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,62 +1,51 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
-
|
| 5 |
-
-
|
| 6 |
-
-
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
|
| 14 |
-
tags:
|
| 15 |
-
- language-identification
|
| 16 |
-
- fasttext
|
| 17 |
-
- continual-learning
|
| 18 |
-
- leaf-surgery
|
| 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 |
-
model = ContinualLID.from_pretrained("script-langid/fasttext-leaf-surgery-11lang")
|
| 53 |
-
|
| 54 |
-
# Inference example:
|
| 55 |
-
text = "නමෝ තස්ස භගවතෝ අරහතෝ සම්මා සම්බුද්ධස්ස"
|
| 56 |
-
prediction = model.predict(text)
|
| 57 |
-
print(prediction) # 'pi' (Pali)
|
| 58 |
-
```
|
| 59 |
-
|
| 60 |
-
## Repository & Research
|
| 61 |
-
- **GitHub**: [Sinhala-Script-Language-Identification-LangID-for-Sinhala-Pali-and-Sanskrit](https://github.com/Maleesha-K/Sinhala-Script-Language-Identification-LangID-for-Sinhala-Pali-and-Sanskrit)
|
| 62 |
-
- **Research**: University of Moratuwa, Department of Computer Science & Engineering.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
language:
|
| 4 |
+
- sin
|
| 5 |
+
- pli
|
| 6 |
+
- san
|
| 7 |
+
- en
|
| 8 |
+
- ta
|
| 9 |
+
- hi
|
| 10 |
+
- bn
|
| 11 |
+
- ar
|
| 12 |
+
- fr
|
| 13 |
+
- de
|
| 14 |
+
tags:
|
| 15 |
+
- language-identification
|
| 16 |
+
- fasttext
|
| 17 |
+
- continual-learning
|
| 18 |
+
- leaf-surgery
|
| 19 |
+
- table-3-multilingual-rehearsal
|
| 20 |
+
pipeline_tag: text-classification
|
| 21 |
+
base_model: facebook/fasttext-language-identification
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
# fastText Continual Leaf Surgery: 11-Language Multilingual Rehearsal (Table 3)
|
| 25 |
+
|
| 26 |
+
This model represents our **Continual Learning (Leaf Surgery)** architecture trained with the 11-language balanced rehearsal buffer (Table 3 in the research paper):
|
| 27 |
+
> **"A Benchmark for Sinhala-Script Language Identification: Disambiguating Sinhala, Pali, and Sanskrit in Closed and Open World Contexts"**
|
| 28 |
+
> *University of Moratuwa, Department of Computer Science & Engineering*
|
| 29 |
+
|
| 30 |
+
## 1. Architecture & Innovation
|
| 31 |
+
- **Hierarchical Softmax Leaf Surgery**: The Sinhala (`si`) leaf node in the official Facebook `lid.176.bin` Huffman tree was split into Sinhala and Pali branches.
|
| 32 |
+
- **Multilingual Rehearsal**: Fine-tuned on the balanced 11-language Aya dataset buffer (3 target languages in Sinhala script + 8 global/anchor languages: English, Tamil, Hindi, Bengali, Arabic, French, German, and Sanskrit Devanagari) to preserve cross-lingual representations.
|
| 33 |
+
|
| 34 |
+
## 2. Benchmark Performance (11-Language Evaluation)
|
| 35 |
+
- **WiLI-2018 (Macro-F1):** **0.9811** (Accuracy: 98.00%)
|
| 36 |
+
- **CommonLID (Macro-F1):** **0.9486** (Accuracy: 96.82%)
|
| 37 |
+
- **FLORES+ (Macro-F1):** **0.9395** (Accuracy: 92.71%)
|
| 38 |
+
|
| 39 |
+
## 3. How to Load and Run Inference in Python
|
| 40 |
+
```python
|
| 41 |
+
from data_pipeline.fasttext_continual.model import ContinualLID
|
| 42 |
+
|
| 43 |
+
# Loads weights.pt, config.json, and vocab.json automatically from Hugging Face
|
| 44 |
+
model = ContinualLID.from_pretrained("script-langid/fasttext-leaf-surgery-11lang")
|
| 45 |
+
|
| 46 |
+
# Inference example:
|
| 47 |
+
text = "නමෝ තස්ස භගවතෝ අරහතෝ සම්මා සම්බුද්ධස්ස"
|
| 48 |
+
prediction, score = model.predict(text)
|
| 49 |
+
print(f"Language: {prediction}, Score: {score:.4f}")
|
| 50 |
+
# Output: Language: pi, Score: 0.99...
|
| 51 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|