Hypothetical scenario. Northwind's assistant retrieves a passage about repairs when Priya asks about refunds. The search system calls the passage “similar.” That is a claim about a representation and scoring rule, not a verdict that the passage answers the question.
A vector is an ordered list
A vector can be represented as an ordered list of numbers. In a geometric picture the numbers locate a point or specify a direction and length relative to coordinate axes. The order matters: swapping coordinates changes the vector's meaning within the chosen representation. Two lists of different lengths cannot be compared by casually multiplying corresponding coordinates and ignoring the rest.
An embedding model maps an input, such as a query or passage, to a vector intended to support useful comparisons. The coordinates are learned representations, not usually named business attributes such as “refund amount” or “customer trust.” Assigning a human meaning to one coordinate requires evidence beyond the existence of the number.
For retrieval, a query and candidate documents must inhabit compatible representation spaces. The same number of coordinates is necessary for many comparison operations, but it is not sufficient to establish compatibility. Two embedding versions can both output lists of the same length while organizing their learned spaces differently.
Multiply pairs, then add
Worked example. Choose a = (1, 2) and b = (2, 1). Their dot product multiplies corresponding coordinates and sums the results: a · b = (1 × 2) + (2 × 1) = 2 + 2 = 4. The result is a single number, not another two-coordinate vector.
The Euclidean length of a is √(1² + 2²) = √5. The length of b is √(2² + 1²) = √5 as well. Cosine similarity divides the dot product by the product of the lengths: 4 / (√5 × √5) = 4 / 5 = 0.8. For these nonzero vectors, the result describes directional alignment under this geometry.
Now scale b by three to get c = (6, 3). The dot product with a becomes (1 × 6) + (2 × 3) = 12, three times the earlier result. The length of c is three times √5, so cosine remains 12 / (√5 × 3√5) = 12 / 15 = 0.8. Scaling changed the dot product without changing the direction.
Normalization changes the comparison
Normalizing a nonzero vector to unit length divides each coordinate by its length. When both vectors are normalized this way, their dot product equals their cosine similarity. That can make an index's dot-product operation implement a directional comparison, but only if the data and queries follow the same normalization convention.
A zero vector has length zero, so the cosine formula would divide by zero. The application needs an explicit rule for that case, such as rejecting or treating the item as unscorable. Quietly converting an undefined comparison into a confident retrieval result hides a representation failure.
In the wild. Sentence Transformers' similarity documentation describes using embeddings and configurable similarity functions to compare text. The chosen scoring function is part of the retrieval contract. A score should be interpreted under that model and function, rather than compared blindly with scores from a different embedding system.
Ranking is a decision, not an answer
A ranking orders candidates according to a rule. The first result is the best among the candidates considered under that rule; it may still be irrelevant, obsolete or inaccessible to the caller. Search can only return evidence from its candidate set, and the embedding representation may miss a distinction important to the user's question.
For Northwind, “refund” and “repair” may appear in similar support language while describing different procedures. The search result needs a source passage, version and access scope. A later answer should be checked against that passage. Neither a high dot product nor a high cosine score substitutes for confirming which policy actually governs the request.
A high score is not a confidence percentage
Misconception: cosine 0.8 means an eighty-percent chance that the passage is correct. The calculation above produced 0.8 from geometry alone. Turning a score into a calibrated task probability requires a separate empirical relationship, a relevant evaluation set and a declared outcome.
A second mistake is assuming a dot-product ranking and a cosine ranking are interchangeable. If vector lengths vary, their relative rankings can differ. The scaled example demonstrates why: c gets a larger dot product than b even though their directional alignment with a is identical.
Use these calculations when inspecting retrieval behavior, choosing a similarity function or migrating an embedding model. The small vectors make the arithmetic visible; they are not embeddings produced by a real model. Larger dimensions add numbers but do not remove the need for compatible spaces, correct normalization, source evidence and task-level evaluation.
Check yourself
Why does c have dot product 12 while b has dot product 4, although cosine stays 0.8?
c is three times b. Scaling changes length and therefore the dot product, but it preserves direction and cancels in the cosine ratio.
Can cosine be computed for a zero vector by using the normal formula?
No. Its length is zero, so the denominator is zero. The system needs an explicit handling rule instead of silently assigning a valid-looking score.
Does the top passage with cosine 0.8 prove the current refund policy?
No. It is a ranking score, not a truth probability. Inspect the passage, its date, its authorization scope and whether it actually supports the answer.
Go deeper
- Video — watch first: Dot products and duality — Grant Sanderson. Watch first to connect coordinate multiplication with directional comparison.
- Book chapter: Mathematics for Machine Learning — chapter 3, Analytic Geometry — Marc Peter Deisenroth, A. Aldo Faisal and Cheng Soon Ong. Develops norms, inner products and the geometry used in cosine similarity.
- Primary document: Semantic Textual Similarity — Sentence Transformers documentation. Makes the choice of embedding similarity function explicit.