Uploading Models
Please click on the link below for a comprehensive review of uploading models on Hugginface:
Repositories
Models, Spaces, and Datasets are hosted on the Hugging Face Hub as Git repositories, which means that version control and collaboration are core elements of the Hub.
In a nutshell, a repository (also known as a repo) is a place where code and assets can be stored to back up your work, share it with the community, and work in a team.
Creating a repository
Using the Hub’s web interface you can easily create repositories, add files and explore models,
There are three kinds of repositories on the Hub, and in this guide you’ll be creating a model repository for demonstration purposes.
To create a new repository, visit huggingface.co/new:

Specify the owner of the repository: this can be either you or any of the organisations you’re affiliated with.
Them enter your model’s name, this will also be the name of the repository. Then Specify whether you want your model to be public or private.
Specify the license. You can leave the License field blank for now. To learn about licenses, visit the Licenses documentation.
After creating your model repository, you should see a page like this:

Note that the Hub prompts you to create a Model Card, which you can learn about in the Model Cards documentation.
Including a Model Card in your model repo is best practice, but since we’re only making a test repo at the moment we can skip this.
Choose Repository Type: Decide whether you want to link the repository with an individual user or an organization. Organizations can collect models related to a company, community, or library.
Upload Methods
There are a number of upload methods.
Because model repos are Git repositories we can use Git to push your model files to the Hub.
Follow the guide on Getting Started with Repositories for detailed instructions on using the git CLI to commit and push your models.
Custom PyTorch Model: If your model is a custom PyTorch model, use the
huggingface_hub
Python library, which enables capabilities likefrom_pretrained
,push_to_hub
, and automated download metrics.Web Interface: Alternatively, you can upload models using the web interface. Visit huggingface.co/new and follow the steps to create a new model repository. You can upload files from your computer and leave a commit message to document your changes.
Inspect Files and History: After uploading, you can inspect your repository, view recently added files, explore commits, and see the difference introduced by each commit.
Add Metadata: Enhance your model card by adding metadata such as the task type, used library, language, dataset, metrics, license, and more. This helps users understand your model better.
Model Usage Examples:
For libraries with built-in support, like Transformers, use methods provided by the library to push/load from the Hub.
For custom PyTorch models, leverage the
PyTorchModelHubMixin
class from thehuggingface_hub
library. Define hyperparameters in a config dictionary, create a class that takes the config, and utilizesave_pretrained
,push_to_hub
, andfrom_pretrained
methods.Ensure automated download metrics are available for your model, and consider adding a model card to provide additional information about your model.
Last updated
Was this helpful?