# Does this modified version of the triplet loss function introduced with SBERT that uses the cosine similarity make sense?

I am working on a modified version of the triplet loss function introduced with SBERT, where instead of the Euclidean distance we use the cosine similarity. The formula to minimize is max( (|s_a*s_p| / |s_a|*|s_p|) - (|s_a*s_n| / |s_a|*|s_n|) + e, 0) where s_a is the embedding of the anchor sentences (the context), s_p is the embedding of the positive sentence (correct continuation) and s_n is the embedding of the negative sentence (wrong continuation).

I would like to check that the function I came up with makes sense from a theoretical point of view. Where should I look to check which features a loss function should satisfy?

Motivation for the question: I'm getting my hands dirty with contrastive loss functions, and this is an easy variation I came up with.

• You should share with us the loss function (the formula) that you came up with. Maybe you should also explain how it's different from the original loss and why we came up with this new one.
– nbro
Apr 4, 2022 at 8:52
• I modified the question as recommended. Apr 4, 2022 at 9:11
• Edit your post to include this info directly there. Note that you can use mathjax on this site.
– nbro
Apr 4, 2022 at 9:12
• I'm getting my hands dirty with contrastive loss functions, and this is an easy variation I came up with. Apr 4, 2022 at 9:12
• I modified the title to be more specific and to be the question that I think you're asking. Make sure that's the case. Again, I would highly recommend that you use mathjax to format the loss function.
– nbro
Apr 4, 2022 at 9:22