Comparison controls
Cosine compares direction and ignores length.
With unit-length vectors, cosine similarity and dot product are numerically identical.
0° means the same direction; 90° is perpendicular; 180° is exactly opposite, where cosine similarity reaches −1.
Length affects dot product but not cosine similarity.
Toy vector space
Ranked candidates
| Candidate | Rel. angle | Length | Cosine | Dot |
|---|
Best available is not necessarily relevant. Candidate A can be the nearest vector while failing the query’s date limit; Candidate B is a commentary rather than an empirical study. The score never observes those human criteria unless the representation and retrieval pipeline preserve them.
Dot product and cosine similarity: formulas and worked example
Multiply each pair of coordinates, then add. A longer vector can receive a larger score even when its direction is less closely aligned.
Divide the dot product by both vector lengths. This removes magnitude and leaves directional alignment. When both lengths are one, the denominator is one and the two scores are identical.
Worked example: combine coordinate products, then normalise
q = [1, 2] d = [3, 4]
- Dot product: q · d = (1 × 3) + (2 × 4) = 3 + 8 = 11.
- Vector lengths: ‖q‖ = √(1² + 2²) = √5, and ‖d‖ = √(3² + 4²) = 5.
- Cosine similarity: cos(q,d) = 11 ÷ (√5 × 5) ≈ 0.984.
Cosine similarity combines the dot product with the two vector lengths: the dot product is its numerator, and dividing by the lengths removes magnitude from the comparison.
This page avoids a zero-length vector because its cosine similarity is undefined: there is no direction to compare.
Lab appendix
How to read a two-dimensional picture of a high-dimensional space
Why does the picture have only two axes?
A two-dimensional vector has two coordinates, [x, y], so we can draw it as an arrow on a flat page. Add one more coordinate and it becomes [x, y, z]: the same kind of arrow in three-dimensional space. Keep adding coordinates and the pattern becomes [x1, x2, …, xn]. Real text embeddings commonly contain hundreds or thousands of coordinates, so we cannot draw their full spaces.
The comparison rule does not change as dimensions are added. Dot product multiplies each pair of matching coordinates and adds the results; cosine then divides that total by both vector lengths, which removes magnitude from the comparison. The horizontal and vertical axes here are anonymous drawing coordinates—not concepts such as “open access” or “citations”, and not a projection of a real embedding. This is a deliberately complete two-dimensional toy space in which every number can be inspected.
Can cosine or dot-product scores be negative?
Yes. Cosine similarity is 1 for the same direction, 0 at 90°, and negative when the angle is greater than 90°, reaching −1 for exactly opposite directions. Candidate C begins in that negative region. A dot product can also be negative; without normalisation it has no fixed minimum or maximum because vector length also contributes.
Negative does not automatically mean “opposite in meaning”. It describes geometry in the representation the model learnt. Some text-embedding models produce mostly positive scores for ordinary inputs or occupy only a narrow part of the mathematical range. Even when every candidate scores below zero, the highest score is still the nearest or best available under that rule.
The safe interpretation: the axes make the arithmetic drawable; the embedding model gives the coordinates their operational meaning; the comparison rule turns those coordinates into a score; and a person or evaluation set supplies the relevance judgement.
Companion to “How Search Decides What You See”. Everything runs locally in this page; no query or vector is sent anywhere.