Translation
Transformers
English
Kinyarwanda

Update model card: Intended Use, Limitations, code example, BibTeX, licence/email/description fixes

#1
Files changed (1) hide show
  1. README.md +76 -32
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
- ### Model Description
17
 
18
- <!-- Provide a longer summary of what this model is. -->
 
19
 
20
- This is a Machine Translation model, finetuned from [NLLB](https://huggingface.co/facebook/nllb-200-distilled-1.3B)-200's distilled 1.3B model, it is meant to be used in machine translation for education-related data.
 
21
 
22
- - **Finetuning code repository:** the code used to finetune this model can be found [here](https://github.com/Digital-Umuganda/twb_nllb_finetuning)
23
 
24
- ## Quantization details
25
 
26
- The model is quantized to 8-bit precision using the Ctranslate2 library.
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
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
36
 
 
 
 
37
 
38
- ## How to Get Started with the Model
 
39
 
40
- Use the code below to get started with the model.
41
 
 
 
 
 
 
 
42
 
43
- ### Training Procedure
44
 
45
- The model was finetuned on three datasets; a [general](https://huggingface.co/datasets/mbazaNLP/Kinyarwanda_English_parallel_dataset) purpose dataset, a [tourism](https://huggingface.co/datasets/mbazaNLP/NMT_Tourism_parallel_data_en_kin), and an [education](https://huggingface.co/datasets/mbazaNLP/NMT_Education_parallel_data_en_kin) dataset.
 
 
46
 
47
- The model was finetuned in two phases.
48
 
49
- #### Phase one:
50
- - General purpose dataset
51
- - Education dataset
52
- - Tourism dataset
53
 
54
- #### Phase two:
55
- - Education dataset
 
56
 
57
- Other than the dataset changes between phase one, and phase two finetuning; no other hyperparameters were modified. In both cases, the model was trained on an A100 40GB GPU for two epochs.
58
 
 
 
 
59
 
60
  ## Evaluation
61
 
62
- <!-- This section describes the evaluation protocols and provides the results. -->
63
 
 
 
 
 
64
 
 
65
 
66
- <!-- This should link to a Data Card if possible. -->
67
 
 
 
 
68
 
69
- #### Metrics
70
 
71
- Model performance was measured using BLEU, spBLEU, TER, and chrF++ metrics.
72
 
73
- ### Results
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ```