MathematicianNLPer commited on
Commit
bf88f83
·
verified ·
1 Parent(s): 849b792

Copy from GemMaroc/GemMaroc-27b-it

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ 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
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags:
4
+ - MoroccanArabic
5
+ - Darija
6
+ - GemMaroc
7
+ - DarijaLLM
8
+ - conversational
9
+ pipeline_tag: text-generation
10
+ datasets:
11
+ - GemMaroc/TULU-3-50k-darija-english
12
+ language:
13
+ - ar
14
+ - ary
15
+ - en
16
+ base_model:
17
+ - google/gemma-3-27b-it
18
+ ---
19
+
20
+ # Model Card for Model ID
21
+
22
+ <!-- Provide a quick summary of what the model is/does. -->
23
+
24
+
25
+ # GemMaroc‑27B
26
+
27
+ Unlocking **Moroccan Darija** proficiency in a state‑of‑the‑art large language model, trained with a *minimal‑data, green‑AI* recipe that preserves Gemma‑27B’s strong reasoning abilities while adding fluent Darija generation.
28
+
29
+ ---
30
+
31
+ ## Model at a glance
32
+
33
+ | | Details |
34
+ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
35
+ | **Model ID** | `AbderrahmanSkiredj1/GemMaroc-27b-it` |
36
+ | **Base model** | [`google/gemma-3-27b`](https://huggingface.co/google/gemma-3-27b) |
37
+ | **Architecture** | Decoder‑only Transformer (Gemma 3) |
38
+ | **Parameters** | 27 billion |
39
+ | **Context length** | 2 048 tokens |
40
+ | **Training regime** | Supervised fine‑tuning (LoRA → merged) on 50 K high‑quality Darija/English instructions TULU‑50K slice |
41
+ | **Compute budget** | 48 GPU·h (8 × H100‑80GB × 6 h) – ≈ 26 kWh / 10 kg CO₂e |
42
+ | **License** | Apache 2.0 |
43
+
44
+ ---
45
+
46
+ ## Why another Darija model?
47
+
48
+ * **Inclusive AI** > 36 million speakers of Moroccan Arabic remain underserved by open LLMs.
49
+ * **Quality‑over‑quantity** A carefully curated 50 K instruction set surfaces Darija competence without sacrificing cross‑lingual reasoning.
50
+ * **Green AI** GemMaroc achieves Atlas‑Chat‑level Darija scores using < 2 % of the energy.
51
+
52
+ ---
53
+
54
+ ## Benchmark summary
55
+
56
+ | Model | Darija MMLU | Darija HellaSwag | GSM8K @5 | HellaSwag (EN) |
57
+ | ---------------- | ----------- | ---------------- | ---------- | -------------- |
58
+ | Atlas‑Chat‑27B | **61.9 %** | 48.4 % | 82.0 % | 77.8 % |
59
+ | **GemMaroc‑27B** | 61.6 % | **60.5 %** | **84.2 %** | **79.3 %** |
60
+
61
+ <sub>Zero‑shot accuracy; full table in the paper.</sub>
62
+
63
+ ---
64
+
65
+ ## Quick start
66
+
67
+ ```python
68
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
69
+
70
+ model_id = "AbderrahmanSkiredj1/GemMaroc-27b-it"
71
+
72
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
73
+ model = AutoModelForCausalLM.from_pretrained(
74
+ model_id,
75
+ torch_dtype="auto",
76
+ device_map="auto"
77
+ )
78
+
79
+ pipe = pipeline(
80
+ "text-generation",
81
+ model=model,
82
+ tokenizer=tokenizer,
83
+ device_map="auto",
84
+ max_new_tokens=1024,
85
+ temperature=0.7,
86
+ repetition_penalty=1.2,
87
+ no_repeat_ngram_size=3,
88
+ )
89
+
90
+ messages = [
91
+ {"role": "user", "content": "شنو هي نظرية ‘butterfly effect’؟ فسّرها بدارجة ونقّط مثال بسيط."}
92
+ ]
93
+
94
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
95
+ print(pipe(prompt)[0]["generated_text"][len(prompt):])
96
+ ```
97
+
98
+ ### Chat template (Gemma 3 format)
99
+
100
+ The tokenizer provides a baked‑in Jinja template that starts with a **begin‑of‑sequence** token (`<bos>`), then alternates user/model turns, each wrapped by `<start_of_turn>` … `<end_of_turn>` markers. When you set `add_generation_prompt=True` it ends after the opening model tag so the model can continue:
101
+
102
+ ```
103
+ <bos><start_of_turn>user
104
+ {user message}<end_of_turn>
105
+ <start_of_turn>model
106
+ ```
107
+
108
+ The assistant will keep generating tokens until it decides to emit `<end_of_turn>`.
109
+
110
+ ```python
111
+ prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
112
+ ```
113
+
114
+ No manual token juggling required—the call above handles BOS, turn delimiters, and newline placement automatically.
115
+
116
+ ---
117
+
118
+ Pre‑quantised checkpoints will be published under the same repo tags (`gemmaroc‑27b‑awq‑int4`, `gemmaroc‑27b‑gguf‑q4_k_m`).
119
+
120
+ ---
121
+
122
+ ## Training recipe (one‑paragraph recap)
123
+
124
+ 1. **Data** Translate a 44 K reasoning slice of TULU 50K into Darija, keeping 20 % English for cross‑lingual robustness.
125
+ 2. **LoRA SFT** Rank 16, α = 32, 3 epochs, bf16, context 2 048.
126
+ 3. **Merge & push** Merge LoRA into base weights (`peft.merge_and_unload`), convert to safetensors, upload.
127
+
128
+ ---
129
+
130
+ ## Limitations & ethical considerations
131
+
132
+ * Sentiment and abstractive summarisation still trail state‑of‑the‑art.
133
+ * Tokeniser is unchanged; rare Darija spellings may fragment.
134
+ * Model may inherit societal biases present in pre‑training data.
135
+ * No RLHF / RLAIF safety alignment yet – apply a moderation layer in production.
136
+
137
+ ---
138
+
139
+ ## Citation
140
+
141
+ If you use GemMaroc in your work, please cite:
142
+
143
+ ```bibtex
144
+ @misc{skiredj2025gemmarocunlockingdarijaproficiency,
145
+ title={GemMaroc: Unlocking Darija Proficiency in LLMs with Minimal Data},
146
+ author={Abderrahman Skiredj and Ferdaous Azhari and Houdaifa Atou and Nouamane Tazi and Ismail Berrada},
147
+ year={2025},
148
+ eprint={2505.17082},
149
+ archivePrefix={arXiv},
150
+ primaryClass={cs.CL},
151
+ url={https://arxiv.org/abs/2505.17082},
152
+ }
153
+
154
+
155
+ ```
config.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Gemma3ForConditionalGeneration"
4
+ ],
5
+ "boi_token_index": 255999,
6
+ "eoi_token_index": 256000,
7
+ "eos_token_id": [
8
+ 1,
9
+ 106
10
+ ],
11
+ "image_token_index": 262144,
12
+ "initializer_range": 0.02,
13
+ "mm_tokens_per_image": 256,
14
+ "model_type": "gemma3",
15
+ "text_config": {
16
+ "attention_bias": false,
17
+ "attention_dropout": 0.0,
18
+ "attn_logit_softcapping": null,
19
+ "cache_implementation": "hybrid",
20
+ "final_logit_softcapping": null,
21
+ "head_dim": 128,
22
+ "hidden_activation": "gelu_pytorch_tanh",
23
+ "hidden_size": 5376,
24
+ "initializer_range": 0.02,
25
+ "intermediate_size": 21504,
26
+ "max_position_embeddings": 131072,
27
+ "model_type": "gemma3_text",
28
+ "num_attention_heads": 32,
29
+ "num_hidden_layers": 62,
30
+ "num_key_value_heads": 16,
31
+ "query_pre_attn_scalar": 168,
32
+ "rms_norm_eps": 1e-06,
33
+ "rope_local_base_freq": 10000.0,
34
+ "rope_scaling": {
35
+ "factor": 8.0,
36
+ "rope_type": "linear"
37
+ },
38
+ "rope_theta": 1000000.0,
39
+ "sliding_window": 1024,
40
+ "sliding_window_pattern": 6,
41
+ "torch_dtype": "bfloat16",
42
+ "use_cache": true,
43
+ "vocab_size": 262208
44
+ },
45
+ "torch_dtype": "bfloat16",
46
+ "transformers_version": "4.50.0.dev0",
47
+ "vision_config": {
48
+ "attention_dropout": 0.0,
49
+ "hidden_act": "gelu_pytorch_tanh",
50
+ "hidden_size": 1152,
51
+ "image_size": 896,
52
+ "intermediate_size": 4304,
53
+ "layer_norm_eps": 1e-06,
54
+ "model_type": "siglip_vision_model",
55
+ "num_attention_heads": 16,
56
+ "num_channels": 3,
57
+ "num_hidden_layers": 27,
58
+ "patch_size": 14,
59
+ "torch_dtype": "bfloat16",
60
+ "vision_use_head": false
61
+ }
62
+ }
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 2,
3
+ "cache_implementation": "hybrid",
4
+ "do_sample": true,
5
+ "eos_token_id": [
6
+ 1,
7
+ 106
8
+ ],
9
+ "pad_token_id": 0,
10
+ "top_k": 64,
11
+ "top_p": 0.95,
12
+ "transformers_version": "4.50.0.dev0"
13
+ }
model-00001-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e6be3cbab588533a4b00f2d7f0409327fa0a9608dd698e2f18102b930ee39e0
3
+ size 3797563736
model-00002-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:464e049a45839e53faa1329063614ddebd5877e30e749a30c303c748f2376cc7
3
+ size 3996872248
model-00003-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d9677954e3c2caea91856d7454330d5cc2cb9eff41c628facef7899167cbfcb
3
+ size 3897739432
model-00004-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d66a4d1c4195942c3e05fa7f79b7654b3e3981e48336eab6daa60ac7439e5aa
3
+ size 3897783032
model-00005-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:14d51a1e62d9d8cee5f6b2762b9aeb5ec842f126f7c92681333d1275cb49b4a6
3
+ size 3897783048
model-00006-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e599fe743df2d6983646121e7f91faaeb710852b137cf0c85f0e13e6dc86478
3
+ size 3996872312
model-00007-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b876f51177e09bf1753a7e2fba6a728e3d3e00eba3917f0569a18aadbc9e854
3
+ size 3897739488
model-00008-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c8070843e45521ff2f3e6b5026ab6db39b485c8a433128d3e099eec7ffeb2e9
3
+ size 3897783032
model-00009-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af4e30f25df5d0647ce86533bfef534b2e03fd6d7e2c068b6a36d1e8303fd3b7
3
+ size 3897783048
model-00010-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ee8a6eecce1fb7823d8662291dd4dd20ba611cc409399714b76b7a3437137f7
3
+ size 3996872312
model-00011-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d211b9fa4d49423d485049ff1268cd2620fc50f517987acf3f91b0994f2da52b
3
+ size 3897739488
model-00012-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:595acef257e9c18b27d9fcc21603b89af1859aad97acb53ea21462639ec36209
3
+ size 3897783032
model-00013-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a55fdc43e97d92d377998f28f6834c6cbc4ddbbefbf3bce2fe9d6a32220161d
3
+ size 3897783048
model-00014-of-00014.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24591d035bb0003b1d89041429da29359ef2693e8775c04416b68bea9a701606
3
+ size 3996883168
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
preprocessor_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_rgb": null,
3
+ "do_normalize": true,
4
+ "do_pan_and_scan": null,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Gemma3ImageProcessor",
13
+ "image_seq_length": 256,
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "pan_and_scan_max_num_crops": null,
20
+ "pan_and_scan_min_crop_size": null,
21
+ "pan_and_scan_min_ratio_to_activate": null,
22
+ "processor_class": "Gemma3Processor",
23
+ "resample": 2,
24
+ "rescale_factor": 0.00392156862745098,
25
+ "size": {
26
+ "height": 896,
27
+ "width": 896
28
+ }
29
+ }
processor_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "image_seq_length": 256,
3
+ "processor_class": "Gemma3Processor"
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "boi_token": "<start_of_image>",
3
+ "bos_token": {
4
+ "content": "<bos>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false
9
+ },
10
+ "eoi_token": "<end_of_image>",
11
+ "eos_token": {
12
+ "content": "<eos>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false
17
+ },
18
+ "image_token": "<image_soft_token>",
19
+ "pad_token": {
20
+ "content": "<pad>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ },
26
+ "unk_token": {
27
+ "content": "<unk>",
28
+ "lstrip": false,
29
+ "normalized": false,
30
+ "rstrip": false,
31
+ "single_word": false
32
+ }
33
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4667f2089529e8e7657cfb6d1c19910ae71ff5f28aa7ab2ff2763330affad795
3
+ size 33384568
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff