Системи машинного навчання, які працюють у реальних умовах: статичне й динамічне виведення результатів
Тримайте все під контролем за допомогою колекцій Зберігайте контент і організовуйте його за категоріями відповідно до своїх потреб.
Виведення результатів – це процес, за якого навчена модель робить прогнози, обробляючи приклади без міток. Загалом, модель може робити прогнози одним із двох способів.
Статичне виведення результатів (інша назва – виведення результатів офлайн або групове виведення результатів) означає, що модель робить прогнози на основі групи звичайних прикладів без міток, а потім десь кешує ці прогнози.
Динамічне виведення результатів (інша назва – виведення результатів онлайн або виведення результатів у реальному часі) означає, що модель робить прогноз лише за запитом, наприклад, коли його запитує клієнт.
Розгляньмо яскравий приклад. Уявіть дуже складну модель, якій потрібна одна година, щоби вивести прогноз. Для цього чудово підходить статичне виведення результатів.
Рисунок 4. При статичному виведенні результатів модель генерує прогнози, які потім кешуються на сервері.
Припустімо, що ця сама складна модель помилково використовує динамічне виведення результатів замість статичного. Якщо багато клієнтів майже одночасно надсилатимуть запити на прогнози, відповіді на більшість із них не буде годинами або днями.
Тепер розгляньмо модель, яка виводить результати швидко, можливо, за 2 мілісекунди, використовуючи відносний мінімум обчислювальних ресурсів. У цьому разі клієнти можуть швидко й ефективно отримувати прогнози шляхом динамічного виведення результатів, як показано на рисунку 5.
Рисунок 5. При динамічному виведенні результатів модель дає прогнози за запитом.
Статичне виведення результатів
Статичне виведення результатів має певні переваги й недоліки.
Переваги
Не потрібно занадто турбуватися про витрати на виведення результатів.
Можна виконати постперевірку прогнозів перед виведенням.
Недоліки
Система здатна виводити лише кешовані прогнози, тому може не вміти давати відповіді на запити з нетиповими прикладами вхідних даних.
Затримка оновлення може становити години або дні.
Динамічне виведення результатів
Динамічне виведення результатів має певні переваги й недоліки.
Переваги
Модель може виводити прогноз щодо будь-якого нового об’єкта, щойно він надходить. Це чудово підходить для прогнозів із довгим хвостом (менш типових).
Недоліки
Потреба у великих обчислювальних потужностях, а також чутливість до затримок. Ця комбінація може обмежити складність моделі; тобто, можливо, доведеться побудувати простішу модель, яка виводитиме прогнози швидше, ніж складна версія.
Більші потреби, пов’язані з моніторингом.
Вправи. Перевірте свої знання
Які три із чотирьох тверджень про статичне виведення результатів, наведених нижче, правильні?
Модель має створювати прогнози для всіх можливих вхідних даних.
Так, модель має робити прогнози для всіх можливих вхідних даних і зберігати їх у кеші або таблиці пошуку. Якщо набір того, що прогнозує модель, обмежений, статичне виведення результатів може бути хорошим вибором. Однак цей спосіб не може забезпечити повне охоплення вхідних даних довільної форми, таких як запити користувачів, що мають довгий хвіст нетипових або рідкісних об’єктів.
Система може перевіряти зроблені прогнози, перш ніж виводити їх.
Так, це корисна перевага статичного виведення результатів.
Для заданих вхідних даних така модель може виводити прогноз швидше, ніж та, що працює з динамічним виведенням результатів.
Так, при статичному виведенні результатів модель майже завжди може виводити прогнози швидше, ніж при динамічному.
Можна швидко реагувати на зміни у світі.
Ні, це недолік статичного виведення результатів.
Яке одне з тверджень про динамічне виведення результатів, наведених нижче, правильне?
Можна надати прогнози для всіх можливих об’єктів.
Так, це сильна сторона динамічного виведення результатів. Будь-якому запиту, що надходить, буде надано оцінку. При динамічному виведенні результатів обробляються розподіли з довгим хвостом (тобто з великою кількістю рідкісних об’єктів), наприклад, простір усіх можливих речень з оглядів фільмів.
Можна виконати постперевірку прогнозів перед їх використанням.
Загалом неможливо виконати постперевірку всіх прогнозів перед їх використанням, оскільки вони створюються за запитом. А втім, потенційно можна відстежувати сукупні показники якості прогнозів, щоб забезпечити певний рівень перевірки якості, однак це дає змогу дізнатися про проблему, лише коли вона вже стала поширеною.
Якщо використовується динамічне виведення результатів, не потрібно турбуватися про затримку прогнозів так, як при статичному.
Якщо результати виводяться динамічно, затримка прогнозів часто стає справжньою проблемою. На жаль, її не завжди можна вирішити, додавши більше серверів для виведення результатів.
[null,null,["Останнє оновлення: 2025-04-22 (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,["[**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\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\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 \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)"]]