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.

Save Model Locally trainer.save_model()

See original GitHub issue

First off, super excited about all this work! Also really appreciate the youtube presentation and the blogpost, super insightful to read through. I went through the existing issues and couldn’t find whether this an existing functionality:

Is there a way to save the model locally instead of pushing to the hub? So in addition to this: trainer.push_to_hub(f"setfit-myowndataset-multilabel-example") be able to do this too: trainer.save_model("file-path/setfit-myowndatase-multilabel-example")

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

2reactions
kavya-pccommented, Nov 24, 2022

It can be done by trainer.model._save_pretrained(save_directory=save_directory).

Here is the link to the solution where it has already been answered - https://github.com/huggingface/setfit/issues/102

2reactions
kgourgoucommented, Nov 24, 2022

You should be able to do model.save(path_str) as usual.

https://github.com/huggingface/setfit/blob/5313939b638b57668a1b5a67ef600e54da221d9a/src/setfit/modeling.py#L579

or if your model is not wrapped, model._save_pretrained(path_str).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to save my model to use it later - Hugging Face Forums
You can save models with trainer.save_model("path_to_save") . Another cool thing you can do is you can push your model to the Hugging Face...
Read more >
Save and load models | TensorFlow Core
Model progress can be saved during and after training. This means a model can resume where it left off and avoid long training...
Read more >
Saving, Loading, Downloading, and Uploading Models
In R and Python, you can save a model locally or to HDFS using the h2o.saveModel (R) or h2o.save_model (Python) function . This...
Read more >
Saving and Loading Models - PyTorch
To load the items, first initialize the model and optimizer, then load the dictionary locally using torch.load() . From here, you can easily...
Read more >
huggingface transformers - saving finetuned model locally
1 Answer 1 · is this different from Trainer.save_model() , i.e. does it save the same thing? · 1. @yulGM, yes that should...
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