4 ms·
What are better alternatives to cosine similarity?
by h_koko 3y ago
What are better alternatives to cosine similarity?
- minimaxir 3y agoThere aren't any alternatives: cosine similarity is effectively an extension of Euclidian distance, which is the mathematical correct way for finding the distance between vectors. You may not want to use cosine similarity as your only metric for rankings, however, and you may want to experiment with how you construct the embeddings.
- rocqua 3y agoEuclidean distance is only 'mathematically correct' if you care about rotations in your space being distance preserving. I don't think that is really the case in these spaces. There is a whole branch of mathematics called dedicated to other ways to measure distance.
- 0xdeadbeefbabe 3y agoHow wouldn't distances be preserved under rotation. I'm asking for a friend of course.
- rocqua 3y agoIn the Manhattan distance for example if you rotate your coordinate grid, distances will change.
- _t89y 3y agoFor describing semantics in natural language? Pretty much anything else.
- singularity2001 3y agolike?
- _t89y 3y agoHaving a mid-century theory of natural language semantics isn't necessarily a bad thing. You just have to pick the right one.
- stormfather 3y ago...like?
- _t89y 3y agohttps://news.ycombinator.com/item?id=39680852 https://news.ycombinator.com/item?id=39680852
- singularity2001 3y agoWhat happens when you mix cosine similarity with euclidean distance? at least give a small penalty if the euclidean distance is too far off?
- wongarsu 3y agoIf your embeddings are normalized this won't change much, since euclidean distance and cosine similarity produce the same ranking on normalized vectors. If your embeddings aren't normalized it's worth trying. In our use cases it never made a substantial difference, but I imagine there are cases where it does.