facebookresearch / faiss

A library for efficient similarity search and clustering of dense vectors.
https://faiss.ai
MIT License
30.69k stars 3.58k forks source link

How does the ivfflat index use search_preassigned #3535

Closed lambda7xx closed 2 months ago

lambda7xx commented 3 months ago

Summary

Platform

OS:

Faiss version:

Installed from:

Faiss compilation options:

Running on:

Interface:

Reproduction instructions

lambda7xx commented 3 months ago

my faiss-cpu version is 1.8. my code is below

index.search_preassigned(emb.shape[0], emb, nnn, candidate_cluster, None, topk_distance, topk_indices)

I try to use the search_preassigned API for ivfflat. I want to search the top-nnn vector in the candidate cluster and set the centroid_dis as None(https://faiss.ai/cpp_api/struct/structfaiss_1_1IndexIVFFlat.html). Base on the document(https://faiss.ai/cpp_api/struct/structfaiss_1_1IndexIVFFlat.html), it has the search_preassigned.

but my error is

TypeError: handle_Index.<locals>.replacement_search_preassigned() takes 5 positional arguments but 8 were given
type(self.index):<class 'faiss.swigfaiss_avx2.IndexIVFFlat'>