Calculate cosine similarity between two embedding vectors for semantic similarity analysis.
cosine_similarity
is a utility function for calculating the cosine similarity between two embedding vectors. It’s dependency-free and provides a quick way to measure semantic similarity between texts.
Name | Type | Required | Description |
---|---|---|---|
vec_a | List[float] | ✓ | First embedding vector |
vec_b | List[float] | ✓ | Second embedding vector |
float
between -1 and 1:
A · B
is the dot product of vectors A and B||A||
and ||B||
are the magnitudes (L2 norms) of vectors A and B