liveBook · Manning

Versioning

As explained in Machine Learning System Design

Model versioning is the practice of assigning and managing distinct identifiers for machine learning model revisions.

A model update can change predictions even when the calling code stays the same. Assigning a distinct version to each model revision makes that change visible and lets callers request a specific revision. In an API, loading the requested version when a model is initialized is one straightforward approach. section 13.1

Do not replace a model while leaving its version unchanged. That can change system behavior without notifying callers, and some model updates are breaking changes. Check the rest of the prediction pipeline too: changes to input and output data, preprocessing, postprocessing, or dependencies can also affect compatibility, sometimes unintentionally. section 13.1

Listing 13.3 Adding a model version to the API
class Model:
    def __init__(self, version):
        self.version = version
        self.model = load_model(version)

    def predict(self, features, time=None, seed=42):
        if time is None:
            time = datetime.now()
        return self.model.predict(features, time, seed)

The Model constructor accepts a version and passes it to load_model; predictions then use the loaded revision. section 13.1

A dependency change that changed outputs

A Python-version upgrade produced mismatched outputs in a system that required full compatibility, despite everything else being held static. The lesson is to test behavior, not just whether the model identifier stayed the same. section 13.1

Model versions are only part of a reproducible result. If a feature calculation or its data source changes, old and new values should not be mixed without distinction. Dataset metadata can record feature versions alongside the features and timestamp range, making it possible to return to an older dataset and reproduce an earlier model result. section 11.4.2

How Machine Learning System Design covers it

How deep it goes
Shows version selection during initialization and warns about unbumped changes, but defers more advanced management to the model registry pattern.
Examples
Uses a version-loading Model class and a Python upgrade that caused mismatched outputs.
What it assumes
Assumes familiarity with model prediction and API initialization; illustrates version selection with a short Python class.
What you can do after
Operate/configure it by requesting a model version at initialization and checking whether pipeline changes require a version change.
How it connects
Connects model versioning to API compatibility, preprocessing, postprocessing, dependencies, feature stores, and dataset reproducibility.

Also explained in

Compare how 25 books explain versioning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning System Design. The section links point to the parts of the book it draws on.