Back to Glossary
MLOps

Model Versioning

Definition

Model versioning is the practice of tracking and managing different versions of ML models and their associated artifacts, enabling reproducibility, comparison, rollback, and auditing throughout the model lifecycle.

Why It Matters

Without versioning, models become black boxes with amnesia. “Which model is in production?” becomes a research project. Rollbacks are impossible since you can’t go back to what you didn’t save. Debugging is futile since you can’t reproduce what you didn’t track.

Good versioning answers critical questions: What exact model is serving traffic? What data trained it? What code processed that data? What hyperparameters were used? When was it deployed, and who approved it?

For AI engineers, versioning extends beyond model weights. Prompt templates, RAG configurations, evaluation datasets, and system prompts all need versioning. A “model version” often means the entire AI system configuration.

Implementation Basics

Effective model versioning tracks multiple interconnected artifacts:

1. Model Artifacts The actual model files: weights, architecture definitions, tokenizers, configs. Store immutably and never overwrite. Use content-addressable storage (hash-based naming) or semantic versioning.

2. Code Version Git commit hash for training and serving code. Pin exact library versions (requirements.txt, poetry.lock). Store as metadata alongside model artifacts.

3. Data Version Reference to exact training data used. For large datasets, use DVC or similar tools to version data separately from code. Include data preprocessing version.

4. Configuration Hyperparameters, feature engineering settings, training arguments. Store as YAML/JSON alongside model. These determine reproducibility.

5. Metadata Training metrics, evaluation results, compute resources used, training duration. Author, timestamp, experiment links. Rich metadata enables meaningful comparisons.

Versioning Strategies:

  • Semantic versioning (v1.2.3): Major.Minor.Patch for human-readable versions
  • Git-based (commit hash): Automatic, precise, but hard to read
  • Timestamp-based (2024-01-15-14:30): Good for frequent iterations
  • Hybrid: Semantic for production, timestamp for experiments

Tools:

  • DVC: Version data and models alongside code in Git
  • MLflow Model Registry: Full lifecycle management
  • W&B Artifacts: Cloud-hosted versioning
  • Custom: S3 + metadata database

Start with immutable artifact storage and never overwrite model files. Add rich metadata as you learn what’s important. Graduate to full lifecycle management when you have multiple models and team collaboration.

Source

Model versioning connects code, data, and model artifacts together, enabling full reproducibility and tracking of the entire ML experiment.

https://dvc.org/doc/use-cases/versioning-data-and-models