Skip to main content

How to Add a Signature to an MLflow Model

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A model's signature is its contract: the columns it expects, their types, and what it returns. MLflow saves it with the model and checks every prediction's input against it, so wrong data is refused with a clear message instead of a wrong answer. mlflow.models.infer_signature builds one from your data. This guide adds one to a scikit-learn model, with real output from MLflow 3.18.0.

Syntax​

Syntax
signature = infer_signature(model_input, model_output)
mlflow.sklearn.log_model(sk_model, name="...", signature=signature)
PartWhat it means
infer_signaturemlflow.models.infer_signature: reads the column names and types of the input, and the type and shape of the output
model_inputData the model takes, such as the training features
model_outputWhat the model returns for that data, such as model.predict(model_input)
signature=signatureSaves the signature with the model, in its MLmodel file

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: Infer the Signature and Log It​

The example fits a linear regression to scikit-learn's diabetes data, infers the signature from the training features and the model's predictions, prints it and logs it with the model:

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

signature.py
import mlflow
from mlflow.models import infer_signature
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("signature-demo")

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

signature = infer_signature(X, model.predict(X))
print(signature)

with mlflow.start_run():
mlflow.sklearn.log_model(model, name="diabetes-model", signature=signature)
Terminal
uv run python signature.py
Output
2026/11/21 14:12:05 INFO mlflow.tracking.fluent: Experiment with name 'signature-demo' does not exist. Creating a new experiment.
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:
[Tensor('float64', (-1,))]
params:
None

2026/11/21 14:12:05 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:05 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:05 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:05 INFO mlflow.utils.uv_utils: Exported 91 dependencies via uv
2026/11/21 14:12:05 INFO mlflow.utils.environment: Successfully exported 91 requirements from uv project. Skipping package capture based inference.
🏃 View run redolent-kit-275 at: http://127.0.0.1:8080/#/experiments/5/runs/3494174d9b6c429a9a424335ac0f6eea
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/5

The output of signature.py in a terminal: the signature's inputs list the ten diabetes columns, age to s6, each double and required; outputs are a float64 tensor of shape (-1,); params None; then MLflow exports the requirements and links the run.

The signature has three parts:

  • inputs: one entry per column, with its name and type. All ten diabetes columns are decimals, so all are double, and required, because none has a missing value.
  • outputs: Tensor('float64', (-1,)). predict returns a NumPy array, so the output is described as a tensor of decimals; -1 means any number of rows.
  • params: settings passed at prediction time. This model takes none.

Step 2: See It in the MLmodel File​

The signature lives in the model's MLmodel file. Open the model from the experiment's Models tab, then its Artifacts tab:

The model's Artifacts tab with MLmodel open: after the flavors and IDs, a signature section with inputs listing each diabetes column as double and required, and outputs as a float64 tensor of shape -1.

MLmodel (excerpt)
signature:
inputs: '[{"type": "double", "name": "age", "required": true}, {"type": "double",
"name": "sex", "required": true}, {"type": "double", "name": "bmi", "required":
true}, {"type": "double", "name": "bp", "required": true}, {"type": "double",
"name": "s1", "required": true}, {"type": "double", "name": "s2", "required":
true}, {"type": "double", "name": "s3", "required": true}, {"type": "double",
"name": "s4", "required": true}, {"type": "double", "name": "s5", "required":
true}, {"type": "double", "name": "s6", "required": true}]'
outputs: '[{"type": "tensor", "tensor-spec": {"dtype": "float64", "shape": [-1]}}]'
params: null

Whenever the model is loaded as a Python function, MLflow checks the input against these lines first: How to Check Data Against an MLflow Model's Signature shows what it accepts and refuses.

Common Mistakes​

MistakeWhat happensDo this instead
Inferring from data with whole-number columnsMLflow warns about integer columns, and a missing value later is refusedFixed: Hint: Inferred schema contains integer column(s)
Inferring the output from predict when the model returns probabilitiesThe signature describes labels the model never returnsFixed: MLflow Signature Says long for a predict_proba Model

Troubleshooting​

SymptomLikely causeFix
UserWarning: Hint: Inferred schema contains integer column(s)...Whole-number columns in model_inputRead them as decimals before inferring
A model has no signature section in MLmodelIt was logged without a signature or input exampleLog it again with signature=

FAQ​

Can MLflow infer the signature for me?​

Yes: give log_model an input example instead, as in How to Add an Input Example to an MLflow Model. MLflow then infers the signature from it.

What does required mean?​

That the column must be present in every prediction's input. MLflow's guide: "Required fields: Must be present or validation fails".

Conclusion​

infer_signature(X, model.predict(X)) described the model's ten double input columns and its float64 output, and log_model(signature=...) saved that contract in the model's MLmodel file, where every future prediction is checked against it.

Additional Resources​