Get the latest tech news
Alternatives to cosine similarity
Cosine similarity is the recommended way to compare vectors, but what other distance functions are there? And are any of them better?
It's often the technical underpinning of RAG pipelines ( Retrieval Augmented Generation), for instance, where related content is "found" and injected into the context of a message passed to an LLM. The "combined" score is a simple average (mean) of the F-score, AP, and NDCG scores.As predicted by the theory, the cosine similarity, dot product, and Euclidean distance functions all produced identical results. TL;RD: For normalized vectors like those used by LLM embeddings, calculating the dot product is the optimal way to determine their similarity.
Or read this on Hacker News