Sub topic 3
Tracking Data, Code, and Model Lineage
Assume you understand training, evaluation, deployment, Git, CI/CD, and the purpose of a model registry. This chapter focuses on how to connect those parts into one traceable record.
Model lineage is the record of where a model came from. It connects a model version to the training data, feature definitions, source code, configuration, dependencies, evaluation results, and release decision that produced it. A model name such as credit-scoring:2.4.0 is not enough. You need references that identify the exact inputs.
The lineage chain
A useful lineage chain looks like this:
- A dataset snapshot identifies the exact rows and schema used for training.
- A Git commit identifies the code and configuration.
- An experiment identifies the run, parameters, metrics, and artifacts.
- A model artifact identifies the serialized model and its checksum.
- A registry version connects the artifact to evaluation and approvals.
- A deployment record identifies where and when the version was released.
Use immutable or content-addressed references where possible. A date-based name such as customers-march.csv can be replaced accidentally. A snapshot ID, object version, or SHA-256 checksum gives you stronger evidence that the referenced content has not changed.
| Lineage item | Example reference | Evidence it provides |
|---|---|---|
| Training data | `dataset-snapshot-2026-03-01` | Which data was used |
| Source code | Git SHA `8f31c2a` | Which implementation ran |
| Model artifact | SHA-256 checksum | Which binary was released |
| Evaluation | `eval-2.4.0.json` | Which tests supported approval |
Capturing lineage in a release record
Store lineage with the model version rather than only in a separate experiment system. The release record should also state the intended purpose, risk tier, oversight method, and approvers. These fields help connect engineering evidence to governance decisions and technical documentation.
import hashlib
import json
def content_ref(value: object) -> str:
"""Return a stable reference for a JSON-serializable value."""
payload = json.dumps(
value, sort_keys=True, separators=(",", ":")
).encode("utf-8")
return hashlib.sha256(payload).hexdigest()
release = {
"model": "credit-scoring",
"version": "2.4.0",
"training_data_ref": "dataset-snapshot-2026-03-01",
"code_commit": "8f31c2a",
"evaluation_report": "reports/eval-2.4.0.json",
"artifact_sha256": content_ref({"weights": [0.12, -0.44]}),
}
print(release["training_data_ref"])
print(release["artifact_sha256"])The checksum proves that the value hashed at recording time matches the value checked later. It does not prove that the original data was suitable, representative, or legally usable. Those questions require separate data governance and evaluation evidence.
Common errors
- Recording only the latest Git branch instead of the exact commit.
- Storing a mutable dataset path without a snapshot or checksum.
- Tracking model metrics without linking them to the model artifact.
- Allowing a release record to be edited without an audit event.
- Treating lineage as proof of model quality rather than proof of origin.
Exercise
A deployed model has a Git commit and an artifact checksum, but no training-data snapshot reference. What important lineage question remains unanswered?
Show answer
You cannot identify the exact data used to train the deployed model, so the training run cannot be fully reproduced or audited.