Skip to main content

How to Add an Input Example to an MLflow Model

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

An input example is a few rows of real input, saved with the model. Anyone who loads the model later sees exactly what it expects, MLflow infers the signature from it, and it writes a ready-made request body for the model's REST API. One argument to log_model does all three. This guide adds one, with real output and files from MLflow 3.18.0.

Syntax​

Syntax
mlflow.sklearn.log_model(sk_model, name="...", input_example=rows)
PartWhat it means
input_example=rowsA few rows of valid input, such as X.head(3)

With it, MLflow:

  • saves the rows as input_example.json, and the same rows as a REST API request as serving_input_example.json;
  • infers the model's signature from the rows, when you don't pass signature= yourself.

MLflow's reference: "If an input example is provided when logging a model, a model signature will be automatically inferred and stored if not explicitly provided."

Prerequisites​

  • An MLflow tracking server at http://127.0.0.1:8080. MLflow's tracking server guide shows how to start one.
  • mlflow and scikit-learn in your project, for example with uv add mlflow scikit-learn pandas.

Step 1: Log a Model with an Input Example​

The example logs a linear regression trained on scikit-learn's diabetes data, with its first three rows as the example, and prints the signature MLflow inferred:

The input_example.py script in a macOS-style code window: it fits a LinearRegression to the diabetes data, logs it named diabetes-model with input_example set to X.head(3), and prints model_info.signature.

input_example.py
import mlflow
from sklearn.datasets import load_diabetes
from sklearn.linear_model import LinearRegression

mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("input-example-demo")

X, y = load_diabetes(return_X_y=True, as_frame=True)
model = LinearRegression().fit(X, y)

with mlflow.start_run():
model_info = mlflow.sklearn.log_model(model, name="diabetes-model", input_example=X.head(3))

print(model_info.signature)
Terminal
uv run python input_example.py
Output
2026/11/21 14:12:09 INFO mlflow.tracking.fluent: Experiment with name 'input-example-demo' does not exist. Creating a new experiment.
2026/11/21 14:12:10 INFO mlflow.utils.uv_utils: Detected uv project: found uv.lock and pyproject.toml in /Users/you/source/mlflow-demo
2026/11/21 14:12:10 INFO mlflow.utils.uv_utils: Detected uv project: found uv.lock and pyproject.toml in /Users/you/source/mlflow-demo
2026/11/21 14:12:10 INFO mlflow.utils.environment: Detected uv project at /Users/you/source/mlflow-demo. Attempting to export requirements via 'uv export'.
2026/11/21 14:12:10 INFO mlflow.utils.uv_utils: Exported 91 dependencies via uv
2026/11/21 14:12:10 INFO mlflow.utils.environment: Successfully exported 91 requirements from uv project. Skipping package capture based inference.
🏃 View run classy-shrew-577 at: http://127.0.0.1:8080/#/experiments/6/runs/5cbb0f33406b46b0b45bc8a17000477d
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/6
inputs:
['age': double (required), 'sex': double (required), 'bmi': double (required), 'bp': double (required), 's1': double (required), 's2': double (required), 's3': double (required), 's4': double (required), 's5': double (required), 's6': double (required)]
outputs:
[double (required)]
params:
None

The output of input_example.py in a terminal: MLflow exports the requirements and links the run, then the inferred signature lists the ten diabetes columns as double and required, and one double output.

No signature= was passed, yet the model has one: the ten input columns, read from the example rows, and the output, read from the model's predictions for them.

Step 2: Open the Example Files​

Open the model from the experiment's Models tab, then its Artifacts tab, and click input_example.json:

The model's Artifacts tab with input_example.json open: the files now include input_example.json and serving_input_example.json, and the file shows the ten column names followed by the first row of values.

Two files are new, compared with a model logged without an example:

  • input_example.json: the three rows, as column names and rows of values (pandas' "split" layout).
  • serving_input_example.json: the same rows wrapped as a request to the model's REST API, under a dataframe_split key:
serving_input_example.json (excerpt)
{
"dataframe_split": {
"columns": [
"age",
"sex",
"bmi",
"bp",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6"
],
"data": [
[
0.038075906433423026,
0.05068011873981862,
0.061696206518683294,
0.0218723855140367,
-0.04422349842444599,
-0.03482076283769895,
-0.04340084565202491,

MLmodel records both under saved_input_example_info. You can send serving_input_example.json as it is to a model served by MLflow, or test the model with it in a fresh environment, as in How to Test an MLflow Model in a Fresh Environment.

Common Mistakes​

MistakeWhat happensDo this instead
Passing the whole training set as the exampleIt's stored with the model, every row of itA few rows, such as X.head(3)
Relying on the inferred signature for a model that returns probabilitiesIt's inferred from predict, not from the probabilitiesPass the signature yourself

Troubleshooting​

SymptomLikely causeFix
UserWarning: Hint: Inferred schema contains integer column(s)...Whole-number columns in the example, or whole-number predictionsFixed: Hint: Inferred schema contains integer column(s)
No input_example.json in the model's filesThe model was logged without input_exampleLog it again with one

FAQ​

What's the difference between the two files?​

input_example.json is the rows; serving_input_example.json is a request body for the REST API, the rows inside dataframe_split.

Do I still need infer_signature?​

Not when the example is enough to describe input and output. Pass signature= yourself when the model's output isn't what predict returns.

Conclusion​

log_model(..., input_example=X.head(3)) saved three rows as input_example.json and a REST request as serving_input_example.json, and MLflow inferred the signature from them, with no infer_signature call in the script.

Additional Resources​