Views
No views yet

Arabic reasoning-specialized language model fine-tuned from Qwen2.5-3B .GPRO1{
2 "peft_type": "LORA",
3 "r": 64,
4 "lora_alpha": 64,
5 "lora_dropout": 0,
6 "target_modules": [
7 "k_proj", "gate_proj", "o_proj", "down_proj",
8 "v_proj", "up_proj", "q_proj"
9 ],
10 "bias": "none",
11 "inference_mode": true
12}<reasoning>
[Step-by-step reasoning process in Arabic]
</reasoning>
<answer>
[Final answer in Arabic]
</answer>1from unsloth import FastLanguageModel
2
3max_seq_length = 1024 # Can increase for longer reasoning traces
4lora_rank = 64 # Larger rank = smarter, but slower
5
6
7model, tokenizer = FastLanguageModel.from_pretrained(
8 model_name = "Omartificial-Intelligence-Space/Diraya-3B-Instruct-Ar",
9 max_seq_length = max_seq_length,
10 load_in_4bit = True, # False for LoRA 16bit
11 fast_inference = True, # Enable vLLM fast inference
12 max_lora_rank = lora_rank,
13)
14
15
16# System prompt to enforce XML structure
17system_prompt = """
18Respond in the following format in Arabic language only:
19<reasoning>
20...
21</reasoning>
22<answer>
23...
24</answer>
25"""
26
27# Prepare user question
28user_question = "كل يوم، تُطعم وندي كل دجاجة من دجاجاتها ثلاث أكواب من العلف المختلط. تقدم الدجاجات وجباتهم في ثلاث وجبات منفصلة. في الصباح، تعطي قطيعها من الدجاج 15 كوبًا من العلف. في فترة ما بعد الظهر، تعطي دجاجاتها 25 كوبًا أخرى من العلف. كم عدد أكواب العلف التي تحتاجها لتقديمها لدجاجاتها في الوجبة الأخيرة من اليوم إذا كان حجم قطيع وندي 20 دجاجة؟"
29
30# Prepare input for the model
31messages = [
32 {"role": "system", "content": system_prompt},
33 {"role": "user", "content": user_question}
34]
35input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
36
37# Generate response
38inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
39outputs = model.generate(
40 **inputs,
41 max_new_tokens=512,
42 temperature=0.7,
43 top_p=0.95
44)
45response = tokenizer.decode(outputs[0], skip_special_tokens=True)
46print(response)
1@misc{diraya3b,
2 title={Diraya-3B-Instruct-Ar: An Arabic Reasoning-Specialized Language Model},
3 author={Omartificial-Intelligence-Space},
4 year={2025},
5 howpublished={\url{https://huggingface.co/Omartificial-Intelligence-Space/Diraya-3B-Instruct-Ar}}
6}1@misc{qwen2.5,
2 title = {Qwen2.5: A Party of Foundation Models},
3 url = {https://qwenlm.github.io/blog/qwen2.5/},
4 author = {Qwen Team},
5 month = {September},
6 year = {2024}
7}
8
9@article{qwen2,
10 title={Qwen2 Technical Report},
11 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},
12 journal={arXiv preprint arXiv:2407.10671},
13 year={2024}
14}