CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 4 · Lesson 31/56

    Basic elements of a RAG application: flavor, embeddings, retriever, dependencies and signature

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

    19 min read
    1.47% of exam
    13 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Choose between the mlflow.langchain flavor, the ResponsesAgent interface and a custom pyfunc model for a given RAG chain
    • Pick an embedding model and embedding source for an AI Search index and keep indexing and querying on the same model
    • Turn a retriever choice into concrete VectorSearchRetrieverTool settings: index, num_results, query_type, columns and filters
    • Declare and pin dependencies so Model Serving can build the container image
    • Explain what a model signature and an input example are for, and why Unity Catalog needs the signature

    Key concept

    The logged RAG model as a deployable package — A RAG chain reaches production as one MLflow model: a flavor that says how to load and call it, an embedding model and retriever it depends on, a list of pinned packages to rebuild its environment, and a signature that tells every consumer what goes in and what comes out. Leaving any one of them wrong breaks the deployment, not the notebook.

    1.What a RAG application is made of

    A RAG application answers a question in three moves: retrieve supporting data, combine it with the request into a prompt, and have an LLM generate the answer. The retrieval step queries an outside knowledge base such as a vector store, keyword search or SQL database, and the generation step is a normal LLM call over the augmented prompt.

    Getting that chain from a notebook to a serving endpoint means making six concrete choices. The model flavor decides how MLflow saves and reloads the chain. The embedding model turns document chunks and queries into vectors. The retriever fixes which index is searched and how many results come back. The dependencies let Model Serving rebuild the Python environment. The model signature and input example describe the request and response format to everything that will call the model. Each choice is made once, at logging time, and each one fails in its own way when it is wrong.

    Checkpoint 1 of 9· Match them up

    A RAG chain is being logged for deployment. Match each element you choose at logging time to the job it does.

    Tap a term, then the definition that fits it.

    Sources12

    2.Choosing the MLflow model flavor

    A flavor is the convention MLflow uses to save a model so that downstream tools can load it. MLflow ships built-in flavors for libraries it supports natively, plus the generic python-function flavor, pyfunc, for anything else. The rule for a RAG chain follows from that: when the whole chain is built from one natively supported framework, log it with that framework's flavor; when it is not, write a custom pyfunc model.

    A chain composed entirely of LangChain components — a retriever, a prompt template and an LLM joined with LangChain's chain APIs — belongs in the mlflow.langchain flavor. You pass the chain object itself as lc_model, and you reload it with the load_model function of the same flavor. Tracing comes with it: calling mlflow.langchain.autolog() logs nested traces for every chain invocation, so the retriever and prompt steps show up without extra code. The framework you picked therefore decides the flavor; see Choosing an agent framework (LangChain, LangGraph, DSPy, OpenAI SDK) for that choice.

    Logging a LangChain chain with the built-in langchain flavor, including parameters and an input examplepython
    model_info = mlflow.langchain.log_model(
      lc_model=chain,
      name="basic_chain",
      params={
        "temperature": 0.1,
        "max_tokens": 2000,
        "prompt_template": str(prompt)
      },
      model_type="agent",
      input_example={"messages": "What is MLflow?"},
    )

    A custom pyfunc model is the right tool when the chain does not fit a built-in flavor: inputs need preprocessing before predict, raw outputs must be post-processed, there is per-request branching, or the framework is not natively supported by MLflow. The price is that you write the model yourself by subclassing mlflow.pyfunc.PythonModel, with a load_context function for one-time loading and a predict function that runs on every request. Wrapping a pure LangChain chain this way throws away the native serialization and adds code to maintain, which is why pyfunc is the fallback rather than the default.

    Flavors built for other model types do not fit a RAG chain. mlflow.sklearn packages estimators, and the Transformers flavor wraps a single model; neither one represents a retriever, a prompt template and an LLM call composed together. For agents, the MLflow ResponsesAgent interface is the recommended way to author, and it also handles signature inference for you.

    Which flavor fits which RAG chain
    Chain is built asLog it withWhy
    LangChain components composed with chain APIsmlflow.langchain.log_model(lc_model=chain, ...)Native serialization, autolog tracing, reload with the flavor's load_model
    An agent authored for Databricks product featuresThe ResponsesAgent interfaceRecommended for agents; MLflow infers a compatible signature
    Custom Python with pre- or post-processing, branching, or an unsupported frameworkmlflow.pyfunc.log_model with a PythonModel subclassYou write load_context and predict yourself

    Checkpoint 2 of 9· Check yourself

    Your team is logging several RAG chains. Which one should be logged as a custom pyfunc model (a PythonModel subclass) instead of with a built-in MLflow flavor?

    Checkpoint 3 of 9· Exam question

    A team is building a RAG chain in Databricks entirely out of LangChain-compatible components: a retriever, a prompt template, and an LLM composed with LangChain's chain APIs. They want to log the chain with MLflow so it is natively serialized, automatically traced, and reloadable with a matching load_model call. Which model flavor should they use?

    Sources3425

    3.Choosing the embedding model and where embeddings are computed

    The embedding model is chosen once for the index and then used on both sides of every search. At query time the retrieval query is embedded with the same model that embedded the document chunks, and the closest chunks are returned. Pick the model with the documents and queries in mind — context length is one criterion, covered in Embedding model context length — and then treat it as fixed for the life of the index.

    For production on standard endpoints, Databricks recommends databricks-qwen3-embedding-0-6b behind a provisioned throughput serving endpoint; databricks-bge-large-en is another Databricks-hosted option. Two serving settings matter. Remove the default Scale to zero, because a scaled-down endpoint can take minutes to warm up and the first query may time out. And use CPU endpoints only for small datasets and tests; larger datasets need a GPU endpoint or index initialization can time out.

    The second decision is who computes the embeddings. Choosing Compute embeddings on a Delta Sync Index points the index at a text column and lets Databricks embed it with the model you select, re-syncing as the source table changes, with no separate embedding pipeline to run. Use existing embeddings means your table already holds precomputed vectors in an array[float] column and you supply the dimension. A Direct Vector Access Index puts you in charge of writing vectors through the REST API or Python SDK. The choice is sticky: a self-managed embedding index cannot be converted to a Databricks-managed one later; you would create a new index and recompute embeddings.

    Three ways to provide embeddings for an AI Search index
    OptionWho computes embeddingsHow the index stays current
    Delta Sync Index, Compute embeddingsDatabricks, with the embedding model you selectSyncs automatically with the source table
    Delta Sync Index, Use existing embeddingsYou, before writing the array[float] columnSyncs automatically with the source table
    Direct Vector Access IndexYouYou write vectors through the REST API or Python SDK

    Checkpoint 4 of 9· Check yourself

    Six months after launch, a team whose Delta Sync Index uses "Use existing embeddings" decides it no longer wants to run its own embedding pipeline. It wants Databricks to compute the embeddings instead. What does it have to do?

    Checkpoint 5 of 9· Exam question

    A developer is creating a Delta Sync index in Mosaic AI Vector Search (Databricks AI Search) over a Delta table of chunked documents. They want Databricks to automatically compute and refresh embeddings from a text column whenever the source table changes, without operating a separate embedding pipeline. Which embedding configuration satisfies this?

    Sources678

    4.Turning the retriever choice into configuration

    Which kind of retrieval suits a query — semantic, keyword or both — is covered in Choosing the retriever from the shape of the query. For a Databricks RAG app, that choice becomes a handful of arguments on VectorSearchRetrieverTool from databricks-langchain or databricks-openai, which exposes an AI Search index as a tool the chain or agent can call.

    A retriever configured with an explicit index, result count, returned columns, filter, query type and embedding modelpython
    embedding_model = DatabricksEmbeddings(
        endpoint="databricks-bge-large-en",
    )
    
    vs_tool = VectorSearchRetrieverTool(
      index_name="catalog.schema.index_name", # Index name in the format 'catalog.schema.index'
      num_results=5, # Max number of documents to return
      columns=["primary_key", "text_column"], # List of columns to include in the search
      filters={"text_column LIKE": "Databricks"}, # Filters to apply to the query
      query_type="ANN", # Query type ("ANN" or "HYBRID").
      tool_name="databricks_docs_retriever", # Used by the LLM to understand the purpose of the tool
      tool_description="Purpose of the tool", # Used by the LLM to understand the purpose of the tool
      text_column="text_column", # Specify text column for embeddings. Required for direct-access index or delta-sync index with self-managed embeddings.
      embedding=embedding_model # The embedding model. Required for direct-access index or delta-sync index with self-managed embeddings.
    )

    Each argument carries a decision. index_name is the three-part Unity Catalog name. num_results is k, and it is not a free knob: how many chunks you retrieve and how you combine them with the query can significantly change answer quality. query_type="HYBRID" adds keyword matching to vector similarity, which pays off when the data has SKUs or identifiers that pure similarity search handles poorly. columns and filters can only use columns that were indexed, so a column left out of the index cannot be returned to the prompt or used to narrow results.

    The last two arguments depend on the embedding option. With Databricks-managed embeddings the tool needs neither. With a Direct Vector Access index or a Delta Sync Index on self-managed embeddings, text_column and the embedding model are required, and that embedding model must be the one that built the index.

    Checkpoint 6 of 9· Fill the gap

    This retriever configuration has to cap how many chunks come back for the prompt, which is the k that affects answer quality. Which argument fills the blank?

    embedding_model = DatabricksEmbeddings(
        endpoint="databricks-bge-large-en",
    )
    
    vs_tool = VectorSearchRetrieverTool(
      index_name="catalog.schema.index_name", # Index name in the format 'catalog.schema.index'
       ? =5, # Max number of documents to return
      columns=["primary_key", "text_column"], # List of columns to include in the search
      filters={"text_column LIKE": "Databricks"}, # Filters to apply to the query
      query_type="ANN", # Query type ("ANN" or "HYBRID").
      tool_name="databricks_docs_retriever", # Used by the LLM to understand the purpose of the tool
      tool_description="Purpose of the tool", # Used by the LLM to understand the purpose of the tool
      text_column="text_column", # Specify text column for embeddings. Required for direct-access index or delta-sync index with self-managed embeddings.
      embedding=embedding_model # The embedding model. Required for direct-access index or delta-sync index with self-managed embeddings.
    )

    Sources6879

    5.Declaring and pinning dependencies

    Model Serving does not reuse your notebook's environment. During deployment it builds a container from the libraries captured or specified in the MLflow model, so a package missing from the model is a deployment failure even though the chain ran fine interactively. Whenever you log a model, MLflow writes requirements.txt and conda.yaml next to it; those files, not the signature, are where package versions live.

    Built-in flavors such as mlflow.langchain reliably record their library's version. With mlflow.pyfunc.log_model, MLflow infers requirements with mlflow.models.infer_pip_requirements and can miss packages, especially ones without a built-in flavor. Add those with extra_pip_requirements, and pin the exact version — nltk== plus the installed version, not a bare nltk. Replacing the whole list with pip_requirements or conda_env is generally discouraged, because it overrides what MLflow picked up automatically.

    The mlflow-skinny case is the one exception to the advice against pip_requirements. Databricks Runtime ML includes mlflow-skinny by default, so a pyfunc model logged there without pip_requirements records the wrong package. Always pin mlflow==<version> explicitly when logging a pyfunc model on DBR ML.

    Pinning the full mlflow package when logging a pyfunc model on Databricks Runtime MLpython
    # DBR ML ships with mlflow-skinny by default, so specify mlflow explicitly
    # to ensure Model Serving compatibility.
    mlflow.pyfunc.log_model(
        name="model",
        python_model=your_model,
        pip_requirements=["mlflow==3.8.1"],  # use mlflow, not mlflow-skinny
        registered_model_name="catalog.schema.model_name",
    )

    Two kinds of dependency fall outside pip. Local .py modules and private wheels go in code_paths (code_path in MLflow 2.x); MLflow stores them with the model and adds them to the Python path on load. Non-Python dependencies such as Java, R or Linux packages are never picked up automatically, so log a small .txt or .json artifact listing them through the artifacts argument. Inference should also run on the same Databricks Runtime version used to build the model, which MLflow records in the databricks_runtime field of the MLmodel file.

    Checkpoint 7 of 9· Fill the gap

    You are logging a custom pyfunc RAG model on a Databricks Runtime ML cluster, and Model Serving has to be able to build its container. Which parameter belongs in the blank?

    # DBR ML ships with mlflow-skinny by default, so specify mlflow explicitly
    # to ensure Model Serving compatibility.
    mlflow.pyfunc.log_model(
        name="model",
        python_model=your_model,
         ? =["mlflow==3.8.1"],  # use mlflow, not mlflow-skinny
        registered_model_name="catalog.schema.model_name",
    )

    Sources102113

    6.Model signature and input example

    A model signature is the input and output schema of the model. It is a contract with every caller: Databricks uses MLflow model signatures to define an agent's input and output, and product features such as the AI Playground assume the agent has one of a set of supported signatures. A signature does not record package versions — that is requirements.txt — and it does not hold access grants or index settings.

    Unity Catalog enforces the contract at registration: models in Unity Catalog require a signature, and model versions registered without one have limitations. For a model that is not an agent, you infer the signature from sample inputs and the model's outputs and pass it to log_model.

    Inferring a signature from inputs and predictions and attaching it at logging timepython
    from mlflow.models.signature import infer_signature
    
    signature = infer_signature(training_data, model.predict(training_data))
    mlflow.sklearn.log_model(model, "model", signature=signature)

    Agents written with the ResponsesAgent interface skip this step. MLflow infers a signature that is compatible with Databricks product features, which is one reason it is the recommended authoring approach for agents on Databricks.

    An input example is a concrete request logged with the model through input_example, such as {"messages": "What is MLflow?"} in the LangChain logging call. It shows the next developer what a valid request looks like, and it gives you a ready payload for checking that the model can be served before deployment with mlflow.models.predict. Running that check is cheaper than finding a schema or dependency mistake after the container build.

    Checkpoint 8 of 9· Check yourself

    Before registering a RAG chain in Unity Catalog, a colleague suggests putting package versions into the model signature so that Model Serving installs the right libraries. Where does MLflow actually keep the package versions it uses to rebuild the environment?

    Checkpoint 9 of 9· Exam question

    In the context of registering a RAG model to Unity Catalog via MLflow, what is the primary purpose of the model signature?

    Sources12133

    Sources

    (13)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Retrieval: The user's request is used to query an outside knowledge base such as a vector store, keyword search, or SQL database.”
      ↩︎ What a RAG application is made of
    2. 2.
      “The format defines a convention that lets you save a model in different flavors (python-function, pytorch, sklearn, and so on)”
      ↩︎ What a RAG application is made of
      “To load a previously logged model for inference or further development, use mlflow.<model-type>.load_model(modelpath)”
      ↩︎ Choosing the MLflow model flavor
      “When you log a model, MLflow automatically logs requirements.txt and conda.yaml files.”
      ↩︎ Declaring and pinning dependencies
      “An MLflow Model is a standard format for packaging machine learning models that can be used in a variety of downstream tools”
      ↩︎ Key concept
      “When you log a model, MLflow automatically logs requirements.txt and conda.yaml files. You can use these files to recreate the model development environment”
      ↩︎ Checkpoint
      “When you log a model, MLflow automatically logs requirements.txt and conda.yaml files.”
      ↩︎ Checkpoint
    3. 3.
      “Your model framework is not natively supported by MLflow.”
      ↩︎ Choosing the MLflow model flavor
      “predict - this function houses all the logic that is run every time an input request is made.”
      ↩︎ Choosing the MLflow model flavor
      “Model Serving requires mlflow (not mlflow-skinny) in conda.yaml and cannot build the container image otherwise.”
      ↩︎ Declaring and pinning dependencies
      “use mlflow.models.predict to validate models before deployment.”
      ↩︎ Model signature and input example
      “Model Serving requires mlflow (not mlflow-skinny) in conda.yaml and cannot build the container image otherwise.”
      ↩︎ Exam trap 3
      “Your application requires the model's raw outputs to be post-processed for consumption.”
      ↩︎ Checkpoint
    4. 4.
      “You can enable tracing for LangChain by calling the mlflow.langchain.autolog function”
      ↩︎ Choosing the MLflow model flavor
    5. 5.
      “The following code snippet shows how to log a LangChain agent. Use the log_model() method for your flavor of agent.”
      ↩︎ Choosing the MLflow model flavor
      “The following code snippet shows how to log a LangChain agent. Use the log_model() method for your flavor of agent.”
      ↩︎ Exam trap 1
    6. 6.
      “the retrieval query is translated into an embedding using the same embedding model that was used to embed the document chunks during data preparation”
      ↩︎ Choosing the embedding model and where embeddings are computed
      “determining how many chunks to retrieve in step 2 and how to combine them with the user's query in step 3 can significantly impact”
      ↩︎ Turning the retriever choice into configuration
    7. 7.
      “For production applications using standard endpoints, Databricks recommends using the foundation model databricks-qwen3-embedding-0-6b with a provisioned throughput serving endpoint.”
      ↩︎ Choosing the embedding model and where embeddings are computed
      “Databricks recommends that you remove the default selection of Scale to zero.”
      ↩︎ Choosing the embedding model and where embeddings are computed
      “You should only use CPU endpoints for small datasets and tests. For larger datasets, use a GPU endpoint for optimal performance.”
      ↩︎ Choosing the embedding model and where embeddings are computed
      “Indicate if you want Databricks to compute embeddings for a text column in the source table (Compute embeddings)”
      ↩︎ Choosing the embedding model and where embeddings are computed
      “The user is responsible for updating this table using the REST API or the Python SDK.”
      ↩︎ Choosing the embedding model and where embeddings are computed
      “is always used for ingestion and is also used for querying unless you specify a different model here.”
      ↩︎ Choosing the embedding model and where embeddings are computed
      “Only indexed columns can be returned in search results or used as filters.”
      ↩︎ Turning the retriever choice into configuration
    8. 8.
      “It is not possible to convert a self-managed embedding index to a Databricks-managed index.”
      ↩︎ Choosing the embedding model and where embeddings are computed
      “This method is particularly useful in RAG applications where source data has unique keywords such as SKUs or identifiers”
      ↩︎ Turning the retriever choice into configuration
      “It is not possible to convert a self-managed embedding index to a Databricks-managed index.”
      ↩︎ Exam trap 2
    9. 9.
      “Required for direct-access index or delta-sync index with self-managed embeddings.”
      ↩︎ Turning the retriever choice into configuration
      “Use the same embedding model that created the index vectors.”
      ↩︎ Prediction
    10. 10.
      “This container includes libraries automatically captured or specified in the MLflow model.”
      ↩︎ Declaring and pinning dependencies
    11. 11.
      “Be sure to log the requirements with the exact library version”
      ↩︎ Declaring and pinning dependencies
      “you can specify additional dependencies with the extra_pip_requirements parameter in the log_model command.”
      ↩︎ Declaring and pinning dependencies
      “doing so is generally discouraged because this overrides the dependencies which MLflow picks up automatically.”
      ↩︎ Declaring and pinning dependencies
      “MLflow stores any files or directories passed using code_paths or code_path as artifacts along with the model in a code directory.”
      ↩︎ Declaring and pinning dependencies
      “MLflow does not automatically pick up non-Python dependencies, such as Java packages, R packages, and native packages (such as Linux packages).”
      ↩︎ Declaring and pinning dependencies
      “Databricks recommends running inference on the same runtime version that you used during training”
      ↩︎ Declaring and pinning dependencies
    12. 12.
      “Databricks uses MLflow Model Signatures to define agents' input and output schema.”
      ↩︎ Model signature and input example
      “Product features like the AI Playground assume that your agent has one of a set of supported model signatures.”
      ↩︎ Model signature and input example
      “If you follow the recommended approach to authoring agents using the ResponsesAgent interface, MLflow will automatically infer a signature for your agent”
      ↩︎ Model signature and input example
      “Databricks uses MLflow Model Signatures to define agents' input and output schema.”
      ↩︎ Exam trap 4

    Spotted a mistake, or was something unclear? Tell us.