Model Registration & Versioning
A trained model is just a file until it's registered. Learn to package, register, version, and manage models through their lifecycle β from experiment to production to retirement.
From experiment to production artifact
Think of a model like a recipe youβve perfected.
Youβve tested 50 variations and finally nailed it. Now you need to: write it down properly (package), file it in a recipe book with a version number (register), and decide when to use it, update it, or retire it (lifecycle).
Without this process, your βbest modelβ is just a file on someoneβs laptop. With it, every model is tracked, versioned, and ready for deployment.
Registering an MLflow model
After a successful training run, register the model in the Azure ML model registry:
from azure.ai.ml.entities import Model
from azure.ai.ml.constants import AssetTypes
# Register from an MLflow run
model = Model(
path="azureml://jobs/{run_id}/outputs/artifacts/churn-model",
name="churn-predictor",
version="3",
type=AssetTypes.MLFLOW_MODEL,
description="Churn prediction model β LightGBM, F1=0.961",
tags={
"algorithm": "lightgbm",
"dataset_version": "v2",
"f1_score": "0.961"
}
)
registered_model = ml_client.models.create_or_update(model)
Whatβs happening:
- Line 6: Points to the model artifact from a specific training run β full lineage
- Line 9:
MLFLOW_MODELtype β includes the model file, conda environment, and MLmodel metadata - Lines 11-14: Tags make the model searchable and auditable
Or register directly from MLflow:
import mlflow
# During training, log and register in one step
with mlflow.start_run():
# ... train model ...
mlflow.sklearn.log_model(model, "model",
registered_model_name="churn-predictor")
Exam tip: MLflow model format
The MLflow model format is a directory containing:
MLmodelβ metadata file listing flavors (sklearn, pytorch, etc.)model.pkl(or equivalent) β the serialised modelconda.yamlβ environment dependenciesrequirements.txtβ pip dependencies
This standard format means the model can be deployed to any MLflow-compatible platform. The exam favours MLflow model format over custom serialisation.
Feature retrieval specification
A feature retrieval spec bundles feature definitions with the model, ensuring that inference uses the correct features in the correct format:
from azure.ai.ml.entities import Model
model = Model(
path="./model_output",
name="churn-predictor",
version="4",
type=AssetTypes.MLFLOW_MODEL,
properties={
"feature_retrieval_spec": "feature_retrieval_spec.yaml"
}
)
The spec file defines which features the model expects and where to retrieve them:
# feature_retrieval_spec.yaml
feature_store_uri: azureml://featurestores/churn-features
features:
- name: customer_tenure_months
source: customer_features:v2
- name: monthly_charges
source: billing_features:v1
- name: support_tickets_30d
source: support_features:v3
Scenario: Kai packages the churn model
Kaiβs churn model needs 12 features to make predictions. Without a feature retrieval spec, the deployment team has to guess which features to send. With the spec bundled into the model:
- Training time: model is trained on features from the feature store
- Registration: feature spec is packaged with the model
- Deployment time: the endpoint reads the spec and automatically retrieves the right features
- Result: zero ambiguity about what the model needs
Priya (CTO): βNo more deployment bugs because someone sent the wrong features.β
Model lifecycle management
Models go through stages as they mature:
| Stage | Meaning | Action |
|---|---|---|
| None (default) | Just registered, not validated | Run evaluation before promoting |
| Staging | Being tested, not serving production traffic | Deploy to staging endpoint, run tests |
| Production | Actively serving predictions | Deploy to production endpoint |
| Archived | Retired, kept for audit/compliance | Remove from endpoints, retain in registry |
# Update model stage
from azure.ai.ml.entities import Model
model = ml_client.models.get(name="churn-predictor", version="3")
# Archive an old version
ml_client.models.archive(name="churn-predictor", version="1")
# Restore if needed (for audit or rollback)
ml_client.models.restore(name="churn-predictor", version="1")
Scenario: Dr. Fatima's model governance at Meridian
Meridian Financial has strict model governance requirements. Dr. Fatima implements a lifecycle policy:
- Registration β every model must include: algorithm, dataset version, metrics, and feature spec
- Staging gate β model must pass responsible AI evaluation (Module 11) before staging
- Production gate β model must pass A/B test against current production model
- Archiving β retired models kept for 7 years (regulatory requirement)
- Version limit β max 10 active versions per model; older ones auto-archived
James Chen (CISO): βEvery model decision is auditable. Thatβs what regulators want to see.β
Key terms flashcards
Knowledge check
Kai's deployment team keeps sending the wrong features to the churn model endpoint, causing prediction errors. What should Kai bundle with the registered model?
Dr. Fatima needs to retire an old model version but must keep it available for regulatory audits for 7 years. What should she do?
π¬ Video coming soon
Next up: Model Approval & Responsible AI Gates β ensuring models are fair, explainable, and safe before deployment.