Cosine Similarity
Definition
A metric that measures the similarity between two vectors by calculating the cosine of the angle between them, commonly used to compare text embeddings.In-Depth Explanation
Cosine similarity ranges from -1 (opposite) to 1 (identical), with 0 indicating no similarity. It measures orientation rather than magnitude, making it ideal for comparing text embeddings of different lengths. Two sentences with similar meanings will have embeddings pointing in similar directions, yielding high cosine similarity even if they use different words.
Real-World Example
The embeddings for "I love dogs" and "I adore puppies" might have 0.95 cosine similarity, while "I hate cats" might only score 0.2.