CLIP icon indicating copy to clipboard operation
CLIP copied to clipboard

Why cosine loss instead of just dot product?

Open ekgren opened this issue 5 years ago • 1 comments

Trying to find the motivation in the article but I'm left without a definitive answer.

What is the motivation of using L2 normed dot product instead of simply the dot product in the loss?

ekgren avatar Mar 23 '21 10:03 ekgren

The main purpose is to stabilize training, by limiting the dynamic range of the logits. With the cosine similarities being within [-1, 1] and an upper-bounded temperature parameter, it's a simple way to prevent the model predictions from exploding. Radovanovi et al. found that the "hubness phenomenon" is less severe with cosine similarity, although synthetic data was used.

jongwook avatar Mar 24 '21 06:03 jongwook