AI-300 Practice Question 75: Scoring Script Init

Microsoft Machine Learning Operations Engineer Associate (AI-300) · Test 8 · question 5 of 10

Implement machine learning model lifecycle and operationseasy

A custom scoring script for a managed online endpoint loads the model file from disk inside its run() function. Every request now takes several seconds. Where should the model be loaded to remove this delay?

Select one answer
Show answer and explanation

Answer:

  • D. In init(), which runs once at startup, into a global variable

A scoring script must define init() and run(). init() runs once when the container starts, so it is the place for expensive one-time work such as loading the model into a global variable. run() then only performs inference for each request (option D).

- A is wrong because the model would still be reloaded for every request. A longer timeout only prevents timeouts and does not remove the delay. - B is wrong because this guarantees that the load cost is paid on every single request. - C is wrong because an environment describes packages. It does not load a model into memory for the scoring code.

Reference: Deploy and score a machine learning model by using an online endpoint

Practice Test 8 ›

Study guides for AI-300