Update README.md
Browse files
README.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
# Model Card for Model ID
|
@@ -8,192 +19,133 @@ tags: []
|
|
8 |
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
|
10 |
|
|
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
<!-- Provide a longer summary of what this model is. -->
|
17 |
-
|
18 |
-
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
-
|
20 |
-
- **Developed by:** [More Information Needed]
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
-
|
28 |
-
### Model Sources [optional]
|
29 |
-
|
30 |
-
<!-- Provide the basic links for the model. -->
|
31 |
-
|
32 |
-
- **Repository:** [More Information Needed]
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
-
|
36 |
-
## Uses
|
37 |
-
|
38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
-
|
40 |
-
### Direct Use
|
41 |
-
|
42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
-
|
44 |
-
[More Information Needed]
|
45 |
-
|
46 |
-
### Downstream Use [optional]
|
47 |
-
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
-
|
50 |
-
[More Information Needed]
|
51 |
-
|
52 |
-
### Out-of-Scope Use
|
53 |
-
|
54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
-
|
56 |
-
[More Information Needed]
|
57 |
-
|
58 |
-
## Bias, Risks, and Limitations
|
59 |
-
|
60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
-
|
62 |
-
[More Information Needed]
|
63 |
-
|
64 |
-
### Recommendations
|
65 |
-
|
66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
-
|
68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
-
|
70 |
-
## How to Get Started with the Model
|
71 |
-
|
72 |
-
Use the code below to get started with the model.
|
73 |
-
|
74 |
-
[More Information Needed]
|
75 |
-
|
76 |
-
## Training Details
|
77 |
-
|
78 |
-
### Training Data
|
79 |
-
|
80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
-
|
84 |
-
### Training Procedure
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
|
125 |
-
|
126 |
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
-
|
130 |
|
131 |
-
|
132 |
|
|
|
|
|
|
|
133 |
|
|
|
134 |
|
135 |
-
##
|
136 |
|
137 |
-
|
|
|
|
|
|
|
138 |
|
139 |
-
|
140 |
|
141 |
-
|
142 |
|
143 |
-
|
144 |
|
145 |
-
|
|
|
146 |
|
147 |
-
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
|
153 |
-
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
-
|
|
|
|
|
158 |
|
159 |
-
|
|
|
|
|
160 |
|
161 |
-
|
162 |
|
163 |
-
|
164 |
|
165 |
-
|
|
|
|
|
|
|
|
|
166 |
|
167 |
-
|
168 |
|
169 |
-
|
|
|
|
|
170 |
|
171 |
-
|
172 |
|
173 |
-
|
174 |
|
175 |
-
|
176 |
|
177 |
-
|
178 |
|
179 |
-
|
180 |
|
181 |
-
|
|
|
|
|
182 |
|
183 |
-
|
184 |
|
185 |
-
|
186 |
|
187 |
-
|
|
|
|
|
|
|
188 |
|
189 |
-
|
190 |
|
191 |
-
|
192 |
|
193 |
-
|
194 |
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
-
## Model Card Contact
|
198 |
|
199 |
-
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
tags:
|
4 |
+
- MoroccanArabic
|
5 |
+
- Darija
|
6 |
+
- GemMaroc
|
7 |
+
datasets:
|
8 |
+
- GemMaroc/TULU-3-50k-darija-english
|
9 |
+
language:
|
10 |
+
- ar
|
11 |
+
- ary
|
12 |
+
- en
|
13 |
+
base_model:
|
14 |
+
- google/gemma-3-27b-it
|
15 |
---
|
16 |
|
17 |
# Model Card for Model ID
|
|
|
19 |
<!-- Provide a quick summary of what the model is/does. -->
|
20 |
|
21 |
|
22 |
+
# GemMaroc‑27B
|
23 |
|
24 |
+
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.
|
25 |
|
26 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
## Model at a glance
|
29 |
|
30 |
+
| | Details |
|
31 |
+
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
32 |
+
| **Model ID** | `AbderrahmanSkiredj1/GemMaroc-27b-it` |
|
33 |
+
| **Base model** | [`google/gemma-3-27b`](https://huggingface.co/google/gemma-3-27b) |
|
34 |
+
| **Architecture** | Decoder‑only Transformer (Gemma 3) |
|
35 |
+
| **Parameters** | 27 billion |
|
36 |
+
| **Context length** | 2 048 tokens |
|
37 |
+
| **Training regime** | Supervised fine‑tuning (LoRA → merged) on 50 K high‑quality Darija/English instructions TULU‑50K slice |
|
38 |
+
| **Compute budget** | 48 GPU·h (8 × H100‑80GB × 6 h) – ≈ 26 kWh / 10 kg CO₂e |
|
39 |
+
| **License** | Apache 2.0 |
|
40 |
|
41 |
+
---
|
42 |
|
43 |
+
## Why another Darija model?
|
44 |
|
45 |
+
* **Inclusive AI** > 36 million speakers of Moroccan Arabic remain underserved by open LLMs.
|
46 |
+
* **Quality‑over‑quantity** A carefully curated 50 K instruction set surfaces Darija competence without sacrificing cross‑lingual reasoning.
|
47 |
+
* **Green AI** GemMaroc achieves Atlas‑Chat‑level Darija scores using < 2 % of the energy.
|
48 |
|
49 |
+
---
|
50 |
|
51 |
+
## Benchmark summary
|
52 |
|
53 |
+
| Model | Darija MMLU | Darija HellaSwag | GSM8K @5 | HellaSwag (EN) |
|
54 |
+
| ---------------- | ----------- | ---------------- | ---------- | -------------- |
|
55 |
+
| Atlas‑Chat‑27B | **61.9 %** | 48.4 % | 82.0 % | 77.8 % |
|
56 |
+
| **GemMaroc‑27B** | 61.6 % | **60.5 %** | **84.2 %** | **79.3 %** |
|
57 |
|
58 |
+
<sub>Zero‑shot accuracy; full table in the paper.</sub>
|
59 |
|
60 |
+
---
|
61 |
|
62 |
+
## Quick start
|
63 |
|
64 |
+
```python
|
65 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
66 |
|
67 |
+
model_id = "AbderrahmanSkiredj1/GemMaroc-27b-it"
|
|
|
|
|
|
|
|
|
68 |
|
69 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
70 |
+
model = AutoModelForCausalLM.from_pretrained(
|
71 |
+
model_id,
|
72 |
+
torch_dtype="auto",
|
73 |
+
device_map="auto"
|
74 |
+
)
|
75 |
|
76 |
+
pipe = pipeline(
|
77 |
+
"text-generation",
|
78 |
+
model=model,
|
79 |
+
tokenizer=tokenizer,
|
80 |
+
device_map="auto",
|
81 |
+
max_new_tokens=1024,
|
82 |
+
temperature=0.7,
|
83 |
+
repetition_penalty=1.2,
|
84 |
+
no_repeat_ngram_size=3,
|
85 |
+
)
|
86 |
|
87 |
+
messages = [
|
88 |
+
{"role": "user", "content": "شنو هي نظرية ‘butterfly effect’؟ فسّرها بدارجة ونقّط مثال بسيط."}
|
89 |
+
]
|
90 |
|
91 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
92 |
+
print(pipe(prompt)[0]["generated_text"][len(prompt):])
|
93 |
+
```
|
94 |
|
95 |
+
### Chat template (Gemma 3 format)
|
96 |
|
97 |
+
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:
|
98 |
|
99 |
+
```
|
100 |
+
<bos><start_of_turn>user
|
101 |
+
{user message}<end_of_turn>
|
102 |
+
<start_of_turn>model
|
103 |
+
```
|
104 |
|
105 |
+
The assistant will keep generating tokens until it decides to emit `<end_of_turn>`.
|
106 |
|
107 |
+
```python
|
108 |
+
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
|
109 |
+
```
|
110 |
|
111 |
+
No manual token juggling required—the call above handles BOS, turn delimiters, and newline placement automatically.
|
112 |
|
113 |
+
---
|
114 |
|
115 |
+
Pre‑quantised checkpoints will be published under the same repo tags (`gemmaroc‑27b‑awq‑int4`, `gemmaroc‑27b‑gguf‑q4_k_m`).
|
116 |
|
117 |
+
---
|
118 |
|
119 |
+
## Training recipe (one‑paragraph recap)
|
120 |
|
121 |
+
1. **Data** Translate a 44 K reasoning slice of TULU 50K into Darija, keeping 20 % English for cross‑lingual robustness.
|
122 |
+
2. **LoRA SFT** Rank 16, α = 32, 3 epochs, bf16, context 2 048.
|
123 |
+
3. **Merge & push** Merge LoRA into base weights (`peft.merge_and_unload`), convert to safetensors, upload.
|
124 |
|
125 |
+
---
|
126 |
|
127 |
+
## Limitations & ethical considerations
|
128 |
|
129 |
+
* Sentiment and abstractive summarisation still trail state‑of‑the‑art.
|
130 |
+
* Tokeniser is unchanged; rare Darija spellings may fragment.
|
131 |
+
* Model may inherit societal biases present in pre‑training data.
|
132 |
+
* No RLHF / RLAIF safety alignment yet – apply a moderation layer in production.
|
133 |
|
134 |
+
---
|
135 |
|
136 |
+
## Citation
|
137 |
|
138 |
+
If you use GemMaroc in your work, please cite:
|
139 |
|
140 |
+
```bibtex
|
141 |
+
@misc{abderrahman2025gemmaroc,
|
142 |
+
author = {Skiredj, Abderrahman and Azhari, Ferdaous and Atou, Houdaifa and Tazi, Nouamane and Berrada, Ismail},
|
143 |
+
title = {{GemMaroc: Unlocking Darija Proficiency in LLMs with Minimal Data}},
|
144 |
+
year = {2025},
|
145 |
+
publisher = {Zenodo},
|
146 |
+
doi = {10.5281/zenodo.15492072},
|
147 |
+
url = {https://doi.org/10.5281/zenodo.15492072}
|
148 |
+
}
|
149 |
|
|
|
150 |
|
151 |
+
```
|