How to use `merge_result_table_with`?
AntonioLopardo opened this issue · comments
Summary
How to use merge_result_table_with
? I always seem to get a TypeError, I don't understand how to use the function to merge the results of the searches from two different indexes. The code below merges the same search in itself but it should still work. I tried on CPU and GPU and the function never runs. Thanks for any help.
Installed from: pip with !pip install --upgrade --force-reinstall faiss-cpu
Running on:
- CPU
- GPU
Interface:
- C++
- Python
Reproduction instructions
I tried this code directly in colab and it does not work there
import numpy as np
import faiss
np.random.seed(4)
dim = 3
dataset = np.random.rand(10, dim)
n = 5
qs = np.random.rand(n, dim)
k = 2
print(dataset.shape, dataset.dtype)
index = faiss.IndexFlatL2(dim)
index.add(dataset)
D, I = index.search(qs, k)
print(D.dtype, I.dtype)
faiss.merge_result_table_with(n, k, I, D, I, D, True, 0)
When running this code I get TypeError: Wrong number or type of arguments for overloaded function 'merge_result_table_with'. Possible C/C++ prototypes are: faiss::merge_result_table_with(size_t,size_t,int64_t *,float *,int64_t const *,float const *,bool,int64_t) faiss::merge_result_table_with(size_t,size_t,int64_t *,float *,int64_t const *,float const *,bool) faiss::merge_result_table_with(size_t,size_t,int64_t *,float *,int64_t const *,float const *)
Please use merge_knn_table
faiss/faiss/python/extra_wrappers.py
Line 282 in 8fc3775
Thanks! Is there a way to drop duplicates using this function? I'm experimenting with replication and would like to avoid have the same id multiples times after merging.
It is not integrated.