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?

1 Like

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

I have a follow up question on this topic.

What is the purpose of having the flexibility of creating different branches of a model (in ui) whilst not being able to push a model to it using trainer.push_to_hub ? I might not be understanding the use-case of model branches.

I am new to the framework so trying to understand best practise for model versioning as well.