Articles → NLP → Cosine Similarity In NLP
Cosine Similarity In NLP
What Is Cosine Similarity?
Formula
- A · B = Dot product of vectors A and B
||A|| = Magnitude (length) of vector A||B|| = Magnitude (length) of vector B
Example
A = [1, 2, 3]B = [2, 4, 6]
A · B = (1×2) + (2×4) + (3×6) = 28
||A|| = √(1² + 2² + 3²) = √14||B|| = √(2² + 4² + 6²) = √56
Range Of Values
| Value | Meaning |
|---|
| 1 | Exactly similar |
| 0 | No similarity (orthogonal) |
| -1 | Opposite direction |
| Posted By - | Karan Gupta |
| |
| Posted On - | Sunday, March 1, 2026 |