facebookresearch / faiss

A library for efficient similarity search and clustering of dense vectors.
https://faiss.ai
MIT License
30.78k stars 3.59k forks source link

`ndis` is always 0 for `IndexHNSWFlat` #1993

Open jtibshirani opened 3 years ago

jtibshirani commented 3 years ago

After searching with IndexHNSWFlat, the reported number of distance computations hnsw_stats.ndis can remain 0. Looking through the code, it doesn't seem like ndis is being updated. It wonder if it's related to https://github.com/facebookresearch/faiss/pull/862, where the distance computers were refactored?

I noticed this while testing through the ann-benchmarks repo, which uses hnsw_stats.ndis to report the number of distance computations.

Thanks for the great package and for making helpful debugging info like this available!

mdouze commented 3 years ago

Yes right, the distances are still collected in the IndexFlat distance computer but not copied to the stats anymore.

https://github.com/facebookresearch/faiss/blob/master/faiss/IndexFlat.cpp#L123

Marking as an enhancement.

petrizhang commented 2 years ago

So how do we get the ndis stats for IndexHNSWFlat from Python?

Yes right, the distances are still collected in the IndexFlat distance computer but not copied to the stats anymore.

https://github.com/facebookresearch/faiss/blob/master/faiss/IndexFlat.cpp#L123

Marking as an enhancement.