Jargonautica
Maths and Statistics

Dot Product and Cosine Similarity

Also called: Dot Product, Cosine Similarity

The two standard ways of asking how similar two lists of numbers are. Multiply them position by position and add up the result, and you get a number that is large when they point the same way. Divide by their lengths and you get a score between minus one and one that ignores magnitude. This single operation is what makes semantic search and attention work.

Technical view

The dot product equals the product of magnitudes times the cosine of the angle between vectors. Cosine similarity normalises it, isolating direction, which suits embeddings where magnitude reflects token frequency or text length rather than meaning. Attention scores are scaled dot products; retrieval ranks by cosine similarity. Note that high cosine similarity indicates distributional relatedness, not truth, entailment or agreement.


Part of AI Terminology Index, section: Maths and Statistics.

How it connects

Dot Product and Cosine Similarity links to 7 other terms. The faint lines are links between those terms. See it in the full graph.

EmbeddingsEmbeddingsSemantic SearchSemantic SearchVector DatabaseVector DatabaseApproximate Nearest Neighbour SearchApproximate Nearest…VectorVectorLinear AlgebraLinear AlgebraAttentionAttentionDot Product and Cosine Similarity