Dot Product Similarity
What it is
Dot product (inner product) similarity between two vectors is the sum of element-wise products. For unit-normalised vectors, dot product equals cosine similarity. In dense retrieval, dot product is the standard scoring function due to its computational efficiency and interpretability.
[illustrate: Two vectors projected in 2D; angle between them; dot product as projection of one vector onto the other]
How it works
For vectors u and v of dimension d:
dot_product(u, v) = Σ(u_i × v_i) for i = 1 to d
Relationship to cosine similarity:
cosine(u, v) = dot_product(u, v) / (||u|| × ||v||)- If u and v are unit-normalised (||u|| = ||v|| = 1), then
cosine(u, v) = dot_product(u, v)
In dense retrieval, embeddings are often L2-normalised to unit length, making dot product and cosine identical. Unnormalized dot product biases toward longer vectors.
Example
Query embedding (normalized): q = [0.5, 0.3, 0.8, 0.0, ...] ||q|| = 1.0
Document embedding (normalized): d = [0.6, 0.2, 0.7, 0.1, ...] ||d|| = 1.0
dot_product(q, d) = 0.5×0.6 + 0.3×0.2 + 0.8×0.7 + 0.0×0.1 + ...
= 0.30 + 0.06 + 0.56 + 0.0 + ...
= 0.92
cosine(q, d) = 0.92 / (1.0 × 1.0) = 0.92
Variants and history
Dot product scoring is fundamental to vector space models (Salton & McGill, 1983). Modern dense retrieval systems adopted dot product after embedding normalization became standard. Alternative metrics include Euclidean distance (L2) and Manhattan distance (L1), but dot product dominates due to computational efficiency on GPUs and CPUs.
When to use it
Use dot product similarity when:
- Vectors are L2-normalised (unit length)
- Computational speed is critical
- GPU/SIMD acceleration is available
- You want interpretability (alignment of directions)
- Cosine similarity is desired without normalization overhead
Dot product is the industry standard for dense retrieval. Always verify embeddings are normalised; unnormalized dot product can bias toward magnitude rather than direction.