Distances are not calculated correctly for IndexHNSWFlat using METRIC_Lp.
#include <faiss/IndexHNSW.h>
#include <iostream>
int main() {
faiss::IndexHNSWFlat index(1, 32, faiss::METRIC_Lp);
index.metric_arg = 3;
float data[1] = {0.0};
index.add(1, data);
float query[1] = {2.0};
float distance;
faiss::idx_t label;
index.search(1, query, 1, &distance, &label);
std::cout << "Distance: " << distance << std::endl;
std::cout << "Label: " << label << std::endl;
return 0;
}
Running the above outputs the following.
I would expect to see a distance of (2 ^ 3) ^ 1/3 = 2.
For a simpler example, replace the index in the above code with faiss::IndexFlat index(1, faiss::METRIC_Lp);. This outputs the following.
The output seems to skip the final exponent of 1/3.
I am curious if either behavior is reproducible on other machines. If so, is this intended functionality?
Distances are not calculated correctly for IndexHNSWFlat using METRIC_Lp.
Running the above outputs the following.
I would expect to see a distance of (2 ^ 3) ^ 1/3 = 2.
For a simpler example, replace the index in the above code with
faiss::IndexFlat index(1, faiss::METRIC_Lp);. This outputs the following.The output seems to skip the final exponent of 1/3.
I am curious if either behavior is reproducible on other machines. If so, is this intended functionality?