Databricks Certified Generative AI Engineer Associate free question 7 / 10 · Domain 4: Assembling and Deploying Applications
A team logged a custom pyfunc model with its preprocessing and postprocessing written inside predict, and plans to put it on a Model Serving endpoint. Which way of checking, before deployment, that the model can be served does the Databricks documentation point to?
- Turn the model into a UDF with mlflow.pyfunc.spark_udf and run it against a table
- Pass an evaluation dataset to mlflow.evaluate and confirm that metrics are produced
- Extract the dependencies with mlflow.pyfunc.get_model_dependencies and check them
- Pass the logged model and an input to mlflow.models.predict and check that it runs
Show the answer and explanation
Answer: D
Why this is correct
Both the page on deploying custom Python code to Model Serving and the MLflow page on online serving carry a note before the deployment steps: it is beneficial to verify that the model can be served, and mlflow.models.predict is the tool they name for that. A pyfunc model runs arbitrary Python for preprocessing, inference and postprocessing, so a coding mistake or a missing dependency tends to stay hidden until the endpoint is built. The endpoint builds a container from the model, and a failure at that point costs a long wait before you can fix and rebuild. The guidance is to call the logged model through this function first and confirm that it is in a servable form.
Why the other options are wrong
"Pass an evaluation dataset to mlflow.evaluate and confirm that metrics are produced" … mlflow.evaluate measures the quality of answers on an evaluation dataset with metrics. It is not what the documentation names as the pre-deployment serving check, and getting metrics does not show that the model runs in the endpoint container.
"Extract the dependencies with mlflow.pyfunc.get_model_dependencies and check them" … This function pulls the model's dependency files and returns their location, so that you can match the notebook environment to the model with %pip install. It helps align environments, but the documented validation for serving is mlflow.models.predict.
"Turn the model into a UDF with mlflow.pyfunc.spark_udf and run it against a table" … spark_udf turns the model into a Spark UDF for batch or streaming inference over a whole table. Running on a table in Spark is a different thing from being servable as a REST endpoint, and the documentation does not name it as a pre-deployment check.
Key point
After logging, the flow is: log the model, check it with mlflow.models.predict, register it in Unity Catalog, and deploy it to a Model Serving endpoint. If a deployed endpoint fails, look at the container build logs for startup problems and at the model server logs for inference problems; both are on the Logs tab of the endpoint page.