Cosine, Dot Product, and Euclidean Similarity

AI systems turn text, images, and users into embeddings: lists of numbers that capture meaning. To find related items, we need a way to compare those vectors.

Let us use:

Cosine similarity: compare direction

Cosine similarity ignores magnitude and measures the angle between vectors. Its value usually ranges from -1 to 1; higher means more similar.

Although B is larger, it points in exactly the same direction as A. Cosine similarity is a strong default for semantic search, where meaning matters more than vector size.

Dot product: compare direction and magnitude

The dot product multiplies matching dimensions and adds them. A larger score means stronger alignment, but vector magnitude also affects the result.

Dot product is useful when magnitude carries information, and it is especially fast for ranking normalized embeddings. With normalized vectors, dot product and cosine similarity are equivalent.

Euclidean distance: compare physical closeness

Euclidean distance is the straight-line distance between two points. Here, smaller means more similar.

C is physically closer to A, even though B points in the same direction. Euclidean distance works well when absolute position and scale matter, such as clustering spatial features.

Quick rule of thumb

The best metric depends on what the embedding's magnitude represents—and whether it should influence similarity at all.