Databricks Generative AI Engineer Associate · Section 4 · 22% of the exam
Code a chain using a pyfunc model with pre- and post-processing
One of the objectives of the Databricks Certified Generative AI Engineer Associate exam, in the section “Assembling and Deploying Applications”. Here is what it covers, the points to remember and a question to try.
What it covers
A generative AI application on Databricks is code that you package as an MLflow model: either a composed chain (for example LangChain) or a custom pyfunc model that wraps pre-processing, the LLM call and post-processing. This lesson shows how to write both, which elements a RAG application needs before it can be served, and how to log and register it in Unity Catalog.
Points to remember
- A chain is a fixed sequence (prompt, model, parser, optional retriever). An agent chooses tools at run time.
- LCEL composes runnables with
|.ChatDatabricks(model=...)(aliasendpoint=) wraps any Databricks chat endpoint, andStrOutputParserreturns plain text. PythonModel.load_contextruns once per load (clients, artifacts).predict(context, model_input, params)runs per request and holds pre- and post-processing.- Models from code: log a
.pyfile that callsmlflow.models.set_model(obj). In MLflow 3, usename=instead ofartifact_path=. - RAG elements: flavor, embedding model (same on both sides, context length matters), retriever, dependencies, input example, signature, plus resources.
Try a question
A RAG chain is logged with models from code, and the requirements MLflow infers from its imports are correct except one: a helper uses the rapidfuzz package, which is missing, so the served model fails with ModuleNotFoundError: No module named 'rapidfuzz'. The team wants to keep every inferred requirement and add only this package. Which log_model argument should they use?
- A
pip_requirements=["rapidfuzz"] - B
code_paths=["rapidfuzz"] - C
extra_pip_requirements=["rapidfuzz"] - D
artifacts={"rapidfuzz": "rapidfuzz"}
Show the answer
C. extra_pip_requirements adds packages to the list MLflow infers, while pip_requirements replaces that list entirely. code_paths ships local modules that pip can't install, and artifacts packages files that the model reads in load_context. In practice, pin the version you tested with, for example rapidfuzz==<version>.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Chains, pyfunc models and packaging a RAG application teaches this objective (about 50 minutes), and 14 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.
More in this section
- Control access to resources from model serving endpoints
- Code a simple chain according to requirements
- Choose the basic elements needed to create a RAG application: model flavor, embedding model, retriever, dependencies, input examples, model signature
- Register the model to Unity Catalog using MLflow
- Create and query a Vector Search index
- Identify how to serve an LLM application that leverages Foundation Model APIs
- Explain the key concepts and components of Mosaic AI Vector Search
- Identify batch inference workloads and apply ai_query() appropriately
- Configure vector search for a particular solution based on number of embeddings, update frequency, latency, and cost requirements
- Configure a persistent datastore to store and retrieve intermediate memory or structured information
- Apply CI/CD best practices such as updating a Vector Search index, promoting prompts across environments, and testing individual components of an agent
- Integrate managed, external, and custom MCP servers based on a given application requirements