4 ms·
> This is what a dot-product would look like in PeachPy Is it just me (I'm far from an expert here) or is this code really weird? Why does ymm_one appear to co
by eigenket 3y ago
> This is what a dot-product would look like in PeachPy
Is it just me (I'm far from an expert here) or is this code really weird? Why does ymm_one appear to contain the number zero? Why do we subtract what looks like it should be the inner product we want from ymm_one at the end?
- eigenket 3y agoI 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.
- t-vi 3y agoThe subtraction is because "is an example of constructing the “Inner Product” distance" per the text above it. That ymmone might not be one could be because they only need that up to a constant and so don't care, but it's probably not ideal to name the thing containing 0s ymmone.
- eigenket 3y agoIs there a context where it is usual to call minus the dot-product a distance?