Model Registry
You've trained a great model. How does the software engineering team actually get it to put it on the website? A Model Registry is the central 'app store' for your company's models, handling stages like Staging, Production, and Archive.
Why Does This Exist?
When a data scientist finishes training a model, they have a file (e.g., fraud_model_v4.pkl). How does that file get to the backend engineering team so they can build an API around it?
Traditionally, the data scientist would email the file, drop it in a shared Slack channel, or upload it to a random S3 bucket. This creates chaos. Which bucket? Which version is actually live on the website right now? If the website crashes, how do we roll back to the previous model?
A Model Registry solves this. It is a centralized repository—like NPM for JavaScript packages or DockerHub for containers—specifically built for Machine Learning models.
Think of It Like This
Think of It Like This
Imagine a pharmaceutical company inventing a new drug. The chemists test hundreds of formulas in the lab (Experiment Tracking). Eventually, they find a formula that works and lock down the exact recipe (Model Versioning). But they can't just throw the recipe out the window to the factory. They put the final recipe into a secure, heavily-audited Vault. The factory managers look at the Vault to see which recipe is currently approved for "Mass Production." The Vault is the Model Registry.
How It Actually Works
A Model Registry provides three core features:
1. Centralized Storage
It acts as the single source of truth for all model artifacts. When an ML Pipeline finishes successfully, it pushes the model to the registry under a specific name, like Customer_Churn_Model_v4.
2. Lifecycle Stages
Models don't just exist; they have a lifecycle. A registry tracks the state of every model version. The standard stages are:
- None: The model was just uploaded.
- Staging: The model is currently being tested by the QA team or running in a shadow deployment.
- Production: This is the model currently serving live user traffic.
- Archived: The model was deprecated and is no longer used.
3. Approvals and Governance
You do not want a junior data scientist accidentally pushing a broken model directly to Production. Registries allow you to set up CI/CD approval workflows. For example, a model can only move from Staging to Production if two senior engineers click "Approve" in the UI.
Show Me the Code
Here is how you use MLflow's Model Registry via Python. Usually, this code runs automatically at the very end of your ML Pipeline DAG.
import mlflowfrom mlflow import MlflowClient
client = MlflowClient()model_name = "Fraud_Detection_XGBoost"
# 1. Register a model (this creates Version 1 if it didn't exist)# (Assuming you already trained it and have a run_id from Experiment Tracking)result = mlflow.register_model( f"runs:/{run_id}/model", model_name)print(f"Registered {model_name} as Version {result.version}")
# 2. Transition the model to Staging for testingclient.transition_model_version_stage( name=model_name, version=result.version, stage="Staging")
# ... Imagine weeks of QA testing happen here ...
# 3. Promote to Production (and automatically archive the old production model)client.transition_model_version_stage( name=model_name, version=result.version, stage="Production", archive_existing_versions=True)
print(f"Version {result.version} is now LIVE in Production!")Watch Out For
Watch Out For
Confusing the Registry with the Tracker. People often confuse Experiment Tracking with the Model Registry.
- The Tracker contains every single garbage model you tried to train (hundreds of runs per day).
- The Registry contains ONLY the polished, finalized models that you actually intend to deploy (maybe one per week). If you push every single experiment to the Registry, you defeat its purpose as a curated, governed release mechanism.
The Quick Version
- A Model Registry is the central repository where finalized ML models are stored and managed.
- It bridges the gap between Data Science (who build the models) and Software Engineering (who deploy them).
- It tracks the Lifecycle Stages of a model (None Staging Production Archived).
- It provides strict governance, requiring approvals before a model can serve live user traffic.
What to Read Next
rest-api-serving— How backend engineers pull theProductionmodel from the registry and wrap it in a web server.shadow-and-canary-deployments— How to safely test a model when it is in theStagingphase of the registry.cicd-for-ml— How to automate the approval and deployment process using GitOps.