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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
---
|
3 |
+
|
4 |
+
license: gemma
|
5 |
+
library_name: transformers
|
6 |
+
pipeline_tag: text-generation
|
7 |
+
extra_gated_button_content: Acknowledge license
|
8 |
+
tags:
|
9 |
+
- conversational
|
10 |
+
language:
|
11 |
+
- ar
|
12 |
+
datasets:
|
13 |
+
- MBZUAI-Paris/Darija-SFT-Mixture
|
14 |
+
base_model:
|
15 |
+
- google/gemma-2-2b-it
|
16 |
+
|
17 |
+
---
|
18 |
+
|
19 |
+
[![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
|
20 |
+
|
21 |
+
|
22 |
+
# QuantFactory/Atlas-Chat-2B-GGUF
|
23 |
+
This is quantized version of [MBZUAI-Paris/Atlas-Chat-2B](https://huggingface.co/MBZUAI-Paris/Atlas-Chat-2B) created using llama.cpp
|
24 |
+
|
25 |
+
# Original Model Card
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
# Atlas-Chat Model Card
|
30 |
+
|
31 |
+
|
32 |
+
## Model Overview
|
33 |
+
|
34 |
+
Atlas-Chat is a family of open models instruction-tuned for Darija, the colloquial Arabic of Morocco, developed as part of the [Jais](https://arxiv.org/abs/2308.16149) project for standard Arabic and its extentions to dialectal Arabic. These models are designed for language generation and excel in various applications such as question answering, summarization, and translation. Thanks to their compact size, Atlas-Chat models can be deployed in resource-constrained environments like laptops, desktops, or personal cloud setups, making advanced AI accessible to Darija speakers and promoting widespread innovation. Two versions are available:
|
35 |
+
* [Atlas-Chat-2B](https://huggingface.co/MBZUAI-Paris/Atlas-Chat-2B): A small-sized version with 2 billion parameters, capable of generating fluent Moroccan Darija text while maintaining efficiency.
|
36 |
+
* [Atlas-Chat-9B](https://huggingface.co/MBZUAI-Paris/Atlas-Chat-9B): A larger version with 9 billion parameters, providing more nuanced, contextually rich language generation for complex tasks.
|
37 |
+
|
38 |
+
The models are designed to assist with:
|
39 |
+
|
40 |
+
* Conversational agents and chatbots that operate in Darija.
|
41 |
+
* Translation, summarization, and content generation in informal dialect.
|
42 |
+
* Cultural research related to Morocco and its language.
|
43 |
+
|
44 |
+
**Paper:** [Atlas-Chat: Adapting Large Language Models for Low-Resource Moroccan Arabic Dialect](https://arxiv.org/abs/2409.17912)
|
45 |
+
|
46 |
+
## 👥 Our Team
|
47 |
+
|
48 |
+
The model is developed by MBZUAI France Lab, an AI research center in Paris affiliated with the [Mohamed bin Zayed University of Artificial Intelligence (MBZUAI)](https://mbzuai.ac.ae/) headquartered in Abu Dhabi.
|
49 |
+
|
50 |
+
|
51 |
+
## Usage
|
52 |
+
|
53 |
+
Below we share some code snippets on how to get quickly started with running the model. First, install the Transformers library with:
|
54 |
+
|
55 |
+
```sh
|
56 |
+
pip install -U transformers sentencepiece
|
57 |
+
```
|
58 |
+
|
59 |
+
Then, copy the snippet from the section that is relevant for your use case.
|
60 |
+
|
61 |
+
#### Running with the `pipeline` API
|
62 |
+
|
63 |
+
```python
|
64 |
+
import torch
|
65 |
+
from transformers import pipeline
|
66 |
+
|
67 |
+
pipe = pipeline(
|
68 |
+
"text-generation",
|
69 |
+
model="MBZUAI-Paris/Atlas-Chat-9B",
|
70 |
+
model_kwargs={"torch_dtype": torch.bfloat16},
|
71 |
+
device="cuda" # replace with "mps" to run on a Mac device
|
72 |
+
)
|
73 |
+
|
74 |
+
messages = [
|
75 |
+
{"role": "user", "content": 'شكون لي صنعك؟'},
|
76 |
+
]
|
77 |
+
|
78 |
+
outputs = pipe(messages, max_new_tokens=256, temperature=0.0)
|
79 |
+
assistant_response = outputs[0]["generated_text"][-1]["content"].strip()
|
80 |
+
print(assistant_response)
|
81 |
+
```
|
82 |
+
|
83 |
+
- Response:
|
84 |
+
|
85 |
+
|
86 |
+
>صنعاتني جامعة محمد بن زايد للذكاء الاصطناعي، لي هي جامعة بحثية ديال الدراسات العليا الهدف ديالها أنها تزيد بالذكاء الاصطناعي لقدّام وتنفع بيه الإنسانية. يمكن ليك تزور https://mbzuai.ac.ae/ar/about/ باش تعرف كثر على جامعة محمد بن زايد للذكاء الاصطناعي والمهمة ديالها!
|
87 |
+
|
88 |
+
|
89 |
+
#### Running the model on a single / multi GPU
|
90 |
+
|
91 |
+
```sh
|
92 |
+
pip install accelerate
|
93 |
+
```
|
94 |
+
|
95 |
+
```python
|
96 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
97 |
+
import torch
|
98 |
+
|
99 |
+
model_id = "MBZUAI-Paris/Atlas-Chat-9B"
|
100 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
101 |
+
model = AutoModelForCausalLM.from_pretrained(
|
102 |
+
model_id,
|
103 |
+
device_map="auto",
|
104 |
+
torch_dtype=torch.bfloat16,
|
105 |
+
)
|
106 |
+
|
107 |
+
messages = [
|
108 |
+
{"role": "user", "content": "شنو كيتسمى المنتخب المغربي ؟"},
|
109 |
+
]
|
110 |
+
|
111 |
+
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True, , add_generation_prompt=True)
|
112 |
+
|
113 |
+
outputs = model.generate(**input_ids, max_new_tokens=256)
|
114 |
+
|
115 |
+
print(tokenizer.decode(outputs[0]))
|
116 |
+
```
|
117 |
+
|
118 |
+
- Response:
|
119 |
+
>المنتخب المغربي كيتسمى أيضا "أسود الأطلس"
|
120 |
+
|
121 |
+
|
122 |
+
<!-- You can ensure the correct chat template is applied by using `tokenizer.apply_chat_template` as follows:
|
123 |
+
```python
|
124 |
+
|
125 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
126 |
+
import torch
|
127 |
+
|
128 |
+
model_id = "MBZUAI-Paris/Atlas-Chat-9B"
|
129 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
130 |
+
model = AutoModelForCausalLM.from_pretrained(
|
131 |
+
model_id,
|
132 |
+
device_map="auto",
|
133 |
+
torch_dtype=torch.bfloat16,
|
134 |
+
)
|
135 |
+
|
136 |
+
messages = [
|
137 |
+
{"role": "user", "content": "شنو هيا ا��إيجابيات ديال الطاقة المتجددة؟"},
|
138 |
+
]
|
139 |
+
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True, add_generation_prompt=True)
|
140 |
+
|
141 |
+
outputs = model.generate(**input_ids, max_new_tokens=256, temperature=0.0)
|
142 |
+
|
143 |
+
print(tokenizer.decode(outputs[0]))
|
144 |
+
```
|
145 |
+
|
146 |
+
- Response:
|
147 |
+
```text
|
148 |
+
<bos><start_of_turn>user
|
149 |
+
شنو هيا الإيجابيات ديال الطاقة المتجددة؟<end_of_turn>
|
150 |
+
<start_of_turn>model
|
151 |
+
الطاقة المتجددة عندها بزاف ديال الإيجابيات، منها:
|
152 |
+
|
153 |
+
1. الاستدامة: مصادر الطاقة المتجددة بحال الريح، الشمس، والطاقة الكهرومائية كيتجددو بشكل طبيعي، يعني ما غاديش ينفدو مع الوقت. هاد الشي كيخليهم مصدر طاقة مستدام اللي ممكن نعتمدو عليه على المدى الطويل.
|
154 |
+
|
155 |
+
2. تقليل انبعاثات الكربون: مصادر الطاقة المتجددة عموماً عندها انبعاثات كربونية أقل من الوقود الأحفوري، وهاد الشي كيساعد فالتخفيف من التغير المناخي وتقليل تلوث الهواء.
|
156 |
+
|
157 |
+
3. الاستقلال الطاقي: مصادر الطاقة المتجددة ممكن نستعملوها باش نقللو من الاعتماد على الوقود الأحفوري المستورد، وهاد الشي كيزيد من الاستقلال الطاقي وكيقلل من خطر التقطيع.
|
158 |
+
|
159 |
+
4. خلق فرص الشغل: صناعة الطاقة المتجددة كتخلق فرص شغل فمجالات بحال تركيب الألواح الشمسية، صيانة توربينات الرياح، وبناء محطات
|
160 |
+
``` -->
|
161 |
+
|
162 |
+
#### Quantized Versions through `bitsandbytes`
|
163 |
+
|
164 |
+
<details>
|
165 |
+
<summary>
|
166 |
+
Using 8-bit precision (int8)
|
167 |
+
</summary>
|
168 |
+
|
169 |
+
```sh
|
170 |
+
pip install bitsandbytes accelerate
|
171 |
+
```
|
172 |
+
|
173 |
+
```python
|
174 |
+
# pip install bitsandbytes accelerate
|
175 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
176 |
+
|
177 |
+
model_id = "MBZUAI-Paris/Atlas-Chat-9B"
|
178 |
+
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
179 |
+
|
180 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
181 |
+
model = AutoModelForCausalLM.from_pretrained(
|
182 |
+
model_id,
|
183 |
+
quantization_config=quantization_config,
|
184 |
+
)
|
185 |
+
text = f"""
|
186 |
+
شرح ليا هاد الهضرة:
|
187 |
+
في القرن 19 لقاو الذّهب في كاليفورنيا، ناضو لّي كيبيعو العتلة والفاس كيقنعو الناس بلي غيديرو لاباس يلا قلبو على الذهب... فالأخير اغتنى تجار أدوات التنقيب والحفر. وحاليا كاين لّي كيقنع الأخرين بلي هو مليونير، وعندو الوقت يورّي للآخرين كيفاش يديرو لاباس.
|
188 |
+
"""
|
189 |
+
messages = [
|
190 |
+
{"role": "user", "content": text},
|
191 |
+
]
|
192 |
+
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to("cuda")
|
193 |
+
|
194 |
+
outputs = model.generate(**input_ids, max_new_tokens=256)
|
195 |
+
print(tokenizer.decode(outputs[0]).split("<start_of_turn>model")[-1])
|
196 |
+
```
|
197 |
+
|
198 |
+
- Response:
|
199 |
+
|
200 |
+
>هاد الهضرة كتهضر على قصة قديمة من القرن 19 فين تكتشف الذهب فكاليفورنيا. هاد الشي خلق حالة ديال الجنون على الذهب، فين بزاف ديال الناس مشاو لتما باش يقلبو عليه. كانو حتى ناس اللي كانو كيبيعو أدوات التنقيب بحال الفاس والعتلة، وكانو كيقنعو الناس بلي غادي يربحو الفلوس إلا مشاو يقلبو على الذهب. فالنهاية، هادوك اللي كانو كيبيعو هاد الأدوات هوما اللي ربحو بزاف، حيت كانو كيربحو من كل واحد اللي كان كيشري منهم.
|
201 |
+
>
|
202 |
+
>هاد القصة كتشبه للي كاينة دابا، فين كاينين ناس اللي كيدعيو بلي هوما مليونير وكيبيعو نصائح على كيفاش تربح الفلوس. بحال هادوك اللي كانو كيبيعو الأدوات فالماضي، حتى هاد الناس كيربحو من هاد الشي، حيت كياخدو الفلوس من الناس اللي كيشريو منهم النصائح ديالهم.
|
203 |
+
|
204 |
+
|
205 |
+
</details>
|
206 |
+
|
207 |
+
<details>
|
208 |
+
<summary>
|
209 |
+
Using 4-bit precision
|
210 |
+
</summary>
|
211 |
+
|
212 |
+
```python
|
213 |
+
# pip install bitsandbytes accelerate
|
214 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
215 |
+
|
216 |
+
model_id = "MBZUAI-Paris/Atlas-Chat-9B"
|
217 |
+
quantization_config = BitsAndBytesConfig(load_in_4bit=True)
|
218 |
+
|
219 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
220 |
+
model = AutoModelForCausalLM.from_pretrained(
|
221 |
+
model_id,
|
222 |
+
quantization_config=quantization_config,
|
223 |
+
)
|
224 |
+
text = f"""ترجم للدارجة:
|
225 |
+
Atlas Chat is the first open source large language model that talks in Darija.
|
226 |
+
"""
|
227 |
+
messages = [
|
228 |
+
{"role": "user", "content": text},
|
229 |
+
]
|
230 |
+
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True, add_generation_prompt=True)
|
231 |
+
|
232 |
+
outputs = model.generate(**input_ids, max_new_tokens=256, temperature=0.0)
|
233 |
+
print(tokenizer.decode(outputs[0]).split("<start_of_turn>model")[-1])
|
234 |
+
```
|
235 |
+
|
236 |
+
- Response:
|
237 |
+
|
238 |
+
>أطلّاس شات هو أول نموذج لغوي كبير مفتوح المصدر كايهضر بالدارجة.
|
239 |
+
|
240 |
+
|
241 |
+
</details>
|
242 |
+
|
243 |
+
|
244 |
+
### Chat Template
|
245 |
+
|
246 |
+
The models use a chat template that must be adhered to conversational use.
|
247 |
+
The easiest way to apply it is using the tokenizer's built-in chat template, as shown in the following snippet.
|
248 |
+
|
249 |
+
Let's load the model and apply the chat template to a conversation. In this example, we'll start with a single user interaction:
|
250 |
+
|
251 |
+
```python
|
252 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
253 |
+
import transformers
|
254 |
+
import torch
|
255 |
+
|
256 |
+
model_id = "MBZUAI-Paris/Atlas-Chat-9B"
|
257 |
+
dtype = torch.bfloat16
|
258 |
+
|
259 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
260 |
+
model = AutoModelForCausalLM.from_pretrained(
|
261 |
+
model_id,
|
262 |
+
device_map="cuda",
|
263 |
+
torch_dtype=dtype,)
|
264 |
+
|
265 |
+
chat = [
|
266 |
+
{ "role": "user", "content": "أشنو كايمييز المملكة المغربية." },
|
267 |
+
]
|
268 |
+
prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
|
269 |
+
```
|
270 |
+
|
271 |
+
At this point, the prompt contains the following text:
|
272 |
+
|
273 |
+
```
|
274 |
+
<bos><start_of_turn>user
|
275 |
+
أشنو كايمييز المملكة المغربية.<end_of_turn>
|
276 |
+
<start_of_turn>model
|
277 |
+
```
|
278 |
+
|
279 |
+
As you can see, each turn is preceded by a `<start_of_turn>` delimiter and then the role of the entity
|
280 |
+
(either `user`, for content supplied by the user, or `model` for LLM responses). Turns finish with
|
281 |
+
the `<end_of_turn>` token.
|
282 |
+
|
283 |
+
You can follow this format to build the prompt manually, if you need to do it without the tokenizer's
|
284 |
+
chat template.
|
285 |
+
|
286 |
+
After the prompt is ready, generation can be performed like this:
|
287 |
+
|
288 |
+
```python
|
289 |
+
inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
|
290 |
+
outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512)
|
291 |
+
print(tokenizer.decode(outputs[0]))
|
292 |
+
```
|
293 |
+
|
294 |
+
- Response:
|
295 |
+
|
296 |
+
>المغرب كايميزو بزاف ديال الحوايج، منهم:
|
297 |
+
>
|
298 |
+
>1. التنوع الثقافي: المغرب بلاد فيها بزاف ديال الثقافات، كل وحدة فيهم عندها التقاليد ديالها واللغة ديالها والماكلة ديالها. هاد التنوع كايبان فالموسيقى والرقص والفنون التقليدية.
|
299 |
+
>
|
300 |
+
>2. التراث التاريخي: المغرب عندو تاريخ غني كايمتد لآلاف السنين، فيه حضارات قديمة بحال مملكة موريطانيا، والرومان، والبيزنطيين، والفتوحات الإسلامية. هاد التراث كايبان فالمعالم التاريخية بحال مدينة فاس، والمدينة القديمة ديال مراكش، والمدينة القديمة ديال شفشاون.
|
301 |
+
>
|
302 |
+
>3. المناظر الطبيعية: المغرب بلاد فيها مناظر طبيعية متنوعة، من السواحل الزرقة والصحاري الكبيرة، للجبال العالية والوديان الخضراء. هاد التنوع كايمكنك من ممارسة أنشطة خارجية بحال المشي لمسافات طويلة، والتخييم، والرياضات المائية.
|
303 |
+
>
|
304 |
+
>4. الماكلة: الماكلة المغربية معروفة بالتنوع ديالها والطعم ديالها. من بين الأطباق الأكثر شعبية كاين الطاجين، والكسكس، والبريوات، والكوكتيل ديال الفواكه.
|
305 |
+
>
|
306 |
+
>5. الناس: المغاربة معروفين بالضيافة ديالهم والترحاب ديالهم. كايكونو فرحانين باش يشاركو الثقافة والتقاليد ديالهم مع الزوار.
|
307 |
+
|
308 |
+
|
309 |
+
|
310 |
+
|
311 |
+
### Inputs and outputs
|
312 |
+
|
313 |
+
* **Input:** Text string, such as a question, a prompt, or a document to be
|
314 |
+
summarized.
|
315 |
+
* **Output:** Generated Darija text in response to the input, such
|
316 |
+
as an answer to a question, or a summary of a document.
|
317 |
+
|
318 |
+
### Chatbot interface using Ollama
|
319 |
+
|
320 |
+
You can also use Ollama and chatbot-ollama to create a chatbot user-interface to better test the model.
|
321 |
+
First you need to install Ollama on your machine from [here](https://github.com/ollama/ollama) and have node.js installed as well. Then, download and prepare the model as follows:
|
322 |
+
```bash
|
323 |
+
|
324 |
+
huggingface-cli download MBZUAI-Paris/Atlas-Chat-9B --local-dir Atlas-Chat-9B/
|
325 |
+
ollama create Atlas-Chat-9B -f Atlas-Chat-9B/modelfile
|
326 |
+
ollama serve
|
327 |
+
```
|
328 |
+
Finally, in a new terminal clone chatbot-ollama repository from Github and run it:
|
329 |
+
```bash
|
330 |
+
git clone https://github.com/ivanfioravanti/chatbot-ollama.git
|
331 |
+
cd chatbot-ollama
|
332 |
+
npm ci
|
333 |
+
npm run dev
|
334 |
+
```
|
335 |
+
You can start chatting with the model by visiting http://localhost:3000.
|
336 |
+
### Citation
|
337 |
+
If you use Atlas-Chat in your research, please cite our paper:
|
338 |
+
```none
|
339 |
+
@article{shang2024atlaschatadaptinglargelanguage,
|
340 |
+
title={Atlas-Chat: Adapting Large Language Models for Low-Resource Moroccan Arabic Dialect},
|
341 |
+
author={Guokan Shang and Hadi Abdine and Yousef Khoubrane and Amr Mohamed and Yassine Abbahaddou and Sofiane Ennadir and Imane Momayiz and Xuguang Ren and Eric Moulines and Preslav Nakov and Michalis Vazirgiannis and Eric Xing},
|
342 |
+
year={2024},
|
343 |
+
eprint={2409.17912},
|
344 |
+
archivePrefix={arXiv},
|
345 |
+
primaryClass={cs.CL},
|
346 |
+
url={https://arxiv.org/abs/2409.17912},
|
347 |
+
}
|
348 |
+
```
|
349 |
+
|
350 |
+
|
351 |
+
|
352 |
+
|
353 |
+
## Training Data
|
354 |
+
The model was trained on diverse datasets focusing on Darija consisting for approximatley 450k instructions of a maximum length of 2048 tokens, including:
|
355 |
+
|
356 |
+
* Synthetic instructions created to guide the model in processing various types of language tasks tailord towards Moroccan culture.
|
357 |
+
* Instruction samples created from publicly available Moroccan Arabic datasets including translation, summarization and sentiment analysis.
|
358 |
+
* Translated English and multi-lingual instruction-tuning datasets.
|
359 |
+
|
360 |
+
Our training dataset [Darija-SFT-Mixture](https://huggingface.co/datasets/MBZUAI-Paris/Darija-SFT-Mixture) is publicly available.
|
361 |
+
|
362 |
+
|
363 |
+
## Implementation Information
|
364 |
+
Atlas-Chat models are based on Gemma 2 models. The Atlas-Chat models were trained using 8 Nvidia's A100 80 GB GPUs in parallel using FSDP on AWS Sagemaker. The model is trained using HuggingFace transformers and parameter-efficient fine-tuning with LoRA rank of 256.
|
365 |
+
|
366 |
+
|
367 |
+
## Evaluation
|
368 |
+
The Atlas-Chat models were evaluated on a comprehensive suite of tasks using various datasets and benchmarks to assess their performance across multiple dimensions. These included tasks such as:
|
369 |
+
|
370 |
+
* **DarijaMMLU:** A Darija version of ArabicMMLU and MMLU benchmarks translated from MSA and English respectively.
|
371 |
+
* **DarijaHellaSwag:** A Darija version of HellaSwag.
|
372 |
+
* **Belebele Ary_Arab:** Belebele is a multiple-choice machine reading comprehension dataset published by Facebook spanning 122 language variants. The Evaluation is done on the Ary_Arab part of Belebele that refers to Darija.
|
373 |
+
* **Sentiment Analysis.**
|
374 |
+
* **Translation:** Including six directions and four languages: Darija, MSA, English and French.
|
375 |
+
* **Summarization.**
|
376 |
+
|
377 |
+
The models were compared against a collection of existing open-source Arabic models to gauge their effectiveness, with a particular focus on performance in Darija. All scores are based on zero-shot performance. The prompts are written mainly in Darija. The metric used for DarijaMMLU, DarijaHellaSwag, Belebele Ary and Sentiment Analysis is the normalized accuracy. We used [Language Model Evaluation Harness](https://github.com/MBZUAI-Paris/lm-evaluation-harness-atlas-chat) to conduct these evaluations.
|
378 |
+
|
379 |
+
<table>
|
380 |
+
<tr>
|
381 |
+
<td rowspan="2">Model</td>
|
382 |
+
<td rowspan="2"><a href="https://huggingface.co/datasets/MBZUAI-Paris/DarijaMMLU" target="_blank">DarijaMMLU</a></td>
|
383 |
+
<td rowspan="2"><a href="MBZUAI-Paris/DarijaHellaSwag" target="_blank">DarijaHellaSwag</a></td>
|
384 |
+
<td rowspan="2"><a href="https://huggingface.co/datasets/facebook/belebele/viewer/ary_Arab" target="_blank">Belebele Ary</a></td>
|
385 |
+
<td rowspan="2"><a href="https://huggingface.co/datasets/MBZUAI-Paris/DarijaBench" target="_blank">Sentiment Analysis</a></td>
|
386 |
+
<td colspan="2"><a href="https://huggingface.co/datasets/MBZUAI-Paris/DarijaBench" target="_blank">DoDa-10k (Translation)</a></td>
|
387 |
+
<td rowspan="2"><a href="https://huggingface.co/datasets/MBZUAI-Paris/DarijaBench" target="_blank">MArSum (Summarization)</a><br/>(LLM as a judge)</td>
|
388 |
+
</tr>
|
389 |
+
<tr>
|
390 |
+
<td>BLEU</td>
|
391 |
+
<td>chrF</td>
|
392 |
+
</tr>
|
393 |
+
<tr>
|
394 |
+
<td><a href="https://huggingface.co/inceptionai/jais-family-1p3b-chat" target="_blank">jais-family-1p3b-chat</a></td>
|
395 |
+
<td>35.39</td>
|
396 |
+
<td>32.51</td>
|
397 |
+
<td>38.33</td>
|
398 |
+
<td>45.29</td>
|
399 |
+
<td>00.13</td>
|
400 |
+
<td>06.18</td>
|
401 |
+
<td>00.50</td>
|
402 |
+
</tr>
|
403 |
+
<tr>
|
404 |
+
<td><a href="https://huggingface.co/inceptionai/jais-family-2p7b-chat" target="_blank">jais-family-2p7b-chat</a></td>
|
405 |
+
<td>37.44</td>
|
406 |
+
<td>34.49</td>
|
407 |
+
<td>44.11</td>
|
408 |
+
<td>51.56</td>
|
409 |
+
<td>00.25</td>
|
410 |
+
<td>07.46</td>
|
411 |
+
<td>00.90</td>
|
412 |
+
</tr>
|
413 |
+
<tr>
|
414 |
+
<td><a href="https://huggingface.co/google/gemma-2-2b-it" target="_blank">gemma-2-2b-it</a></td>
|
415 |
+
<td>28.58</td>
|
416 |
+
<td>32.42</td>
|
417 |
+
<td>25.22</td>
|
418 |
+
<td>53.36</td>
|
419 |
+
<td>00.10</td>
|
420 |
+
<td>04.96</td>
|
421 |
+
<td>06.80</td>
|
422 |
+
</tr>
|
423 |
+
<tr>
|
424 |
+
<td><strong><a href="https://huggingface.co/MBZUAI-Paris/Atlas-Chat-2B" target="_blank">Atlas-Chat-2B</a></strong></td>
|
425 |
+
<td><b>44.97</td>
|
426 |
+
<td><b>41.48</td>
|
427 |
+
<td><b>53.89</td>
|
428 |
+
<td><b>73.99</td>
|
429 |
+
<td><b>22.76</td>
|
430 |
+
<td><b>44.86</td>
|
431 |
+
<td><b>55.22</td>
|
432 |
+
</tr>
|
433 |
+
<tr style="border-top: 4px solid;"></tr>
|
434 |
+
<tr>
|
435 |
+
<td><a href="https://huggingface.co/inceptionai/jais-family-6p7b-chat" target="_blank">jais-family-6p7b-chat</a></td>
|
436 |
+
<td>39.96</td>
|
437 |
+
<td>41.57</td>
|
438 |
+
<td>51.22</td>
|
439 |
+
<td>56.78</td>
|
440 |
+
<td>00.73</td>
|
441 |
+
<td>11.85</td>
|
442 |
+
<td>03.02</td>
|
443 |
+
</tr>
|
444 |
+
<tr>
|
445 |
+
<td><a href="https://huggingface.co/inceptionai/jais-adapted-7b-chat" target="_blank">jais-adapted-7b-chat</a></td>
|
446 |
+
<td>39.30</td>
|
447 |
+
<td>35.19</td>
|
448 |
+
<td>43.67</td>
|
449 |
+
<td>52.72</td>
|
450 |
+
<td>00.60</td>
|
451 |
+
<td>09.43</td>
|
452 |
+
<td>02.82</td>
|
453 |
+
</tr>
|
454 |
+
<tr>
|
455 |
+
<td><a href="https://huggingface.co/inceptionai/jais-family-13b-chat" target="_blank">jais-family-13b-chat</a></td>
|
456 |
+
<td>45.11</td>
|
457 |
+
<td>43.90</td>
|
458 |
+
<td>58.67</td>
|
459 |
+
<td>41.73</td>
|
460 |
+
<td>00.92</td>
|
461 |
+
<td>11.71</td>
|
462 |
+
<td>01.77</td>
|
463 |
+
</tr>
|
464 |
+
<tr>
|
465 |
+
<td><a href="https://huggingface.co/inceptionai/jais-adapted-13b-chat" target="_blank">jais-adapted-13b-chat</a></td>
|
466 |
+
<td>45.20</td>
|
467 |
+
<td>40.65</td>
|
468 |
+
<td>49.67</td>
|
469 |
+
<td>66.68</td>
|
470 |
+
<td>00.87</td>
|
471 |
+
<td>10.52</td>
|
472 |
+
<td>01.92</td>
|
473 |
+
</tr>
|
474 |
+
<tr>
|
475 |
+
<td><a href="https://huggingface.co/FreedomIntelligence/AceGPT-7B-chat" target="_blank">AceGPT-7b-chat</a></td>
|
476 |
+
<td>35.98</td>
|
477 |
+
<td>36.57</td>
|
478 |
+
<td>30.11</td>
|
479 |
+
<td>40.23</td>
|
480 |
+
<td>00.44</td>
|
481 |
+
<td>11.33</td>
|
482 |
+
<td>02.28</td>
|
483 |
+
</tr>
|
484 |
+
<tr>
|
485 |
+
<td><a href="https://huggingface.co/FreedomIntelligence/AceGPT-13B-chat" target="_blank">AceGPT-13b-chat</a></td>
|
486 |
+
<td>41.09</td>
|
487 |
+
<td>38.35</td>
|
488 |
+
<td>33.11</td>
|
489 |
+
<td>59.58</td>
|
490 |
+
<td>00.98</td>
|
491 |
+
<td>16.70</td>
|
492 |
+
<td>02.80</td>
|
493 |
+
</tr>
|
494 |
+
<tr>
|
495 |
+
<td><a href="https://huggingface.co/google/gemma-2-9b-it" target="_blank">gemma-2-9b-it</a></td>
|
496 |
+
<td>35.91</td>
|
497 |
+
<td>42.43</td>
|
498 |
+
<td>31.00</td>
|
499 |
+
<td>59.87</td>
|
500 |
+
<td>03.10</td>
|
501 |
+
<td>19.16</td>
|
502 |
+
<td>13.81</td>
|
503 |
+
</tr>
|
504 |
+
<tr>
|
505 |
+
<td><a href="meta-llama/Meta-Llama-3.1-8B-Instruct" target="_blank">Llama-3.1-8B-Instruct</a></td>
|
506 |
+
<td>44.13</td>
|
507 |
+
<td>38.24</td>
|
508 |
+
<td>47.00</td>
|
509 |
+
<td>44.08</td>
|
510 |
+
<td>00.92</td>
|
511 |
+
<td>14.19</td>
|
512 |
+
<td>01.28</td>
|
513 |
+
</tr>
|
514 |
+
<tr>
|
515 |
+
<td><strong><a href="https://huggingface.co/MBZUAI-Paris/Atlas-Chat-9B" target="_blank">Atlas-Chat-9B</a></strong></td>
|
516 |
+
<td><b>58.23</td>
|
517 |
+
<td><b>57.75</td>
|
518 |
+
<td><b>74.56</td>
|
519 |
+
<td><b>81.89</td>
|
520 |
+
<td><b>28.08</td>
|
521 |
+
<td><b>50.48</td>
|
522 |
+
<td><b>59.76</td>
|
523 |
+
</tr>
|
524 |
+
|
525 |
+
|
526 |
+
|
527 |
+
</table>
|
528 |
+
|
529 |
+
|
530 |
+
## Usage and Limitations
|
531 |
+
|
532 |
+
These models have certain limitations that users should be aware of.
|
533 |
+
<details>
|
534 |
+
<summary>Intended Usage</summary>
|
535 |
+
|
536 |
+
Open Large Language Models (LLMs) have a wide range of applications across
|
537 |
+
various industries and domains. The following list of potential uses is not
|
538 |
+
comprehensive. The purpose of this list is to provide contextual information
|
539 |
+
about the possible use-cases that the model creators considered as part of model
|
540 |
+
training and development.
|
541 |
+
|
542 |
+
* Content Creation and Communication
|
543 |
+
* Text Generation: These models can be used to generate creative text formats
|
544 |
+
such as poems, scripts, code, marketing copy, and email drafts.
|
545 |
+
* Chatbots and Conversational AI: Power conversational interfaces for customer
|
546 |
+
service, virtual assistants, or interactive applications.
|
547 |
+
* Text Summarization: Generate concise summaries of a text corpus, research
|
548 |
+
papers, or reports.
|
549 |
+
* Research and Education
|
550 |
+
* Natural Language Processing (NLP) Research: These models can serve as a
|
551 |
+
foundation for researchers to experiment with NLP techniques, develop
|
552 |
+
algorithms, and contribute to the advancement of the field.
|
553 |
+
* Language Learning Tools: Support interactive language learning experiences,
|
554 |
+
aiding in grammar correction or providing writing practice.
|
555 |
+
* Knowledge Exploration: Assist researchers in exploring large bodies of text
|
556 |
+
by generating summaries or answering questions about specific topics.
|
557 |
+
</details>
|
558 |
+
<details>
|
559 |
+
<summary>Limitations</summary>
|
560 |
+
|
561 |
+
* Training Data
|
562 |
+
* The quality and diversity of the training data significantly influence the
|
563 |
+
model's capabilities. Biases or gaps in the training data can lead to
|
564 |
+
limitations in the model's responses.
|
565 |
+
* The scope of the training dataset determines the subject areas the model can
|
566 |
+
handle effectively.
|
567 |
+
* Context and Task Complexity
|
568 |
+
* LLMs are better at tasks that can be framed with clear prompts and
|
569 |
+
instructions. Open-ended or highly complex tasks might be challenging.
|
570 |
+
* A model's performance can be influenced by the amount of context provided
|
571 |
+
(longer context generally leads to better outputs, up to a certain point).
|
572 |
+
* Language Ambiguity and Nuance
|
573 |
+
* Natural language is inherently complex. LLMs might struggle to grasp subtle
|
574 |
+
nuances, sarcasm, or figurative language.
|
575 |
+
* Factual Accuracy
|
576 |
+
* LLMs generate responses based on information they learned from their
|
577 |
+
training datasets, but they are not knowledge bases. They may generate
|
578 |
+
incorrect or outdated factual statements.
|
579 |
+
* Common Sense
|
580 |
+
* LLMs rely on statistical patterns in language. They might lack the ability
|
581 |
+
to apply common sense reasoning in certain situations.
|
582 |
+
</details>
|
583 |
+
<details>
|
584 |
+
<summary> Ethical Considerations and Risks</summary>
|
585 |
+
|
586 |
+
The development of large language models (LLMs) raises several ethical concerns.
|
587 |
+
In creating an open model, we have carefully considered the following:
|
588 |
+
|
589 |
+
* Bias and Fairness
|
590 |
+
* LLMs trained on large-scale, real-world text data can reflect socio-cultural
|
591 |
+
biases embedded in the training material.
|
592 |
+
* Misinformation and Misuse
|
593 |
+
* LLMs can be misused to generate text that is false, misleading, or harmful.
|
594 |
+
* Guidelines are provided for responsible use with the model, see the
|
595 |
+
[Responsible Generative AI Toolkit][rai-toolkit].
|
596 |
+
* Transparency and Accountability:
|
597 |
+
* This model card summarizes details on the models' architecture,
|
598 |
+
capabilities, limitations, and evaluation processes.
|
599 |
+
* A responsibly developed open model offers the opportunity to share
|
600 |
+
innovation by making LLM technology accessible to developers and researchers
|
601 |
+
across the AI ecosystem.
|
602 |
+
|
603 |
+
Risks identified and mitigations:
|
604 |
+
|
605 |
+
* Perpetuation of biases: It's encouraged to perform continuous monitoring
|
606 |
+
(using evaluation metrics, human review) and the exploration of de-biasing
|
607 |
+
techniques during model training, fine-tuning, and other use cases.
|
608 |
+
* Generation of harmful content: Mechanisms and guidelines for content safety
|
609 |
+
are essential. Developers are encouraged to exercise caution and implement
|
610 |
+
appropriate content safety safeguards based on their specific product policies
|
611 |
+
and application use cases.
|
612 |
+
* Privacy violations: Models were trained on data filtered for removal of PII
|
613 |
+
(Personally Identifiable Information). Developers are encouraged to adhere to
|
614 |
+
privacy regulations with privacy-preserving techniques.
|
615 |
+
|
616 |
+
</details>
|
617 |
+
|
618 |
+
|
619 |
+
## Acknowledgement
|
620 |
+
We would like to express our gratitude to the following institutions for their contributions to this work: École Polytechnique, LINAGORA and KTH Royal Institute of Technology. Additionally, we extend our thanks to the AtlasIA community.
|