Machine Learning Associate · 12% of the exam

Model Deployment: free practice questions

5 sample questions from our 17-question bank for this domain — answers and explanations included. These are the same scenario-based style as the real Databricks exam.

1. A registered scikit-learn model is loaded for batch scoring in Spark. Why is applying it as an MLflow pyfunc/Spark UDF advantageous?

  • A. It applies the model in parallel across the cluster while reusing the logged model's environment for consistent results✓ Correct
  • B. It retrains the model on each partition
  • C. It requires no model to be logged
  • D. It only works for a single row at a time
Explanation

Wrapping the MLflow model as a Spark UDF distributes scoring across the cluster and reuses the logged environment, giving scalable, consistent inference. It doesn't retrain per partition (B), it needs a logged model (C), and it scales beyond one row (D).

2. A data science team is building a real-time fraud scoring API on Databricks. The model requires features computed from both (a) a pre-computed aggregation table updated hourly and (b) on-the-fly transaction-level features computed at request time. The team wants to serve these features with the lowest possible latency. Which architecture BEST satisfies these requirements?

  • A. Compute all features at request time using a Spark SQL query against the Delta table, then call the model endpoint.
  • B. Use a Databricks Feature Store online store (e.g., backed by DynamoDB or CosmosDB) for the pre-computed aggregations and compute transaction-level features in the serving function logic, combining both before scoring.✓ Correct
  • C. Run a streaming Structured Streaming job that updates features in real time and writes them to the MLflow artifact store for retrieval at inference time.
  • D. Precompute and cache all possible feature combinations in a Pandas DataFrame on the model serving node at startup.
Explanation

Option B is correct: the Databricks Feature Store supports publishing feature tables to online stores (low-latency key-value stores such as DynamoDB or Azure CosmosDB). Pre-computed aggregations are published there and can be retrieved in sub-millisecond time by entity key during real-time serving. Transaction-level features that depend on the incoming request payload are computed inline within the serving function. Combining both sources at the model server is the standard pattern for hybrid feature serving. Option A is wrong because issuing a Spark SQL query against Delta at request time introduces seconds-level latency due to Spark job overhead, violating real-time SLAs. Option C is wrong because the MLflow artifact store is an object store (e.g., S3/ADLS) designed for model artifacts, not for low-latency feature retrieval at serving time. Option D is impractical because enumerating and caching all possible feature combinations is computationally infeasible for a large entity space and would consume enormous memory.

3. Which factors most directly determine whether to choose batch, streaming, or real-time serving for a model?

  • A. Required latency and data arrival pattern/volume✓ Correct
  • B. The color of the dashboard
  • C. The number of notebook cells
  • D. The cluster's name
Explanation

Deployment choice is driven by latency requirements and how/when data arrives (bulk, streaming, or per-request). The other options are irrelevant to the decision.

4. An ML engineer is setting up batch inference on Databricks using a model registered in the Unity Catalog MLflow Model Registry. They want to load the model as a Spark UDF to score a large Delta table. Which approach correctly loads the model for this purpose?

  • A. loaded_model = mlflow.pyfunc.load_model('models:/prod_catalog.ml_models.churn_model/3'); predictions = loaded_model.predict(spark_df.toPandas())
  • B. loaded_model = mlflow.pyfunc.spark_udf(spark, 'models:/prod_catalog.ml_models.churn_model/3', result_type='double'); predictions_df = spark_df.withColumn('prediction', loaded_model(*feature_cols))✓ Correct
  • C. loaded_model = spark.read.format('mlflow').load('prod_catalog.ml_models.churn_model'); predictions_df = spark_df.join(loaded_model, on='id')
  • D. loaded_model = mlflow.sklearn.load_model('models:/prod_catalog.ml_models.churn_model@champion'); predictions = spark.createDataFrame(loaded_model.predict(spark_df))
Explanation

Option B is correct: mlflow.pyfunc.spark_udf() wraps any MLflow model as a Spark UDF, enabling distributed scoring directly on a Spark DataFrame without collecting data to the driver, which is essential for large-scale batch inference. Option A loads the model as a Python object and calls predict() on a Pandas DataFrame converted from the full Spark DataFrame — this defeats the purpose of distributed processing and will fail for large datasets due to memory constraints. Option C uses a non-existent 'mlflow' Spark data source format. Option D uses mlflow.sklearn.load_model, which loads a Python object, and then incorrectly tries to create a Spark DataFrame from the predictions, which would also require driver-side scoring.

5. A retail ML team wants to perform batch inference on 2 billion records stored in a Delta table using a model registered in Unity Catalog. They want to maximize throughput and leverage Spark parallelism. Which of the following approaches is MOST appropriate?

  • A. Collect all 2 billion records to the Spark driver with `df.collect()`, run inference in a loop, then write results back with `spark.createDataFrame()`.
  • B. Use `mlflow.pyfunc.spark_udf()` to create a Spark UDF from the registered model, then apply it to the Delta table using `df.withColumn()` or `df.select()` to distribute inference across the cluster.✓ Correct
  • C. Use Databricks Model Serving to expose the model as a REST endpoint and call the endpoint in a `for` loop over batches of records from the driver.
  • D. Convert the Delta table to a pandas DataFrame, run inference with `model.predict()`, and write results to a new Delta table using `spark.createDataFrame()`.
Explanation

Correct: `mlflow.pyfunc.spark_udf()` wraps a registered MLflow model as a Spark UDF, allowing inference to be distributed across all worker nodes in the cluster. This is the recommended pattern for large-scale batch inference on Databricks, fully leveraging Spark parallelism and Delta Lake I/O. Wrong - A: `df.collect()` moves all 2 billion records to the single driver node, which will cause out-of-memory errors and completely defeats the purpose of a distributed cluster. Wrong - C: Model Serving REST endpoints are designed for real-time/online inference with low-latency requirements, not high-throughput batch workloads. Calling a REST endpoint in a loop over billions of records would be extremely slow due to HTTP overhead and is not a scalable batch pattern. Wrong - D: Converting a 2-billion-row Delta table to a pandas DataFrame requires collecting all data to the driver, which will cause OOM errors — same problem as option A.

12 more questions in this domain

Practice the full bank with instant grading, flashcards, and a timed mock exam.

Start practicing free