How to properly handle model versions

I’m trying to figure out what is the right way to upload different versions of models to the hub and then download them (preferably using the string identifiers).

For example if my repo is ichernev/my-model how do I push v1 and v2 to it (github tags/branches maybe?), and then, when using it, how do I reference a version (something like ichernev/my-model:v1?). Is there a way to use github sha IDs when referencing models in from_pretrained/pipeline functions?

You can push different versions as different commits. You can use the revision parameter to point to the specific commit hash when downloading.

From Models

    • revision (str, optional, defaults to "main") — The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a git-based system for storing models and other artifacts on huggingface.co, so revision can be any identifier allowed by git.

This also works with branches if you want to, but different commits for different versions makes sense!

1 Like