Commit
e457502
·
verified ·
1 Parent(s): 70888cc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +175 -178
README.md CHANGED
@@ -1,202 +1,199 @@
1
  ---
2
  base_model: unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit
3
  library_name: peft
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
 
 
 
 
11
 
12
- ## Model Details
 
 
 
 
13
 
14
- ### Model Description
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
 
18
 
 
 
 
 
 
 
 
 
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
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
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
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
200
- ### Framework versions
201
-
202
- - PEFT 0.14.0
 
1
  ---
2
  base_model: unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit
3
  library_name: peft
4
+ license: apache-2.0
5
+ language:
6
+ - ar
7
+ tags:
8
+ - arabic
9
+ - reasoning
10
+ - llm
11
+ - DIRA
12
  ---
13
 
14
+ # Diraya-3B-Instruct-Ar
15
+
16
+ ## Model Description
17
+
18
+ Diraya-3B-Instruct-Ar is an Arabic reasoning-specialized language model fine-tuned from Qwen2.5-3B. This model is part of the DIRA (Diraya Arabic Reasoning AI) collection, which focuses on enhancing the logical inference and mathematical reasoning capabilities of Arabic language models.
19
+
20
+ ## Key Features
21
+
22
+ - **Arabic-first reasoning**: Optimized specifically for complex reasoning tasks in Arabic
23
+ - **Structured reasoning format**: Trained to output reasoning in a clear XML format
24
+ - **Mathematical reasoning**: Enhanced ability to solve multi-step math problems
25
+ - **Instruction-tuned**: Follows instructions reliably in Arabic
26
+ - **Lightweight**: Based on the efficient 3B parameter model architecture
27
+
28
+ ## Technical Details
29
+
30
+ **Base Model**: [Qwen2.5-3B](https://huggingface.co/Qwen/Qwen2.5-3B) via [unsloth/Qwen2.5-3B-Instruct-unsloth-bnb-4bit](https://huggingface.co/unsloth/Qwen2.5-3B-Instruct-unsloth-bnb-4bit)
31
 
32
+ **Model Type**: Instruction-tuned causal language model
33
 
34
+ **Parameter Count**: 3.09B (2.77B non-embedding)
35
 
36
+ **Architecture**:
37
+ - 36 transformer layers
38
+ - 16 attention heads for queries (GQA)
39
+ - 2 attention heads for keys/values
40
+ - Context length: 32,768 tokens
41
 
42
+ **Training Approach**:
43
+ - Fine-tuned using GPRO (General Policy Reinforcement Optimization)
44
+ - Training focused on structured reasoning output format using XML tags
45
+ - Optimized for mathematical reasoning using the Arabic GSM8K dataset
46
+ - Multiple reward functions including correctness, format adherence, and output structure
47
 
48
+ **LoRA Configuration**:
49
+ ```json
50
+ {
51
+ "peft_type": "LORA",
52
+ "r": 64,
53
+ "lora_alpha": 64,
54
+ "lora_dropout": 0,
55
+ "target_modules": [
56
+ "k_proj", "gate_proj", "o_proj", "down_proj",
57
+ "v_proj", "up_proj", "q_proj"
58
+ ],
59
+ "bias": "none",
60
+ "inference_mode": true
61
+ }
62
+ ```
63
 
64
+ ## Usage
65
 
66
+ The model is designed to output structured reasoning in the following format:
67
 
68
+ ```
69
+ <reasoning>
70
+ [Step-by-step reasoning process in Arabic]
71
+ </reasoning>
72
+ <answer>
73
+ [Final answer in Arabic]
74
+ </answer>
75
+ ```
76
 
77
+ ### Example Usage
 
 
 
 
 
 
78
 
79
+ ```python
80
+ from transformers import AutoModelForCausalLM, AutoTokenizer
81
 
82
+ # Load the model and tokenizer
83
+ model_name = "Omartificial-Intelligence-Space/Diraya-3B-Instruct-Ar"
84
+ model = AutoModelForCausalLM.from_pretrained(model_name)
85
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
86
 
87
+ # System prompt to enforce XML structure
88
+ system_prompt = """
89
+ Respond in the following format in Arabic language only:
90
+ <reasoning>
91
+ ...
92
+ </reasoning>
93
+ <answer>
94
+ ...
95
+ </answer>
96
+ """
97
 
98
+ # Prepare user question
99
+ user_question = "كل يوم، تُطعم وندي كل دجاجة من دجاجاتها ثلاث أكواب من العلف المختلط. تقدم الدجاجات وجباتهم في ثلاث وجبات منفصلة. في الصباح، تعطي قطيعها من الدجاج 15 كوبًا من العلف. في فترة ما بعد الظهر، تعطي دجاجاتها 25 كوبًا أخرى من العلف. كم عدد أكواب العلف التي تحتاجها لتقديمها لدجاجاتها في الوجبة الأخيرة من اليوم إذا كان حجم قطيع وندي 20 دجاجة؟"
100
 
101
+ # Prepare input for the model
102
+ messages = [
103
+ {"role": "system", "content": system_prompt},
104
+ {"role": "user", "content": user_question}
105
+ ]
106
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
107
 
108
+ # Generate response
109
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
110
+ outputs = model.generate(
111
+ **inputs,
112
+ max_new_tokens=512,
113
+ temperature=0.7,
114
+ top_p=0.95
115
+ )
116
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
117
+ print(response)
118
+ ```
119
+
120
+ ## Training Data
121
+
122
+ This model was primarily fine-tuned on:
123
+
124
+ - **Arabic GSM8K Dataset**: A comprehensive collection of grade school math problems translated to Arabic, requiring multi-step reasoning
125
+ - **Format**: Training emphasized structured reasoning using XML tags to clearly separate reasoning steps from final answers
126
+
127
+ ## Training and Evaluation Results
128
+
129
+ ### Training Progress
130
+
131
+
132
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/628f7a71dd993507cfcbe587/21ZC26E-3Zh2Xw3a6h3WL.png)
133
+
134
+ *Figure: Composition of Rewards over Training Steps showing the evolution of model performance across different reward functions*
135
+
136
+ The training utilized multiple reward functions to optimize different aspects of the model's performance:
137
+ - **Correctness Reward** (red): Measures the model's ability to generate the correct final answer
138
+ - **Integer Reward** (blue): Ensures the model outputs valid numerical responses
139
+ - **Format Rewards** (purple/gray): Promote proper XML structure adherence
140
+ - **XML Count Reward** (yellow): Fine-tunes the exact XML tag placement and completeness
141
+
142
+ As shown in the visualization, the model demonstrated consistent improvement across all reward dimensions throughout the training process. The upper values in rewards indicate higher-quality outputs that simultaneously satisfy multiple optimization criteria. This multi-objective training approach resulted in a model that not only produces correct answers but does so with clear, well-structured reasoning.
143
+
144
+ The model demonstrates strong performance on Arabic mathematical reasoning tasks, with particular strengths in:
145
+ - Producing well-structured reasoning steps
146
+ - Following the required XML output format
147
+ - Arriving at correct numerical answers for multi-step problems
148
+
149
+ ## Limitations
150
+
151
+ - Specialized for reasoning tasks and may not perform as well on general conversational tasks
152
+ - Performance may vary on complex mathematical problems beyond grade-school level
153
+ - Limited to the Arabic language
154
+
155
+ ## Responsible Use
156
+
157
+ This model is intended for educational and research purposes. While it excels at mathematical reasoning, please note:
158
+ - It should not replace human judgment for critical decisions
159
+ - Results should be verified when used in educational contexts
160
+ - The model inherits limitations from its base model Qwen2.5-3B
161
 
