AI & DataIntermediate
Cosine Similarity
PronunciationKOH-sine sim-i-LAR-i-tee
Definition
Cosine similarity is a metric used to measure how similar two vectors are by calculating the cosine of the angle between them. It focuses on the orientation of the vectors rather than their magnitude, making it ideal for comparing semantic meanings in high-dimensional spaces.
Where you hear it
In machine learning projects, when building search engines, or when working with vector databases and Large Language Models.
Examples
We used cosine similarity to find the most relevant documents for the user's query.
The system calculates the cosine similarity between the input embedding and the stored vectors.
Common mistake
Confusing it with Euclidean distance, which measures the straight-line distance between points rather than the angle between vectors.