What is the difference between cosine similarity and dot product for embeddings?
RAG & Vector DB Interview: Embeddings, Cosine Similarity, Dimensions, Models Compared
Audio flashcard · 0:30Nortren·
What is the difference between cosine similarity and dot product for embeddings?
0:30
Cosine similarity measures the angle between two vectors regardless of their magnitude, returning a value between negative one and one. Dot product multiplies vectors element-wise and sums the result, factoring in both angle and magnitude. For unit-normalized vectors the two metrics produce identical rankings, since cosine equals the dot product divided by the product of magnitudes. Dot product is faster to compute because it skips the normalization step, which is why most production systems normalize embeddings once at ingest and use dot product at query time.
platform.openai.com