question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add simple class to ease saving loading from HF hub

See original GitHub issue

Would 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sguggercommented, Jan 19, 2021

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 !

1reaction
patrickvonplatencommented, Jan 19, 2021

I’m fine with adding a .upload_to_hub() method in PreTrainedModel(....) next to save_pretrained(...) and from_pretrained(...) - I don’t think we really need a new Mixin class for that

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found