Data & Retrieval

Dot Product

A similarity measure summing the products of two vectors’ components — bigger when they point the same way and are large.

The dot product of two vectors multiplies their corresponding components and sums the results, giving a single number that grows when the vectors point in similar directions and have large magnitudes. It is a core similarity measure for embeddings and the basic operation inside attention and neural layers.

Worked example: vector search often ranks by dot product between the query embedding and document embeddings; and attention scores each token pair by the dot product of a query and a key vector before softmax. Gotcha: the dot product mixes direction AND magnitude, so a long vector can score high just for being large — which is why cosine similarity (the dot product of NORMALIZED vectors) is used when you care about direction only; some embedding models are trained for dot product, others for cosine, and using the wrong one degrades retrieval.