[mlflow Series 6] mlflow model registry

Time:2021-7-22

What is it?

This paper is based on mlflow version 1.11.0
just asOfficial websiteWhat I said:

The MLflow Model Registry component is a centralized model store, set of APIs, and UI, to collaboratively manage the full lifecycle of an MLflow Model. It provides model lineage (which MLflow experiment and run produced the model), model versioning, stage transitions (for example from staging to production), and annotations

Model registry is a centralized model storage, APIs and UI, which is used to manage the model in the whole cycle. It can provide a model blood relationship, model version, and model phase switch.

What can it do? Let’s look at the frontMlflow Series 1In this article, if we don’t use model registry, we have to start the service in the following way:

 export MLFLOW_TRACKING_URI=http://localhost:5002        
  mlflow models serve -m runs:/e69aed0b22fb45debd115dfc09dbc75a/model -p 1234 --no-conda       

Here we have to provide run_ The ID is e69aed0b22fb45debd115dfc09dbc75a
If we use model registry, we can start the service in the following way:

export MLFLOW_TRACKING_URI=http://localhost:5002

mlflow models serve -m "models:/sk-learn-random-forest-reg-model/Production"

Sk learn random forest reg model is the name of the model, and production is the stage stage. We will introduce the details in the next section
What is the specific effect
Model registry allows us to start a service without specifying run_ ID. in this way, we don’t need to find run every time we start the service_ ID. in this way, we don’t need to modify the file every time we restart. It’s a lot more convenient for algorithmers. Moreover, model registry logically divides the stages and can switch stages. In this way, when we manage the model, we can intuitively know which model the current algorithm service is based on

How to operate

Now let’s demonstrate how to operate the model registry, assuming that we have followed theMlflow Series 1We have operated on Python wine.py for many times, so that we can see multiple versions of an experiment on the interface, as follows:
[mlflow Series 6] mlflow model registry

Click the registry model as follows:
[mlflow Series 6] mlflow model registry

In this way, we can register the model, and the name of the model (assuming we call it wine here) can be entered by ourselves

Click wine,

[mlflow Series 6] mlflow model registry

Click version 3,

[mlflow Series 6] mlflow model registry
In this way, we can switch stages. The default stage is none,
Staging indicates the preparation phase, production indicates the online environment phase, and archived indicates the archive phase, that is, the abandoned state
[mlflow Series 6] mlflow model registry
We can also delete the model
[mlflow Series 6] mlflow model registry
Of course, you can also delete a specific version of the model. Just click the version, and then the deletion position is the same as the above position

In this way, we can start and access the service in the following way, without caring about the specific run_ ID, just switch stage to production on the interface

#Start the service
mlflow models serve -m "models:/wine/Production" -p 12346 -h 0.0.0.0 --no-conda
#Access services
curl -X POST -H "Content-Type:application/json; format=pandas-split" --data '{"columns":["alcohol", "chlorides", "citric acid", "density", "fixed acidity", "free sulfur dioxide", "pH", "residual sugar", "sulphates", "total sulfur dioxide", "volatile acidity"],"data":[[12.8, 0.029, 0.48, 0.98, 6.2, 29, 3.33, 1.2, 0.39, 75, 0.66]]}' http://localhost:12346/invocations

So far, the main part of mlflow model registry has been introduced