-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Setting search parameters for one query
Faiss indexes have their search-time parameters as object fields.
However, it can be useful to set these parameters separately per query.
For example, for an IndexIVF
, one query vector may be run with nprobe=10
and another with nprobe=20
.
This is problematic when the searches are called from different threads.
To support this use case, a SearchParameter
object can be provided as the last argument of the search()
function.
Index types that accept search parameters have a corresponding SearchParameter
child object.
For example, IndexIVFPQ
has a SearchParameterIVFPQ
object.
The search will look like:
D, I = index.search(xq, 10, params=faiss.SearchParametersIVFPQ(nprobe = 10)
Note that the params=
is mandatory, not to confuse the search parameters with possible I
and D
output buffers that can also be provided.
In C++:
idx_t *I = ...
float *D = ...
faiss::SearchParametersIVFPQ params;
params.nprobe = 10;
index.search(nq, xq, 10, D, I, ¶ms);
Faiss building blocks: clustering, PCA, quantization
Index IO, cloning and hyper parameter tuning
Threads and asynchronous calls
Inverted list objects and scanners
Indexes that do not fit in RAM
Brute force search without an index
Fast accumulation of PQ and AQ codes (FastScan)
Setting search parameters for one query
Binary hashing index benchmark