Definition
A mathematical metric used in RAG pipelines to measure the semantic similarity between two high-dimensional vectors by calculating the cosine of the angle between them, effectively determining how closely the 'meaning' of a query aligns with a document chunk regardless of vector magnitude.
Measures the directional alignment of vectors rather than their spatial distance (Euclidean) or length.
"Two laser pointers in a dark room; the more they point in the same direction, the higher the similarity, regardless of how far the light travels."
- Vector Embeddings(Prerequisite)
- Dot Product(Mathematical Variant)
- Euclidean Distance (L2)(Alternative Metric)
- K-Nearest Neighbors (k-NN)(Search Algorithm)
Conceptual Overview
A mathematical metric used in RAG pipelines to measure the semantic similarity between two high-dimensional vectors by calculating the cosine of the angle between them, effectively determining how closely the 'meaning' of a query aligns with a document chunk regardless of vector magnitude.
Disambiguation
Measures the directional alignment of vectors rather than their spatial distance (Euclidean) or length.
Visual Analog
Two laser pointers in a dark room; the more they point in the same direction, the higher the similarity, regardless of how far the light travels.