Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue regarding stats #3449

Open
anupsingh15 opened this issue May 16, 2024 · 1 comment
Open

issue regarding stats #3449

anupsingh15 opened this issue May 16, 2024 · 1 comment

Comments

@anupsingh15
Copy link

Hello,

I am implementing the HNSW index on a dummy dataset. I want to know how many exact distance computations are performed during the search. To do so, I use faiss.cvar.hnsw_stats.ndis; however, it always returns 0. Could you tell me how to fix the issue?

Code:

x = np.random.randn(10000,128)
M=32
index_hnsw = faiss.IndexHNSWFlat(128, M)            
index_hnsw.hnsw.efConstruction = 40        
index_hnsw.hnsw.efSearch = 16   
index_hnsw.add(x)

D, I = index_hnsw.search(x[:10], 2)
cands = faiss.cvar.hnsw_stats.ndis #total cands evaluated across all queries
@mlomeli1
Copy link
Contributor

mlomeli1 commented May 28, 2024

This was fixed by @mdouze in #3309 (thank you Matthijs for flagging!). @anupsingh15 you need use the nightly package (see INSTALL.md) so this fix is included in the version of faiss you have in your conda environment, for your reference:

conda create -n faiss_1_8_0_nightly python=3.10
conda activate faiss_1_8_0_nightly
conda install -c pytorch/label/nightly -c nvidia faiss-gpu=1.8.0

the output is then

import numpy as np
import faiss
x = np.random.randn(10000,128)
M=32
index_hnsw = faiss.IndexHNSWFlat(128, M)            
index_hnsw.hnsw.efConstruction = 40        
index_hnsw.hnsw.efSearch = 16   
index_hnsw.add(x)

D, I = index_hnsw.search(x[:10], 2)
cands = faiss.cvar.hnsw_stats.ndis #total cands evaluated across all queries
cands
10268

@anupsingh15 anupsingh15 changed the title Non exhaustive search candidates stats in HNSW issue computing stats May 29, 2024
@anupsingh15 anupsingh15 changed the title issue computing stats issue regarding stats May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants