Home / GenAI Engineer practice test / Assembling and Deploying Applications / Question

Databricks Generative AI Engineer Associate · free practice question

When building an MLflow PyFunc wrapper for a text classification model, the system receives a raw string as input, which requires lowercasing and tokenization…

Exam-style question on Assembling and Deploying Applications from the free GenAI Engineer practice test, with the answer and a full explanation below.

Updated November 11, 2026

Assembling and Deploying Applications

When building an MLflow PyFunc wrapper for a text classification model, the system receives a raw string as input, which requires lowercasing and tokenization prior to prediction. Similarly, the model's direct output (an array of probabilities) needs conversion into a human-readable label string before being sent back to the user. Within the structure of the PyFunc class, where is the most appropriate place to implement these necessary data transformations?

  1. APut the input preparation in __init__() so it runs at model load, and do the output conversion in a utility module called outside the PyFunc
  2. BPut both the input preparation and the output formatting in load_context(), which MLflow invokes after each prediction
  3. CDo the input preparation at the start of predict(), before calling the model, and the output formatting at the end of predict()
  4. DPut the input preparation in predict() and move the output formatting to a separate REST endpoint that the client calls afterwards
Answer & explanation

Correct answer: C

WHY C is correct: In an MLflow PyFunc model, the predict() method is the single point of entry for every inference request. Pre-processing (lowercase, tokenize) should be applied first within predict() to transform raw input, then the model is called, then post-processing (array → label) should be applied to the model's output before the result is returned. This keeps the full input→output contract inside the PyFunc class.

WHY NOT A: __init__() runs once at object creation time. It is used to load artifacts, not to transform per-request data. Pre-processing cannot live there because it needs access to each individual inference input.

WHY NOT B: load_context() is called by MLflow once during model loading to set up resources such as loading custom files or initializing state. It is not called on each prediction request and cannot hold per-request transformations.

WHY NOT D: Splitting post-processing into a separate REST endpoint breaks the single-endpoint contract expected by model serving clients and fragment the inference pipeline across two network calls.

Take the full GenAI Engineer practice test free →

Would you pass today?

This question is one of 45 in the free, timed Databricks Generative AI Engineer Associate practice test. Take it and get a section-by-section score.

Start the free test →