162
+ ## Related Resources
163
 
164
+ This model is part of the DIRA (Diraya Arabic Reasoning AI) collection:
165
+ - [Arabic GSM8K Dataset](https://huggingface.co/datasets/Omartificial-Intelligence-Space/Arabic-gsm8k): The dataset used for training this model
166
+
167
+ ## Citation
168
+
169
+ If you use this model in your research, please cite:
170
+
171
+ ```bibtex
172
+ @misc{diraya3b,
173
+ title={Diraya-3B-Instruct-Ar: An Arabic Reasoning-Specialized Language Model},
174
+ author={Omartificial-Intelligence-Space},
175
+ year={2025},
176
+ howpublished={\url{https://huggingface.co/Omartificial-Intelligence-Space/Diraya-3B-Instruct-Ar}}
177
+ }
178
+ ```
179
+
180
+ ## Acknowledgements
181
 
182
+ This model builds upon the Qwen2.5-3B model by the Qwen Team and utilizes optimization techniques from Unsloth. We acknowledge their valuable contributions to the field of language modeling.
183
+
184
+ ```bibtex
185
+ @misc{qwen2.5,
186
+ title = {Qwen2.5: A Party of Foundation Models},
187
+ url = {https://qwenlm.github.io/blog/qwen2.5/},
188
+ author = {Qwen Team},
189
+ month = {September},
190
+ year = {2024}
191
+ }
192
 
193
+ @article{qwen2,
194
+ title={Qwen2 Technical Report},
195
+ author={An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhihao Fan},
196
+ journal={arXiv preprint arXiv:2407.10671},
197
+ year={2024}
198
+ }
199
+ ```