FlagEmbedding icon indicating copy to clipboard operation
FlagEmbedding copied to clipboard

Loss function for fine-tuning

Open austinmw opened this issue 1 year ago • 2 comments
trafficstars

Hi, what is the name of the loss function used for fine-tuning? And could you please point me to where it is defined?

Edit: looks like CrossEntropyLoss with In-Batch Negative Sampling? What happens if no negatives are provided, does it just assume all other examples are negatives anyway and result in worse performance? And if negatives are provided it will only construct batches with no context overlap?

austinmw avatar Jan 30 '24 18:01 austinmw

Hi, the loss function is at https://github.com/FlagOpen/FlagEmbedding/blob/master/FlagEmbedding/baai_general_embedding/finetune/modeling.py#L98

Yes, we use CrossEntropyLoss with In-Batch Negative Sampling. We will use the provided negatives and if set use_inbatch_neg to True (default value is True), we also use the passages from other queries as negatives.

staoxiao avatar Jan 31 '24 02:01 staoxiao

how to change the loss function ? can u show me

qcname avatar Aug 14 '24 01:08 qcname