InnerProduct possible BUG: 1.0 - sum(x * y). In faiss and milvus, its just sum(x * y)
Arthur-Bi opened this issue · 1 comments
Arthur-Bi commented
The original code is 6e829d1
which is 1.0 - sum(-1 * x * y)
Then in a9a2cd5
Code is changed to 1.0 - sum(x * y)
**Q1: why is -1 deleted in second commit? **
Q2: why is 1.0 - sum(-1 * x * y) in the original code? Because I checked the IP in milvus and faiss, it's just sum(x * y)
Faiss
FAISS_PRAGMA_IMPRECISE_FUNCTION_BEGIN
float fvec_inner_product(const float* x, const float* y, size_t d) {
float res = 0.F;
FAISS_PRAGMA_IMPRECISE_LOOP
for (size_t i = 0; i != d; ++i) {
res += x[i] * y[i];
}
return res;
}
Milvus
func IPImplPure(a []float32, b []float32) float32 {
var sum float32
for i := range a {
sum += a[i] * b[i]
}
return sum
}
guoxiangCN commented
Hello, i also have the same question Q2 ? can you explain it ? maybe the inner product is designed for l2 norm to calac cosine ?