Back to the Index

Model Registry

What is a model registry?

A model registry is a version control system for models that provides APIs to store and retrieve models and model-related artifacts. A model registry stores different versions of models, including metadata about their performance metrics, author, creation date, dependencies, usage, and lineage (training experiment code/hyperparameters and /training data).

When is a model registry needed?

Model registries are recommended for projects involving ML pipelines and/or those that require stringent governance, traceability, and management. The model registry stores the models and their metadata as the output of training pipelines, decoupling training pipelines from inference pipelines. Inference pipelines download a versioned model from the model registry during initialization, and keep it cached (this is safe, as models are immutable) for inference requests. In general, a model registry enables better collaboration, versioning, and organization of models in MLOps.

Examples of a model registry

Some model registries provide a unified API for storing and retrieving models and their metadata, such as Hopsworks, Sagemaker, and Weights & Biases, while others, such as MLFlow, separate the metadata store for model metadata from an artifact store, where the serialized models are stored.

Example code for registering a Scikit-Learn model to Hopsworks is shown below:

 from hsml.schema import Schema
from hsml.model_schema import ModelSchema

input_schema = Schema(X_train)  # take schema from train-set features DataFrame
output_schema = Schema(y_train) # take schema from train-set labels DataFrame

fraud_model = mr.sklearn.create_model("the_model",
                                      # 'accuracy' for the model is computed on the test set
                                      metrics={'accuracy': accuracy},
                                      # 'input_example' is used as a test row for a deployment
                                      input_example=X_train.sample().to_numpy(), 
                                      model_schema=ModelSchema(input_schema=input_schema, output_schema=output_schema))
fraud_model.save('the_model')
Does this content look outdated? If you are interested in helping us maintain this, feel free to contact us.