أنظمة تعلُّم الآلة للإنتاج: اختبار النشر
تنظيم صفحاتك في مجموعات يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
أنت الآن جاهز لنشر نموذج أحادي القرن الذي يتوقّع ظهور أحادي القرن. عند نشر مسار تعلُّم الآلة، من المفترض أن يتم تشغيله وتعديله و تقديمه بدون أي مشكلة. لو كان نشر النموذج سهلًا مثل الضغط على زر نشر كبير. يتطلّب نظام تعلُّم الآلة الكامل إجراء اختبارات بشأن ما يلي:
- التحقّق من صحة بيانات الإدخال
- التحقّق من هندسة الخصائص
- التحقّق من جودة إصدارات النماذج الجديدة
- التحقّق من صحة البنية الأساسية لعرض الإعلانات
- اختبار الدمج بين مكوّنات مسار الإحالة الناجحة
يفضّل العديد من مهندسي البرمجيات استخدام أسلوب التطوير بالاستناد إلى الاختبارات (TDD). في أسلوب TDD، يكتب مهندسو البرامج الاختبارات قبل كتابة الرمز المصدر "الحقيقي". ومع ذلك، يمكن أن يكون اختبار التطوير المتقدّم أمرًا صعبًا في تعلُّم الآلة. على سبيل المثال، قبل تدريب النموذج، لا يمكنك كتابة اختبار للتحقّق من الخسارة. بدلاً من ذلك، عليك أولاً اكتشاف الخسارة التي يمكن تحقيقها أثناء تطوير النموذج، وثم اختبار إصدارات النموذج الجديدة مقارنةً بالخسارة التي يمكن تحقيقها.
لمحة عن نموذج Unicorn
يشير هذا القسم إلى نموذج شركة يونيكورن. في ما يلي ما تحتاج إلى معرفته:
أنت تستخدِم تعلُّم الآلة لبناء نموذج تصنيف يتنبّأ بظهور وحيد القرن. توضّح مجموعة البيانات 10,000 مرّة ظهور لحيوانات أحادية القرن و 10,000 مرّة عدم ظهور. تحتوي مجموعة البيانات على الموقع الجغرافي، والوقت من اليوم، والارتفاع، ودرجة الحرارة، والرطوبة، والغطاء النباتي، ومدى ظهور قوس قزح، والعديد من الميزات الأخرى.
اختبار تعديلات النموذج باستخدام تدريب قابل للتكرار
قد تريد مواصلة تحسين نموذج حيوان أحادي القرن. على سبيل المثال، لنفترض أنّك أجريت بعض عمليات هندسة الميزات الإضافية على ميزة معيّنة ثم أعددت تدريب النموذج على أمل الحصول على نتائج أفضل (أو على الأقلّ النتائج نفسها). يصعب أحيانًا إعادة تدريب النموذج. لتحسين إمكانية إعادة الإجراء، اتّبِع الاقتراحات التالية:
إنشاء بذرة محددة لأداة إنشاء الأرقام العشوائية لمعرفة التفاصيل، يُرجى الاطّلاع على التعشّب في عملية إنشاء البيانات.
يمكنك إعداد مكوّنات النموذج بترتيب ثابت لضمان حصول المكوّنات على العدد العشوائي نفسه من أداة إنشاء الأرقام العشوائية في كل مرة. تعالج مكتبات الذكاء الاصطناعي هذا الشرط تلقائيًا في العادة.
احتساب متوسط عدة عمليات تنفيذ للنموذج
استخدِم ميزة التحكّم في الإصدارات، حتى في عمليات التكرار الأولية، حتى تتمكّن من تحديد الرمز البرمجي والمَعلمات عند التحقيق في النموذج أو مسار الإحالة الناجحة.
حتى بعد اتّباع هذه الإرشادات، قد تظل هناك مصادر أخرى لعدم تحديد المسار.
اختبار طلبات البيانات من واجهة برمجة تطبيقات تعلُّم الآلة
كيف تختبر التعديلات على طلبات البيانات من واجهة برمجة التطبيقات؟ يمكنك إعادة تدريب النموذج، ولكن يتطلب ذلك الكثير من الوقت. بدلاً من ذلك، يمكنك كتابة اختبار وحدة لإنشاء بيانات إدخال عشوائية وتنفيذ خطوة واحدة من التدرج التنازلي. إذا اكتملت هذه الخطوة بدون أخطاء، هذا يعني أنّ أي تعديلات على واجهة برمجة التطبيقات لم تؤثر في نموذجك.
كتابة اختبارات الدمج لمكوّنات مسار الإحالة الناجحة
في مسار تعلُّم الآلة، يمكن أن تؤدي التغييرات في أحد المكوّنات إلى حدوث أخطاء في المكوّنات الأخرى. تأكَّد من أنّ المكوّنات تعمل معًا من خلال كتابة اختبار دمج يشغّل مسار الإحالة الناجحة بالكامل من البداية إلى النهاية.
بالإضافة إلى إجراء اختبارات الدمج باستمرار، يجب إجراء اختبارات الدمج عند طرح نماذج جديدة وإصدارات جديدة من البرامج. إنّ بطء تشغيل المسار بأكمله يجعل اختبار الدمج المستمر أكثر صعوبة. لإجراء اختبارات الدمج بشكل أسرع، يمكنك التدريب على مجموعة فرعية من البيانات أو باستخدام نموذج أبسط. تعتمد التفاصيل على النموذج والبيانات. للحصول على تغطية مستمرة، عليك تعديل الاختبارات الأسرع لكي يتم تشغيلها مع كل إصدار جديد من النموذج أو البرنامج. وفي الوقت نفسه، سيتم تنفيذ الاختبارات البطيئة باستمرار في الخلفية.
التحقّق من جودة النموذج قبل عرضه
قبل طرح إصدار جديد من النموذج في قناة الإصدار العلني، عليك اختباره بحثًا عن نوعَي تدهور الجودة التاليَين:
الانخفاض المفاجئ في الأداء: يمكن أن يؤدي خطأ في الإصدار الجديد إلى خفض الجودة بشكلٍ ملحوظ. التحقّق من صحة الإصدارات الجديدة من خلال التحقّق من جودتها مقارنةً بالإصدار السابق
الانخفاض البطيء في الأداء: قد لا يرصد اختبار الانخفاض المفاجئ في الأداء تدهورًا بطيئًا في جودة النموذج على مدار عدة إصدارات. بدلاً من ذلك، تأكَّد من أنّ توقّعات النموذج على مجموعة بيانات التحقّق تستوفي حدًا أدنى ثابتًا. إذا كانت مجموعة بيانات التحقّق تختلف عن البيانات المنشورة، عليك تعديل مجموعة بيانات التحقّق والتأكّد من أنّ النموذج لا يزال يستوفي الحدّ الأدنى نفسه للجودة.
التحقّق من توافق البنية الأساسية للنموذج قبل عرضه
إذا تم تعديل النموذج بشكل أسرع من الخادم، قد يكون للنموذج اعتمادات برامج مختلفة عن الخادم، ما قد يؤدي إلى عدم التوافق. تأكَّد من توفّر العمليات التي يستخدمها النموذج في الخادم من خلال إعداد النموذج في إصدار مُخصّص للاختبار في بيئة مغلقة من الخادم.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eDeploying a machine learning model involves validating data, features, model versions, serving infrastructure, and pipeline integration.\u003c/p\u003e\n"],["\u003cp\u003eReproducible model training involves deterministic seeding, fixed initialization order, averaging multiple runs, and using version control.\u003c/p\u003e\n"],["\u003cp\u003eIntegration tests ensure that different components of the ML pipeline work together seamlessly, and should be run continuously and for new model/software versions.\u003c/p\u003e\n"],["\u003cp\u003eBefore serving a new model, validate its quality by checking for sudden and slow degradations against previous versions and fixed thresholds.\u003c/p\u003e\n"],["\u003cp\u003eEnsure model-infrastructure compatibility by staging the model in a sandboxed server environment to avoid dependency conflicts.\u003c/p\u003e\n"]]],[],null,["You're ready to deploy the unicorn model that predicts unicorn appearances!\nWhen deploying, your machine learning (ML) pipeline should run, update, and\nserve without a problem. If only deploying a model were as easy as pressing\na big **Deploy** button. Unfortunately, a full machine learning system\nrequires tests for:\n\n- Validating input data.\n- Validating feature engineering.\n- Validating the quality of new model versions.\n- Validating serving infrastructure.\n- Testing integration between pipeline components.\n\nMany software engineers favor test-driven development (TDD). In TDD, software\nengineers write tests *prior* to writing the \"real\" source code.\nHowever, TDD can be tricky in machine learning.\nFor example, before training your model, you can't write a test to validate\nthe loss. Instead, you must first discover the achievable loss during model\ndevelopment and *then* test new model versions against the achievable loss.\n\nAbout the unicorn model\n\nThis section refers to the **unicorn model**. Here's what you need to know:\n\u003e You are using machine learning to build a classification model that predicts\n\u003e unicorn appearances. Your dataset details 10,000 unicorn appearances and\n\u003e 10,000 unicorn non-appearances. The dataset contains the location,\n\u003e time of day, elevation, temperature, humidity, tree cover, presence of a\n\u003e rainbow, and several other features.\n\nTest model updates with reproducible training\n\nPerhaps you want to continue improving your unicorn model. For example, suppose\nyou do some additional feature engineering on a certain feature and then\nretrain the model, hoping to get better (or at least the same) results.\nUnfortunately, it is sometimes difficult to reproduce model training.\nTo improve reproducibility, follow these recommendations:\n\n- Deterministically seed the random number generator.\n For details, see [randomization in data\n generation](/machine-learning/crash-course/production-ml-systems/monitoring#randomization)\n\n- Initialize model components in a fixed order to ensure the components get the\n same random number from the random number generator on every run.\n ML libraries typically handle this requirement automatically.\n\n- Take the average of several runs of the model.\n\n- Use version control, even for preliminary iterations, so that you can\n pinpoint code and parameters when investigating your model or pipeline.\n\nEven after following these guidelines, other sources of nondeterminism might\nstill exist.\n\nTest calls to machine learning API\n\nHow do you test updates to API calls? You could retrain your model, but\nthat's time intensive. Instead, write a unit test to generate random input data\nand run a single step of gradient descent. If this step completes without\nerrors, then any updates to the API probably haven't ruined your model.\n\nWrite integration tests for pipeline components\n\nIn an ML pipeline, changes in one component can cause errors in other\ncomponents. Check that components work together by writing an\n**integration test** that runs the entire pipeline end-to-end.\n\nBesides running integration tests continuously, you should run integration tests\nwhen pushing new models and new software versions. The slowness of running the\nentire pipeline makes continuous integration testing harder. To run integration\ntests faster, train on a subset of the data or with a simpler model. The details\ndepend on your model and data. To get continuous coverage, you'd adjust your\nfaster tests so that they run with every new version of model or software.\nMeanwhile, your slow tests would run continuously in the background.\n\nValidate model quality before serving\n\nBefore pushing a new model version to production, test for\nthe following two types of quality degradations:\n\n- **Sudden degradation.** A bug in the new version could cause significantly\n lower quality. Validate new versions by checking their quality\n against the previous version.\n\n- **Slow degradation.** Your test for sudden degradation might not detect a slow\n degradation in model quality over multiple versions. Instead, ensure your\n model's predictions on a validation dataset meet a fixed threshold. If your\n validation dataset deviates from live data, then update your validation\n dataset and ensure your model still meets the same quality threshold.\n\nValidate model-infrastructure compatibility before serving\n\nIf your model is updated faster than your server, then your model could have\ndifferent software dependencies from your server, potentially causing\nincompatibilities. Ensure that the operations used by the model are present in\nthe server by staging the model in a sandboxed version of the server.\n| **Key terms:**\n|\n| - [Training-serving skew](/machine-learning/glossary#training-serving-skew)\n- [Z-score normalization](/machine-learning/glossary#z-score-normalization) \n[Help Center](https://support.google.com/machinelearningeducation)"]]