News for hackers. Stuff that matters.
Re:Vector Databases: A Technical Primer [pdf] by estebarb on Friday January 12, 2024 @09:14PM (#38976711)
I asked it some time ago: https://cs.stackexchange.com/questions/147713/why-word-embed...

There is other aspect: if all vectors are normalized then cosine distance is just dot product. It is faster to calculate than euclidean distance.

Re:Vector Databases: A Technical Primer [pdf] by soVeryTired on Saturday January 13, 2024 @05:28AM (#38978693)
I have to say, neither of those answers are very satisfying. Neither is wrong but I don't come away with a clear explanation for why cosine similarity is the obvious metric to use.
Re:Vector Databases: A Technical Primer [pdf] by sdenton4 on Saturday January 13, 2024 @10:54AM (#38981047)
For euclidean distance, we have (q-v)^2 = qq + vv - 2qv. The qq and vv don't tell us anything about the relationship between q and v, so are irrelevant to search. So really we are mostly trying to maximize inner product when we search.

Additionally, the scale of q (the query) is constant across any given search, so might as well normalize q; the results won't change.

Then the only question is whether the scale of v matters... It, again, doesn't tell us anything about the relationship between q and v. So, might as well normalize... And then we are just doing cosine similarity.