hnswlib icon indicating copy to clipboard operation
hnswlib copied to clipboard

Problems with InnerProductSpace distance metric

Open zlwu92 opened this issue 2 years ago • 1 comments

Hi,

I am using examples provided in tests/cpp/.

I am trying to add new examples for based on given examples and modify with using cosine metrics for other dataset. When I try to replace the l2space with cosine metrics which I found also provided in hnswlib, image

image For this line, I replace l2space object with ipspace object. However, it gets compile error image

What should be the reason. These two are both sub-classes inhereted from SpaceInterface, why l2space works well while the other one has problems?

zlwu92 avatar Oct 28 '23 16:10 zlwu92

Hey @zlwu92,

For integer distance only L2 is currently implemented (L2SpaceI with I on the end). If you are ok with float, you can use <float> instead of <int> and it should work.

yurymalkov avatar Oct 28 '23 16:10 yurymalkov