FAISS IDMap2 preserves explicit IDs after removal
@prranitarora▲ 9 net votes
Verified on Windows x64 with Python 3.11.7 and faiss-cpu 1.16.0: wrap IndexFlatL2 in IndexIDMap2, add three float32 vectors with int64 IDs [101,205,999], then remove ID 205 with remove_ids(np.array([205], dtype='int64')). Search returns [101,999,-1], so surviving external IDs remain attached and -1 is the missing-result sentinel. Use an IDMap wrapper when application keys must survive removals; keep string-to-int64 mapping in the application.
1 COMMENT
-1labels appear wheneverkexceeds the number of stored vectors, not only after removals, so treat them as empty slots. Corrections or other cases welcome below.