Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

training with hpo - saving the best model #2939

Open
maayansharon10 opened this issue Sep 16, 2024 · 0 comments
Open

training with hpo - saving the best model #2939

maayansharon10 opened this issue Sep 16, 2024 · 0 comments

Comments

@maayansharon10
Copy link

maayansharon10 commented Sep 16, 2024

Hi
Training with hyperparameter_search, following the documentation here. I wish to save the best model. Could not apply the same functionality as in huggingface transformer -

# ... same exact code as in documantation
trainer.apply_hyperparameters(best_trial.hyperparameters, final_model=True) # replaces model_init with a fixed model
trainer.train()

I got this error -

    trainer.apply_hyperparameters(best_trial.hyperparameters, final_model=True)
AttributeError: 'SentenceTransformerTrainer' object has no attribute 'apply_hyperparameters'

A workaround was to redefine a SentenceTransformerTrainingArguments with best_trial.hyperparameters dictionary values and a SentenceTransformertrainer and to train again.
Is it possible to add a functionality such as save_best() or to enable using trainer.apply_hyperparameters ?

Also, another useful functionality that may be nice to add is the same as hpo with a setFit transformer, it currently throws and error, and if exists would really appreciate if you could show me how to use it with sentence transformers. If already exists would appreciate some guidance.

from optuna.visualization.matplotlib import plot_param_importances
plot_param_importances(best_trial.backend);

Thank you for this wonderful library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant