What does cosine similarity actually measure between two embeddings?
Cosine similarity is the cosine of the angle between two vectors, a geometric quantity. It is not a calibrated probability of relevance; that interpretation has to be derived per model.
Picture two arrows pointing out from the same spot. If both point in roughly the same direction, the cosine of the angle between them is close to 1. If one points up and the other points sideways, the cosine is close to 0. That is all cosine is: a way of asking how parallel two arrows are. It does not know whether the two arrows mean similar things in the real world. That extra meaning is something we attach by checking many examples, not something the number tells us on its own. So a high cosine often hints at relatedness, but it is not a built-in promise.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Cosine similarity is one of those concepts that is easy to define and surprisingly easy to mis-interpret. The definition is two sentences of geometry. The misuse pattern fills a whole chapter of production debugging tickets: somebody quoted a cosine number as if it were a calibrated probability of relevance, and the team built a feature on top of that interpretation.
Getting cosine right means holding two layers in your head at once. The bottom layer is geometric: a dot product over magnitudes. The top layer is statistical: contrastive training shapes a distribution that maps cosine values onto a relevance scale, but the mapping is per-model and per-corpus. The interview question is asking you to keep the layers distinct.
The geometric definition and a clean restatement
Given two vectors u and v, cosine similarity is the dot product u · v divided by the product of magnitudes ||u|| * ||v||. The result is the cosine of the angle between the vectors. The range is [-1, 1]: 1 when the vectors point the same way, 0 when they are perpendicular, -1 when they point opposite.
The formula is independent of the magnitudes of u and v. That is the whole point of cosine over raw dot product: text embeddings often have meaningless magnitudes (often a side effect of the pooling layer), and cosine normalizes that out.
For unit-norm vectors (most modern embedding models L2-normalize their outputs, including OpenAI text-embedding-3 and Voyage-3) cosine reduces to a plain dot product:
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- FAISS, Pinecone, and Weaviate all expose cosine and inner-product metrics. For unit-norm embeddings (the default in OpenAI text-embedding-3 and Voyage-3), the two are equivalent.
- Production RAG stacks at Notion, Perplexity, and Cursor pair top-K cosine retrieval with a cross-encoder reranker so absolute cosine never gates user-visible behavior.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow is cosine similarity related to Euclidean distance for unit-norm vectors?
Derive the identity: squared Euclidean distance equals 2 minus 2 times cosine. Monotone relationship on the unit sphere, so the rank order is identical.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Treating cosine as a probability of semantic equivalence and reading 0.8 as 'definitely relevant' on any embedding model.
60 second bullets to scan on the way to the call.
Geometric definition of cosine similarity
Cosine vs dot product on unit-norm vectors
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.