The two scores
The dot product multiplies matching components and sums them. Cosine similarity is that same dot product divided by both vector lengths. The key difference is whether magnitude affects the score.
When they differ
The dot product grows with vector length, so a long vector can score high on similarity just by being big, even if its direction is only loosely aligned. Cosine removes that effect and reports pure direction agreement.
- Use cosine when magnitude is noise and only direction should matter.
- Use the dot product when magnitude carries real signal, such as confidence or popularity baked into the vector.
The normalization bridge
If you L2 normalize every vector to unit length first, the dot product and cosine similarity become identical. Many vector databases exploit this: they normalize once at index time so a fast dot product search returns cosine ranked results.
Key idea
The dot product is sensitive to magnitude while cosine is not, but once vectors are L2 normalized the two become identical, which is why normalization is a common preprocessing step.