UKPLab / sentence-transformers

Multilingual Sentence & Image Embeddings with BERT
https://www.SBERT.net
Apache License 2.0
14.47k stars 2.4k forks source link

Fine Tuning Loss Functions (Custom / Default / Alternatives) #2495

Open DoctorSlimm opened 4 months ago

DoctorSlimm commented 4 months ago

Hiiii was wondering what the default loss function is? + how to implement custom in the framework?

ps: i know this is like totally random so apologies

Notably have been reading the [Atlas paper on fine tuning retrievers] (https://jmlr.org/papers/volume24/23-0037/23-0037.pdf) and the LOOL loss function is interesting:

Screenshot 2024-02-21 at 08 49 42 Screenshot 2024-02-21 at 08 50 02
tomaarsen commented 4 months ago

Hello!

Sentence Transformers doesn't have a "default" loss function per se, users always have to specify one. The current options are listed right here. They're all stored over here: https://github.com/UKPLab/sentence-transformers/tree/master/sentence_transformers/losses

Implementing a custom loss involves creating a class that: