brendaogutu commited on
Commit
95572dc
·
verified ·
1 Parent(s): 0c5ee0c

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ source.spm filter=lfs diff=lfs merge=lfs -text
37
+ target.spm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Swahili-English Translation Model (General Domain Expansion)
3
+
4
+ This model is a fine-tuned version of [Helsinki-NLP/opus-mt-mul-en](https://huggingface.co/Helsinki-NLP/opus-mt-mul-en)
5
+ on a large corpus of general Swahili-English translations while maintaining helpline translation quality.
6
+
7
+ ## Model Details
8
+
9
+ - **Base Model:** Helsinki-NLP/opus-mt-mul-en
10
+ - **Language Pair:** Swahili (sw) → English (en)
11
+ - **Training Data:**
12
+ - CCAligned general corpus (~200k+ samples)
13
+ - Helpline conversation data (oversampled 5x for domain retention)
14
+ - **Special Features:**
15
+ - Domain-aware with `<HELPLINE>` and `<GENERAL>` tags
16
+ - Optimized for both general and helpline translations
17
+ - Knowledge distillation from helpline-specialized model
18
+
19
+ ## Training Procedure
20
+
21
+ ### Memory Optimizations
22
+ - CPU teacher offloading
23
+ - Gradient checkpointing
24
+ - Batch size: 8, Gradient accumulation: 16
25
+
26
+ ### Training Hyperparameters
27
+ - Learning rate: 1.5e-5
28
+ - Epochs: 1
29
+ - Optimizer: AdamW
30
+ - LR Scheduler: Cosine with warmup
31
+
32
+ ## Performance
33
+
34
+ | Domain | BLEU | chrF |
35
+ |--------|------|------|
36
+ | Helpline | X.XX | XX.X |
37
+ | General | X.XX | XX.X |
38
+
39
+ *(Replace with actual metrics from training)*
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ from transformers import MarianMTModel, MarianTokenizer
45
+
46
+ # Load model and tokenizer
47
+ model_name = "brendaogutu/sw-en-opus-mt-general-expanded"
48
+ tokenizer = MarianTokenizer.from_pretrained(model_name)
49
+ model = MarianMTModel.from_pretrained(model_name)
50
+
51
+ # For general translations
52
+ text = "<GENERAL> Habari za asubuhi"
53
+ inputs = tokenizer(text, return_tensors="pt", padding=True)
54
+ outputs = model.generate(**inputs)
55
+ translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
56
+ print(translation) # "Good morning"
57
+
58
+ # For helpline translations
59
+ text = "<HELPLINE> Ninahitaji msaada wa haraka"
60
+ inputs = tokenizer(text, return_tensors="pt", padding=True)
61
+ outputs = model.generate(**inputs)
62
+ translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
63
+ print(translation) # "I need urgent help"
64
+ ```
65
+
66
+ ## Limitations
67
+
68
+ - Optimized for Swahili to English (not bidirectional)
69
+ - Best performance with domain tags (<HELPLINE> or <GENERAL>)
70
+ - May struggle with very technical or specialized vocabulary outside training domains
71
+
72
+ ## Training Details
73
+
74
+ - **Framework:** Transformers + PyTorch
75
+ - **Hardware:** Single GPU training
76
+ - **Training Time:** ~X hours
77
+ - **Checkpoint Strategy:** Every 500 steps for power failure recovery
78
+
79
+ ## Citation
80
+
81
+ If you use this model, please cite:
82
+
83
+ ```bibtex
84
+ @misc{{sw-en-general-expanded,
85
+ author = {{Your Name/Organization}},
86
+ title = {{Swahili-English General Domain Translation Model}},
87
+ year = {{2025}},
88
+ publisher = {{HuggingFace}},
89
+ url = {{https://huggingface.co/brendaogutu/sw-en-opus-mt-general-expanded}}
90
+ }}
91
+ ```
92
+
93
+ ## License
94
+
95
+ This model inherits the license from Helsinki-NLP/opus-mt-mul-en.
96
+
97
+ ## Contact
98
+
99
+ For questions or issues, please open an issue on the model repository.
added_tokens.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "<GENERAL>": 64173,
3
+ "<HELPLINE>": 64172
4
+ }
config.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_dropout": 0.0,
3
+ "activation_function": "swish",
4
+ "add_bias_logits": false,
5
+ "add_final_layer_norm": false,
6
+ "architectures": [
7
+ "MarianMTModel"
8
+ ],
9
+ "attention_dropout": 0.0,
10
+ "bos_token_id": 0,
11
+ "classif_dropout": 0.0,
12
+ "classifier_dropout": 0.0,
13
+ "d_model": 512,
14
+ "decoder_attention_heads": 8,
15
+ "decoder_ffn_dim": 2048,
16
+ "decoder_layerdrop": 0.0,
17
+ "decoder_layers": 6,
18
+ "decoder_start_token_id": 64171,
19
+ "decoder_vocab_size": 64174,
20
+ "dropout": 0.1,
21
+ "encoder_attention_heads": 8,
22
+ "encoder_ffn_dim": 2048,
23
+ "encoder_layerdrop": 0.0,
24
+ "encoder_layers": 6,
25
+ "eos_token_id": 0,
26
+ "extra_pos_embeddings": 64172,
27
+ "forced_eos_token_id": 0,
28
+ "id2label": {
29
+ "0": "LABEL_0",
30
+ "1": "LABEL_1",
31
+ "2": "LABEL_2"
32
+ },
33
+ "init_std": 0.02,
34
+ "is_encoder_decoder": true,
35
+ "label2id": {
36
+ "LABEL_0": 0,
37
+ "LABEL_1": 1,
38
+ "LABEL_2": 2
39
+ },
40
+ "max_length": null,
41
+ "max_position_embeddings": 512,
42
+ "model_type": "marian",
43
+ "normalize_before": false,
44
+ "normalize_embedding": false,
45
+ "num_beams": null,
46
+ "num_hidden_layers": 6,
47
+ "pad_token_id": 64171,
48
+ "scale_embedding": true,
49
+ "share_encoder_decoder_embeddings": true,
50
+ "static_position_embeddings": true,
51
+ "torch_dtype": "float32",
52
+ "transformers_version": "4.53.2",
53
+ "use_cache": true,
54
+ "vocab_size": 64174
55
+ }
generation_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bad_words_ids": [
3
+ [
4
+ 64171
5
+ ]
6
+ ],
7
+ "bos_token_id": 0,
8
+ "decoder_start_token_id": 64171,
9
+ "eos_token_id": 0,
10
+ "forced_eos_token_id": 0,
11
+ "max_length": 512,
12
+ "num_beams": 6,
13
+ "pad_token_id": 64171,
14
+ "renormalize_logits": true,
15
+ "transformers_version": "4.53.2"
16
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6550b6e094e8afaf9f13fa30563127f02078159809b15dc0ae1792d436177834
3
+ size 308268088
register_to_mlflow.sh ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ python register_model.py \
3
+ --model_path /home/brenda/chl_scratch/openchs_rnd/tasks/translation/swahili/models/finetuned-sw-en-general-v2 \
4
+ --experiment_name translation-sw-en \
5
+ --model_name opus-mt-sw-en-general-expanded-v2 \
6
+ --run_id 789785bf2e554d8b8aec869cc9648edc \
7
+ --mlflow_uri http://localhost:5000
source.spm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4a99ea3602b29fbf901ade8b93a45efa3d7c64eab8fc5fa812383efa327a87d
3
+ size 706917
special_tokens_map.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ {
4
+ "content": "<HELPLINE>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false
9
+ },
10
+ {
11
+ "content": "<GENERAL>",
12
+ "lstrip": false,
13
+ "normalized": false,
14
+ "rstrip": false,
15
+ "single_word": false
16
+ },
17
+ {
18
+ "content": "<GENERAL>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ ],
25
+ "eos_token": {
26
+ "content": "</s>",
27
+ "lstrip": false,
28
+ "normalized": false,
29
+ "rstrip": false,
30
+ "single_word": false
31
+ },
32
+ "pad_token": {
33
+ "content": "<pad>",
34
+ "lstrip": false,
35
+ "normalized": false,
36
+ "rstrip": false,
37
+ "single_word": false
38
+ },
39
+ "unk_token": {
40
+ "content": "<unk>",
41
+ "lstrip": false,
42
+ "normalized": false,
43
+ "rstrip": false,
44
+ "single_word": false
45
+ }
46
+ }
target.spm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c6dce5fa58fcd7dde9e81e279b8c075bf42ee558278f73d6fb48e342029d7f19
3
+ size 791194
tokenizer_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "</s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<unk>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "64171": {
20
+ "content": "<pad>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "64172": {
28
+ "content": "<HELPLINE>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "64173": {
36
+ "content": "<GENERAL>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "additional_special_tokens": [
45
+ "<HELPLINE>",
46
+ "<GENERAL>",
47
+ "<GENERAL>"
48
+ ],
49
+ "clean_up_tokenization_spaces": false,
50
+ "eos_token": "</s>",
51
+ "extra_special_tokens": {},
52
+ "model_max_length": 512,
53
+ "pad_token": "<pad>",
54
+ "separate_vocabs": false,
55
+ "source_lang": "mul",
56
+ "sp_model_kwargs": {},
57
+ "target_lang": "eng",
58
+ "tokenizer_class": "MarianTokenizer",
59
+ "unk_token": "<unk>"
60
+ }
training_metadata.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "baseline_helpline_bleu": 0.7138171930464564,
3
+ "baseline_general_bleu": 0.08336173164014311,
4
+ "final_helpline_bleu": 0.7017193706052336,
5
+ "final_general_bleu": 0.14619497807657425,
6
+ "helpline_retention": 0.983051931840432,
7
+ "general_improvement": 1.7537420972451774,
8
+ "production_ready": true,
9
+ "training_samples": 256146,
10
+ "validation_samples": 5228,
11
+ "model_info": {
12
+ "model_name": "openchs/sw-en-opus-mt-mul-en-v1",
13
+ "total_parameters": 77519872,
14
+ "trainable_parameters": 76995584,
15
+ "vocab_size": 64174
16
+ }
17
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff