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

Savely save & load SetFitModel with custom differentiable head #530

Open
Ulipenitz opened this issue May 29, 2024 · 0 comments
Open

Savely save & load SetFitModel with custom differentiable head #530

Ulipenitz opened this issue May 29, 2024 · 0 comments

Comments

@Ulipenitz
Copy link

Ulipenitz commented May 29, 2024

I trained a SetFitModel with a custom Pytorch head which is more complex than the inbuild and gives far superior results and I followed the instructions for building it from here: https://huggingface.co/docs/setfit/en/how_to/classification_heads

The problem is that the save_pretrained method of the model does not save the script with the class definition and so it throws an error that the module for the head is missing when loaded into the inference environment.
(See recommended way to save pytorch model: https://stackoverflow.com/a/43819235)

Is there any way to avoid this, because it is not a good option to copy these scripts between repositories?
Does anyone know if I would face the same problem if I convert to ONNX first and use an ONNX model for inference?

Thanks!

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