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.
Each element does a separate job. Package versions belong to the dependencies, which MLflow logs so the environment can be rebuilt. The signature only describes the format of what goes in and what comes out.
“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”Source: docs.databricks.com
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.
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.
| Chain is built as | Log it with | Why |
|---|---|---|
| LangChain components composed with chain APIs | mlflow.langchain.log_model(lc_model=chain, ...) | Native serialization, autolog tracing, reload with the flavor's load_model |
| An agent authored for Databricks product features | The ResponsesAgent interface | Recommended for agents; MLflow infers a compatible signature |
| Custom Python with pre- or post-processing, branching, or an unsupported framework | mlflow.pyfunc.log_model with a PythonModel subclass | You 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?
Custom pyfunc is for code that the built-in flavors don't fit, such as post-processing raw outputs. A chain built only from LangChain components belongs in mlflow.langchain, which handles native serialization and autolog tracing. A single model on its own matches the Transformers flavor.
“Your application requires the model's raw outputs to be post-processed for consumption.”Source: docs.databricks.com
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?
Correct answer: A — Log the chain with the mlflow.langchain flavor, which stores the retriever, prompt template and LLM as LangChain objects and records each step as a span in MLflow traces.
- A. The LangChain flavor is built to serialize LangChain chain objects such as retrievers, prompt templates and LLM wrappers. It works with MLflow tracing, and the model is reloaded with
mlflow.langchain.load_model. This fits a chain composed of LangChain components. - B. PyFunc can log arbitrary Python code, but it stores the chain behind a hand-written wrapper as generic code and artifacts. That is not native serialization of the LangChain objects. The team would also have to write and maintain the
predictlogic themselves, which the dedicated LangChain flavor makes unnecessary. - C. The scikit-learn flavor serializes trained scikit-learn estimators. A LangChain chain of retriever, prompt template and LLM is not such an estimator and has no
fitstep. The flavor cannot natively serialize the chain, however well the retrieve-then-generate flow resembles a pipeline. - D. The transformers flavor is meant for Hugging Face pipelines and models. At best it could capture the LLM step as a text-generation pipeline. It cannot natively serialize the retriever and prompt template that make up the rest of the chain, so the chain would not be logged as one unit.
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.
| Option | Who computes embeddings | How the index stays current |
|---|---|---|
| Delta Sync Index, Compute embeddings | Databricks, with the embedding model you select | Syncs automatically with the source table |
| Delta Sync Index, Use existing embeddings | You, before writing the array[float] column | Syncs automatically with the source table |
| Direct Vector Access Index | You | You 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?
The embedding source is fixed when the index is created, so a self-managed index cannot be switched to managed embeddings. The team has to build a new index and recompute the embeddings. The separate query-model setting exists only on indexes that already use Compute embeddings. A Direct Vector Access Index makes you write the vectors yourself.
“It is not possible to convert a self-managed embedding index to a Databricks-managed index.”Source: docs.databricks.com
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?
Correct answer: A — Create the Delta Sync index with embedding_source_column set to the chunk text column and embedding_model_endpoint_name set to a Databricks-hosted embedding model endpoint.
- A. Setting
embedding_source_columnto the text column and naming a Databricks-hosted embedding model endpoint makes this a Delta Sync index with Databricks-computed embeddings. Databricks embeds new and changed rows on each sync, so no separate embedding pipeline is needed. - B.
embedding_vector_columnwithembedding_dimensionis the self-managed embeddings setup. The vectors must already exist in the table, so the developer still has to run an external embedding step to fill and refresh that column. That is the pipeline they want to avoid. - C. Embeddings come from a separate scheduled job, and the index only reads the vectors that job writes. The developer would still own and operate an embedding pipeline, because Databricks does not compute embeddings from the text column during the sync.
- D. A Direct Vector Access index does not sync from a Delta table and does not compute embeddings. The developer's own job must generate the vectors and push them on every change, which is a separate embedding pipeline rather than automatic refresh.
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.
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.
)On VectorSearchRetrieverTool, num_results sets k, the most documents the retriever returns. That number is a real decision, because how many chunks you retrieve can significantly change answer quality.
Source: docs.databricks.com5.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.
# 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",
)Normally, replacing the inferred requirements with pip_requirements is discouraged. The mlflow-skinny case on DBR ML is the exception: without pip_requirements, MLflow records mlflow-skinny, and Model Serving cannot build the image. You therefore pin the full mlflow package, with an exact version, in pip_requirements. code_paths is for local .py files and wheels, not for PyPI packages.
Source: docs.databricks.com6.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.
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?
The signature is only the input and output schema, the contract with callers that Unity Catalog requires. Package versions go in the requirements.txt and conda.yaml files that MLflow logs with the model. The databricks_runtime field records the runtime version, not a list of packages.
“When you log a model, MLflow automatically logs requirements.txt and conda.yaml files.”Source: docs.databricks.com
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?
Correct answer: A — It declares the names and data types of the model's inputs and outputs, which Unity Catalog requires so that serving endpoints, the AI Playground and the review app can build valid requests and parse responses.
- A. Correct. The signature declares the names and data types of the model's inputs and outputs. Unity Catalog requires it on registered model versions, so serving endpoints, the AI Playground and the review app can build valid requests and interpret the responses.
- B. Incorrect. Package versions and dependencies are stored in the model's environment specification, such as its requirements or conda files, which serving uses to rebuild the environment. The signature only describes the shape of the input and output data, so it cannot pin libraries.
- C. Incorrect. Access to a registered model is governed by Unity Catalog privileges and grants on the model and its parent catalog and schema, and Unity Catalog evaluates those itself. The signature holds no principals or grants. It only describes the request and response schema.
- D. Incorrect. Embedding dimension, index name and column mapping belong to the Vector Search index and the retriever configuration, not to the model signature. The signature describes only the model's own inputs and outputs. It plays no part in routing query vectors or validating the index schema.
Sources
(13)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 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.https://docs.databricks.com/aws/en/mlflow/modelsOfficial docs
“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.https://docs.databricks.com/aws/en/machine-learning/model-serving/deploy-custom-python-codeOfficial docs
“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.
“You can enable tracing for LangChain by calling the mlflow.langchain.autolog function”
↩︎ Choosing the MLflow model flavor - 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.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/fundamentals-inference-chain-ragOfficial docs
“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.
“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.
“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.
“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.
“This container includes libraries automatically captured or specified in the MLflow model.”
↩︎ Declaring and pinning dependencies - 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.
“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 - 13.https://docs.databricks.com/aws/en/machine-learning/manage-model-lifecycle/migrate-modelsOfficial docs
“Models in Unity Catalog require a signature.”
↩︎ Model signature and input example