← All topics

Similarity Metrics (Mathematical Foundations) · Topic 51

Angular Distance vs. Cosine Similarity

Cosine similarity measures the cosine of the angle between two vectors (a value from −1 to 1). Angular distance is the angle itself (in radians or degrees), often defined as arccos(cosine_similarity). For normalized vectors they carry the same ordering: higher cosine similarity means smaller angle and thus smaller angular distance.

Summary

  • Angular distance is a true metric (triangle inequality, natural unit). Cosine is a similarity; convert via distance = arccos(similarity).
  • Many vector databases use cosine or dot product on normalized vectors; angular and cosine give the same nearest neighbors. Some APIs expose angular for interpretability (e.g. “15° apart”).
  • For normalized vectors, rank order is identical: smaller angular distance ⇔ higher cosine similarity. Pipeline: store normalized vectors, use dot product in the index; optionally convert scores to angular for display.
  • Impact of distance metrics on recall applies when comparing metrics; angular and cosine do not change recall relative to each other.
  • Practical tip: use cosine/dot product internally for speed; convert to degrees (e.g. 180/π × arccos(sim)) only when displaying to users or logging.

Metric vs. similarity

In many vector databases, indexing and search use cosine similarity or its equivalent dot product on normalized vectors. Angular distance is a true metric: it satisfies the triangle inequality and is in a natural unit (angle). Cosine similarity is a similarity, not a distance—larger values mean “closer.” Converting between them is straightforward: distance = arccos(similarity) when similarity is in [−1, 1].

Practical tip: use angular in the API or UI when you want interpretable numbers (e.g. “12° apart”); keep cosine or dot product for internal ranking and indexing. See normalizing vectors: why it is necessary so that cosine and angular stay equivalent.

ANN and API choice

For ANN indexes, both lead to the same nearest neighbors when vectors are normalized, because they preserve rank order. Some systems expose angular distance in the API for interpretability (e.g. “15° apart”), while internally using cosine or dot product for fast computation.

Choosing one or the other is mostly about API clarity and consistency with the rest of your distance metrics. Trade-off: angular is a true metric (useful for some theoretical and pruning arguments); cosine/dot product are faster to compute and more commonly optimized. See impact of distance metrics on recall when evaluating different metrics on your data.

Pipeline summary: ingest and query with normalized vectors; configure the collection for cosine or inner product. At response time, optionally convert returned similarity scores to angular distance (radians or degrees) for logging or UI. Thresholding can be done on either scale (e.g. “cosine > 0.9” or “angle < 25°”); keep one convention across your app for consistency.

Frequently Asked Questions

How do I convert cosine to angular distance?

Angular distance (radians) = arccos(cosine_similarity). Ensure cosine is in [−1, 1]; then angle is in [0, π].

Does ANN ranking change if I use angular instead of cosine?

No. For the same vectors, order is preserved: smaller angular distance ⇔ higher cosine similarity.

Why would I report angular distance to users?

“15° apart” is easier to interpret than “cosine 0.97.” Some APIs return both; use angular for display and cosine/dot product for internal ranking.

Is angular distance the same as 1 − cosine?

No. 1 − cos(θ) is not the angle; it’s a monotonic transform. Angular distance is arccos(cos(θ)) = θ. Both preserve rank order.