ייצור מערכות למידת מכונה: סטטיות לעומת הסקה דינמית
קל לארגן דפים בעזרת אוספים אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
הסקה היא תהליך יצירת תחזיות על ידי החלת מודל מאומן על דוגמאות לא מתויגות. באופן כללי, מודל יכול להסיק תחזיות באחת משתי דרכים:
הסקה סטטית (שנקראת גם הסקה אופליין או הסקה באצווה) היא תהליך שבו המודל מבצע תחזיות על קבוצה של דוגמאות נפוצות ללא תוויות, ולאחר מכן מאחסן את התחזיות האלה במטמון במקום כלשהו.
הסקה דינמית (נקראת גם הסקה אונליין או הסקה בזמן אמת) פירושה שהמודל יוצר תחזיות רק על פי דרישה, למשל כשלקוח מבקש תחזית.
דוגמה קיצונית: נניח שיש מודל מורכב מאוד שנדרשת שעה כדי להסיק ממנו תחזית. זהו כנראה מצב מצוין להסקה סטטית:
איור 4. בהסקה סטטית, מודל יוצר חיזויים, שמאוחסנים במטמון בשרת.
נניח שבאותו מודל מורכב נעשה שימוש בטעות בהסקה דינמית במקום בהסקה סטטית. אם הרבה לקוחות מבקשים תחזיות בערך באותו זמן, רובם לא יקבלו את התחזית הזו במשך שעות או ימים.
עכשיו נבחן מודל שמסיק במהירות, אולי תוך 2 אלפיות שנייה, באמצעות מינימום יחסי של משאבי מחשוב. במצב כזה, לקוחות יכולים לקבל תחזיות במהירות וביעילות באמצעות הסקת מסקנות דינמית, כפי שמתואר באיור 5.
איור 5. בהסקה דינמית, מודל מסיק חיזויים על פי דרישה.
הסקת מסקנות סטטית
להסקה סטטית יש יתרונות וחסרונות מסוימים.
יתרונות
אין צורך לדאוג יותר מדי לגבי עלות ההסקה.
אפשר לבצע אימות של התחזיות לפני השליחה.
חסרונות
אפשר להציג רק תחזיות שנשמרו במטמון, לכן יכול להיות שהמערכת לא תוכל להציג תחזיות לדוגמאות קלט נדירות.
זמן האחזור של העדכון צפוי להיות בשעות או בימים.
מסקנה דינמית
להסקה דינמית יש יתרונות וחסרונות מסוימים.
יתרונות
אפשר להסיק תחזית לגבי כל פריט חדש שמגיע, וזה מצוין לתחזיות של 'זנב ארוך' (פחות נפוצות).
חסרונות
משימות שמתבצעות בעיקר במחשוב וחשוב להן זמן אחזור קצר. השילוב הזה עשוי להגביל את המורכבות של המודל. כלומר, יכול להיות שתצטרכו ליצור מודל פשוט יותר שיכול להסיק תחזיות מהר יותר מאשר מודל מורכב.
יש צורך במעקב אינטנסיבי יותר.
תרגילים: בדיקת ההבנה
אילו שלוש מההצהרות הבאות נכונות לגבי היסק סטטי?
המודל צריך ליצור תחזיות לכל הקלטות האפשריות.
כן, המודל צריך לבצע חיזויים לכל הקלטות האפשריות ולשמור אותם במטמון או בטבלת חיפוש. אם קבוצת הדברים שהמודל מנבא מוגבלת, ייתכן שהסקת מסקנות סטטית היא בחירה טובה. עם זאת, כשמדובר בקלט בפורמט חופשי, כמו שאילתות של משתמשים עם זנב ארוך של פריטים חריגים או נדירים, היסק סטטי לא יכול לספק כיסוי מלא.
המערכת יכולה לאמת תחזיות משוערות לפני שהיא מציגה אותן.
כן, זהו היבט שימושי של הסקת נתונים סטטית.
למודל יש אפשרות לספק חיזוי מהר יותר ממסקנה דינמית, בהתאם לקלט נתון.
כן, כמעט תמיד אפשר להציג חיזויים מהר יותר באמצעות הסקת נתונים סטטית מאשר באמצעות הסקת נתונים דינמית.
תוכלו להגיב במהירות לשינויים בעולם.
לא, זהו חיסרון של הסקת מסקנות סטטית.
אילו מההצהרות הבאות נכונות לגבי היסק דינמי?
אפשר לספק חיזויים לכל הפריטים האפשריים.
כן, זוהי אחת מהיתרונות של הסקת מסקנות דינמית. כל בקשה שתתקבל תקבל ניקוד. באמצעות היסק דינמי אפשר לטפל בהתפלגויות של זנב ארוך (כאלה עם הרבה פריטים נדירים), כמו המרחב של כל המשפטים האפשריים שנכתבו בביקורות על סרטים.
אפשר לבצע אימות של התחזיות אחרי שהן נוצרות, לפני שמשתמשים בהן.
באופן כללי, אי אפשר לבצע אימות של כל התחזיות לאחר שהן נוצרות, לפני שמשתמשים בהן, כי התחזיות נוצרות על פי דרישה. עם זאת, אפשר לעקוב אחרי איכות התחזיות המצטברות כדי לספק רמה מסוימת של בדיקת איכות, אבל התחזיות האלה יפעילו אזעקות אש רק אחרי שהאש כבר תתפשט.
כשמבצעים הסקה דינמית, לא צריך לדאוג לגבי זמן האחזור של התחזיות (זמן ההשהיה עד להחזרת התחזיות) כמו כשמבצעים הסקה סטטית.
זמן האחזור של החיזוי הוא לרוב בעיה אמיתית בהסקה דינמית. לצערנו, לא בטוח שאפשר לפתור בעיות של זמן אחזור של חיזוי על ידי הוספת עוד שרתי היסק.
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-27 (שעון UTC)."],[[["\u003cp\u003eInference involves using a trained model to make predictions on unlabeled examples, and it can be done statically or dynamically.\u003c/p\u003e\n"],["\u003cp\u003eStatic inference generates predictions in advance and caches them, making it suitable for scenarios where prediction speed is critical but limiting its ability to handle uncommon inputs.\u003c/p\u003e\n"],["\u003cp\u003eDynamic inference generates predictions on demand, offering flexibility for diverse inputs but potentially increasing latency and computational demands.\u003c/p\u003e\n"],["\u003cp\u003eChoosing between static and dynamic inference depends on factors like model complexity, desired prediction speed, and the nature of the input data.\u003c/p\u003e\n"],["\u003cp\u003eStatic inference is advantageous when cost and prediction verification are prioritized, while dynamic inference excels in handling diverse, real-time predictions.\u003c/p\u003e\n"]]],[],null,["# Production ML systems: Static versus dynamic inference\n\n[**Inference**](/machine-learning/glossary#inference) is the process of\nmaking predictions by applying a trained model to\n[**unlabeled examples**](/machine-learning/glossary#unlabeled_example).\nBroadly speaking, a model can infer predictions in one of two ways:\n\n- **Static inference** (also called **offline inference** or **batch inference** ) means the model makes predictions on a bunch of common [**unlabeled examples**](/machine-learning/glossary#unlabeled_example) and then caches those predictions somewhere.\n- **Dynamic inference** (also called **online inference** or real-time inference) means that the model only makes predictions on demand, for example, when a client requests a prediction.\n\nTo use an extreme example, imagine a very complex model that\ntakes one hour to infer a prediction.\nThis would probably be an excellent situation for static inference:\n**Figure 4.** In static inference, a model generates predictions, which are then cached on a server.\n\nSuppose this same complex model mistakenly uses dynamic inference instead of\nstatic inference. If many clients request predictions around the same time,\nmost of them won't receive that prediction for hours or days.\n\nNow consider a model that infers quickly, perhaps in 2 milliseconds using a\nrelative minimum of computational resources. In this situation, clients can\nreceive predictions quickly and efficiently through dynamic inference, as\nsuggested in Figure 5.\n**Figure 5.** In dynamic inference, a model infers predictions on demand.\n\nStatic inference\n----------------\n\nStatic inference offers certain advantages and disadvantages.\n\nAdvantages\n\n- Don't need to worry much about cost of inference.\n- Can do post-verification of predictions before pushing.\n\nDisadvantages\n\n- Can only serve cached predictions, so the system might not be able to serve predictions for uncommon input examples.\n- Update latency is likely measured in hours or days.\n\nDynamic inference\n-----------------\n\nDynamic inference offers certain advantages and disadvantages.\n\nAdvantages\n\n- Can infer a prediction on *any* new item as it comes in, which is great for long tail (less common) predictions.\n\nDisadvantages\n\n- Compute intensive and latency sensitive. This combination may limit model complexity; that is, you might have to build a simpler model that can infer predictions more quickly than a complex model could.\n- Monitoring needs are more intensive.\n\nExercises: Check your understanding\n-----------------------------------\n\nWhich **three** of the following four statements are true of static inference? \nThe model must create predictions for all possible inputs. \nYes, the model must make predictions for all possible inputs and store them in a cache or lookup table. If the set of things that the model is predicting is limited, then static inference might be a good choice. However, for free-form inputs like user queries that have a long tail of unusual or rare items, static inference can't provide full coverage. \nThe system can verify inferred predictions before serving them. \nYes, this is a useful aspect of static inference. \nFor a given input, the model can serve a prediction more quickly than *dynamic* inference. \nYes, static inference can almost always serve predictions faster than dynamic inference. \nYou can react quickly to changes in the world. \nNo, this is a disadvantage of static inference. \nWhich **one** of the following statements is true of dynamic inference? \nYou can provide predictions for all possible items. \nYes, this is a strength of dynamic inference. Any request that comes in will be given a score. Dynamic inference handles long-tail distributions (those with many rare items), like the space of all possible sentences written in movie reviews. \nYou can do post-verification of predictions before they are used. \nIn general, it's not possible to do a post-verification of all predictions before they get used because predictions are being made on demand. You can, however, potentially monitor *aggregate* prediction qualities to provide some level of quality checking, but these will signal fire alarms only after the fire has already spread. \nWhen performing dynamic inference, you don't need to worry about prediction latency (the lag time for returning predictions) as much as when performing static inference. \nPrediction latency is often a real concern in dynamic inference. Unfortunately, you can't necessarily fix prediction latency issues by adding more inference servers.\n| **Key terms:**\n|\n| - [Example](/machine-learning/glossary#example)\n| - [Inference](/machine-learning/glossary#inference)\n- [Unlabeled example](/machine-learning/glossary#unlabeled_example) \n[Help Center](https://support.google.com/machinelearningeducation)"]]