Model Version Control

How to Version Control Machine Learning Models

Learn how to version control machine learning models by tracking code, data, settings and model files, so results can be reproduced and compared later.

On this page
  1. What to track
  2. Why ML is harder to version than ordinary software
  3. Use Git for code and small config files
  4. Handle large files with Git LFS or DVC
  5. Track experiments and model versions
  6. Name and tag each version
  7. A simple workflow
  8. Common mistakes
  9. Summary

Version control for machine learning means keeping a record of everything that produced a model: the code, the data, the settings and the model file itself. With that record, you can go back to an earlier model, see what changed between two versions, and reproduce a result when someone asks how it was made.

Git is the usual starting point, but it was designed for source code, which is mostly small text files. Model files and datasets are often large binary files, so most teams combine several tools, each used for the job it handles best.

What to track

A trained model depends on several inputs, so tracking only one of them is rarely enough:

  • Code: training scripts, preprocessing steps and model definitions.
  • Data: the training, validation and test sets, or at least a fingerprint of each one.
  • Settings: hyperparameters, feature lists and random seeds, ideally kept in a configuration file.
  • Environment: library versions, recorded in a requirements file, a lock file or a container image.
  • Model files: the trained weights or the saved model.
  • Results: the metrics from each run, so versions can be compared.

If one of these changes and nothing records it, two runs that look identical may give different results, and it can be hard to find out why.

Why ML is harder to version than ordinary software

In ordinary software, the code is often most of the story. In machine learning, the same code can produce a different model when the data changes, and the same data can produce a different model when the random seed changes. Model files are also large and hard to read. Even a small change to training can alter many of the numbers in a model file, so a line-by-line diff tells you little.

Use Git for code and small config files

Keep training scripts, configuration files and documentation in a Git repository, and commit them often. Each commit has a unique ID, a long hash, and you can record that ID with each training run. Later, you can check out the exact code that produced a given model.

Git does not handle large files well. GitHub hosts Git repositories online, and the difference between the two is covered in “is github a version control?” GitHub also blocks a normal push of any single file over 100 MB, and a repository grows quickly when new model files are committed again and again.

Handle large files with Git LFS or DVC

Two tools fill the large-file gap.

Git LFS (Large File Storage) is an extension for Git. It keeps a small pointer file in the repository and stores the real file on a separate server. It suits a small number of large files when you want to keep the usual Git workflow.

DVC (Data Version Control) is designed for data and machine learning projects. You run dvc add on a data or model file, and DVC writes a small .dvc file that Git tracks. That file records a fingerprint of the real file. Running dvc push sends the real file to remote storage, such as a cloud bucket, and teammates run dvc pull to get the same version. DVC can also describe a pipeline in a dvc.yaml file, so dvc repro reruns only the steps whose inputs have changed.

Either way, the Git history stays small, and each version of the code is still tied to a version of the data.

Track experiments and model versions

Experiment trackers such as MLflow and Weights & Biases record, for each run, the parameters, the metrics and the output files. You can compare runs side by side instead of guessing from file names like model_final_v2.pkl.

MLflow also includes a model registry, where each registered model gets numbered versions.

Metrics only mean something if you know how they were measured, so choose a validation method before training. The common options are covered in the answer to “which are methods used for validating models?”

Name and tag each version

A name should tie a model to its inputs. A name such as churn-model_2026-11-20_a1b2c3d, which holds the date and the first seven characters of the Git commit hash, says more than final.pkl. Git tags can also mark the commit that produced a model you approved, such as v1.2.0.

A simple workflow

  1. Create a Git repository for the project, and ignore the data and model folders in .gitignore.
  2. Track data and model files with DVC or Git LFS, and push them to remote storage.
  3. Pin library versions in a requirements file or a container image.
  4. Put every setting, including the random seed, in one configuration file.
  5. Train the model, and log the parameters, metrics and output file to an experiment tracker.
  6. Commit the code and configuration changes, and tag the commit when a model is approved.
  7. Record which model version is deployed, so you can roll back if needed.

Common mistakes

  • Committing large model files straight into Git, which makes the repository grow fast.
  • Overwriting a model file with a new one that has the same name.
  • Versioning the model but not the preprocessing code. If the features change, the model changes too.
  • Forgetting library versions. A new release of a library can change results.
  • Assuming runs repeat exactly. Setting a seed helps, but some GPU operations are not fully deterministic, so small differences can remain.

Summary

Version control for machine learning works best as a set of linked records: Git for code and configuration, DVC or Git LFS for large files, and an experiment tracker for runs and metrics. Start with the code and one record per model, then add tools as the project grows.

Keep exploring

Guides from other topics

All topics →