التدريب المسبق / Pre-training

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

المستوى: مبتدئ · الدرس 4 من 14

أهداف الدرس

  1. أن تعرف كيف يتعلّم النموذج من النصوص الخام.
  2. أن تفهم قوانين التوسّع ومزيج الخبراء.

في التدريب المسبق يقرأ النموذج كمّاً هائلاً من النصوص — ويب وكتب وكود — ويتعلّم مهمة واحدة: توقّع الرمز التالي. كلما أخطأ زادت «الخسارة»، فتُعدَّل أوزانه قليلاً. وبعد تريليونات الرموز يكتسب اللغة والمعرفة العامة.

التدريب المسبق هو الخطوة الأولى
التدريب المسبق هو الخطوة الأولى
Python
import numpy as np

vocab = ["الطالب", "يقرأ", "الكتاب", "البحر"]
# The model's probabilities for the word after «الطالب يقرأ»
probs = np.array([0.05, 0.05, 0.80, 0.10])
target = vocab.index("الكتاب")

loss = -np.log(probs[target])
print(round(float(loss), 3))   # 0.223 — low loss: the model expected «الكتاب»
المفهومالفكرة
قوانين التوسّعمزيد من البيانات والحجم والحوسبة يعطي تحسّناً يمكن توقّعه
مزيج الخبراءأجزاء متخصّصة يعمل بعضها فقط لكل رمز: قدرة كبيرة بكلفة أقل
جودة البياناتتنظيف، وإزالة التكرار والبيانات الشخصية، وتوازن اللغات

النموذج بعد التدريب المسبق وحده «يكمل النص» ولا يتبع التعليمات؛ هذا ما يعالجه التدريب اللاحق.

تمرين

لماذا تهمّ نسبة العربية في بيانات التدريب المسبق؟

الإجابة

لأن النموذج يتعلّم اللغة بقدر ما يرى منها؛ قلّة العربية تعني فهماً أضعف ورموزاً أكثر.

Level: Beginner · Lesson 4 of 14

Lesson goals

  1. Know how a model learns from raw text.
  2. Understand scaling laws and mixture of experts.

In pre-training the model reads an enormous amount of text — web, books, code — and learns one task: predict the next token. Every miss raises the «loss», and its weights are nudged. After trillions of tokens it has picked up language and general knowledge.

Pre-training is the first step
Pre-training is the first step
Python
import numpy as np

vocab = ["الطالب", "يقرأ", "الكتاب", "البحر"]
# The model's probabilities for the word after «الطالب يقرأ»
probs = np.array([0.05, 0.05, 0.80, 0.10])
target = vocab.index("الكتاب")

loss = -np.log(probs[target])
print(round(float(loss), 3))   # 0.223 — low loss: the model expected «الكتاب»
ConceptThe idea
Scaling lawsMore data, size and compute give a predictable improvement
Mixture of expertsSpecialised parts, only some active per token: big capacity, lower cost
Data qualityCleaning, de-duplication, removing personal data, balancing languages

After pre-training alone a model «continues text» and does not follow instructions; post-training fixes that.

Exercise

Why does the share of Arabic in pre-training data matter?

Answer

A model learns a language as much as it sees it; little Arabic means weaker understanding and more tokens.

التعليقات / 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