Omartificial-Intelligence-Space commited on
Commit
6fa12ef
·
verified ·
1 Parent(s): ef6b490

update readme.md

Browse files
Files changed (1) hide show
  1. README.md +81 -1
README.md CHANGED
@@ -35,9 +35,11 @@ We fine-tuned a pre-trained language model to improve its reasoning capabilities
35
  ### Dataset
36
 
37
  🔹 Training Source: [Omartificial-Intelligence-Space/Arabic_Reasoning_Dataset](https://huggingface.co/datasets/Omartificial-Intelligence-Space/Arabic_Reasoning_Dataset) with 10,000 samples.
 
38
  🔹 Description: Contains instruction-answer pairs for reasoning tasks in Arabic.
39
 
40
  🔹 Validation Source: [MohammedNasser/Arabic_Reasoning_Instruct_QA](https://huggingface.co/datasets/MohammedNasser/ARabic_Reasoning_QA/viewer/default/test)
 
41
  🔹 Description: Contains reasoning challenges to validate model performance.
42
 
43
  ### Preprocessing
@@ -58,21 +60,99 @@ Below is an instruction that describes a task. Write a response that appropriate
58
  #### Model
59
 
60
  ▪️ Base Model: Qwen/QwQ-32B-Preview
 
61
  ▪️ Optimization: LoRA with the following parameters:
 
62
  ▪️Rank r: 16
 
63
  ▪️ LoRA alpha: 16
 
64
  ▪️ Dropout: 0
 
65
  ▪️ Gradient checkpointing: "unsloth" for long contexts.
66
 
67
  #### Training Arguments
68
  ▪️ Batch Size: 8 (per device)
 
69
  ▪️ Gradient Accumulation Steps: 2
 
70
  ▪️ Epochs: 3
 
71
  ▪️ Learning Rate: 2e-4
 
72
  ▪️ Optimizer: adamw_8bit
 
73
  ▪️ Scheduler: Linear
 
74
  ▪️ FP16/BF16: Enabled based on hardware support.
75
 
76
- ## Results and Comparsion
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
 
 
35
  ### Dataset
36
 
37
  🔹 Training Source: [Omartificial-Intelligence-Space/Arabic_Reasoning_Dataset](https://huggingface.co/datasets/Omartificial-Intelligence-Space/Arabic_Reasoning_Dataset) with 10,000 samples.
38
+
39
  🔹 Description: Contains instruction-answer pairs for reasoning tasks in Arabic.
40
 
41
  🔹 Validation Source: [MohammedNasser/Arabic_Reasoning_Instruct_QA](https://huggingface.co/datasets/MohammedNasser/ARabic_Reasoning_QA/viewer/default/test)
42
+
43
  🔹 Description: Contains reasoning challenges to validate model performance.
44
 
45
  ### Preprocessing
 
60
  #### Model
61
 
62
  ▪️ Base Model: Qwen/QwQ-32B-Preview
63
+
64
  ▪️ Optimization: LoRA with the following parameters:
65
+
66
  ▪️Rank r: 16
67
+
68
  ▪️ LoRA alpha: 16
69
+
70
  ▪️ Dropout: 0
71
+
72
  ▪️ Gradient checkpointing: "unsloth" for long contexts.
73
 
74
  #### Training Arguments
75
  ▪️ Batch Size: 8 (per device)
76
+
77
  ▪️ Gradient Accumulation Steps: 2
78
+
79
  ▪️ Epochs: 3
80
+
81
  ▪️ Learning Rate: 2e-4
82
+
83
  ▪️ Optimizer: adamw_8bit
84
+
85
  ▪️ Scheduler: Linear
86
+
87
  ▪️ FP16/BF16: Enabled based on hardware support.
88
 
89
+ ## Usage
90
+
91
+ ```bash
92
+ pip install unsloth
93
+ ```
94
+
95
+ ```bash
96
+ from unsloth import FastLanguageModel
97
+ import torch
98
+ max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
99
+ dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
100
+ load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
101
+
102
+ model, tokenizer = FastLanguageModel.from_pretrained(
103
+ model_name = "Omartificial-Intelligence-Space/Arabic-QWQ-32B-Preview",
104
+ max_seq_length = max_seq_length,
105
+ dtype = dtype,
106
+ load_in_4bit = load_in_4bit,
107
+ # token = "hf_...", # use one if using gated models like meta-llama/Llama-2-7b-hf
108
+ )
109
+
110
+ prompt = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
111
+
112
+ ### Instruction:
113
+ {}
114
+
115
+ ### Response:
116
+ {}"""
117
+
118
+ # alpaca_prompt = Copied from above
119
+ FastLanguageModel.for_inference(model) # Enable native 2x faster inference
120
+ inputs = tokenizer(
121
+ [
122
+ prompt.format(
123
+ "YOUR INSTRUCTION", # instruction
124
+ "", # output - leave this blank for generation!
125
+ )
126
+ ], return_tensors = "pt").to("cuda")
127
+
128
+ outputs = model.generate(**inputs, max_new_tokens = 256, use_cache = True)
129
+ tokenizer.batch_decode(outputs)
130
+ ```
131
+
132
+ ## Results and Comparsion
133
+
134
+ > [!IMPORTANT]
135
+ > The Qwen/QwQ-32B model, while inherently multilingual and supportive of Arabic, exhibits inconsistent performance in Arabic reasoning tasks compared to its stronger default capabilities in English.
136
+ > Our observations indicate that the model often requires explicit, structured prompting to generate coherent Arabic responses, and even then, its reasoning abilities in Arabic can be limited.
137
+ > To address this, we have adapted the model by fine-tuning it with targeted Arabic reasoning datasets and task-specific instructions, enhancing its understanding and alignment with Arabic language tasks.
138
+ > This adaptation demonstrates the need for language-specific adjustments to optimize multilingual models for underrepresented languages like Arabic.
139
+
140
+ The following results of the **Arabic-QwQ** and **QwQ-Preivew** models were analyzed to better understand the impact of fine-tuning on the model's performance, particularly in enhancing its capabilities for Arabic language tasks.
141
+
142
+ 1. An example illustrating how base models generate Chinese responses when provided with an Arabic question:
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
 
158