AI Wisdom

Cosine Similarity

A metric measuring the angle between two vectors, used to compare embedding similarity.

In this article

Cosine similarity computes the cosine of the angle between two vectors, returning values from -1 (opposite) to 1 (identical). It is the standard similarity metric for embeddings because it is scale-invariant โ€” only direction matters, not magnitude. In vector databases, it is used alongside dot product and Euclidean distance for nearest-neighbour search.

What it means in practice

Cosine Similarity is not just vocabulary; it is a design handle. Use it as a reference point when comparing architecture choices, debugging implementation trade-offs, or explaining system behaviour to another engineer. It helps convert a vague technical conversation into a concrete design question with trade-offs that can be tested.

Why engineers care

  • It gives teams a shared name for the behaviour, risk, or architecture choice being discussed.
  • It helps separate the goal from the implementation detail, so you can compare alternatives instead of copying a tool pattern blindly.
  • It creates a useful checklist for reviews: inputs, outputs, failure modes, ownership, cost, latency, and measurement.

Production watch-outs

Be careful with shallow definitions. The useful meaning usually depends on workload, failure mode, data shape, and who owns the system in production.

Related context

Useful neighbouring concepts: Embedding, Semantic Search, Vector Database.

Discussion

Sign in to share your feedback and join the discussion.