Skip to content

Chapter 2 of 8

Cosine similarity and vector magnitude

A document embedded as 3v beats one embedded as v by exactly three times under a raw dot product, even though both point in precisely the same direction and are equally relevant. Cosine similarity divides the two lengths back out and scores them identically. This chapter derives that, scores the same three documents both ways to see which orderings move, and then sets out the cases where a magnitude is genuine signal rather than an artifact of length.

Vector arithmetic — read the current version at https://daviddominguez.dev/learn/en/vector-arithmetic/cosine-similarity

Back to top