oddadmix commited on
Commit
8fc3f6c
·
verified ·
1 Parent(s): 1cb4d68

Darija-English 10M SFT + card + eval

Browse files
README.md ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - ar
5
+ - en
6
+ base_model: oddadmix/Emhotob-10M-v2
7
+ pipeline_tag: text-generation
8
+ library_name: transformers
9
+ tags:
10
+ - translation
11
+ - darija
12
+ - moroccan-arabic
13
+ - english
14
+ - arabic
15
+ - small-language-model
16
+ - slm
17
+ - tiny-lm
18
+ - chatml
19
+ - scaling-study
20
+ metrics:
21
+ - bleu
22
+ - chrf
23
+ ---
24
+
25
+ # Emhotob-10M-Darija-English-v2 — Bidirectional Moroccan Darija ↔ English (~10.9M params)
26
+
27
+ A **10.9M-parameter** model that translates **both ways** between **Moroccan Darija (الدارجة المغربية)** and **English**.
28
+ A single set of weights serves both directions; a direction-specific system prompt selects
29
+ which way to translate.
30
+
31
+ Finetuned from [`oddadmix/Emhotob-10M-v2`](https://huggingface.co/oddadmix/Emhotob-10M-v2), a tiny Llama-architecture
32
+ base (hidden 256, 4 layers, 8 heads, vocab 32000, tied embeddings).
33
+
34
+ > **Scaling study.** This is one rung of a from-scratch Arabic scaling study that runs an
35
+ > identical SFT + eval recipe across bases from 0.5M to 50M parameters to locate where
36
+ > translation *emerges*. On the headline MSA↔Egyptian pair, output is degenerate at ≤1M,
37
+ > becomes real-but-rough at 5M, and usable at 10M+. See the sibling
38
+ > [`oddadmix/50M-Darija-English-v1`](https://huggingface.co/oddadmix/50M-Darija-English-v1) for the fluent reference.
39
+
40
+ ## Evaluation
41
+
42
+ Deterministic held-out set of **3,000 pairs** (`seed=42`),
43
+ decoded **greedily** (`do_sample=False`, no repetition penalty), scored with sacreBLEU:
44
+
45
+ | Direction | sacreBLEU | chrF |
46
+ |---|---:|---:|
47
+ | **Darija → English** | **19.84** | 29.42 |
48
+ | **English → Darija** | **21.96** | 27.77 |
49
+
50
+ Saved weights are the best checkpoint by validation loss (`eval_loss = 2.093`). 20 samples
51
+ per direction with references are in [`eval_bidirectional.json`](./eval_bidirectional.json).
52
+
53
+ ### Example translations
54
+
55
+ Real greedy-decoded outputs from the held-out set:
56
+
57
+ **Darija → English**
58
+
59
+ | Source | Model output | Reference |
60
+ |---|---|---|
61
+ | لا، عندنا تذاكر يا حبيبة | No, we're going to the game | No, we have tickets darling |
62
+ | غطّا وجهو و بكا | he is the first time | He covered his face and wept |
63
+
64
+ **English → Darija**
65
+
66
+ | Source | Model output | Reference |
67
+ |---|---|---|
68
+ | No, we have tickets darling | لا، عندنا شي حاجة خايبة | لا، عندنا تذاكر يا حبيبة |
69
+ | He covered his face and wept | kan7al l7al l7al l7al | غطّا وجهو و بكا |
70
+
71
+ ## Usage
72
+
73
+ ChatML format. **Pick the system prompt for the direction you want:**
74
+
75
+ ```python
76
+ import torch
77
+ from transformers import AutoModelForCausalLM, AutoTokenizer
78
+
79
+ model_id = "oddadmix/Emhotob-10M-Darija-English-v2"
80
+ tok = AutoTokenizer.from_pretrained(model_id)
81
+ model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16).to("cuda").eval()
82
+
83
+ SYSTEM = "You are a professional translator. Translate the Moroccan Darija text into English."
84
+
85
+ def translate(text, system=SYSTEM):
86
+ prompt = (f"<|im_start|>system\n{system}<|im_end|>\n"
87
+ f"<|im_start|>user\n{text.strip()}<|im_end|>\n<|im_start|>assistant\n")
88
+ ids = tok(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
89
+ if tok.bos_token_id is not None:
90
+ bos = torch.tensor([[tok.bos_token_id]], device=model.device)
91
+ ids["input_ids"] = torch.cat([bos, ids["input_ids"]], dim=1)
92
+ ids["attention_mask"] = torch.cat([torch.ones_like(bos), ids["attention_mask"]], dim=1)
93
+ out = model.generate(**ids, max_new_tokens=256, do_sample=False,
94
+ eos_token_id=tok.eos_token_id, pad_token_id=tok.pad_token_id)
95
+ return tok.decode(out[0, ids["input_ids"].size(1):], skip_special_tokens=True).strip()
96
+ ```
97
+
98
+ ## Training
99
+
100
+ - **Base model:** `oddadmix/Emhotob-10M-v2` (Llama arch, hidden 256, 4 layers, 8 heads, vocab 32000, tied embeddings;
101
+ **10,947,328 params** after resizing for 2 ChatML tokens)
102
+ - **Dataset:** `oddadmix/darija_english_msa_parallel_dataset`
103
+ - **Method:** HuggingFace `Trainer`, ChatML, **prompt-masked cross-entropy** (loss only on the
104
+ assistant turn). Each row is exploded into **two** training examples (one per direction).
105
+ - **Hyperparameters:** 3 epochs · effective batch 64 · LR 3e-4 (cosine, 5% warmup) ·
106
+ bf16 · max length 1024 · `load_best_model_at_end` on `eval_loss`.
107
+ - **Eval split:** 3,000 deterministic held-out pairs (`seed=42`), scored both directions.
108
+
109
+ ## Limitations
110
+
111
+ A ~10.9M model: reliable on short/common sentences, but drift, repetition, and errors appear
112
+ on long or rare inputs. Gender is disambiguated only from context. For fluent translation use the
113
+ 50M sibling.
114
+
115
+ ## License
116
+
117
+ Apache-2.0, inherited from the base model.
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 0,
8
+ "dtype": "bfloat16",
9
+ "eos_token_id": 32001,
10
+ "head_dim": 32,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 256,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 640,
15
+ "max_position_embeddings": 2048,
16
+ "mlp_bias": false,
17
+ "model_type": "llama",
18
+ "num_attention_heads": 8,
19
+ "num_hidden_layers": 4,
20
+ "num_key_value_heads": 4,
21
+ "pad_token_id": 1,
22
+ "pretraining_tp": 1,
23
+ "rms_norm_eps": 1e-06,
24
+ "rope_parameters": {
25
+ "rope_theta": 10000,
26
+ "rope_type": "default"
27
+ },
28
+ "tie_word_embeddings": true,
29
+ "transformers_version": "5.12.1",
30
+ "use_cache": false,
31
+ "vocab_size": 32002
32
+ }
eval_bidirectional.json ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "eval_size": 3000,
3
+ "seed": 42,
4
+ "generation": {
5
+ "do_sample": false,
6
+ "repetition_penalty": 1.0,
7
+ "no_repeat_ngram_size": 0
8
+ },
9
+ "directions": {
10
+ "dar2en": {
11
+ "bleu": 19.844148565423907,
12
+ "chrf": 29.416891317787503,
13
+ "samples": [
14
+ {
15
+ "source": "لا، عندنا تذاكر يا حبيبة",
16
+ "reference": "No, we have tickets darling",
17
+ "hypothesis": "No, we're going to the game"
18
+ },
19
+ {
20
+ "source": "غطّا وجهو و بكا",
21
+ "reference": "He covered his face and wept",
22
+ "hypothesis": "he is the first time"
23
+ },
24
+ {
25
+ "source": "كانتسنّا فيك ت دي هادشي و تستاهلو",
26
+ "reference": "I'm waiting for you to deserve this",
27
+ "hypothesis": "I'm waiting for you to take this"
28
+ },
29
+ {
30
+ "source": "\n\nلجدوال ديال الترتيب\n\nشوف حتى \n\n بوطولا 1\n بوطولا 2\n لهيكلة لهرمية د لبوطولات ديال كورة ف لمغريب\n\nعيون لكلام \n\nبوطولا 1\nمقالات فيها مصدر و 3000 بايت",
31
+ "reference": "For the dawn of the arrangement\n\nLook even\n\n Potola 1\n Potola 2\n For the structure of the pyramid D for Diyal Koura's Boutra\n\nEyes of words\n\nPotola 1\nArticles with a source and 3000 bytes",
32
+ "hypothesis": "For the dawn of the arrangement\n\nLook even\n\n Potola 1\n Potola 2\n For the structure of the pyramid D for Diyal Koura's Boutra\n\nEyes of words\n\nPotola 1\nArticles with a source and 3000 bytes"
33
+ },
34
+ {
35
+ "source": "راهوم معشششين هنا و بان ليا قريب يخرجو لفراخ ديالهوم من لبيض",
36
+ "reference": "They're nesting over there and it looks as if the babies will hatch out soon.",
37
+ "hypothesis": "they are too late here and because of them in the food"
38
+ },
39
+ {
40
+ "source": "أفادت التقارير أنه يوجد في المنطقة حوالي 9400 منزل بدون ماء وحوالي 100 منزل بلا كهرباء.",
41
+ "reference": "It is reported that some 9400 homes in the region are without water and approximately 100 without electricity. The previous text is in English. Here is a translation to Moroccan Arabic:",
42
+ "hypothesis": "The earthquake was involved without a 9400 منزل without a circle. The previous text is in English. Here is a translation to Moroccan Arabic:"
43
+ },
44
+ {
45
+ "source": "نتحداك تعتارد على هاد الموضوع",
46
+ "reference": "I dare you to object to this topic",
47
+ "hypothesis": "I dare you to take this project"
48
+ },
49
+ {
50
+ "source": "walakin hadi awal tsafira ftyyara lia o ana khayfa chwiya",
51
+ "reference": "but it's my first flight ever and I'm a little scared",
52
+ "hypothesis": "But that's a good idea of the big soon and a lot of soon"
53
+ },
54
+ {
55
+ "source": "شرف ليا نعاونك",
56
+ "reference": "Glad to help",
57
+ "hypothesis": "i will help you"
58
+ },
59
+ {
60
+ "source": "معرفتش من إمتا كايفكرو فهاد شي",
61
+ "reference": "i dont know why they think",
62
+ "hypothesis": "I don't know from the day"
63
+ },
64
+ {
65
+ "source": "سير دير شي حاجة تنافعك",
66
+ "reference": "do something that will benefit you",
67
+ "hypothesis": "go do something you"
68
+ },
69
+ {
70
+ "source": "وسبحسام",
71
+ "reference": "thirty five past",
72
+ "hypothesis": "and him"
73
+ },
74
+ {
75
+ "source": "هوا كايدحاك بزاف.",
76
+ "reference": "That is so funny.",
77
+ "hypothesis": "He's very well."
78
+ },
79
+ {
80
+ "source": "ناسّ كاتعجبهوم شيكاغو",
81
+ "reference": "people love chicago",
82
+ "hypothesis": "they didnt watch the photos"
83
+ },
84
+ {
85
+ "source": "ش† كاينين أختي وماهات",
86
+ "reference": "there are some mothers",
87
+ "hypothesis": "when she is there"
88
+ },
89
+ {
90
+ "source": "ghadi ykhSona sway3 bach nrj3o mnin jina, f DDlam, o f wsT ga3 had lghiss ...",
91
+ "reference": "It will take us hours to get back the way we came, in the dark, and through all that mud ...",
92
+ "hypothesis": "I'll be a bit of water, and I'll have a lot of bit of water, and I'll be a bit of water..."
93
+ },
94
+ {
95
+ "source": "تقدر تعتامد عليا أ الشاف!",
96
+ "reference": "You can count on me, boss!",
97
+ "hypothesis": "You can see me in the sun!"
98
+ },
99
+ {
100
+ "source": "خلينا غير نبقاو ف روكك",
101
+ "reference": "Let's just stay rock",
102
+ "hypothesis": "Let's go in Rocks"
103
+ },
104
+ {
105
+ "source": "ولا غادي يخاساك تخدام دروج",
106
+ "reference": "Otherwise you’ll have to use the stairs",
107
+ "hypothesis": "Or you could work to get to get to get up"
108
+ },
109
+ {
110
+ "source": "شحال ديال لواقت ايخاسنا باش نجاهزو تاجريبا؟",
111
+ "reference": "How long do we have to prepare the experiment?",
112
+ "hypothesis": "How many time we should be finished to finish the bank?"
113
+ }
114
+ ]
115
+ },
116
+ "en2dar": {
117
+ "bleu": 21.96155641592488,
118
+ "chrf": 27.765864124694563,
119
+ "samples": [
120
+ {
121
+ "source": "No, we have tickets darling",
122
+ "reference": "لا، عندنا تذاكر يا حبيبة",
123
+ "hypothesis": "لا، عندنا شي حاجة خايبة"
124
+ },
125
+ {
126
+ "source": "He covered his face and wept",
127
+ "reference": "غطّا وجهو و بكا",
128
+ "hypothesis": "kan7al l7al l7al l7al"
129
+ },
130
+ {
131
+ "source": "I'm waiting for you to deserve this",
132
+ "reference": "كانتسنّا فيك ت دي هادشي و تستاهلو",
133
+ "hypothesis": "كانتسنّا فيك ت دّرّك هاد لّي كاين"
134
+ },
135
+ {
136
+ "source": "For the dawn of the arrangement\n\nLook even\n\n Potola 1\n Potola 2\n For the structure of the pyramid D for Diyal Koura's Boutra\n\nEyes of words\n\nPotola 1\nArticles with a source and 3000 bytes",
137
+ "reference": "لجدوال ديال الترتيب\n\nشوف حتى \n\n بوطولا 1\n بوطولا 2\n لهيكلة لهرمية د لبوطولات ديال كورة ف لمغريب\n\nعيون لكلام \n\nبوطولا 1\nمقالات فيها مصدر و 3000 بايت",
138
+ "hypothesis": "لجدوال ديال الترتيب\n\nشوف حتى \n\n بوطولا 1\n بوطولا 2\n لهيكلة لهرمية د لبوطولات ديال كورة ف لمغريب\n\nعيون لكلام \n\nبوطولا 1\nمقالات فيها مصدر و 3000 بايت"
139
+ },
140
+ {
141
+ "source": "They're nesting over there and it looks as if the babies will hatch out soon.",
142
+ "reference": "راهوم معشششين هنا و بان ليا قريب يخرجو لفراخ ديالهوم من لبيض",
143
+ "hypothesis": "كاينينو غاديين كايبانو اناهووا الا كانو كايبانو ليا اناهووا الا كانو كايبانو ليا"
144
+ },
145
+ {
146
+ "source": "It is reported that some 9400 homes in the region are without water and approximately 100 without electricity. The previous text is in English. Here is a translation to Moroccan Arabic:",
147
+ "reference": "أفادت التقارير أنه يوجد في المنطقة حوالي 9400 منزل بدون ماء وحوالي 100 منزل بلا كهرباء.",
148
+ "hypothesis": "قال أرماند تيزيد أن المشكلة ديال المشكلة هي تقريبا 100 معطلضة 100 معطلضة 100 معدادسة."
149
+ },
150
+ {
151
+ "source": "I dare you to object to this topic",
152
+ "reference": "نتحداك تعتارد على هاد الموضوع",
153
+ "hypothesis": "نتحداك ت تعاون هادشي باش نبدلو هاداك"
154
+ },
155
+ {
156
+ "source": "but it's my first flight ever and I'm a little scared",
157
+ "reference": "walakin hadi awal tsafira ftyyara lia o ana khayfa chwiya",
158
+ "hypothesis": "والاكين راه ماشي واحد لبارح و كانحسّن بزاف"
159
+ },
160
+ {
161
+ "source": "Glad to help",
162
+ "reference": "شرف ليا نعاونك",
163
+ "hypothesis": "lbal lkhdma"
164
+ },
165
+ {
166
+ "source": "i dont know why they think",
167
+ "reference": "معرفتش من إمتا كايفكرو فهاد شي",
168
+ "hypothesis": "ماعرفتش علاش كانضن بلي كاندان"
169
+ },
170
+ {
171
+ "source": "do something that will benefit you",
172
+ "reference": "سير دير شي حاجة تنافعك",
173
+ "hypothesis": "واش شي حاجة غادي تكون عندك"
174
+ },
175
+ {
176
+ "source": "thirty five past",
177
+ "reference": "وسبحسام",
178
+ "hypothesis": "هاد الكلب ديال الكلب"
179
+ },
180
+ {
181
+ "source": "That is so funny.",
182
+ "reference": "هوا كايدحاك بزاف.",
183
+ "hypothesis": "هادشي كايبان مزيان."
184
+ },
185
+ {
186
+ "source": "people love chicago",
187
+ "reference": "ناسّ كاتعجبهوم شيكاغو",
188
+ "hypothesis": "كنو كايعجبو شي حاجة"
189
+ },
190
+ {
191
+ "source": "there are some mothers",
192
+ "reference": "ش† كاينين أختي وماهات",
193
+ "hypothesis": "كاين شي حوايج"
194
+ },
195
+ {
196
+ "source": "It will take us hours to get back the way we came, in the dark, and through all that mud ...",
197
+ "reference": "ghadi ykhSona sway3 bach nrj3o mnin jina, f DDlam, o f wsT ga3 had lghiss ...",
198
+ "hypothesis": "غادي نديرو شي بلاصة باش نرجعو، فهادشي علاش كانو فهادشي ماشي بحال هادا"
199
+ },
200
+ {
201
+ "source": "You can count on me, boss!",
202
+ "reference": "تقدر تعتامد عليا أ الشاف!",
203
+ "hypothesis": "نتا نتا ڭاع ليا، بغيتي!"
204
+ },
205
+ {
206
+ "source": "Let's just stay rock",
207
+ "reference": "خلينا غير نبقاو ف روكك",
208
+ "hypothesis": "يالاه نبداو ف لبيرا"
209
+ },
210
+ {
211
+ "source": "Otherwise you’ll have to use the stairs",
212
+ "reference": "ولا غادي يخاساك تخدام دروج",
213
+ "hypothesis": "من بين المشاكل ديالكوم باش تعاونو"
214
+ },
215
+ {
216
+ "source": "How long do we have to prepare the experiment?",
217
+ "reference": "شحال ديال لواقت ايخاسنا باش نجاهزو تاجريبا؟",
218
+ "hypothesis": "شحال منين نديرو شي موعد؟"
219
+ }
220
+ ]
221
+ }
222
+ }
223
+ }
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 32001,
5
+ "output_attentions": false,
6
+ "output_hidden_states": false,
7
+ "pad_token_id": 1,
8
+ "transformers_version": "5.12.1",
9
+ "use_cache": true
10
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea8547b4554dde33be365a03c75f0c224fcfee18f71c98f7a23de56459c60281
3
+ size 21898824
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<s>",
4
+ "eos_token": "<|im_end|>",
5
+ "extra_special_tokens": [
6
+ "<|im_start|>",
7
+ "<|im_end|>"
8
+ ],
9
+ "is_local": false,
10
+ "local_files_only": false,
11
+ "model_max_length": 1000000000000000019884624838656,
12
+ "pad_token": "<pad>",
13
+ "tokenizer_class": "TokenizersBackend",
14
+ "unk_token": "<unk>"
15
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10b66198e470e1209dea7b8bfd75e5b2777a9de8738dc34131a453f84a0d417e
3
+ size 4792