What Is Cosine Similarity?
Cosine similarity is a measure of how similar two vectors are, based on the angle between them rather than their length. It returns a value from -1 to 1, where 1 means the vectors point in the same direction and 0 means they are unrelated. In AI, it is the standard way to compare embeddings and find related items.
How cosine similarity works
Cosine similarity looks at direction, not size. Each item, such as a sentence or an image, is turned into an embedding, which is a vector, a list of numbers that places the item as a point in space. Two items with similar meaning point in similar directions, so the angle between their vectors is small and the cosine of that angle is close to 1.
Measuring the angle instead of the straight-line distance is what makes the method robust. A long document and a short one can still register as very similar in meaning, because their direction matches even when their length does not.
Why cosine similarity matters for AI
Cosine similarity is the comparison step behind semantic search and retrieval. When a system needs to find the passages most relevant to a question, it embeds the question, then ranks stored embeddings by how closely they align with it. The highest scores are returned as the best matches.
That same calculation powers vector databases, recommendation systems, and the retrieval stage of RAG. It is a small piece of math doing a lot of quiet work across modern AI.
Related terms
Frequently asked questions.
The stuff we hear most on the first call. Don't see yours? Book a 30-minute conversation.
What does a cosine similarity of 1 mean?
What is the difference between cosine similarity and Euclidean distance?
Want to put AI
to work?
We work with leadership teams to find the right opportunities, define the strategy, and build the systems that move the business forward.