Model Registry
Model Registry
A version-controlled repository for ML models. Manages deployment and rollback.
Model Registry
A version-controlled repository for ML models. Manages deployment and rollback.
A Model Registry is a central repository that manages the entire lifecycle of machine learning models. It systematically tracks model artifacts, metadata, version history, and deployment status, serving as core infrastructure for ML operations (MLOps).
The core function of a model registry is version control. Each model is registered with a unique version, and the training code, dataset version, hyperparameters, and performance metrics are recorded together. This makes it possible to accurately reproduce a model at a specific point in time and to roll back to a previous version when a problem occurs.
In terms of deployment management, a model registry provides the concept of stages. Typically, the deployment status of a model is managed through stages such as 'Staging', 'Production', and 'Archived'. When a new model passes testing, it is promoted from Staging to Production, and the old version is automatically moved to Archived.
Representative tools include MLflow Model Registry, AWS SageMaker Model Registry, Azure ML Model Registry, and Weights & Biases. Choose a tool suited to your organization's size and cloud environment, while taking into account team collaboration and integration with automation pipelines.
This is an example of managing a model registry using MLflow:
import mlflow
from mlflow.tracking import MlflowClient
import sklearn
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
# MLflow 서버 설정
mlflow.set_tracking_uri("http://localhost:5000")
mlflow.set_experiment("iris-classification")
# 1. 모델 학습 및 등록
with mlflow.start_run() as run:
# 데이터 준비
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
# 모델 학습
params = {"n_estimators": 100, "max_depth": 5}
model = RandomForestClassifier(**params)
model.fit(X_train, y_train)
# 메트릭 기록
accuracy = model.score(X_test, y_test)
mlflow.log_params(params)
mlflow.log_metric("accuracy", accuracy)
# 모델 레지스트리에 등록
model_info = mlflow.sklearn.log_model(
model,
"model",
registered_model_name="iris-classifier"
)
print(f"모델 버전: {model_info.registered_model_version}")
# 2. 모델 스테이지 관리
client = MlflowClient()
# Staging으로 승격
client.transition_model_version_stage(
name="iris-classifier",
version=1,
stage="Staging"
)
# Production으로 배포
client.transition_model_version_stage(
name="iris-classifier",
version=1,
stage="Production",
archive_existing_versions=True # 기존 Production 버전 자동 아카이브
)
# 3. Production 모델 로드 및 추론
model_uri = "models:/iris-classifier/Production"
loaded_model = mlflow.sklearn.load_model(model_uri)
prediction = loaded_model.predict([[5.1, 3.5, 1.4, 0.2]])
print(f"예측 결과: {prediction}")
# 4. 모델 버전 히스토리 조회
for mv in client.search_model_versions("name='iris-classifier'"):
print(f"버전 {mv.version}: {mv.current_stage} (생성: {mv.creation_timestamp})")| Solution | Cost | Features | Suitable Scale |
|---|---|---|---|
| MLflow (OSS) | Free (infrastructure costs only) | Flexibility, community | Startups to large enterprises |
| AWS SageMaker | ~$0.05/GB/month per model | AWS ecosystem integration | Companies using AWS |
| Azure ML | Workspace-based | Enterprise security | Enterprise customers |
| Weights & Biases | $50/user/month (team) | Experiment tracking integration | Research teams to startups |
| DVC + Git | Free | Git-based version control | Small teams |
"I'll register this in the model registry and set it up to deploy automatically from the CI/CD pipeline."
Used when building an automated ML deployment workflow.
"We hit a problem with v3, which we deployed yesterday, so we rolled back to v2. It was done right from the registry."
Used when reporting a quick recovery in an incident response situation.
"For model lineage tracking, please also record the training dataset version in the metadata."
A request to ensure model governance and reproducibility.
1. Missing metadata: If you store only the model and do not record the training configuration, data version, and dependencies, reproduction is impossible. At a minimum, store it together with requirements.txt.
2. Indiscriminate version creation: If every experiment is registered in the registry, it becomes hard to manage. Keep it separate from Experiment Tracking and register only validated models.
3. No access permissions set: It is risky if anyone can modify a Production model. Set permissions per stage and introduce an approval process.
4. Storage costs of large models: Storage costs surge for large models such as LLMs. Consider delta storage or model compression.