Add simple class to ease saving loading from HF hub
See original GitHub issueWould like to have a class from which model class can be inherited to add support of Huggingface hub. It will look something like this :
from huggingface_hub import SavingUtils
class MyModel(nn.Module, SavingUtils):
def __init__(self):
self.layer1 = ....
def forward(self, ...):
return ...
model = MyModel()
model.save_pretrained("model_id")
# loading model
model = MyModel.from_pretrained("model_id")
I can make a PR for adding this simple feature if you approve it.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Share a model - Hugging Face
We encourage you to consider sharing your model with the community to help others save time and resources. In this tutorial, you will...
Read more >Adding Custom Layers on Top of a Hugging Face Model
Use task-specific models from the Hugging Face Hub and make them adapt to your task at hand. De-coupling a Model's head from its...
Read more >A complete Hugging Face tutorial: how to build and train a ...
Learn about the Hugging Face ecosystem with a hands-on tutorial on the datasets and transformers library. Explore how to fine tune a Vision ......
Read more >Premium Efficiency Motor Selection And Application Guide
Annual Electric Motor Sales Volume and Energy Savings Potential . ... Efficiency by Class at Full and Part-Load (1,800 RPM, TEFC Motors) ....
Read more >Load a pre-trained model from disk with Huggingface ...
- (not applicable to all derived classes, deprecated) a path or url to a single saved vocabulary file if and only if the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree with @julien-c and @patrickvonplaten on the fact it should be a mixin. Seems like a useful feature, so thanks for tackling this @vasudevgupta7 !
I’m fine with adding a
.upload_to_hub()
method inPreTrainedModel(....)
next tosave_pretrained(...)
andfrom_pretrained(...)
- I don’t think we really need a new Mixin class for that