3 ms·
I can't edit my previous comment for some reason but it looks like the code # Negate the values, to go from "similarity" to "distance" VSUBPS(ymm_c
by eigenket 3y ago
I can't edit my previous comment for some reason but it looks like the code
# Negate the values, to go from "similarity" to "distance"
VSUBPS(ymm_c, ymm_one, ymm_c)
Is actually just subtracting zero from ymm_c for no reason I understand.
- Retr0id 3y agoI believe the argument order is "a = b - c", so it's effectively `ymm_c = 0 - ymm_c`. (And yes, ymm_one does seem to be initialized to zero, I'm not sure why they picked that name for it...)
- eigenket 3y agoThat makes slightly more sense, but then why the heck do you end up needing to negate something while computing a dot product?
- ashvardanian 3y agoSorry, I meant the dot product distance. For vectors A and B it's equal to 1-AB. ...ripped it out of my vector search library :)
- eigenket 3y agoThat's a pretty weird "distance" unless you have some additional constraint like assuming the vectors are 2-norm normalised, in which case you get |a-b|^2 = 2(1-a.b). It is natural to assume vectors have distance 0 from themselves at least, which this thing doesn't (in general). E.g. if you compute this "distance" for a = b = (2,0) then you get that the distance from a to itself is -3 which seems pretty weird.