Views
No views yet

unsloth/gpt-oss-20b-unsloth-bnb-4bitOmartificial-Intelligence-Space/gpt-oss-math-ar⚠️ Note on reasoning: The model is optimized to write out reasoning steps in Arabic. For sensitive use cases (exams, grading, or high-stakes evaluation), always verify outputs.
1from unsloth import FastLanguageModel
2from transformers import TextStreamer
3import torch
4
5max_seq_length = 1024
6dtype = None # auto-detect
7
8model, tokenizer = FastLanguageModel.from_pretrained(
9 model_name="Omartificial-Intelligence-Space/gpt-oss-math-ar",
10 dtype=dtype,
11 max_seq_length=max_seq_length,
12 load_in_4bit=True,
13 full_finetuning=False,
14)
15
16messages = [
17 {"role": "system", "content": "reasoning language: Arabic\n\nYou are an Arabic AI math questions solver that solves math problems step-by-step and explian in Arabic language only."},
18 {"role": "user", "content": "بطات جانيت تضع 16 بيضة في اليوم. فهي تأكل ثلاث منها على الفطور كل صباح وتخبز الكعك لأصدقائها كل يوم بأربع منها. إنها تبيع ما تبقى منها في سوق المزارعين كل يوم مقابل دولارين لكل بيضة بطازجة. كم تجني من الدولار كل يوم في سوق المزارعين؟"},
19]
20inputs = tokenizer2.apply_chat_template(
21 messages,
22 add_generation_prompt = True,
23 return_tensors = "pt",
24 return_dict = True,
25 reasoning_effort = "low",
26).to(model2.device)
27from transformers import TextStreamer
28_ = model2.generate(**inputs, max_new_tokens = 256, streamer = TextStreamer(tokenizer2))Omartificial-Intelligence-Space/Arabic-gsm8k-v2Omartificial-Intelligence-Space/Arabic-gsm8k (main_test split)[ { "content": "reasoning language: Arabic\n\nYou are an Arabic AI math questions solver that solves math problems step-by-step and explian in Arabic language only.", "role": "system" },
{ "content": "باعت نتاليا مشابك إلى 48 من أصدقائها في شهر أبريل، ثم باعت نصف ذلك العدد من المشابك في شهر مايو. كم عدد المشابك التي باعتها نتاليا في شهري أبريل ومايو معًا؟", "role": "user" },
{ "content": "باعت ناتاليا 48 ÷ 2 = 24 مشبكًا في مايو.\nباعت ناتاليا 48 + 24 = 72 مشبكًا في أبريل ومايو مجتمعين.\n#### 72", "role": "assistant" } ][ { "content": "reasoning language: Arabic\n\nYou are an Arabic AI math questions solver that solves math problems step-by-step and explian in Arabic language only.", "role": "system" },
{ "content": "تقرأ جولي كتاباً مؤلفاً من 120 صفحة. بالأمس، تمكنت من قراءة 12 صفحة، واليوم قرأت ضعف عدد الصفحات التي قرأتها بالأمس. إذا أرادت قراءة نصف ما تبقى من صفحات غداً، كم صفحة عليها أن تقرأ؟", "role": "user" },
{ "content": "قرأت مايلا اليوم 12 × 2 = 24 صفحة.\nلذلك فإن إجمالي ما قرأته منذ الأمس هو 12 + 24 = 36 صفحة.\nتبقى 120 - 36 = 84 صفحة ليتم قراءتها.\nوبما أنها تريد قراءة نصف الصفحات المتبقية غدًا، فيجب عليها أن تقرأ 84/2 = 42 صفحة.\n#### 42", "role": "assistant" } ]1model = FastLanguageModel.get_peft_model(
2 model,
3 r = 16,
4 target_modules = ["q_proj", "k_proj", "v_proj", "o_proj",
5 "gate_proj", "up_proj", "down_proj"],
6 lora_alpha = 16,
7 lora_dropout = 0,
8 bias = "none",
9 use_gradient_checkpointing = "unsloth",
10 random_state = 3407,
11 use_rslora = False,
12 loftq_config = None,
13)1from trl import SFTConfig, SFTTrainer
2trainer = SFTTrainer(
3 model = model,
4 tokenizer = tokenizer,
5 train_dataset = dataset,
6 args = SFTConfig(
7 per_device_train_batch_size = 16,
8 gradient_accumulation_steps = 1,
9 warmup_steps = 100,
10 num_train_epochs = 3,
11 learning_rate = 2e-4,
12 logging_steps = 100,
13 optim = "adamw_8bit",
14 weight_decay = 0.01,
15 lr_scheduler_type = "linear",
16 seed = 3407,
17 output_dir = "outputs",
18 report_to = "none",
19 ),
20)max_new_tokens: 128–384 for typical word problemstemperature: 0.1–0.5 (lower for deterministic math)top_p: 0.8–0.95repetition_penalty: ~1.05 (optional)#### <النتيجة>[system] reasoning language: Arabic
You are an Arabic AI math questions solver that solves math problems step-by-step and explian in Arabic language only.
[user] لدى متجر 75 قطعة حلوى. باع 18 قطـعة في الصباح و 23 في المساء. كم تبقى؟Omartificial-Intelligence-Space/Arabic-gsm8k (main_test)#### <number> line; optional step-accuracy analysis for intermediate calculations.@model{gpt_oss_math_ar_oi_space,
title = {gpt-oss-math-ar: Arabic Step-by-Step Math Reasoning Adapter for gpt-oss-20B},
author = {Omer Nacar},
year = {2025},
howpublished = {\url{https://huggingface.co/Omartificial-Intelligence-Space/gpt-oss-math-ar}}
}unsloth/gpt-oss-20b-unsloth-bnb-4bitOmartificial-Intelligence-Space/Arabic-gsm8k and Arabic-gsm8k-v2gpt-oss-math-ar (adapter on gpt-oss-20B) with Arabic step-by-step math reasoning and example inference code.