محمد سلطان الشهراني (@2h_1m) header
محمد سلطان الشهراني (@2h_1m) profile picture

Artificial Intelligence Graduate Sharing AI insights | Machine Learning • LLMs • Data Science

Riyadh
Joined July 2022
AI Daily | Day 32 Self-Attention — الانتباه الذاتي في اليوم السابق تعرفنا على Attention Mechanism، وهي فكرة تساعد النموذج على التركيز على المعلومات الأكثر أهمية. لكن كيف يستخدم النموذج هذه الفكرة لفهم العلاقات بين الكلمات داخل النص نفسه؟ هنا يأتي Self-Attention. 🔹 ما هو Self-Attention؟ هو آلية تسمح للنموذج، عند معالجة كلمة معينة، بالنظر إلى الكلمات الأخرى في نفس التسلسل وتحديد أيها أكثر أهمية لفهم معناها. بمعنى بسيط: كل كلمة تنظر إلى الكلمات الأخرى → تحدد ما هو الأكثر ارتباطًا بها → تستخدم هذه المعلومات لفهم السياق. 🔹 مثال بسيط في الجملة: “وضعت الكتاب على الطاولة لأنها كبيرة.” لفهم المقصود من كلمة “كبيرة”، يحتاج النموذج إلى النظر إلى الكلمات الأخرى في الجملة وتحديد العلاقة بينها. فبدلًا من فهم كل كلمة بشكل منفصل، يساعد Self-Attention النموذج على فهم كيف ترتبط الكلمات ببعضها. 🔹 كيف يعمل بشكل مبسط؟ عند معالجة كل كلمة: 1️⃣ تنظر إلى الكلمات الأخرى في النص 2️⃣ تحسب مدى ارتباطها بكل كلمة 3️⃣ تعطي الكلمات الأكثر أهمية وزنًا أعلى 4️⃣ تستخدم هذه العلاقات لفهم المعنى والسياق 🔹 لماذا هو مهم؟ يساعد Self-Attention النموذج على: 🔗 فهم العلاقات بين الكلمات 📍 ربط الكلمات حتى لو كانت متباعدة 🧠 فهم السياق والمعنى بشكل أفضل ⚡ معالجة الكلمات بشكل أكثر كفاءة 💡 الخلاصة Self-Attention = كل عنصر في النص ينظر إلى العناصر الأخرى في نفس النص ليحدد ما هو الأكثر أهمية لفهمه. وهذه الآلية تعد من أهم الأفكار التي تعتمد عليها نماذج Transformers الحديثة. 🤖 ⸻ Self-Attention — How Words Understand Each Other In the previous day, we learned about the Attention Mechanism, which helps a model focus on important information. But how does a model use this idea to understand relationships between words within the same text? This is where Self-Attention comes in. 🔹 What is Self-Attention? Self-Attention allows a model, when processing a word, to look at other words in the same sequence and determine which ones are most relevant. Simply put: Each word looks at other words → identifies what matters most → uses that information to understand the context. 🔹 Simple Example Consider a sentence where understanding a word depends on information elsewhere in the same sentence. Instead of processing each word in isolation, Self-Attention helps the model understand how words relate to one another. 🔹 How does it work? For each word, the model: 1️⃣ Looks at the other words 2️⃣ Measures their relevance 3️⃣ Gives more important words higher weight 4️⃣ Uses these relationships to understand context 💡 Key takeaway Self-Attention = Each element looks at other elements in the same sequence to determine what is most relevant for understanding it. It is one of the key ideas behind modern Transformer models. 🤖 #ArtificialIntelligence #AI #GenerativeAI #SelfAttention #Attention #Transformers #LLM #DeepLearning #NLP
🤖 Made with AI
68
AI Daily | Day 31 Attention Mechanism — آلية الانتباه 🧠 عندما يقرأ نموذج الذكاء الاصطناعي جملة، هل يتعامل مع جميع الكلمات بنفس الأهمية؟ ليس بالضرورة. هنا تأتي Attention Mechanism أو آلية الانتباه. 🔹 ما هي آلية الانتباه؟ هي آلية تساعد النموذج على تحديد الأجزاء الأكثر أهمية في المعلومات التي يعالجها، بحيث يركز على ما هو مرتبط بالمهمة الحالية. بمعنى بسيط: بدلًا من إعطاء كل الكلمات نفس الاهتمام → يركز النموذج أكثر على الكلمات الأكثر ارتباطًا بالسياق. 🔹 مثال بسيط في الجملة: ذهب أحمد إلى البنك لإيداع المال. لفهم معنى كلمة “البنك”، الكلمات المحيطة مثل “إيداع” و**“المال”** أكثر أهمية من كلمات أخرى. آلية الانتباه تساعد النموذج على ربط هذه الكلمات وفهم أن المقصود هو المؤسسة المالية. 🔹 كيف تعمل بشكل مبسط؟ عند معالجة كلمة أو جزء من النص، يقوم النموذج بـ: 🔍 النظر إلى المعلومات الأخرى المرتبطة بها 🎯 تحديد الأجزاء الأكثر أهمية ⚖️ إعطاء كل جزء وزنًا مختلفًا 🧠 استخدام هذه العلاقات لفهم السياق 🔹 لماذا هي مهمة؟ تساعد آلية الانتباه النموذج على: 📖 فهم العلاقات بين الكلمات 🔗 ربط المعلومات حتى لو كانت متباعدة في النص 🧠 فهم السياق بشكل أفضل ⚙️ التعامل بكفاءة مع النصوص والبيانات المعقدة 💡 الخلاصة Attention Mechanism = إعطاء تركيز أكبر للمعلومات الأكثر أهمية بالنسبة للسياق الحالي. وهذه الفكرة أصبحت واحدة من أهم الأسس التي بُنيت عليها نماذج Transformers الحديثة. ⸻ Attention Mechanism — How AI Focuses on Important Information 🧠 When an AI model reads a sentence, does it treat every word as equally important? Not necessarily. This is where the Attention Mechanism comes in. 🔹 What is Attention? It is a mechanism that helps a model identify which parts of the information are most relevant to the current task. Simply put: Instead of giving every word equal importance → the model focuses more on the information most relevant to the context. 🔹 Simple Example Consider the sentence: Ahmed went to the bank to deposit money. To understand the meaning of “bank,” words like “deposit” and “money” are especially important. Attention helps the model connect these relevant words and understand that bank refers to a financial institution. 🔹 How does it work? When processing information, the model: 🔍 Looks at related information 🎯 Identifies what is most relevant ⚖️ Assigns different levels of importance 🧠 Uses these relationships to understand the context 🔹 Why is it important? Attention helps models: 📖 Understand relationships between words 🔗 Connect information across a sequence 🧠 Better understand context ⚙️ Handle complex information effectively 💡 Key takeaway Attention Mechanism = Giving more focus to the information that matters most in the current context. This idea became one of the key foundations behind modern Transformer models. #ArtificialIntelligence #AI #GenerativeAI #AttentionMechanism #Transformers #LLM #DeepLearning #NLP #MachineLearning
🤖 Made with AI
66
AI Daily | Day 30 AI Hallucinations — هلوسة الذكاء الاصطناعي ⚠️ أحيانًا يعطيك الذكاء الاصطناعي إجابة تبدو منطقية وواثقة جدًا، لكنها في الحقيقة غير صحيحة أو مبنية على معلومات غير موجودة. هذه الظاهرة تُعرف باسم AI Hallucination. 🔹 ما هي هلوسة الذكاء الاصطناعي؟ هي عندما يقوم النموذج بإنشاء معلومات أو تفاصيل غير دقيقة أو غير صحيحة، وقد يقدمها وكأنها حقيقة. 🔹 مثال بسيط تسأل النموذج: ما هي الكتب التي ألّفها هذا الكاتب؟ قد يعطيك قائمة تبدو مقنعة، لكن بعض الكتب أو العناوين قد تكون غير موجودة أصلًا. المشكلة هنا أن النموذج لا “يتحقق من الحقيقة” تلقائيًا، بل يولّد الإجابة بناءً على الأنماط والمعلومات المتاحة له. 🔹 لماذا تحدث؟ قد تحدث بسبب: 🧠 نقص المعلومات أو غموض السؤال 📚 عدم وجود معلومات كافية في السياق ⚠️ الاعتماد على أنماط تعلمها النموذج بدلًا من مصدر موثوق 🎯 محاولة النموذج إعطاء إجابة بدلًا من قول: “لا أعرف” 🔹 كيف نقلل منها؟ 🔍 توفير معلومات ومصادر موثوقة 📌 إعطاء النموذج سياقًا واضحًا 📚 استخدام تقنيات مثل RAG ✅ التحقق من المعلومات المهمة قبل الاعتماد عليها 💡 الخلاصة الذكاء الاصطناعي قد يعطي إجابة تبدو صحيحة، لكنها ليست صحيحة دائمًا. لذلك، كلما كانت المعلومة مهمة، تحقق منها ولا تعتمد على ثقة النموذج وحدها. ⸻ AI Hallucinations — When AI Gets Things Wrong ⚠️ Sometimes, an AI can give an answer that sounds confident and convincing, but is actually incorrect or based on information that doesn’t exist. This is known as an AI Hallucination. 🔹 What is an AI Hallucination? It happens when a model generates information or details that are inaccurate, incorrect, or made up, while presenting them as factual. 🔹 Simple Example You ask: What books did this author write? The model may provide a convincing list, but some of the books might not actually exist. The model doesn’t automatically verify every fact. It generates responses based on patterns and the information available in its context. 🔹 Why does it happen? 🧠 Missing or unclear information 📚 Insufficient context ⚠️ Relying on learned patterns instead of verified sources 🎯 Trying to provide an answer instead of saying “I don’t know” 🔹 How can we reduce it? 🔍 Provide reliable information and sources 📌 Give the model clear context 📚 Use techniques such as RAG ✅ Verify important information before relying on it 💡 Key takeaway An AI answer can sound correct without actually being correct. For important information, don’t rely on the model’s confidence alone—always verify the facts. #ArtificialIntelligence #AI #GenerativeAI #LLM #AIHallucination #RAG #PromptEngineering #MachineLearning #NLP #الذكاء_الاصطناعي
🤖 Made with AI
1
69
AI Daily | Day 29 Context Window — نافذة السياق عندما تتحدث مع نموذج مثل ChatGPT، كيف يستطيع تذكّر ما كتبته قبل عدة رسائل؟ هنا يأتي مفهوم Context Window. 🔹 ما هي نافذة السياق؟ هي كمية المعلومات أو الـTokens التي يستطيع النموذج التعامل معها في نفس الوقت. بشكل مبسط، يمكن اعتبارها مساحة الذاكرة المؤقتة للنموذج أثناء المحادثة. 🔹 مثال بسيط إذا كانت نافذة السياق تحتوي على: السؤال الأول → السؤال الثاني → التعليمات → المعلومات المهمة → السؤال الحالي فإن النموذج يستخدم هذه المعلومات لفهم السياق الكامل وإعطاء إجابة مناسبة. لكن إذا أصبحت المحادثة أطول من سعة نافذة السياق، فقد لا يتمكن النموذج من الاحتفاظ بكل المعلومات القديمة. 🔹 لماذا هي مهمة؟ نافذة سياق أكبر تساعد النموذج على: 📄 التعامل مع نصوص ومستندات طويلة 💬 فهم محادثات أطول 🔗 ربط المعلومات ببعضها 🧠 الحفاظ على سياق المهمة 💡 الخلاصة Context Window = كمية المعلومات التي يستطيع النموذج رؤيتها ومعالجتها ضمن السياق الحالي. كلما كان السياق المناسب متاحًا للنموذج، كان فهمه للمهمة أفضل. ⸻ Context Window — How Much Context Can an AI See? When you talk to a model like ChatGPT, how can it keep track of what was said earlier? This is where the Context Window comes in. 🔹 What is a Context Window? It is the amount of information, measured in tokens, that a model can process at a given time. Simply put, it can be thought of as the model’s working memory during a conversation. 🔹 Simple Example A context window might contain: First question → Previous messages → Instructions → Important information → Current question The model uses this information to understand the overall context and generate a relevant response. If the conversation becomes longer than the available context, not all older information may remain available to the model. 🔹 Why does it matter? A larger context window can help a model: 📄 Process longer documents 💬 Follow longer conversations 🔗 Connect related information 🧠 Maintain task context 💡 Key takeaway Context Window = The amount of information a model can see and process within the current context. The more relevant context available to the model, the better it can understand the task. #ArtificialIntelligence #AI #GenerativeAI #LLM #ContextWindow #PromptEngineering #MachineLearning #NLP
58
AI Daily | Day 28 Zero-shot & Few-shot Prompting في Prompt Engineering، طريقة إعطاء التعليمات للنموذج يمكن أن تؤثر بشكل كبير على النتيجة. ومن أشهر هذه الطرق: Zero-shot و Few-shot Prompting. 🔹 Zero-shot Prompting تعني أن تطلب من النموذج تنفيذ مهمة بدون إعطائه أي أمثلة مسبقة. مثال: صنّف الجملة التالية إلى إيجابية أو سلبية: “هذا الفيلم رائع جدًا.” هنا أعطيت النموذج المهمة مباشرة، واعتمد على المعرفة التي تعلمها مسبقًا. 🔹 Few-shot Prompting تعني أن تعطي النموذج عدة أمثلة قبل أن تطلب منه تنفيذ المهمة. مثال: “هذا المنتج ممتاز” → إيجابي “الخدمة سيئة” → سلبي “الفيلم كان مملًا” → ؟ من خلال الأمثلة، يفهم النموذج النمط المطلوب وطريقة الإجابة. 🔹 ما الفرق بينهما؟ Zero-shot ⚡ مهمة مباشرة بدون أمثلة. Few-shot 📚 مهمة مع عدد قليل من الأمثلة. 🔹 متى نستخدم Few-shot؟ عندما تكون المهمة: 🎯 تحتاج تنسيقًا محددًا 📝 لها أسلوب معين في الإجابة 🔄 تحتاج توضيحًا للنمط المطلوب لكن إضافة أمثلة أكثر ليست دائمًا أفضل، لذلك يجب أن تكون الأمثلة واضحة ومرتبطة بالمهمة. 💡 الخلاصة Zero-shot → تعليمات فقط Few-shot → تعليمات + أمثلة وأحيانًا، بضعة أمثلة جيدة تساعد النموذج على فهم المطلوب بشكل أفضل وتحسين النتيجة. ⸻ Zero-shot & Few-shot Prompting In Prompt Engineering, the way we give instructions to a model can significantly affect the result. Two common approaches are Zero-shot and Few-shot Prompting. 🔹 Zero-shot Prompting You ask the model to perform a task without providing any examples. Example: Classify the following sentence as positive or negative: “This movie is amazing.” The model receives the task directly and relies on patterns learned during training. 🔹 Few-shot Prompting You provide the model with a few examples before asking it to perform the task. Example: “This product is excellent” → Positive “The service is terrible” → Negative “The movie was boring” → ? The examples help the model understand the pattern and expected output. 🔹 What’s the difference? Zero-shot ⚡ A task with no examples. Few-shot 📚 A task with a few examples. 💡 Key takeaway Zero-shot → Instructions only Few-shot → Instructions + Examples A few well-chosen examples can sometimes help the model better understand the task and produce better results. #ArtificialIntelligence #AI #GenerativeAI #LLM #PromptEngineering #ZeroShot #FewShot #MachineLearning #DeepLearning #NLP
🤖 Made with AI
52
AI Daily | Day 27 Prompt Engineering — هندسة الأوامر بعد ما عرفنا كيف يتم تدريب وتخصيص النماذج، ننتقل إلى سؤال مهم: كيف نعطي النموذج تعليمات تساعده على تقديم نتائج أفضل؟ هنا تأتي Prompt Engineering. 🔹 ما هي Prompt Engineering؟ هي طريقة تصميم وكتابة التعليمات (Prompts) بشكل واضح ومحدد للحصول على أفضل نتيجة ممكنة من نموذج الذكاء الاصطناعي. 🔹 مثال بسيط ❌ Prompt ضعيف: اشرح لي الذكاء الاصطناعي. ✅ Prompt أفضل: اشرح لي مفهوم الذكاء الاصطناعي للمبتدئين، باستخدام مثال بسيط، وفي 3 نقاط مختصرة. الطلب الثاني يعطي النموذج سياقًا وهدفًا وشكلًا واضحًا للإجابة. 🔹 ما الذي يجعل الـPrompt جيدًا؟ 🎯 الهدف — ماذا تريد من النموذج؟ 📌 السياق — ما المعلومات التي يحتاجها؟ 📝 التنسيق — كيف تريد الإجابة؟ 👤 الجمهور — لمن ستكون الإجابة؟ 🔹 لماذا هي مهمة؟ Prompt جيد يمكن أن يساعد على: 💡 الحصول على إجابات أكثر دقة 🎯 توجيه النموذج نحو النتيجة المطلوبة 📋 الحصول على مخرجات منظمة ⏱️ تقليل المحاولات والتعديلات 💡 الخلاصة Prompt Engineering = كتابة تعليمات واضحة ومدروسة تساعد نموذج الذكاء الاصطناعي على تقديم نتائج أفضل. Prompt واضح → توجيه أفضل → نتيجة أفضل 🚀 ⸻ Prompt Engineering After learning how models are trained and specialized, an important question comes up: How can we give AI instructions that lead to better results? This is where Prompt Engineering comes in. 🔹 What is Prompt Engineering? It is the practice of designing clear and specific prompts to get better results from AI models. 🔹 Simple Example ❌ Weak Prompt: Explain Artificial Intelligence. ✅ Better Prompt: Explain Artificial Intelligence to a beginner using a simple example and 3 short points. The second prompt provides a clearer goal, context, and output format. 🔹 What makes a good prompt? 🎯 Goal — What do you want? 📌 Context — What does the model need to know? 📝 Format — How should the answer look? 👤 Audience — Who is it for? 💡 Key takeaway Prompt Engineering = Designing clear and thoughtful instructions to help AI models produce better results. Clear Prompt → Better Guidance → Better Results 🚀 #ArtificialIntelligence #AI #GenerativeAI #PromptEngineering #LLM #MachineLearning #DeepLearning #NLP #GPT
🤖 Made with AI
66
AI Daily | Day 26 Fine-tuning — الضبط الدقيق بعد أن يتعلم الـLLM الأساسيات من خلال Pre-training، كيف نجعله أفضل في مهمة أو مجال محدد؟ هنا يأتي دور Fine-tuning. 🔹 ما هو Fine-tuning؟ هو تدريب نموذج مُدرّب مسبقًا على بيانات إضافية متخصصة، حتى يصبح أكثر ملاءمة لمهمة أو مجال معين. 🔹 مثال بسيط تخيل نموذجًا عامًا يعرف الكثير عن اللغة: Pre-trained Model 🧠 ⬇️ بيانات طبية متخصصة 🏥 Fine-tuning 🎯 ⬇️ نموذج متخصص في المجال الطبي 🔹 الفرق بينهما؟ 📚 Pre-training يتعلم الأساسيات والأنماط من كميات ضخمة ومتنوعة من البيانات. 🎯 Fine-tuning يأخذ النموذج الجاهز ويخصصه باستخدام بيانات أصغر وأكثر تخصصًا. 🔹 لماذا نستخدمه؟ يساعد النموذج على: 🎯 أداء مهمة محددة بشكل أفضل 🏥 التخصص في مجال معين 💬 اتباع أسلوب أو تعليمات معينة 📊 تحسين أدائه على نوع محدد من البيانات 💡 الخلاصة Pre-training = تعلم الأساسيات Fine-tuning = تخصيص النموذج لمهمة أو مجال محدد وهكذا ننتقل من نموذج عام إلى نموذج أكثر تخصصًا. ⸻ Fine-tuning After learning the basics through Pre-training, how can we make an LLM better at a specific task or domain? This is where Fine-tuning comes in. 🔹 What is Fine-tuning? Fine-tuning is the process of training a pre-trained model on additional, specialized data to make it better suited for a specific task or domain. 🔹 Simple Example A general-purpose model: Pre-trained Model 🧠 ⬇️ Specialized medical data 🏥 Fine-tuning 🎯 ⬇️ A model specialized for medical tasks 🔹 What’s the difference? 📚 Pre-training Learns general patterns and knowledge from massive and diverse datasets. 🎯 Fine-tuning Adapts the existing model using smaller, more specialized datasets. 🔹 Why use it? It can help a model: 🎯 Perform a specific task better 🏥 Specialize in a domain 💬 Follow a particular style or set of instructions 📊 Improve performance on specific types of data 💡 Key takeaway Pre-training = Learning the fundamentals Fine-tuning = Specializing the model This transforms a general-purpose model into one that is more specialized. #ArtificialIntelligence #AI #GenerativeAI #LLM #FineTuning #MachineLearning #DeepLearning #NLP #GPT
72
AI Daily | Day 25 Pre-training — التدريب المسبق عرفنا كيف تتحول الكلمات إلى Tokens ثم إلى Embeddings، لكن السؤال الآن: كيف يتعلم الـLLM كل هذه الأنماط؟ هنا يأتي دور Pre-training. 🔹 ما هو Pre-training؟ هو المرحلة الأولى والأكبر في تدريب النموذج، حيث يتعلم من كميات ضخمة من البيانات مثل النصوص والكتب والمواقع والأكواد. خلال هذه المرحلة، يتعلم النموذج: 📝 أنماط اللغة 🔗 العلاقات بين الكلمات 🧠 السياق والمعنى 💻 أنماط الأكواد والمعلومات 🔹 كيف يتعلم؟ بشكل مبسط، يُعطى النموذج جزءًا من النص ويحاول التنبؤ بالـToken التالي. مثال: Artificial Intelligence is… يحاول النموذج توقع الـToken التالي، ثم تتم مقارنة توقعه بالإجابة الصحيحة وتعديل النموذج. وتتكرر هذه العملية مليارات المرات أثناء التدريب. 🔹 لماذا هي مهمة؟ لأنها تبني المعرفة والقدرات الأساسية للنموذج قبل أن يتم تخصيصه لمهام معينة. Data → Training → Learned Patterns → Pre-trained Model 💡 الخلاصة Pre-training = المرحلة التي يتعلم فيها الـLLM الأنماط والعلاقات الأساسية من كميات ضخمة من البيانات. وبعدها يمكن تطوير النموذج ليصبح أكثر ملاءمة لمهام واستخدامات محددة. ⸻ Pre-training We learned how text becomes Tokens and then Embeddings. But how does an LLM actually learn all these patterns? This is where Pre-training comes in. 🔹 What is Pre-training? It is the first and largest stage of training, where the model learns from massive amounts of data, such as text, books, websites, and code. During this stage, the model learns: 📝 Language patterns 🔗 Relationships between words 🧠 Context and meaning 💻 Code patterns 🔹 How does it learn? Simply put, the model is given part of a sequence and tries to predict the next token. For example: Artificial Intelligence is… The model predicts the next token, compares its prediction with the correct one, and updates its parameters. This process is repeated billions of times during training. 🔹 Why is it important? It builds the model’s basic knowledge and capabilities before it is adapted for specific tasks. Data → Training → Learned Patterns → Pre-trained Model 💡 Key takeaway Pre-training = The stage where an LLM learns fundamental patterns and relationships from massive amounts of data. #ArtificialIntelligence #AI #GenerativeAI #LLM #PreTraining #MachineLearning #DeepLearning #NLP #GPT
🤖 Made with AI
57
AI Daily | Day 24 Embeddings — تمثيل المعنى بعد أن عرفنا أن النص يتحول إلى Tokens، يأتي سؤال مهم: كيف يفهم النموذج العلاقة والمعنى بين هذه الـTokens؟ هنا تأتي Embeddings. 🔹 ما هي Embeddings؟ هي طريقة لتحويل الكلمات أو الـTokens إلى متجهات رقمية (Vectors) تمثل معناها وعلاقاتها. بدل أن يرى النموذج: King 👑 ككلمة فقط، يتم تمثيلها بمجموعة من الأرقام في مساحة رياضية. والكلمات ذات المعاني المتشابهة تكون عادةً أقرب إلى بعضها في هذه المساحة. 🔹 مثال بسيط تخيل مساحة تحتوي على: King 👑 Queen 👸 Man 👨 Woman 👩 يمكن للـEmbeddings أن تمثل العلاقات والتشابهات بينها بطريقة رقمية. وبالمثل: Cat 🐱 ↔ Kitten 🐈 تكون أقرب دلاليًا من: Cat 🐱 ↔ Car 🚗 🔹 لماذا هي مهمة؟ تُستخدم الـEmbeddings في العديد من تطبيقات الذكاء الاصطناعي مثل: 🔍 Semantic Search — البحث بالمعنى 📚 RAG — استرجاع المعلومات المناسبة 🤖 LLMs — تمثيل المعلومات والعلاقات 🎯 Recommendation Systems — إيجاد العناصر المتشابهة 💡 الخلاصة Embedding = تمثيل رقمي للمعنى والعلاقات. كلما كان شيئان متشابهين في المعنى، يمكن أن تكون Embeddings الخاصة بهما أقرب في الفضاء المتجهي. ⸻ Embeddings After learning how text is converted into Tokens, an important question comes up: How can a model represent relationships and meaning between those tokens? This is where Embeddings come in. 🔹 What are Embeddings? Embeddings convert words or tokens into numerical vectors that represent their meaning and relationships. Instead of seeing: King 👑 as just a word, the model represents it as a set of numbers in a mathematical space. Words with similar meanings are generally closer together in this space. 🔹 Simple Example Imagine a space containing: King 👑 Queen 👸 Man 👨 Woman 👩 Embeddings can represent their relationships and similarities numerically. Similarly: Cat 🐱 ↔ Kitten 🐈 would be semantically closer than: Cat 🐱 ↔ Car 🚗 🔹 Why are they important? Embeddings are widely used in: 🔍 Semantic Search 📚 RAG 🤖 LLMs 🎯 Recommendation Systems 💡 Key takeaway Embedding = A numerical representation of meaning and relationships. The more semantically similar two things are, the closer their embeddings can be in vector space. #ArtificialIntelligence #AI #GenerativeAI #LLM #Embeddings #MachineLearning #DeepLearning #NLP #RAG #SemanticSearch
🤖 Made with AI
1
307
AI Daily | Day 23 Tokens & Tokenization بعد ما عرفنا كيف تعمل LLMs، يجي سؤال مهم: كيف يفهم النموذج النص الذي نكتبه له؟ الإجابة تبدأ من Tokens. 🔹 ما هو الـToken؟ الـ Token هو جزء من النص يعالجه النموذج. وقد يكون: كلمة كاملة، جزءًا من كلمة، أو حتى علامة ترقيم. مثال: I love AI! يمكن تقسيمها تقريبًا إلى: I | love | AI | ! لكن طريقة التقسيم تختلف حسب الـTokenizer المستخدم. 🔹 ما هي Tokenization؟ هي عملية تحويل النص إلى Tokens حتى يستطيع النموذج معالجته. Text → Tokenization → Tokens → LLM 🔹 لماذا هي مهمة؟ لأن الـLLM لا يتعامل مع النص كجمل وكلمات بالطريقة التي نراها نحن، بل يعالج Tokens. ولهذا فإن عدد الـTokens يؤثر على: 📏 طول السياق الذي يستطيع النموذج التعامل معه 💰 تكلفة استخدام بعض النماذج ⚡ سرعة معالجة النص 💡 مثال بسيط كلما كان النص أطول، زاد عدد الـTokens التي يحتاج النموذج إلى معالجتها. لذلك عندما نقول إن نموذجًا لديه Context Window كبيرة، فهذا يعني أنه يستطيع التعامل مع عدد أكبر من الـTokens في نفس السياق. 🧠 الخلاصة Token = جزء من النص يعالجه النموذج. Tokenization = عملية تقسيم النص إلى Tokens. ومن خلال هذه العملية يستطيع الـLLM تحويل النص إلى شكل يمكنه معالجته وفهم أنماطه. ⸻ Tokens & Tokenization After learning how LLMs work, an important question comes up: How does an LLM process the text we give it? The answer starts with Tokens. 🔹 What is a Token? A Token is a piece of text processed by the model. It can be: A whole word, part of a word, or even punctuation. For example: I love AI! It could be split roughly into: I | love | AI | ! The exact splitting depends on the Tokenizer being used. 🔹 What is Tokenization? It is the process of converting text into tokens so the model can process it. Text → Tokenization → Tokens → LLM 🔹 Why does it matter? LLMs don’t process text exactly the way humans see words and sentences. They process Tokens. That’s why the number of tokens affects: 📏 Context length 💰 Cost of some models ⚡ Processing speed 💡 Simple Example The longer the input, the more Tokens the model may need to process. So when we say a model has a large Context Window, it means it can handle more tokens within the same context. 🧠 Key takeaway Token = A piece of text processed by the model. Tokenization = The process of splitting text into Tokens. This allows an LLM to convert text into a form it can process and learn patterns from. #ArtificialIntelligence #AI #GenerativeAI #LLM #Tokenization #Tokens #MachineLearning #DeepLearning #NLP #GPT
🤖 Made with AI
1
44
AI Daily | Day 22 Large Language Models — LLMs 🧠 في اليوم السابق تعرفنا على Generative AI، واليوم ندخل إلى أحد أهم مكوناته: Large Language Models (LLMs) هي نماذج ذكاء اصطناعي تتدرب على كميات ضخمة من النصوص لتتعلم الأنماط والعلاقات الموجودة في اللغة. 🔹 ماذا تستطيع أن تفعل؟ 📝 توليد النصوص ❓ الإجابة عن الأسئلة 🌍 الترجمة 📄 التلخيص 💻 كتابة الأكواد 🔹 كيف تعمل؟ بشكل مبسط، يتعلم الـLLM أثناء التدريب التنبؤ بالـToken التالي بناءً على السياق السابق. مثلاً: The sun rises in the… قد يتوقع: east 🌅 ومع التدريب على كميات هائلة من البيانات، يتعلم النموذج أنماطًا وعلاقات لغوية أكثر تعقيدًا. 🔹 لماذا تسمى Large؟ لأنها عادةً تعتمد على: Massive Data + Huge Parameters + Powerful Compute وهذه العناصر تساعدها على تعلم أنماط معقدة من اللغة. 💡 الخلاصة LLM = نموذج لغوي كبير يتعلم من كميات ضخمة من البيانات، ثم يستخدم ما تعلمه لفهم السياق وتوليد النصوص. ⸻ AI Daily | Day 22 Large Language Models — LLMs 🧠 In the previous post, we introduced Generative AI. Today, we explore one of its most important components: Large Language Models (LLMs) LLMs are AI models trained on massive amounts of text to learn patterns and relationships within language. 🔹 What can they do? 📝 Generate text ❓ Answer questions 🌍 Translate 📄 Summarize 💻 Generate code 🔹 How do they work? Simply put, during training, an LLM learns to predict the next token based on the previous context. For example: The sun rises in the… It may predict: east 🌅 With massive amounts of training data, the model learns increasingly complex patterns and relationships in language. 🔹 Why “Large”? LLMs typically rely on: Massive Data + Huge Parameters + Powerful Compute These elements help them learn complex patterns in language. 💡 Key takeaway LLM = A large language model that learns from massive amounts of data and uses what it learns to understand context and generate text. #ArtificialIntelligence #AI #GenerativeAI #LLM #MachineLearning #DeepLearning #NLP #GPT
1
49
AI Daily | Day 21 الذكاء الاصطناعي التوليدي — Generative AI بعد أن تعرفنا في الأيام السابقة على أساسيات AI وMachine Learning وDeep Learning، ووصلنا إلى Transformers… نبدأ اليوم مرحلة جديدة: Generative AI فما هو الذكاء الاصطناعي التوليدي؟ هو نوع من الذكاء الاصطناعي يستطيع إنشاء محتوى جديد بناءً على الأنماط التي تعلمها من البيانات. يمكنه توليد: 📝 نصوص 🖼️ صور 🎵 موسيقى وصوت 🎬 فيديو 💻 أكواد برمجية 🔹 كيف يختلف عن الذكاء الاصطناعي التقليدي؟ تخيل نموذجًا تقليديًا يتلقى صورة ويجيب: “هذه قطة 🐱” بينما نموذجًا توليديًا يمكن أن تعطيه: “أنشئ صورة لقطة ترتدي نظارة وتجلس أمام حاسوب.” فيقوم بتوليد محتوى جديد بدلًا من مجرد تصنيف أو تحليل المحتوى الموجود. 🔹 كيف يستطيع إنشاء شيء جديد؟ النماذج التوليدية تتعلم الأنماط والعلاقات الموجودة في كميات ضخمة من البيانات. وبعد التدريب، تستطيع استخدام ما تعلمته لتوليد محتوى جديد يشبه الأنماط التي تعلمتها، دون أن يكون مجرد نسخة مباشرة من بيانات التدريب. ومن أشهر التقنيات المستخدمة في Generative AI: Transformers → LLMs Diffusion Models → Image Generation 🔹 أمثلة نستخدمها اليوم •ChatGPT → توليد النصوص •مولدات الصور → إنشاء الصور •أدوات البرمجة بالذكاء الاصطناعي → توليد الأكواد •نماذج الصوت → توليد وتحويل الصوت 💡 مثال بسيط Traditional AI: صورة → “كلب” 🐕 Generative AI: “أنشئ صورة لكلب يركض على الشاطئ وقت الغروب.” 🌅🐕 الأول يفهم أو يصنف ما يراه، بينما الثاني يستطيع إنشاء محتوى جديد. الخلاصة •Traditional AI → يركز غالبًا على التحليل والتصنيف والتنبؤ. •Generative AI → يستطيع إنشاء محتوى جديد. •يمكنه توليد نصوص، صور، صوت، فيديو، وأكواد. •تعتمد تقنيات Generative AI الحديثة على معماريات مثل Transformers وDiffusion Models. 🚀 وهنا تبدأ رحلتنا مع Generative AI. ⸻ Generative AI After exploring the fundamentals of AI, Machine Learning, Deep Learning, and eventually reaching Transformers… Today, we begin a new chapter: Generative AI 🚀 So, what is Generative AI? Generative AI is a type of artificial intelligence that can create new content based on patterns it has learned from data. It can generate: 📝 Text 🖼️ Images 🎵 Music and audio 🎬 Video 💻 Code 🔹 How is it different from traditional AI? Imagine a traditional AI model receiving an image and answering: “This is a cat. 🐱” A generative model, however, could receive: “Generate an image of a cat wearing glasses sitting in front of a computer.” Instead of simply analyzing existing content, it can generate new content. 🔹 How can it create something new? Generative models learn patterns and relationships from massive amounts of data. After training, they can use what they have learned to generate new content that follows those learned patterns without simply being a direct copy of the training data. Some important technologies behind Generative AI include: Transformers → LLMs Diffusion Models → Image Generation 🔹 Examples we use today •ChatGPT → Text generation •AI image generators → Image generation •AI coding tools → Code generation •Audio models → Voice and audio generation 💡 Simple Example Traditional AI: Image → “Dog” 🐕 Generative AI: “Generate an image of a dog running on a beach at sunset.” 🌅🐕 The first understands or classifies existing content, while the second can create new content. Key takeaway •Traditional AI → Often focuses on analysis, classification, and prediction. •Generative AI → Can create new content. •It can generate text, images, audio, video, and code. •Modern Generative AI relies on architectures such as Transformers and Diffusion Models. 🚀 And this is where our Generative AI journey begins. #ArtificialIntelligence #AI #GenerativeAI #MachineLearning #DeepLearning #LLM #Transformers #DiffusionModels #AI
1
107
AI Daily | Day 20 Transformers — بنية المحوّلات في المنشور السابق تعرفنا على RNNs، وكيف تستخدم المعلومات السابقة لفهم البيانات المتسلسلة. لكن كانت هناك مشكلة: ماذا لو كانت المعلومة المهمة بعيدة جدًا عن الجزء الذي نعالجه الآن؟ هنا ظهرت Transformers. ⚡ الـ Transformer هي بنية في الشبكات العصبية صُممت لمعالجة البيانات المتسلسلة، وأصبحت أساسًا للعديد من نماذج الذكاء الاصطناعي الحديثة. 🔹 Attention بدل أن يتعامل النموذج مع جميع أجزاء البيانات بنفس الأهمية، تساعده Attention على التركيز على الأجزاء الأكثر ارتباطًا بالمعلومة التي يحاول فهمها. 🔹 Self-Attention تسمح للنموذج بفهم العلاقة بين عناصر التسلسل المختلفة، حتى لو كانت بعيدة عن بعضها. مثال: “The animal didn’t cross the road because it was tired.” لفهم كلمة “it”، يحتاج النموذج إلى معرفة الكلمة التي ترتبط بها داخل الجملة. وهنا تساعد Self-Attention النموذج على فهم هذه العلاقات. 🔹 Parallel Processing في RNN، تتم معالجة البيانات بشكل متتابع: Word 1 → Word 2 → Word 3 → Word 4 أما Transformers فتستطيع معالجة أجزاء كثيرة من التسلسل بشكل متوازٍ، مما يجعل التدريب أكثر كفاءة. 🚀 لماذا Transformers مهمة؟ لأنها أصبحت الأساس للعديد من التقنيات الحديثة مثل: Transformers → LLMs → GPT → Generative AI ومن هنا نبدأ بفهم كيف تطورت نماذج الذكاء الاصطناعي الحديثة. 💡 مثال بسيط تخيل أنك تقرأ جملة طويلة. بدل أن تقرأ كل كلمة وتحاول الاحتفاظ بها في ذاكرتك واحدة تلو الأخرى، يمكنك النظر إلى الجملة كاملة ومعرفة أي الكلمات ترتبط ببعضها. هذه هي الفكرة الأساسية وراء Attention. الخلاصة •RNN → تعالج التسلسل خطوة بخطوة. •Transformers → تستخدم Attention لفهم العلاقات بين عناصر التسلسل. •Self-Attention → تساعد النموذج على فهم السياق والعلاقات البعيدة. •Parallel Processing → تجعل معالجة البيانات أكثر كفاءة. •أصبحت Transformers أساسًا لـ LLMs وGenerative AI. ⸻ Transformers In the previous post, we learned about RNNs and how they use previous information to understand sequential data. But there was a challenge: What if the important information is far away from the part we’re currently processing? This is where Transformers come in. ⚡ A Transformer is a neural network architecture designed to process sequential data, and it has become the foundation of many modern AI models. 🔹 Attention Instead of treating every part of the input as equally important, Attention helps the model focus on the parts that are most relevant to what it is trying to understand. 🔹 Self-Attention Self-Attention allows the model to understand relationships between different elements in a sequence, even when they are far apart. For example: “The animal didn’t cross the road because it was tired.” To understand what “it” refers to, the model needs to identify the relevant relationship within the sentence. This is where Self-Attention becomes powerful. 🔹 Parallel Processing RNNs process sequences step by step: Word 1 → Word 2 → Word 3 → Word 4 Transformers, however, can process many parts of a sequence in parallel, making training much more efficient. 🚀 Why are Transformers important? Because they became the foundation for many modern AI technologies: Transformers → LLMs → GPT → Generative AI They are a key part of understanding how modern AI models evolved. 💡 Simple Example Imagine reading a long sentence. Instead of processing every word one by one and trying to remember everything, you can look at the sentence as a whole and identify which words are related to each other. That’s the basic idea behind Attention. Key takeaway •RNNs → Process sequences step by step. •Transformers → Use Attention to understand relationships between sequence elements. •Self-Attention → Helps the model understand context and long-range relationships. •Parallel Processing → Makes sequence processing more efficient. •Transformers became the foundation of LLMs and Generative AI. #ArtificialIntelligence #AI #MachineLearning #DeepLearning #NeuralNetworks #Transformers #Attention #SelfAttention #GenerativeAI #DataScience
🤖 Made with AI
2
70
AI Daily | Day 19 الشبكات العصبية المتكررة (RNN) هل يمكن لنموذج الذكاء الاصطناعي أن يتذكر ما حدث سابقًا ليستفيد منه في فهم المعلومات الحالية؟ هنا تأتي Recurrent Neural Networks (RNNs). RNN هي نوع من الشبكات العصبية مصممة للتعامل مع البيانات المتسلسلة (Sequential Data)، حيث يكون ترتيب المعلومات مهمًا. مثل: •📝 النصوص والجمل •🎙️ الكلام والصوت •📈 السلاسل الزمنية 🔹 كيف تعمل؟ عند معالجة كل عنصر من التسلسل، تستخدم RNN المعلومات الحالية بالإضافة إلى جزء من المعلومات السابقة، وتخزنها في Hidden State. يمكن تبسيط الفكرة إلى: Previous Information + Current Input → Hidden State → Next Step وهذا يسمح للنموذج باستخدام السياق السابق عند معالجة المعلومات الجديدة. 🔹 مثال: في الجملة: “The cat drank the ___” عند قراءة كلمة “cat” ثم “drank”، تستطيع RNN الاحتفاظ ببعض المعلومات السابقة لمساعدتها على توقع الكلمة التالية. 🔹 لكن RNN لديها مشكلة: عند التعامل مع تسلسلات طويلة جدًا، قد تواجه مشكلة Vanishing Gradient، مما يجعلها تفقد القدرة على الاستفادة من المعلومات القديمة. ولهذا ظهرت معماريات أكثر تطورًا مثل: LSTM → GRU والتي صُممت للمساعدة في الاحتفاظ بالمعلومات المهمة لفترة أطول. الخلاصة: RNN مصممة لفهم البيانات المتسلسلة من خلال استخدام المعلومات السابقة مع المعلومات الحالية، لكنها تواجه صعوبة في تذكر المعلومات البعيدة في التسلسلات الطويلة. 💡 تخيل أنك تقرأ قصة. لفهم الجملة الحالية، تحتاج أحيانًا إلى تذكر ما حدث في الجمل السابقة. هذا هو المفهوم الأساسي وراء RNN. ❓ سؤال اليوم: برأيك، لماذا تحتاج نماذج معالجة النصوص إلى تذكر المعلومات السابقة لفهم الجملة بشكل صحيح؟ ⸻ Recurrent Neural Networks (RNNs) Can an AI model remember what happened earlier to better understand the information it is processing now? This is where Recurrent Neural Networks (RNNs) come in. RNNs are neural networks designed to work with sequential data, where the order of information matters. Examples include: •📝 Text and sentences •🎙️ Speech and audio •📈 Time-series data 🔹 How does it work? When processing each element in a sequence, an RNN uses the current input along with information from previous steps and stores it in a Hidden State. The idea can be simplified as: Previous Information + Current Input → Hidden State → Next Step This allows the model to use previous context when processing new information. 🔹 Example: Consider the sentence: “The cat drank the ___” After reading “cat” and then “drank”, the RNN can retain some previous information to help predict what comes next. 🔹 But RNNs have a problem: When dealing with very long sequences, they can suffer from the Vanishing Gradient problem, making it difficult to retain information from far earlier in the sequence. This led to more advanced architectures such as: LSTM → GRU which were designed to help preserve important information for longer periods. Key takeaway: RNNs are designed to understand sequential data by using previous information along with the current input, but they can struggle to remember distant information in long sequences. 💡 Imagine reading a story. To understand the current sentence, you sometimes need to remember what happened in previous sentences. That is the basic idea behind an RNN. ❓ Question of the day: Why do you think language models need to remember previous information to properly understand a sentence? #ArtificialIntelligence #AI #MachineLearning #DeepLearning #RNN #LSTM #GRU #NeuralNetworks #DataScience
2
54
AI Daily | Day 18 الشبكات العصبية الالتفافية (CNN) كيف يستطيع الذكاء الاصطناعي فهم الصور؟ هنا تأتي Convolutional Neural Networks (CNNs). CNN هي نوع من الشبكات العصبية مصممة خصيصًا للتعامل مع البيانات التي تحتوي على بنية مكانية، مثل الصور. بدلًا من أن تتعامل مع الصورة كرقم ضخم من البكسلات فقط، تتعلم CNN اكتشاف الخصائص والأنماط تدريجيًا. 🔹 1. Filters / Kernels تمرر CNN فلاتر صغيرة على الصورة لاكتشاف خصائص معينة مثل الحواف والخطوط. 🔹 2. Convolution تتحرك الـFilter على أجزاء الصورة وتنتج قيمًا تساعد النموذج على معرفة أين توجد الخصائص المهمة. 🔹 3. Pooling تقلل حجم المعلومات مع الاحتفاظ بالخصائص المهمة، مما يجعل النموذج أكثر كفاءة. 🔹 4. Feature Learning مع زيادة طبقات الشبكة، تنتقل CNN من تعلم خصائص بسيطة: Edges → Shapes → Patterns → Objects وفي النهاية يمكن استخدام هذه الخصائص في مهام مثل Image Classification وObject Detection. الخلاصة: CNN تتعلم تلقائيًا استخراج الخصائص من الصور، بدءًا من التفاصيل البسيطة وصولًا إلى الأنماط والأجسام المعقدة. 💡 تخيل أنك تنظر إلى صورة سيارة: في البداية قد تلاحظ حوافًا وخطوطًا، ثم تتجمع هذه الخطوط لتشكل عجلات وأبوابًا، وفي النهاية تستطيع الشبكة التعرف على أنها سيارة. ❓ سؤال اليوم: برأيك، كيف تستطيع CNN التعرف على جسم كامل من خلال تعلم خصائص بسيطة مثل الحواف؟ ⸻ Convolutional Neural Networks (CNNs) How can AI understand images? This is where Convolutional Neural Networks (CNNs) come in. A CNN is a type of neural network designed specifically for data with spatial structure, such as images. Instead of treating an image as just a huge collection of pixels, a CNN learns to detect features and patterns step by step. 🔹 1. Filters / Kernels CNNs use small filters that move across an image to detect features such as edges and lines. 🔹 2. Convolution The filter scans different parts of the image and produces values that help the model identify where important features are located. 🔹 3. Pooling Pooling reduces the size of the information while keeping important features, making the model more efficient. 🔹 4. Feature Learning As the network gets deeper, the CNN moves from learning simple features to more complex ones: Edges → Shapes → Patterns → Objects These learned features can then be used for tasks such as Image Classification and Object Detection. Key takeaway: CNNs automatically learn to extract features from images, starting with simple details and gradually building up to complex patterns and objects. 💡 Imagine looking at a picture of a car: You may first notice edges and lines, which combine into wheels and doors, and eventually the network can recognize the whole object as a car. ❓ Question of the day: How do you think a CNN can recognize a complete object by learning simple features like edges? #ArtificialIntelligence #AI #MachineLearning #DeepLearning #CNN #ComputerVision #NeuralNetworks #DataScience
2
85
AI Daily | Day 17 التنظيم (Regularization) في المنشور السابق تعلمنا كيف تساعد Optimizers النموذج على تحديث أوزانه بطريقة أكثر كفاءة. لكن ماذا لو بدأ النموذج يحفظ بيانات التدريب بدل أن يتعلم الأنماط العامة؟ هنا تأتي Regularization. هي مجموعة من التقنيات التي تساعد على تقليل Overfitting، وتجعل النموذج أكثر قدرة على التعميم على بيانات جديدة لم يرها من قبل. من أشهر تقنيات Regularization: 🔹 L1 Regularization تضيف عقوبة على الأوزان الكبيرة، وقد تجعل بعض الأوزان تساوي صفرًا، مما يساعد النموذج على التركيز على الخصائص الأكثر أهمية. 🔹 L2 Regularization تعاقب الأوزان الكبيرة وتدفع النموذج إلى استخدام أوزان أصغر وأكثر توازنًا، مما يقلل من تعقيد النموذج. 🔹 Dropout ⭐ يقوم بإيقاف بعض الخلايا العصبية عشوائيًا أثناء التدريب، مما يمنع النموذج من الاعتماد بشكل كبير على خلايا معينة ويشجعه على تعلم تمثيلات أكثر قوة. الخلاصة: •Regularization تساعد على تقليل Overfitting. •L1 وL2 تتحكم في حجم الأوزان. •Dropout يمنع الاعتماد الزائد على خلايا معينة. •الهدف الأساسي هو جعل النموذج يعمّم بشكل أفضل على بيانات جديدة. 💡 تخيل طالبًا يحفظ إجابات الاختبار حرفيًا بدل أن يفهم المادة. إذا تغير السؤال قليلًا، سيفشل. Regularization تشجع النموذج على فهم الأنماط بدل حفظ بيانات التدريب. ❓ سؤال اليوم: برأيك، أيهما أفضل لمنع Overfitting: تقليل تعقيد النموذج أم إضافة Dropout؟ ولماذا؟ ⸻ Regularization In the previous post, we learned how Optimizers help models update their weights more efficiently. But what happens if a model starts memorizing the training data instead of learning general patterns? That’s where Regularization comes in. Regularization is a set of techniques used to reduce Overfitting and help a model generalize better to new, unseen data. Some of the most common techniques are: 🔹 L1 Regularization Penalizes large weights and can drive some weights toward zero, helping the model focus on the most important features. 🔹 L2 Regularization Penalizes large weights and encourages the model to use smaller, more balanced weights, reducing model complexity. 🔹 Dropout ⭐ Randomly disables some neurons during training, preventing the network from relying too heavily on specific neurons and encouraging more robust representations. Key takeaway: •Regularization helps reduce Overfitting. •L1 and L2 control the size of model weights. •Dropout prevents the network from relying too much on specific neurons. •The main goal is to help the model generalize better to unseen data. 💡 Imagine a student who memorizes exam answers instead of understanding the material. If the question changes slightly, they may fail. Regularization encourages the model to learn patterns instead of memorizing the training data. ❓ Question of the day: Which do you think is better for preventing Overfitting: reducing model complexity or adding Dropout? Why? #ArtificialIntelligence #AI #MachineLearning #DeepLearning #NeuralNetworks #Regularization #Overfitting #Dropout #DataScience
🤖 Made with AI
1
85
AI Daily | Day 16 خوارزميات التحسين (Optimizers) في المنشور السابق تعلمنا أن Epochs تحدد عدد المرات التي يمر فيها النموذج على بيانات التدريب. لكن أثناء التدريب، يبقى سؤال مهم: كيف يمكننا جعل تحديث الأوزان أكثر كفاءة؟ هنا يأتي دور Optimizers. الـ Optimizer هو خوارزمية تساعد النموذج على تحديث أوزانه بطريقة أكثر كفاءة أثناء التدريب، بهدف الوصول إلى أقل قيمة ممكنة للـ Loss. ومن أشهرها: 🔹 SGD (Stochastic Gradient Descent) يحدّث الأوزان باستخدام الـ Gradients، وهو بسيط لكنه قد يكون بطيئًا أو متذبذبًا. 🔹 Momentum يستخدم اتجاه التحديثات السابقة للمساعدة على التحرك بشكل أسرع وتقليل التذبذب. 🔹 RMSprop يكيّف حجم الخطوة لكل وزن بناءً على الـ Gradients السابقة. 🔹 Adam ⭐ يجمع بين أفكار Momentum و RMSprop، وغالبًا يكون خيارًا جيدًا كبداية في كثير من النماذج. الخلاصة: •Gradient Descent يساعدنا على معرفة اتجاه تقليل الـ Loss. •Optimizer يحدد طريقة أكثر كفاءة لتحديث الأوزان. •اختيار الـ Optimizer المناسب قد يجعل التدريب أسرع وأكثر استقرارًا. 💡 تخيل أنك تريد الوصول إلى قمة جبل بأسرع طريقة. Gradient Descent يخبرك أي اتجاه تنزل فيه، بينما الـ Optimizer يساعدك على تحديد كيف تتحرك وبأي سرعة بناءً على خطواتك السابقة. ❓ سؤال اليوم: إذا كان لديك نموذج جديد وتريد البدء بالتدريب، أي Optimizer ستختار: SGD أم Adam؟ ولماذا؟ ⸻ Optimizers In the previous post, we learned that Epochs determine how many times a model goes through the training data. But during training, an important question remains: How can we make weight updates more efficient? This is where Optimizers come in. An Optimizer is an algorithm that helps the model update its weights more efficiently during training, with the goal of minimizing the Loss. Some of the most common optimizers are: 🔹 SGD (Stochastic Gradient Descent) Updates weights using gradients. It is simple but can sometimes be slow or unstable. 🔹 Momentum Uses previous update directions to move faster and reduce oscillations. 🔹 RMSprop Adapts the step size for each weight based on previous gradients. 🔹 Adam ⭐ Combines ideas from Momentum and RMSprop, and is often a strong starting choice for many models. Key takeaway: •Gradient Descent helps determine the direction that reduces the Loss. •Optimizer determines a more efficient way to update the weights. •Choosing the right optimizer can make training faster and more stable. 💡 Imagine you’re trying to reach the bottom of a mountain efficiently. Gradient Descent tells you which direction to move, while the Optimizer helps determine how you should move and how much to adjust each step based on previous steps. ❓ Question of the day: If you were training a new model, which optimizer would you choose: SGD or Adam? Why? #ArtificialIntelligence #AI #MachineLearning #DeepLearning #NeuralNetworks #Optimizers #Adam #ModelTraining
🤖 Made with AI
88
AI Daily | Day 15 Epochs— عدد مرات مرور النموذج على بيانات التدريب في المنشور السابق تعلمنا أن Batch Size يحدد عدد العينات التي يعالجها النموذج قبل تحديث الأوزان. لكن يبقى سؤال مهم: كم مرة يجب أن يرى النموذج بيانات التدريب كاملة؟ هنا يأتي دور Epoch. الـ Epoch هو مرور النموذج مرة واحدة على كامل مجموعة بيانات التدريب. مثال بسيط: إذا كان لديك 1,000 عينة وBatch Size = 100: •كل Epoch = 10 Batches •Epoch واحد → النموذج يرى الـ1,000 عينة مرة واحدة. •5 Epochs → النموذج يرى البيانات كاملة 5 مرات. لكن زيادة عدد الـ Epochs ليست دائمًا أفضل. •Epochs قليلة جدًا ➜ النموذج لا يتعلم الأنماط بشكل كافٍ → Underfitting ❌ •عدد مناسب ➜ يتعلم الأنماط بشكل جيد → Good Fit ✅ •Epochs كثيرة جدًا ➜ قد يحفظ بيانات التدريب بدل تعلم الأنماط العامة → Overfitting ❌ لذلك أثناء التدريب نراقب أداء النموذج على Validation Data لمعرفة متى نتوقف عن التدريب. الخلاصة: •Batch Size = كم عينة يعالج النموذج قبل تحديث الأوزان. •Epoch = كم مرة يمر النموذج على كامل بيانات التدريب. •زيادة Epochs تساعد على التعلم، لكن زيادتها أكثر من اللازم قد تؤدي إلى Overfitting. 💡 تخيل أنك تدرس كتابًا كاملًا: قراءة الكتاب مرة واحدة = 1 Epoch، وقراءته 5 مرات = 5 Epochs. لكن قراءة الكتاب عشرات المرات لا تعني بالضرورة أنك ستصبح أفضل؛ قد تبدأ بحفظ التفاصيل بدل فهم الفكرة. ❓ سؤال اليوم: هل تعتقد أن زيادة عدد الـ Epochs تجعل النموذج دائمًا أفضل؟ ولماذا؟ ⸻ Epochs — How Many Times Does a Model See the Data? In the previous post, we learned that Batch Size determines how many samples the model processes before updating its weights. But here’s an important question: How many times should the model go through the entire training dataset? That’s where an Epoch comes in. An Epoch is one complete pass through the entire training dataset. For example: If you have 1,000 samples and a Batch Size of 100: •1 Epoch = 10 Batches •1 Epoch → the model sees all 1,000 samples once. •5 Epochs → the model sees the entire dataset 5 times. But more Epochs don’t always mean better performance. •Too few Epochs ➜ the model may not learn enough → Underfitting ❌ •A suitable number ➜ the model learns useful patterns → Good Fit ✅ •Too many Epochs ➜ the model may memorize the training data → Overfitting ❌ That’s why we monitor the model’s performance on validation data to determine when training should stop. Key takeaway: •Batch Size = How many samples are processed before a weight update. •Epoch = How many times the model goes through the entire training dataset. •More Epochs can improve learning, but too many may lead to Overfitting. 💡 Imagine studying an entire book: Reading it once = 1 Epoch, and reading it 5 times = 5 Epochs. But reading it dozens of times doesn’t necessarily make you better; you might start memorizing details instead of understanding the concepts. ❓ Question of the day: Do you think increasing the number of Epochs always makes a model better? Why? #ArtificialIntelligence #AI #MachineLearning #DeepLearning #NeuralNetworks #Epochs #ModelTraining #DataScience
🤖 Made with AI
72
AI Daily | Day 14 حجم الدفعة (Batch Size) في المنشور السابق تعلمنا أن Learning Rate يحدد حجم الخطوة عند تحديث الأوزان. لكن يبقى سؤال مهم: كم عدد البيانات التي يستخدمها النموذج قبل أن يقوم بتحديث الأوزان؟ هنا يأتي دور Batch Size. Batch Size هو عدد عينات البيانات التي يعالجها النموذج قبل إجراء تحديث واحد للأوزان. على سبيل المثال: إذا كان لديك 1000 صورة و Batch Size يساوي 100، فإن النموذج سيقسم البيانات إلى 10 دفعات، ويحدث الأوزان بعد كل دفعة. اختيار Batch Size يؤثر على سرعة التدريب واستهلاك الذاكرة واستقرار عملية التعلم. بشكل عام: •Batch Size صغير ➜ تحديثات أكثر، واستهلاك أقل للذاكرة، لكن التدريب قد يكون أكثر تذبذبًا. •Batch Size كبير ➜ تحديثات أقل، وتدريب أكثر استقرارًا، لكنه يحتاج ذاكرة أكبر. الخلاصة: •Batch Size هو عدد العينات المستخدمة قبل كل تحديث للأوزان. •يؤثر على سرعة التدريب واستهلاك الذاكرة. •لا توجد قيمة مثالية تناسب جميع النماذج. 💡 تخيل أنك تصحح أوراق اختبار. يمكنك تصحيح ورقة واحدة ثم تسجيل النتائج، أو تصحيح 50 ورقة ثم تسجيلها دفعة واحدة. هذا يشبه فكرة Batch Size. ❓ سؤال اليوم: لو كان جهازك يمتلك ذاكرة محدودة، هل ستختار Batch Size كبيرًا أم صغيرًا؟ ولماذا؟ ⸻ Batch Size In the previous post, we learned that the Learning Rate controls how large each weight update is. But here’s another important question: How many training examples should the model process before updating its weights? This is where Batch Size comes in. Batch Size is the number of training samples the model processes before performing one weight update. For example: If you have 1,000 images and a Batch Size of 100, the model splits the dataset into 10 batches and updates the weights after each batch. Choosing the right Batch Size affects training speed, memory usage, and learning stability. In general: •Small Batch Size ➜ more frequent updates, lower memory usage, but noisier training. •Large Batch Size ➜ fewer updates and smoother training, but requires more memory. Key takeaway: •Batch Size determines how many samples are processed before each weight update. •It impacts training speed, memory usage, and stability. •There is no single best Batch Size for every model. 💡 Imagine grading exam papers. You can record the score after every single paper or wait until you’ve graded a stack of papers before recording the results. That’s similar to how Batch Size works. ❓ Question of the day: If your computer had limited memory, would you choose a large or a small Batch Size? Why? #ArtificialIntelligence #AI #MachineLearning #DeepLearning #BatchSize #ModelTraining #DataScience
🤖 Made with AI
82