centroid computation and -1 indices #3722
Unanswered
olivierabz
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am having trouble understanding the behaviour of faiss (and
IndexIVFFlat
) in a simple context of KNN where I sometimes get -1 indices instead of neighbours indices. I have read the documentation and previous issues about this topic and understand that -1 are retrieved when there are not enough neighbours in the searched cluster(s) to provide the expected total of k neighbours.In my case, I only want 1 neighbour for each of my test vectors, and so I have set
nprobe = 1
, expecting to have at least one candidate vector in each cluster/list.I produce the code provided below to illustrate/reproduce the problem. I generate a training set made of 2 times 10 unique vectors and I want to get the nearest neighbour for 10 test vectors (which are just translations of the unique training vectors).
The first thing we see is that despite having 10 unique vectors, each duplicated twice and setting nlist=10, I do not get centroids overlapping each points. Instead, I get two centroids that are very close to each other (the darker red circle on the figure) and I get a cluster in between two points.
When looking for neighbours for the 10 test vectors, I end up with one vector not getting any index (the point in purple).
I have 2 questions:
Note that if I try with 30 vectors (i.e. 3 duplications of each original vectors), I don't get the same behaviour and get what I'd expect: 10 centroids overlapping the 10 unique vectors and no -1 index in the search step).
This behaviour is also dependent of the test values (behaviour not observed if I use
X_test = np.array(unique_rows) + 0.75
Note that this is a minimalist example and that we have first observed this on a much larger dataset.
Any help in understand this would be greatly appreciated. Thanks.
Platform
macOS 10.13.2
Faiss version 1.8.0 installed
Beta Was this translation helpful? Give feedback.
All reactions