What is dot-product similarity in vector retrieval?
Dot-product similarity is a way to measure how strongly two vectors point in the same direction.
In vector retrieval, it can be used to score how well a query embedding matches a document embedding.
How it works
Suppose we have two vectors:
Query = [1, 2]
Document = [3, 4]
The dot product is calculated by multiplying matching dimensions and adding the results:
1 × 3 + 2 × 4 = 11
A larger dot product generally means the two vectors are more strongly aligned.
Why it is useful in retrieval
During retrieval, the query is converted into an embedding.
Each document chunk already has an embedding.
The system computes a similarity score between the query vector and document vectors, then ranks the documents.
With dot product:
Higher score → usually stronger match
Lower score → weaker match
Important difference from cosine similarity
Cosine similarity focuses mainly on the angle between two vectors.
Dot product depends on both:
- Direction
- Vector magnitude
This means two vectors pointing in a similar direction can receive different dot-product scores if one has a much larger magnitude.
That may be desirable or undesirable depending on how the embedding model was trained.
Example
Consider:
A = [1, 1]
B = [2, 2]
C = [1, 0]
A and B point in exactly the same direction.
Their cosine similarity is 1 because their direction is identical.
But their dot product is:
A · B = 4
The magnitude of B contributes to the score.
So dot product is not purely measuring angle.
What happens with normalized embeddings?
If both vectors are normalized to unit length, their magnitude becomes 1.
In that case:
Dot product = cosine similarity
This is why some vector-search systems can use dot product and cosine similarity almost interchangeably when embeddings are normalized.
Dot product vs cosine similarity
Use cosine similarity when you mainly care about directional similarity and want vector magnitude to have little or no effect.
Use dot product when the embedding model is designed so that magnitude carries useful information, or when the model provider recommends dot-product scoring.
The similarity metric should match how the embedding model was trained.
Performance consideration
Dot product is computationally simple.
For large-scale vector search, it can be efficient because it only requires element-wise multiplication and summation.
Vector databases often combine it with approximate nearest-neighbor indexes to retrieve similar vectors quickly.
Interview takeaway
Dot-product similarity multiplies corresponding dimensions of two vectors and sums them. A larger value generally indicates stronger alignment, but unlike cosine similarity, dot product is affected by vector magnitude. If embeddings are unit-normalized, dot product and cosine similarity produce equivalent rankings. The correct metric should match the embedding model's training and recommendations.
Learning Sequence
Retrieval-Augmented Generation Curriculum
Explore Related Questions
Deepen your understanding across related Retrieval-Augmented Generation topics.