MLflow Onboarding
MLflow supports two broad use cases that require different onboarding paths:
- GenAI applications and agents: LLM-powered apps, chatbots, RAG pipelines, tool-calling agents. Key MLflow features include tracing for observability, evaluation with LLM judges, and prompt management, among others.
- Traditional ML / deep learning models: scikit-learn, PyTorch, TensorFlow, XGBoost, etc. Key MLflow features include experiment tracking (parameters, metrics, artifacts), model logging, and model deployment, among others.
Determining which use case applies is the first and most important step. The onboarding path, quickstart tutorials, and integration steps differ significantly between the two.
Step 1: Determine the Use Case
Before recommending tutorials or integration steps, determine which use case the user is working on. Use the signals below, checking them in order. If the signals are ambiguous or absent, you MUST ask the user directly.
Signal 1: Check the Codebase
Search the user's project for imports and usage patterns that indicate the use case:
GenAI indicators (any of these suggest GenAI):
- Imports from LLM client libraries:
openai, anthropic, google.generativeai, google.genai, langchain, langchain_openai, langgraph, llamaindex, litellm, autogen, crewai, dspy
- Imports from MLflow GenAI modules:
mlflow.genai, mlflow.tracing, mlflow.openai, mlflow.langchain
- Usage of chat completions, embeddings, or agent frameworks
- Prompt templates or prompt engineering code
Traditional ML indicators (any of these suggest ML):
- Imports from ML frameworks:
sklearn, torch, tensorflow, keras, xgboost, lightgbm, catboost, statsmodels, scipy
- Imports from MLflow ML modules:
mlflow.sklearn, mlflow.pytorch, mlflow.tensorflow
- Model training loops,
.fit() calls, hyperparameter tuning code
- Dataset loading with tabular/image/time-series data
# Search for GenAI indicators
grep -rl --include='*.py' -E '(import openai|import anthropic|from langchain|from langgraph|import litellm|from mlflow\.genai|from mlflow\.tracing|mlflow\.openai|mlflow\.langchain|ChatCompletion|chat\.completions)' .
# Search for ML indicators
grep -rl --include='*.py' -E '(from sklearn|import torch|import tensorflow|import keras|import xgboost|import lightgbm|mlflow\.sklearn|mlflow\.pytorch|mlflow\.tensorflow|\.fit\()' .
Signal 2: Check the Experiment Type Tag
If the codebase or project directory is the MLflow repository itself, skip to Signal 3 — the MLflow repo contains code for all use cases and does not indicate the user's intent.
If the experiment ID is known, check its mlflow.experimentKind tag. This tag is set by MLflow to indicate the experiment type:
mlflow experiments get --experiment-id <EXPERIMENT_ID> --output json > /tmp/exp_detail.json
jq -r '.tags["mlflow.experimentKind"] // "not set"' /tmp/exp_detail.json
genai_development → GenAI use case
custom_model_development → Traditional ML use case
- Not set → Proceed to Signal 3
If the experiment ID is not known, skip to Signal 3.
Signal 3: Ask the User
If the codebase and experiment signals are inconclusive, ask directly:
Are you building a GenAI application (e.g., an LLM-powered chatbot, RAG pipeline, or tool-calling agent) or a traditional ML/deep learning model (e.g., training a classifier, regression model, or neural network)?
Do not guess. The onboarding paths are different enough that starting down the wrong one wastes the user's time.
Step 2: Recommend Quickstart Tutorials
Once the use case is determined, recommend the appropriate quickstart tutorials from the MLflow documentation. Present them to the user and ask if they'd like to follow along or jump directly to integrating MLflow into their project.
GenAI Path
The MLflow GenAI documentation is at: https://mlflow.org/docs/latest/genai/getting-started/
Choose the most relevant tutorials based on the user's context and what they've told you. Available tutorials include:
If none of these match the user's needs, look up the MLflow GenAI documentation for more relevant guides.
Traditional ML Path
The MLflow ML documentation is at: https://mlflow.org/docs/latest/ml/getting-started/
Choose the most relevant tutorials based on the user's context and what they've told you. Available tutorials include:
If none of these match the user's needs, look up the MLflow ML documentation for more relevant guides.
Step 3: Integrate MLflow into the User's Project
After the user has reviewed the quickstart tutorials (or opted to skip them), offer to help integrate MLflow directly into their codebase. Always ask for the user's consent before making changes to their code.
GenAI Integration
The core integration for GenAI apps is tracing — capturing LLM calls, tool invocations, and agent steps automatically.
If asked to create an example project: Do not assume the user has LLM API keys (e.g., OpenAI, Anthropic). Instead, create traces with mock data using @mlflow.trace and mlflow.start_span() to demonstrate tracing without requiring external API access. For example:
import mlflow
mlflow.set_experiment("example-genai-app")
@mlflow.trace
def mock_chat(query: str) -> str:
with mlflow.start_span(name="retrieve_context") as span:
context = "Mock retrieved context for: " + query
span.set_inputs({"query": query})
span.set_outputs({"context": context})
with mlflow.start_span(name="generate_response") as span:
response = "Mock response based on: " + context
span.set_inputs({"context": context, "query": query})
span.set_outputs({"response": response})
return response
mock_chat("What is MLflow?")
What to set up (for an existing project):
Autologging — If the user's code uses a supported framework, a single line automatically traces all calls to their LLM provider. See https://mlflow.org/docs/latest/genai/tracing/ for the full list of supported providers. If the provider is supported:
import mlflow
# Pick the one that matches the user's LLM provider:
mlflow.openai.autolog() # OpenAI SDK
mlflow.anthropic.autolog() # Anthropic SDK
mlflow.gemini.autolog() # Google Gemini (google-genai SDK)
mlflow.langchain.autolog() # LangChain / LangGraph
mlflow.litellm.autolog() # LiteLLM
Add this call once at application startup (e.g., top of main.py, app.py, or the entry point module). It must execute before any LLM calls are made.
If the provider is not supported by autologging, skip to step 3 (Custom tracing) and use @mlflow.trace to manually instrument the relevant functions.
Experiment configuration — Set the experiment so traces are organized:
mlflow.set_experiment("my-genai-app")
Or via environment variable: export MLFLOW_EXPERIMENT_NAME="my-genai-app"
Custom tracing (optional) — For functions that aren't automatically traced (custom tools, business logic), use the @mlflow.trace decorator:
@mlflow.trace
def my_custom_tool(query: str) -> str:
# ... tool logic ...
return result
Where to add it: Find the application's entry point or initialization module and add the autologging call there. Search for the main LLM client instantiation (e.g., openai.OpenAI(), ChatOpenAI()) to find the right location.
Prompt Registry (optional) — MLflow can version, store, and load prompts so application code loads a prompt by URI instead of hard-coding the template.
import mlflow
# Register a prompt version
prompt_version = mlflow.genai.register_prompt(
name="my_prompt",
template="Answer the user's question: {{question}}",
)
print(prompt_version.uri) # prompts:/my_prompt/1
# Load it back in application code
prompt = mlflow.genai.load_prompt("prompts:/my_prompt/1")
On Databricks (Unity Catalog): prompts are stored under a UC catalog.schema, so name is a three-part catalog.schema.my_prompt and the workspace must have the Prompt Registry preview enabled (account admin -> Previews -> "Prompt Registry"). On success register_prompt logs a workspace UI link and auto-links the active experiment's Prompts tab to catalog.schema. If that tab is empty after registering, the active experiment was not auto-linked (older mlflow versions do not set this tag automatically). Set it manually:
mlflow.set_experiment_tag(
"mlflow.promptRegistryLocation",
"catalog.schema", # two-part: catalog.schema (no prompt name)
)
Traditional ML Integration
The core integration for ML is experiment tracking — capturing parameters, metrics, and models from training runs.
What to set up:
Autologging — If the user's code uses a supported framework, a single line automatically logs parameters, metrics, and models during training. See https://mlflow.org/docs/latest/ml/ for the full list of supported frameworks. If the framework is supported:
import mlflow
# Pick the one that matches the user's ML framework:
mlflow.sklearn.autolog() # scikit-learn
mlflow.pytorch.autolog() # PyTorch / PyTorch Lightning
mlflow.tensorflow.autolog() # TensorFlow / Keras
mlflow.xgboost.autolog() # XGBoost
mlflow.lightgbm.autolog() # LightGBM
Add this call once before training starts. It automatically captures model.fit() calls, logged metrics, and model artifacts.
If the framework is not supported by autologging, skip to step 3 (Manual logging) and use mlflow.log_param(), mlflow.log_metric(), and mlflow.log_artifact() to log data explicitly.
Experiment configuration — Set the experiment so runs are organized:
mlflow.set_experiment("my-ml-experiment")
Or via environment variable: export MLFLOW_EXPERIMENT_NAME="my-ml-experiment"
Manual logging (optional) — For metrics or parameters not captured by autologging:
with mlflow.start_run():
mlflow.log_param("custom_param", value)
mlflow.log_metric("custom_metric", value)
Where to add it: Find the training script or module where model.fit() (or equivalent) is called. Add the autologging call before the training loop begins.
Verification
After integration, verify that MLflow is capturing data correctly:
GenAI Verification
- Run the application and trigger at least one LLM call
- Check for traces:
mlflow traces search \
--experiment-id <EXPERIMENT_ID> \
--max-results 5 \
--extract-fields 'info.trace_id,info.state,info.request_time' \
--output json > /tmp/verify_traces.json
jq '.traces | length' /tmp/verify_traces.json
- If traces appear, open the MLflow UI to inspect them visually
ML Verification
- Run the training script
- Check for runs:
mlflow runs search \
--experiment-id <EXPERIMENT_ID> \
--max-results 5 \
--output json > /tmp/verify_runs.json
jq '.runs | length' /tmp/verify_runs.json
- If runs appear, open the MLflow UI to inspect logged parameters, metrics, and artifacts
1---2name: mlflow-onboarding3description: Onboards users to MLflow by determining their use case (GenAI agents/apps or traditional ML/deep learning) and guiding them through relevant quickstart tutorials and initial integration. If an experiment ID is available, it should be supplied as input to help determine the use case. Use when the user asks to get started with MLflow, set up tracking, add observability, or integrate MLflow into their project. Triggers on "get started with MLflow", "set up MLflow", "onboard to MLflow", "add MLflow to my project", "how do I use MLflow".4---5
6# MLflow Onboarding
7
8MLflow supports two broad use cases that require different onboarding paths:
9
10- **GenAI applications and agents**: LLM-powered apps, chatbots, RAG pipelines, tool-calling agents. Key MLflow features include **tracing** for observability, **evaluation** with LLM judges, and **prompt management**, among others.
11- **Traditional ML / deep learning models**: scikit-learn, PyTorch, TensorFlow, XGBoost, etc. Key MLflow features include **experiment tracking** (parameters, metrics, artifacts), **model logging**, and **model deployment**, among others.
12
13Determining which use case applies is the first and most important step. The onboarding path, quickstart tutorials, and integration steps differ significantly between the two.
14
15## Step 1: Determine the Use Case
16
17Before recommending tutorials or integration steps, determine which use case the user is working on. Use the signals below, checking them in order. **If the signals are ambiguous or absent, you MUST ask the user directly.**
18
19### Signal 1: Check the Codebase
20
21Search the user's project for imports and usage patterns that indicate the use case:
22
23**GenAI indicators** (any of these suggest GenAI):
24- Imports from LLM client libraries: `openai`, `anthropic`, `google.generativeai`, `google.genai`, `langchain`, `langchain_openai`, `langgraph`, `llamaindex`, `litellm`, `autogen`, `crewai`, `dspy`
25- Imports from MLflow GenAI modules: `mlflow.genai`, `mlflow.tracing`, `mlflow.openai`, `mlflow.langchain`
26- Usage of chat completions, embeddings, or agent frameworks
27- Prompt templates or prompt engineering code
28
29**Traditional ML indicators** (any of these suggest ML):
30- Imports from ML frameworks: `sklearn`, `torch`, `tensorflow`, `keras`, `xgboost`, `lightgbm`, `catboost`, `statsmodels`, `scipy`
31- Imports from MLflow ML modules: `mlflow.sklearn`, `mlflow.pytorch`, `mlflow.tensorflow`
32- Model training loops, `.fit()` calls, hyperparameter tuning code
33- Dataset loading with tabular/image/time-series data
34
35```bash
36# Search for GenAI indicators
37grep -rl --include='*.py' -E '(import openai|import anthropic|from langchain|from langgraph|import litellm|from mlflow\.genai|from mlflow\.tracing|mlflow\.openai|mlflow\.langchain|ChatCompletion|chat\.completions)' .
38
39# Search for ML indicators
40grep -rl --include='*.py' -E '(from sklearn|import torch|import tensorflow|import keras|import xgboost|import lightgbm|mlflow\.sklearn|mlflow\.pytorch|mlflow\.tensorflow|\.fit\()' .
41```
42
43### Signal 2: Check the Experiment Type Tag
44
45If the codebase or project directory is the MLflow repository itself, skip to Signal 3 — the MLflow repo contains code for all use cases and does not indicate the user's intent.
46
47If the experiment ID is known, check its `mlflow.experimentKind` tag. This tag is set by MLflow to indicate the experiment type:
48
49```bash
50mlflow experiments get --experiment-id <EXPERIMENT_ID> --output json > /tmp/exp_detail.json
51jq -r '.tags["mlflow.experimentKind"] // "not set"' /tmp/exp_detail.json
52```
53
54- **`genai_development`** → GenAI use case
55- **`custom_model_development`** → Traditional ML use case
56- **Not set** → Proceed to Signal 3
57
58If the experiment ID is not known, skip to Signal 3.
59
60### Signal 3: Ask the User
61
62If the codebase and experiment signals are inconclusive, ask directly:
63
64> Are you building a **GenAI application** (e.g., an LLM-powered chatbot, RAG pipeline, or tool-calling agent) or a **traditional ML/deep learning model** (e.g., training a classifier, regression model, or neural network)?
65
66**Do not guess.** The onboarding paths are different enough that starting down the wrong one wastes the user's time.
67
68## Step 2: Recommend Quickstart Tutorials
69
70Once the use case is determined, recommend the appropriate quickstart tutorials from the MLflow documentation. Present them to the user and ask if they'd like to follow along or jump directly to integrating MLflow into their project.
71
72### GenAI Path
73
74The MLflow GenAI documentation is at: https://mlflow.org/docs/latest/genai/getting-started/
75
76Choose the most relevant tutorials based on the user's context and what they've told you. Available tutorials include:
77
78- **Tracing Quickstart** (https://mlflow.org/docs/latest/genai/tracing/quickstart/) — Enabling automatic tracing for LLM calls. Covers starting an MLflow server, creating an experiment, enabling autologging, and viewing traces in the UI.
79 - Python + OpenAI variant: https://mlflow.org/docs/latest/genai/tracing/quickstart/python-openai/
80 - TypeScript + OpenAI variant: https://mlflow.org/docs/latest/genai/tracing/quickstart/typescript-openai
81 - OpenTelemetry (language-agnostic) variant: also linked from the quickstart page
82- **Evaluation Quickstart** (https://mlflow.org/docs/latest/genai/eval-monitor/quickstart/) — Evaluating GenAI application quality using LLM judges (scorers). Covers defining datasets, prediction functions, and built-in + custom scorers.
83- **Version Tracking Quickstart** (https://mlflow.org/docs/latest/genai/version-tracking/quickstart/) — Prompt management, application versioning, and connecting tracing to versioned prompts.
84
85If none of these match the user's needs, look up the MLflow GenAI documentation for more relevant guides.
86
87### Traditional ML Path
88
89The MLflow ML documentation is at: https://mlflow.org/docs/latest/ml/getting-started/
90
91Choose the most relevant tutorials based on the user's context and what they've told you. Available tutorials include:
92
93- **Tracking Quickstart** (https://mlflow.org/docs/latest/ml/tracking/quickstart/) — Experiment tracking with scikit-learn: autologging, manual parameter/metric/model logging, and exploring results in the MLflow UI.
94- **Deep Learning Tutorial** (https://mlflow.org/docs/latest/ml/getting-started/deep-learning/) — Training a PyTorch model with MLflow logging: parameters, metrics, checkpoints, and system metrics (GPU utilization, memory).
95- **Hyperparameter Tuning Tutorial** (https://mlflow.org/docs/latest/ml/getting-started/hyperparameter-tuning/) — Running hyperparameter searches with Optuna + MLflow, comparing results, and selecting the best model.
96
97If none of these match the user's needs, look up the MLflow ML documentation for more relevant guides.
98
99## Step 3: Integrate MLflow into the User's Project
100
101After the user has reviewed the quickstart tutorials (or opted to skip them), offer to help integrate MLflow directly into their codebase. **Always ask for the user's consent before making changes to their code.**
102
103### GenAI Integration
104
105The core integration for GenAI apps is **tracing** — capturing LLM calls, tool invocations, and agent steps automatically.
106
107**If asked to create an example project:** Do not assume the user has LLM API keys (e.g., OpenAI, Anthropic). Instead, create traces with mock data using `@mlflow.trace` and `mlflow.start_span()` to demonstrate tracing without requiring external API access. For example:
108
109```python
110import mlflow
111
112mlflow.set_experiment("example-genai-app")
113
114@mlflow.trace
115def mock_chat(query: str) -> str:
116 with mlflow.start_span(name="retrieve_context") as span:
117 context = "Mock retrieved context for: " + query
118 span.set_inputs({"query": query})
119 span.set_outputs({"context": context})
120 with mlflow.start_span(name="generate_response") as span:
121 response = "Mock response based on: " + context
122 span.set_inputs({"context": context, "query": query})
123 span.set_outputs({"response": response})
124 return response
125
126mock_chat("What is MLflow?")
127```
128
129**What to set up (for an existing project):**
130
1311. **Autologging** — If the user's code uses a supported framework, a single line automatically traces all calls to their LLM provider. See https://mlflow.org/docs/latest/genai/tracing/ for the full list of supported providers. If the provider is supported:
132
133 ```python
134 import mlflow
135
136 # Pick the one that matches the user's LLM provider:
137 mlflow.openai.autolog() # OpenAI SDK
138 mlflow.anthropic.autolog() # Anthropic SDK
139 mlflow.gemini.autolog() # Google Gemini (google-genai SDK)
140 mlflow.langchain.autolog() # LangChain / LangGraph
141 mlflow.litellm.autolog() # LiteLLM
142 ```
143
144 Add this call once at application startup (e.g., top of `main.py`, `app.py`, or the entry point module). It must execute before any LLM calls are made.
145
146 If the provider is **not** supported by autologging, skip to step 3 (Custom tracing) and use `@mlflow.trace` to manually instrument the relevant functions.
147
1482. **Experiment configuration** — Set the experiment so traces are organized:
149
150 ```python
151 mlflow.set_experiment("my-genai-app")
152 ```
153
154 Or via environment variable: `export MLFLOW_EXPERIMENT_NAME="my-genai-app"`
155
1563. **Custom tracing** (optional) — For functions that aren't automatically traced (custom tools, business logic), use the `@mlflow.trace` decorator:
157
158 ```python
159 @mlflow.trace
160 def my_custom_tool(query: str) -> str:
161 # ... tool logic ...
162 return result
163 ```
164
165**Where to add it:** Find the application's entry point or initialization module and add the autologging call there. Search for the main LLM client instantiation (e.g., `openai.OpenAI()`, `ChatOpenAI()`) to find the right location.
166
1674. **Prompt Registry** (optional) — MLflow can version, store, and load prompts so application code loads a prompt by URI instead of hard-coding the template.
168
169 ```python
170 import mlflow
171
172 # Register a prompt version
173 prompt_version = mlflow.genai.register_prompt(
174 name="my_prompt",
175 template="Answer the user's question: {{question}}",
176 )
177 print(prompt_version.uri) # prompts:/my_prompt/1
178
179 # Load it back in application code
180 prompt = mlflow.genai.load_prompt("prompts:/my_prompt/1")
181 ```
182
183 **On Databricks (Unity Catalog):** prompts are stored under a UC `catalog.schema`, so `name` is a three-part `catalog.schema.my_prompt` and the workspace must have the Prompt Registry preview enabled (account admin -> Previews -> "Prompt Registry"). On success `register_prompt` logs a workspace UI link and auto-links the active experiment's Prompts tab to `catalog.schema`. If that tab is empty after registering, the active experiment was not auto-linked (older mlflow versions do not set this tag automatically). Set it manually:
184
185 ```python
186 mlflow.set_experiment_tag(
187 "mlflow.promptRegistryLocation",
188 "catalog.schema", # two-part: catalog.schema (no prompt name)
189 )
190 ```
191
192### Traditional ML Integration
193
194The core integration for ML is **experiment tracking** — capturing parameters, metrics, and models from training runs.
195
196**What to set up:**
197
1981. **Autologging** — If the user's code uses a supported framework, a single line automatically logs parameters, metrics, and models during training. See https://mlflow.org/docs/latest/ml/ for the full list of supported frameworks. If the framework is supported:
199
200 ```python
201 import mlflow
202
203 # Pick the one that matches the user's ML framework:
204 mlflow.sklearn.autolog() # scikit-learn
205 mlflow.pytorch.autolog() # PyTorch / PyTorch Lightning
206 mlflow.tensorflow.autolog() # TensorFlow / Keras
207 mlflow.xgboost.autolog() # XGBoost
208 mlflow.lightgbm.autolog() # LightGBM
209 ```
210
211 Add this call once before training starts. It automatically captures `model.fit()` calls, logged metrics, and model artifacts.
212
213 If the framework is **not** supported by autologging, skip to step 3 (Manual logging) and use `mlflow.log_param()`, `mlflow.log_metric()`, and `mlflow.log_artifact()` to log data explicitly.
214
2152. **Experiment configuration** — Set the experiment so runs are organized:
216
217 ```python
218 mlflow.set_experiment("my-ml-experiment")
219 ```
220
221 Or via environment variable: `export MLFLOW_EXPERIMENT_NAME="my-ml-experiment"`
222
2233. **Manual logging** (optional) — For metrics or parameters not captured by autologging:
224
225 ```python
226 with mlflow.start_run():
227 mlflow.log_param("custom_param", value)
228 mlflow.log_metric("custom_metric", value)
229 ```
230
231**Where to add it:** Find the training script or module where `model.fit()` (or equivalent) is called. Add the autologging call before the training loop begins.
232
233## Verification
234
235After integration, verify that MLflow is capturing data correctly:
236
237### GenAI Verification
238
2391. Run the application and trigger at least one LLM call
2402. Check for traces:
241 ```bash
242 mlflow traces search \
243 --experiment-id <EXPERIMENT_ID> \
244 --max-results 5 \
245 --extract-fields 'info.trace_id,info.state,info.request_time' \
246 --output json > /tmp/verify_traces.json
247 jq '.traces | length' /tmp/verify_traces.json
248 ```
2493. If traces appear, open the MLflow UI to inspect them visually
250
251### ML Verification
252
2531. Run the training script
2542. Check for runs:
255 ```bash
256 mlflow runs search \
257 --experiment-id <EXPERIMENT_ID> \
258 --max-results 5 \
259 --output json > /tmp/verify_runs.json
260 jq '.runs | length' /tmp/verify_runs.json
261 ```
2623. If runs appear, open the MLflow UI to inspect logged parameters, metrics, and artifacts