Unexpected index size after inserting elements with same ids with DirectMap.Hashtable #3667
Replies: 3 comments
-
This is expected. The index is perfectly fine with having several vectors with the same ids (they could be class labels for example). |
Beta Was this translation helpful? Give feedback.
-
Sorry, I did not know this was the expected behavior. So, is there an index (or configuration) that allows only one vector per id, and updates the "old" vector if another one is added with an id that is currently in use? Moreover, right now I have a new doubt. You said that "The direct map is used only for reconstruction" but if I want to add and remove elements with non-sequential ids, even if I never reconstruct them, I still need DirectMap.Hashtable, is it correct? Thanks |
Beta Was this translation helpful? Give feedback.
-
@javierjuan u can use |
Beta Was this translation helpful? Give feedback.
-
Summary
I am using an
IVF
index withDirectMap.Hashtable
to allow adding elements with arbitrary ids. After training the index, and adding 10000 elements (with a specific set of ids), checking the index size throughindex.ntotal
correctly returns 10000 . However, if I add again the same set of elements with the same ids the index size increases to 20000.I don't know if I am missing something but what I would expect here is that if I add elements with
ids
that are currently in use in the index, those elements in the index will be replaced with the new ones. However, when I check theindex.ntotal
it returns 20000, like if the index had grown with 10000 new elements. But in addition, if I try to reconstruct the elements ranging from 10000 to 19999, a key not found exception is raised (as expected) because theseids
do not exist.Am I missing something? Is it not the correct way to check the index size by querying
index.ntotal
?Thanks
Platform
OS: Windows 10
Faiss version: 1.7.2
Installed from: faiss-cpu from pip
Faiss compilation options: None
Running on:
Interface:
Reproduction instructions
Beta Was this translation helpful? Give feedback.
All reactions