Replies: 1 comment 1 reply
-
|
SearchParametersIVF by default has nprobe 1. You have 10 clusters (nlist). If you set nprobe to 10 as well in SearchParametersIVF, does this still reproduce? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
During queries with IndexIVFFlat and SearchParametersIVF, I occasionally get an index value of -1. How should I modify the threshold to address this?
thanks
`
import faiss
import numpy as np
dimension = 5
n_vectors = 1000
vectors = np.random.rand(n_vectors, dimension).astype(np.float32)
nlist = 10
quantizer = faiss.IndexFlatL2(dimension)
index = faiss.IndexIVFFlat(quantizer, dimension, nlist)
index.train(vectors)
index.add(vectors)
index.nprobe = nlist
query_vector = np.random.rand(1, dimension).astype(np.float32)
distances, indices = index.search(query_vector, k=3)
specific_indices = np.array([10, 20, 30, 40, 50], dtype=np.int64)
if hasattr(faiss, 'SearchParametersIVF'):
ivf_params_array = faiss.SearchParametersIVF()
selector_array = faiss.IDSelectorArray(len(specific_indices), faiss.swig_ptr(specific_indices))
ivf_params_array.sel = selector_array
array_distances, array_indices = index.search(query_vector, k=3, params=ivf_params_array)
`
IDSelectorArray and IDSelectorBatch output:[[2.4531160e-01 5.5956078e-01 3.4028235e+38]], index:[[30 40 -1]]
IDSelectorBitmap output: [3.4028235e+38 3.4028235e+38 3.4028235e+38]] and [[-1 -1 -1]] (The bitmap results don't match other methods. Occasionally, strange values like 300, -1, or -1 appear.")
Beta Was this translation helpful? Give feedback.
All reactions