Dot Product as Alignment

Multiply matching coordinates and add

The dot product multiplies matching vector coordinates and adds the results. For [1, 2] and [3, 4], it is 1×3 + 2×4 = 11. Geometrically, it grows when vectors point in similar directions and becomes negative when they point in opposing directions, though magnitude also affects its size.

Cosine similarity divides the dot product by both vector lengths, focusing on direction rather than magnitude. Identical directions score 1, perpendicular directions score 0, and opposite directions score -1. Embedding search often uses this to rank passages whose meaning vectors point similarly to a query.

query     = [1, 1]
document A= [2, 2]  same direction -> cosine 1
document B= [1,-1]  perpendicular  -> cosine 0
Analogy: Two hikers walking northeast are aligned even if one walks twice as far. Cosine similarity compares headings; a raw dot product also rewards distance traveled.
Warning: Equal vector length does not make embeddings from different models comparable. Their coordinate systems must come from the same embedding contract, as the existing embeddings module explains.