Instructions to use mbazaNLP/Quantized_Nllb_Finetuned_Edu_En_Kin_8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mbazaNLP/Quantized_Nllb_Finetuned_Edu_En_Kin_8bit with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("translation", model="mbazaNLP/Quantized_Nllb_Finetuned_Edu_En_Kin_8bit")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mbazaNLP/Quantized_Nllb_Finetuned_Edu_En_Kin_8bit", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update model card: Intended Use, Limitations, code example, BibTeX, licence/email/description fixes
#1
by rdelyon - opened
README.md
CHANGED
|
@@ -1,73 +1,117 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-2.0
|
| 3 |
datasets:
|
| 4 |
-
- mbazaNLP/NMT_Tourism_parallel_data_en_kin
|
| 5 |
- mbazaNLP/NMT_Education_parallel_data_en_kin
|
| 6 |
- mbazaNLP/Kinyarwanda_English_parallel_dataset
|
|
|
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
- rw
|
| 10 |
library_name: transformers
|
| 11 |
-
|
| 12 |
pipeline_tag: translation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
-
## Model Details
|
| 15 |
|
| 16 |
-
#
|
| 17 |
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
## Quantization
|
| 25 |
|
| 26 |
-
|
| 27 |
-
```
|
| 28 |
pip install ctranslate2
|
| 29 |
-
|
| 30 |
-
Using the command:
|
| 31 |
-
```
|
| 32 |
-
ct2-transformers-converter --model <model-dir> --quantization int8 --output_dir <output-model-dir>
|
| 33 |
```
|
| 34 |
|
| 35 |
-
|
| 36 |
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
-
Use the code below to get started with the model.
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
### Training Procedure
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
| 50 |
-
-
|
| 51 |
-
-
|
| 52 |
-
-
|
| 53 |
|
| 54 |
-
|
| 55 |
-
-
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
## Evaluation
|
| 61 |
|
| 62 |
-
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
##
|
| 70 |
|
| 71 |
-
|
| 72 |
|
| 73 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-2.0
|
| 3 |
datasets:
|
|
|
|
| 4 |
- mbazaNLP/NMT_Education_parallel_data_en_kin
|
| 5 |
- mbazaNLP/Kinyarwanda_English_parallel_dataset
|
| 6 |
+
- mbazaNLP/NMT_Tourism_parallel_data_en_kin
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
- rw
|
| 10 |
library_name: transformers
|
|
|
|
| 11 |
pipeline_tag: translation
|
| 12 |
+
tags:
|
| 13 |
+
- ctranslate2
|
| 14 |
+
- quantized
|
| 15 |
+
- int8
|
| 16 |
+
- education
|
| 17 |
---
|
|
|
|
| 18 |
|
| 19 |
+
# Quantized_Nllb_Finetuned_Edu_En_Kin_8bit — English ↔ Kinyarwanda (Education, 8-bit)
|
| 20 |
|
| 21 |
+
8-bit quantized machine translation model for English ↔ Kinyarwanda, specialised for
|
| 22 |
+
**education-domain** content.
|
| 23 |
|
| 24 |
+
Fine-tuned from [facebook/nllb-200-distilled-1.3B](https://huggingface.co/facebook/nllb-200-distilled-1.3B)
|
| 25 |
+
and quantized to int8 using [CTranslate2](https://github.com/OpenNMT/CTranslate2).
|
| 26 |
|
| 27 |
+
**Fine-tuning code:** [Digital-Umuganda/twb_nllb_finetuning](https://github.com/Digital-Umuganda/twb_nllb_finetuning)
|
| 28 |
|
| 29 |
+
## Quantization
|
| 30 |
|
| 31 |
+
```bash
|
|
|
|
| 32 |
pip install ctranslate2
|
| 33 |
+
ct2-transformers-converter --model <source-model-dir> --quantization int8 --output_dir <output-dir>
|
|
|
|
|
|
|
|
|
|
| 34 |
```
|
| 35 |
|
| 36 |
+
## Usage
|
| 37 |
|
| 38 |
+
```python
|
| 39 |
+
import ctranslate2
|
| 40 |
+
from transformers import NllbTokenizer
|
| 41 |
|
| 42 |
+
tokenizer = NllbTokenizer.from_pretrained("facebook/nllb-200-distilled-1.3B")
|
| 43 |
+
translator = ctranslate2.Translator("path/to/Quantized_Nllb_Finetuned_Edu_En_Kin_8bit")
|
| 44 |
|
|
|
|
| 45 |
|
| 46 |
+
def translate(text: str, src_lang: str, tgt_lang: str) -> str:
|
| 47 |
+
tokenizer.src_lang = src_lang
|
| 48 |
+
tokens = tokenizer.convert_ids_to_tokens(tokenizer.encode(text))
|
| 49 |
+
results = translator.translate_batch([tokens], target_prefix=[[tgt_lang]])
|
| 50 |
+
target_ids = tokenizer.convert_tokens_to_ids(results[0].hypotheses[0][1:])
|
| 51 |
+
return tokenizer.decode(target_ids, skip_special_tokens=True)
|
| 52 |
|
|
|
|
| 53 |
|
| 54 |
+
print(translate("Education is the key to development.", "eng_Latn", "kin_Latn"))
|
| 55 |
+
print(translate("Uburezi ni urufunguzo rw'iterambere.", "kin_Latn", "eng_Latn"))
|
| 56 |
+
```
|
| 57 |
|
| 58 |
+
## Intended Use
|
| 59 |
|
| 60 |
+
**Suitable for:**
|
| 61 |
+
- Education-domain English ↔ Kinyarwanda translation
|
| 62 |
+
- Resource-constrained or edge deployments where model size matters
|
| 63 |
+
- EdTech applications for Rwanda
|
| 64 |
|
| 65 |
+
**Not intended for:**
|
| 66 |
+
- General-purpose or tourism translation
|
| 67 |
+
- High-stakes translation without human review
|
| 68 |
|
| 69 |
+
## Training
|
| 70 |
|
| 71 |
+
Fine-tuned in two phases on education and general parallel data; then quantized to int8.
|
| 72 |
+
See [Nllb_finetuned_education_en_kin](https://huggingface.co/mbazaNLP/Nllb_finetuned_education_en_kin)
|
| 73 |
+
for full training details.
|
| 74 |
|
| 75 |
## Evaluation
|
| 76 |
|
| 77 |
+
Results from the full-precision base model (8-bit quantization introduces minor degradation):
|
| 78 |
|
| 79 |
+
| Lang. Direction | BLEU | spBLEU | chrF++ | TER |
|
| 80 |
+
|-----------------|-------|--------|--------|-------|
|
| 81 |
+
| Eng → Kin | 45.96 | 59.20 | 68.79 | 41.61 |
|
| 82 |
+
| Kin → Eng | 43.98 | 44.94 | 63.05 | 41.41 |
|
| 83 |
|
| 84 |
+
<!-- TODO: add quantized model evaluation scores -->
|
| 85 |
|
| 86 |
+
## Limitations
|
| 87 |
|
| 88 |
+
- 8-bit quantization may introduce minor accuracy degradation versus the full-precision model.
|
| 89 |
+
- Domain-adapted for education content; quality may drop on out-of-domain text.
|
| 90 |
+
- Outputs should be reviewed for high-stakes use cases.
|
| 91 |
|
| 92 |
+
## Bias and Fairness
|
| 93 |
|
| 94 |
+
Training data reflects written, formal educational language. Colloquial Kinyarwanda may be translated with lower quality.
|
| 95 |
|
| 96 |
+
## Bias and Fairness
|
| 97 |
+
|
| 98 |
+
Machine translation models can reflect and amplify biases present in training data. Known limitations include:
|
| 99 |
+
|
| 100 |
+
- **Domain bias:** Fine-tuned on specific domain data; performance may be lower on out-of-domain text.
|
| 101 |
+
- **Cultural bias:** Idiomatic expressions, gender-neutral constructs, and culturally specific references in English may not translate accurately or naturally into Kinyarwanda.
|
| 102 |
+
- **Data source bias:** Training data was sourced from specific platforms; text from other sources or registers may yield lower quality translations.
|
| 103 |
+
- **Gender:** English gender-neutral pronouns may be rendered with gendered forms in Kinyarwanda based on distributional patterns in training data.
|
| 104 |
+
|
| 105 |
+
Validate translation quality on domain-representative samples before deployment in high-stakes contexts (legal, medical, government communications).
|
| 106 |
+
|
| 107 |
+
## Citation
|
| 108 |
+
|
| 109 |
+
```bibtex
|
| 110 |
+
@misc{mbazaNLP2023quantized_nllb_edu,
|
| 111 |
+
author = {MBAZA-NLP Community},
|
| 112 |
+
title = {Quantized {NLLB} Finetuned Education En-Kin 8bit},
|
| 113 |
+
year = {2023},
|
| 114 |
+
url = {https://huggingface.co/mbazaNLP/Quantized_Nllb_Finetuned_Edu_En_Kin_8bit},
|
| 115 |
+
note = {Hugging Face model repository}
|
| 116 |
+
}
|
| 117 |
+
```
|