Model Soups
اكتشف كيف تحسن حساء النماذج (Model Soups) الدقة والمتانة عن طريق حساب متوسط أوزان نماذج Ultralytics YOLO. تعلم تعزيز الأداء دون زيادة زمن الوصول.
تشير Model Soups إلى تقنية في تعلم الآلة حيث يتم حساب المتوسط الحسابي لأوزان شبكات عصبية متعددة، تم ضبطها بدقة من نفس النموذج الأساسي المدرب مسبقًا باستخدام معاملات فائقة مختلفة، لإنشاء نموذج واحد أكثر قوة. يسمح هذا النهج للمطورين بتحسين الدقة العامة والتعميم دون زيادة التكلفة الحسابية أثناء الاستدلال.
When fine-tuning a model, practitioners typically run a wide hyperparameter tuning sweep to find the best-performing configuration. Traditionally, the single best model is selected, and the rest are discarded. However, creating a model soup capitalizes on the diverse features learned by all the models in the sweep. By directly averaging their model weights, the resulting network often outperforms the single best model, effectively combining their strengths while minimizing overfitting. This process is highly efficient and can be easily managed within collaborative environments like the Ultralytics Platform.
Link to this sectionتطبيقات العالم الحقيقي#
تعتبر Model Soups فعالة للغاية في السيناريوهات التي تكون فيها الموارد الحسابية محدودة، ولكن يلزم توفر دقة ومتانة عاليتين.
- Autonomous Vehicle Vision: When deploying object detection systems in self-driving cars, models must generalize across diverse lighting and weather conditions. By averaging multiple models trained with varied data augmentations and learning rates, engineers create a highly robust soup that maintains a low inference latency. This ensures real-time processing speeds crucial for autonomous navigation remain unaffected.
- التشخيص الطبي عبر الهاتف المحمول: في تطبيقات الذكاء الاصطناعي على الحافة (edge AI)، مثل تشغيل image classification على الهواتف الذكية للفحص الجلدي الأولي، تكون الطاقة الحسابية محدودة للغاية. يوفر الـ model soup الدقة المعززة المطلوبة للموثوقية السريرية مع ضمان ملاءمة البصمة النهائية بسهولة على mobile edge devices دون استنزاف البطارية أو الحاجة إلى اتصال سحابي.
Link to this sectionالتمييز بين المفاهيم ذات الصلة#
للتنقل في مشهد deep learning optimization، من المهم تمييز Model Soups عن التقنيات المماثلة:
- Model Ensemble: يجمع التجميع (Ensembling) بين توقعات (مخرجات) نماذج مستقلة متعددة. في حين أن هذا يحسن الدقة، فإنه يتطلب تشغيل كل نموذج أثناء الاستدلال، مما يضاعف التكلفة الحسابية. تقوم Model Soups بحساب متوسط الأوزان قبل الاستدلال، مما يحافظ على التكلفة الحسابية مطابقة لنموذج واحد.
- Model Merging: هذا مصطلح أوسع لدمج النماذج التي ربما تم تدريبها على مهام أو مجموعات بيانات مختلفة تمامًا. تعتبر Model Soups مجموعة فرعية محددة من الدمج حيث تنشأ جميع النماذج من نفس pre-trained base architecture بالضبط ويتم ضبطها بدقة على نفس المهمة المستهدفة.
Link to this sectionمثال على التنفيذ#
يتضمن إنشاء model soup موحد الوصول إلى PyTorch state dictionary لنماذج مدربة متعددة وحساب متوسط مصفوفاتها رياضيًا. أدناه مثال موجز لكيفية تحقيق ذلك باستخدام سير عمل Ultralytics YOLO26 المدعوم أصليًا بواسطة PyTorch framework.
import torch
# Load the PyTorch state dictionaries from two fine-tuned YOLO26 models
model1 = torch.load("yolo26_run1.pt")["model"].state_dict()
model2 = torch.load("yolo26_run2.pt")["model"].state_dict()
# Create a uniform model soup by averaging the model weights
soup_dict = {key: (model1[key] + model2[key]) / 2.0 for key in model1.keys()}
# The resulting soup_dict can now be loaded into a new YOLO26 instanceBy leveraging this technique, computer vision practitioners can easily boost performance metrics like zero-shot learning capabilities and general robustness without sacrificing the deployment speed required for modern, edge-first AI architectures.






