How to Load a Registered Model by Alias in MLflow
Code that serves a model shouldn't need a change every time a better version is registered. With an alias, it doesn't: it loads models:/<name>@<alias>, and MLflow hands it whichever version the alias points to at that moment. This guide loads a model by alias, moves the alias, and loads again with the same line. Real output from MLflow 3.18.0.
Syntax
model = mlflow.pyfunc.load_model("models:/registered-model-name@alias")
| Part | What it means |
|---|---|
registered-model-name | The registered model |
alias | The alias, such as production or champion |
model | The version the alias points to, ready to predict |
MLflow's Model Registry workflows page: "To fetch a model version by alias, specify the model alias in the model URI, and it will fetch the model version currently under it." The same address works with each flavor's load_model, such as mlflow.sklearn.load_model.
Prerequisites
- An MLflow tracking server with a database backend at
http://127.0.0.1:8080, such asmlflow server --port 8080with its default SQLite database. The registry needs one. mlflowandscikit-learnin your project, for example withuv add mlflow scikit-learn pandas.
Step 1: Load by Alias, Move the Alias, Load Again
The example registers two versions of a model that predicts how far diabetes progresses in a year: a linear regression, then a ridge regression. It points production at version 1 and loads models:/diabetes-progression@production, then points production at version 2 and loads the same address:

import mlflow
from mlflow import MlflowClient
from sklearn.datasets import load_diabetes
from sklearn.linear_model import LinearRegression, Ridge
mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("load-by-alias-example")
client = MlflowClient()
name = "diabetes-progression"
X, y = load_diabetes(return_X_y=True, as_frame=True)
for model in (LinearRegression(), Ridge(alpha=1.0)): # versions 1 and 2
model.fit(X, y)
with mlflow.start_run():
mlflow.sklearn.log_model(model, name="model", registered_model_name=name, input_example=X.head(3))
patients = X.head(2)
client.set_registered_model_alias(name, "production", "1")
model = mlflow.pyfunc.load_model(f"models:/{name}@production")
print("@production on version 1:", model.predict(patients).round(1))
client.set_registered_model_alias(name, "production", "2")
model = mlflow.pyfunc.load_model(f"models:/{name}@production")
print("@production on version 2:", model.predict(patients).round(1))
uv run python load_by_alias.py
@production on version 1: [206.1 68.1]
@production on version 2: [182.7 91. ]

The same address gave different predictions: 206.1 and 68.1 from the linear regression, then 182.7 and 91 from the ridge regression, once the alias pointed to it. The loading code never changed; only the alias moved.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Loading the model once and keeping it for months | A moved alias isn't picked up until the next load | Load again when you want the current version, such as at each start |
| Logging only the alias | You can't tell later which version made a prediction | Look the version up first and log its number |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The address loads an old version | The alias wasn't moved, or the model was loaded before it moved | Check the alias, then load again |
INVALID_PARAMETER_VALUE: Registered model alias production not found. | The alias doesn't exist on that registered model | Set it first, or check its spelling |
FAQ
How do I know which version the alias gave me?
Ask the registry before loading: client.get_model_version_by_alias(name, "production").version. How to Find Which Version an Alias Points To in MLflow shows it.
Can I load a fixed version instead?
Yes, with models:/<name>/<version>: How to Load a Specific Version of a Registered Model in MLflow.
Conclusion
mlflow.pyfunc.load_model("models:/diabetes-progression@production") loaded version 1 while production pointed to it and version 2 after the alias moved, with no change to the loading code.
Additional Resources
- Model Registry workflows — fetching a model version by alias.
- mlflow.pyfunc.load_model — the model addresses it accepts.
