PhyseaWiki How AI actually works physea.ai →

Embeddings & vectors

How do you compare two embeddings to measure relatedness?

To compare two embeddings you measure the angle or distance between their vectors. Cosine similarity, the cosine of the angle between them, is the standard tool: higher means more related, and for length-one vectors it reduces to a dot product.

Last updated 2026-07-25 · Physea Labs

To compare two embeddings, you measure the angle or distance between their vectors. Cosine similarity, the cosine of the angle between them, is the standard tool: higher means more related. OpenAI notes that because its embeddings are normalized to length one, “cosine similarity can be computed slightly faster using just a dot product.”[1] This is the arithmetic that turns “are these about the same thing?” into a single comparable score.

The reason cosine works well here is what it deliberately ignores: length. Cosine similarity is the dot product of two vectors divided by the product of their magnitudes, and that division cancels out how long each vector is, leaving only the angle between them. A quick sanity check on why that matters: point one vector at (1, 1) and a second at (5, 5) — same direction, wildly different length — and cosine similarity between them comes back as a perfect 1.0, exactly as it should for two vectors describing the same thing at different scales. Two vectors can point in nearly the same direction, meaning nearly the same thing, while having very different magnitudes, say a short query next to a long document, and cosine similarity treats them as closely related anyway. Raw Euclidean distance would not; it would penalize the size difference as if it were a difference in meaning, which is the wrong thing to measure when the actual question is “are these about the same topic,” not “are these the same length.”

The score itself has a fixed range that is easy to reason about: 1 means two vectors point in exactly the same direction, 0 means they sit at a right angle with nothing measured in common, and -1 means they point in opposite directions. In practice, most real embedding comparisons land in a narrower positive band than that full range might suggest, since even unrelated text in the same language tends to share enough background structure to pull scores above zero.

Two embeddings each a vector in the space Angle between them smaller angle, more related Cosine similarity score one comparable number
OpenAI's own embeddings are normalized to length one, which is what lets this angle calculation collapse to a plain dot product.

References

  1. Embeddings guide — OpenAI