⚙️ Recommendation Engine
Cosine Similarity Explained
Cosine similarity measures how alike two vectors are by the angle between them. Learn how it works and why recommendation engines use it to compare interests and articles.
By Headlinne Editorial Team · Updated on
Measuring similarity by angle
Cosine similarity compares two vectors by the angle between them rather than their length. It ranges from 1 (pointing the same direction—very similar) through 0 (perpendicular—unrelated) to -1 (opposite). For text embeddings, values typically fall in a positive band.
Using the angle instead of raw distance means cosine similarity ignores magnitude. A short article and a long one on the same topic can still score as highly similar, because what matters is direction in meaning-space, not size.
Why recommenders use it
Cosine similarity is the standard way to compare embeddings. In Headlinne, the engine computes the cosine between a user's taste vector and each candidate article's embedding to produce a semantic affinity signal for ranking.
It is cheap to compute, well-behaved, and interpretable: a higher cosine means "closer in meaning," which maps naturally onto "more likely to be relevant."
Turning a score into a signal
A raw cosine value is not directly usable as a ranking weight—the useful range is narrow and depends on how the vectors were built. Headlinne maps cosine onto a 0-to-1 scale using a calibrated band: below a low threshold maps to 0, above a high threshold maps to 1, and values in between scale linearly.
This calibration matters. Because taste vectors are centroids, their cosines with individual articles run lower than query-to-document cosines, so the band is tuned to be more lenient for feed ranking than for search.
Limits to keep in mind
Cosine similarity is useful but not magic:
- It only reflects what the embedding model captured
- High similarity means "related," not necessarily "good" or "true"
- Thresholds need calibration for each use case (feed vs. search)
- It compares meaning, so two opposing takes on a topic can look similar
Key takeaways
- ✓Cosine similarity compares vectors by angle, ignoring their length.
- ✓Headlinne uses it to score how close an article is to a user's taste vector.
- ✓Raw cosine is calibrated onto a 0–1 band tuned differently for feed and search.
Frequently asked questions
Why use the angle instead of the distance?
The angle captures similarity in meaning independent of text length. Two documents of very different sizes on the same topic still point in a similar direction.
Does high cosine similarity mean two articles agree?
Not necessarily. It means they are semantically related. Two articles arguing opposite sides of the same issue can be highly similar because they discuss the same subject.
Related Headlinne features
Related reading
Continue learning
Embeddings and Vector Search
Embeddings turn articles and interests into vectors, and vector search finds the closest matches. Learn how Headlinne uses them to power semantic recommendations and search.
Exploration vs. Exploitation
Every recommender must balance showing what it knows you like against discovering new interests. Learn this core trade-off and how Headlinne uses Thompson sampling to solve it.
Start reading personalized news with Headlinne
Create your free account and build a feed that learns what you care about.