koaning / embetter

just a bunch of useful embeddings
https://koaning.github.io/embetter/
MIT License
469 stars 15 forks source link

How to save the learner(contrastivelearner) as pytorch? #88

Closed vimal-quilt closed 9 months ago

vimal-quilt commented 1 year ago

Thanks for the wonderful library. i want to save the learner as a pytorch module or to onnx graph. will u let me know how to do this?

koaning commented 1 year ago

I'd like to have a method for this at some point, but I'm not 100% sure what the cleanest solution would be for the entire API.

Until then, you can confirm in the code that a trained learner would have a .network_ property that's a PyTorch object. You should be able to save that as you normally would.

vimal-quilt commented 1 year ago

Thanks for the reply. one more question. i see there is a accuracy drop in using this method of contrastive learner + logistic regression vs setfit method. will u comment something on this?

koaning commented 1 year ago

If you share the benchmark code I might be better able to comment. What happens if you compare with the SbertLearner? Theoretically that should be the same. Unless I made an implementation mistake or if I misunderstood their implementation.