CertLumen

Databricks Generative AI Engineer Associate · Section 4 · 22% of the exam

Choose the basic elements needed to create a RAG application: model flavor, embedding model, retriever, dependencies, input examples, model signature

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=...) (alias endpoint=) wraps any Databricks chat endpoint, and StrOutputParser returns plain text.
  • PythonModel.load_context runs once per load (clients, artifacts). predict(context, model_input, params) runs per request and holds pre- and post-processing.
  • Models from code: log a .py file that calls mlflow.models.set_model(obj). In MLflow 3, use name= instead of artifact_path=.
  • RAG elements: flavor, embedding model (same on both sides, context length matters), retriever, dependencies, input example, signature, plus resources.

Try a question

A GenAI engineer wraps a RAG chain in a custom mlflow.pyfunc.PythonModel. Its predict method creates a new Vector Search client and a new OpenAI-compatible client on every call, and latency on the serving endpoint is far higher than in the notebook. Where should the clients be created?

  1. AIn load_context, which runs once when the model is loaded
  2. BIn a module-level if __name__ == "__main__": block of the model file
  3. CIn the input_example, so that they are saved together with the model
  4. DIn predict_stream, which MLflow calls before predict on each request
Show the answer

A. PythonModel.load_context(self, context) runs once when the model is loaded, which makes it the place for clients, connections and files from context.artifacts. predict runs for every request, so setup work there is repeated each time and adds latency.

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

← Previous objective · All 56 objectives · Next objective →