Cosine Similarity
A normalized similarity measure based on the angle between vectors, computed from their dot product and magnitudes.
Definition
For two non-zero vectors, cosine similarity is:
cos(theta) = (a · b) / (||a|| ||b||)Values near 1 indicate similar direction, values near -1 indicate opposite direction, and 0 corresponds to orthogonality.
Use with Embeddings
In text, image or speaker embeddings, direction is often more useful than absolute vector magnitude. If vectors are already L2-normalized, ranking by cosine similarity is equivalent to ranking by dot product and repeated norm calculation can be avoided.
This is why the metric is common in speaker embeddings and vector-retrieval pipelines.
Boundaries
A high cosine score does not prove that two real-world objects are identical or causally related. The meaning of the score depends on the embedding model and its training distribution. Decision thresholds have to be validated on the intended data.
Related Concepts
- Embedding
- Vector Database
- Dot Product
- Nearest Neighbor
Related article: Image Feature Vectors and Matching