MLflow Model Registry
Managing MLFlow logged models and artifacts
When would you want to use it?
You can use the MLflow model registry throughout your experimentation, QA, and production phases to manage and track machine learning model versions. It is designed to help teams collaborate on model development and deployment, and keep track of which models are being used in which environments. With the MLflow model registry, you can store and manage models, deploy them to different environments, and track their performance over time.
This is particularly useful in the following scenarios:
If you are working on a machine learning project and want to keep track of different model versions as they are developed and deployed.
If you need to deploy machine learning models to different environments and want to keep track of which version is being used in each environment.
If you want to monitor and compare the performance of different model versions over time and make data-driven decisions about which models to use in production.
If you want to simplify the process of deploying models either to a production environment or to a staging environment for testing.
How do you deploy it?
Once the MLflow integration is installed, you can register an MLflow model registry component in your stack:
The MLFlow model registry will automatically use the same configuration as the MLFlow Experiment Tracker. So if you have a remote MLFlow tracking server configured in your stack, the MLFlow model registry will also use the same configuration.
How do you use it?
There are different ways to use the MLflow model registry. You can use it in your ZenML pipelines with the built-in step, or you can use the ZenML CLI to register your model manually or call the model registry API within a custom step in your pipeline. The following sections show you how to use the MLflow model registry in your ZenML pipelines and with the ZenML CLI:
Register models inside a pipeline
ZenML provides a predefined mlflow_model_deployer_step
that you can use to register a model in the MLflow model registry which you have previously logged to MLflow:
List of available parameters
When using the mlflow_register_model_step
, you can set a variety of parameters for fine-grained control over which information is logged with your model:
name
: The name of the model. This is a required parameter.version
: version: The version of the model.trained_model_name
: Name of the model artifact in MLflow.model_source_uri
: The path to the model. If not provided, the model will be fetched from the MLflow tracking server via thetrained_model_name
.description
: A description of the model version.metadata
: A list of metadata to associate with the model version.
The model_source_uri
parameter is the path to the model within the MLflow tracking server.
If you are using a local MLflow tracking server, the path will be something like file:///.../mlruns/667102566783201219/3973eabc151c41e6ab98baeb20c5323b/artifacts/model
.
If you are using a remote MLflow tracking server, the path will be something like s3://.../mlruns/667102566783201219/3973eabc151c41e6ab98baeb20c5323b/artifacts/model
.
You can find the path of the model in the MLflow UI. Go to the Artifacts
tab of the run that produced the model and click on the model. The path will be displayed in the URL:
Register models via the CLI
Sometimes adding a mlflow_registry_training_pipeline
step to your pipeline might not be the best option for you, as it will register a model in the MLflow model registry every time you run the pipeline.
If you want to register your models manually, you can use the zenml model-registry models register-version
CLI command instead:
Deploy a registered model
Interact with registered models
You can also use the ZenML CLI to interact with registered models and their versions.
The zenml model-registry models list
command will list all registered models in the model registry:
To list all versions of a specific model, you can use the zenml model-registry models list-versions REGISTERED_MODEL_NAME
command:
For more details on a specific model version, you can use the zenml model-registry models get-version REGISTERED_MODEL_NAME -v VERSION
command:
Finally, to delete a registered model or a specific model version, you can use the zenml model-registry models delete REGISTERED_MODEL_NAME
and zenml model-registry models delete-version REGISTERED_MODEL_NAME -v VERSION
commands respectively.
Last updated