Version a model and its training data together
In this article (5 sections)
A model version without its training-data and configuration versions cannot explain what changed. Create a release manifest that binds the artifact, canonical data snapshot, feature list, threshold, code revision and evaluation evidence.
Hash three components
The deployment lab creates SHA-256 hashes for the serialized model, a canonically sorted synthetic training CSV and sorted JSON configuration.
from deployment_cases import version_case
result = version_case()
for field in ["model_sha256", "data_sha256", "config_sha256"]:
assert len(result[field]) == 64
print(result["model_version"], result["config"])The release is risk-2026-09-20.1. Its configuration names four features, threshold 0.5 and 450 training rows. Separate hashes reveal whether data, artifact or configuration changed.
Canonicalize before hashing
Row order, float formatting and serialization metadata can change bytes without changing logical data. Define sorting, encoding, schema and float representation. Store the snapshot or immutable location as well as its hash; a hash cannot recover missing data.
The model hash proves byte equality, not that the source is trustworthy or the model is good. Signatures, controlled storage and access policies address provenance; evaluation and approval address quality.
Make lineage queryable
Link model version to code revision, environment, experiment run, split manifest, metric report, schema and release decision. Predictions should log the model version and request ID so incidents can reconstruct which artifact acted.
Do not put private data in a public model registry or portfolio. Publish synthetic manifests or non-sensitive metadata with permissions and retention controls.
The Data Science course uses lineage to make a model release reproducible and rollback-safe.
Exercise
Change one row, one threshold and one coefficient separately. Verify which hash changes, generate a manifest and test that a release loader rejects mismatched components.
Continue learning
This article is part of the Model deployment and MLOps sequence. Use the neighbouring tasks when you need the prerequisite or the next application.
- Review the prerequisite or neighbouring task in Design a model API error contract.
- Continue with Build a lightweight experiment tracking convention.
Reference: Python hashlib documentation.
Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.
This article is part of our Data Science programme — 6 months. From data foundations to machine learning, deep learning and deployment.
Explore Data Science