نماذج الاستدلال / Reasoning models

الترتيب / Order
7 من 14 / 7 of 14
آخر تحديث / Updated
8 أكتوبر 2026 / 8 October 2026

المستوى: متوسط · الدرس 7 من 14

أهداف الدرس

  1. أن تفهم «التفكير قبل الإجابة».
  2. أن تعرف كيف تُدرَّب بالمكافآت التي يمكن التحقّق منها.

نماذج الاستدلال تكتب خطوات تفكير قبل الإجابة، وتصرف وقتاً أطول على المسائل الصعبة. تُدرَّب بالتعلّم المعزّز على مسائل يمكن التحقّق من إجابتها آلياً — رياضيات وبرمجة — فتُكافَأ حين تصيب. ومن الطرق الشائعة أن تُجرَّب عدّة إجابات للسؤال نفسه ويُقارَن كلٌّ منها بمتوسّط المجموعة.

Python
import numpy as np

def reward(answer: str, correct: str) -> float:
    return 1.0 if answer.strip() == correct else 0.0   # verifiable: no human needed

answers = ["42", "41", "42", "40"]                  # 4 tries at the same question
r = np.array([reward(a, "42") for a in answers])
advantage = (r - r.mean()) / (r.std() + 1e-6)       # better than the group -> pushed up
print(r, advantage.round(2))                        # [1. 0. 1. 0.] [ 1. -1.  1. -1.]
المهمةنموذج سريعنموذج استدلال
ترجمة أو تلخيص✓
مسألة رياضيات متعدّدة الخطوات✓
تصحيح كود وتحليل خطأ✓

اطلب من النموذج أن يتحقّق من إجابته قبل أن يعطيها؛ هذا يحسّن الدقّة كثيراً في المسائل الصعبة.

تمرين

لماذا تُدرَّب نماذج الاستدلال على الرياضيات والبرمجة خصوصاً؟

الإجابة

لأن صحة الإجابة فيها يمكن التحقّق منها آلياً، فتكون المكافأة دقيقة وبلا حاجة إلى إنسان.

Level: Intermediate · Lesson 7 of 14

Lesson goals

  1. Understand «thinking before answering».
  2. Know how they are trained with verifiable rewards.

Reasoning models write out steps before answering, and spend longer on hard problems. They are trained with reinforcement learning on problems whose answers can be checked automatically — maths and code — and are rewarded when right. A common method samples several answers to one question and compares each with the group average.

Python
import numpy as np

def reward(answer: str, correct: str) -> float:
    return 1.0 if answer.strip() == correct else 0.0   # verifiable: no human needed

answers = ["42", "41", "42", "40"]                  # 4 tries at the same question
r = np.array([reward(a, "42") for a in answers])
advantage = (r - r.mean()) / (r.std() + 1e-6)       # better than the group -> pushed up
print(r, advantage.round(2))                        # [1. 0. 1. 0.] [ 1. -1.  1. -1.]
TaskFast modelReasoning model
Translate or summarise✓
Multi-step maths problem✓
Debugging and error analysis✓

Ask the model to check its answer before giving it; that improves accuracy a lot on hard problems.

Exercise

Why are reasoning models trained especially on maths and code?

Answer

Their answers can be checked automatically, so the reward is exact and needs no human.

التعليقات / Comments

لا تعليقات بعد. كن أول من يسأل. / No comments yet. Be the first to ask.

تعليق الطالب يظهر فوراً، وتعليق الزائر بعد موافقة المدرّس. / A student's comment shows at once; a visitor's once the teacher approves it.

في «الذكاء الاصطناعي: من الصفر إلى الاحتراف» / In “AI: from zero to hero”

  1. 1ما الذكاء الاصطناعي التوليدي؟ / What is generative AI?فيها صور / has picturesالتعليقات مفتوحة / comments open
  2. 2الرموز والتضمينات / Tokens and embeddingsفيها كود / has codeفيها صور / has picturesالتعليقات مفتوحة / comments open
  3. 3المحوّل والانتباه / Transformers and attentionفيها كود / has codeفيها صور / has picturesالتعليقات مفتوحة / comments open
  4. 4التدريب المسبق / Pre-trainingفيها كود / has codeفيها صور / has picturesالتعليقات مفتوحة / comments open
  5. 5الضبط بالتعليمات / Instruction tuning (SFT)فيها كود / has codeالتعليقات مفتوحة / comments open
  6. 6التعلّم من التفضيلات / Learning from preferencesفيها كود / has codeفيها صور / has picturesالتعليقات مفتوحة / comments open
  7. 7نماذج الاستدلال / Reasoning modelsفيها كود / has codeالتعليقات مفتوحة / comments open
  8. 8الضبط الدقيق الفعّال / Efficient fine-tuningفيها كود / has codeفيها صور / has picturesالتعليقات مفتوحة / comments open
  9. 9هندسة الأوامر والسياق / Prompt and context engineeringفيها كود / has codeالتعليقات مفتوحة / comments open
  10. 10الاسترجاع المعزّز (RAG) من الصفر / RAG from scratchفيها كود / has codeفيها صور / has picturesالتعليقات مفتوحة / comments open
  11. 11RAG المتقدّم / Advanced RAGفيها كود / has codeالتعليقات مفتوحة / comments open
  12. 12الوكلاء والأدوات / Agents and toolsفيها كود / has codeفيها صور / has picturesالتعليقات مفتوحة / comments open
  13. 13التقييم والأمان / Evaluation and safetyفيها كود / has codeفيها صور / has picturesالتعليقات مفتوحة / comments open
  14. 14مشروع ختامي: مساعد عربي / Capstone: an Arabic assistantفيها كود / has codeفيها صور / has picturesفيها نموذج / has a formالتعليقات مفتوحة / comments open

↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق↑ ↓ to move · Enter to open · Esc to close