Open anupsingh15 opened 5 months ago
This is because the distance_to_code
function does not have a simplified wrapping layer.
It can still be called using swig_ptr
:
dist_comp = index_pq.get_FlatCodesDistanceComputer()
dist_comp.set_query(faiss.swig_ptr(x_norm[0]))
dist_comp.distance_to_code(faiss.swig_ptr(codes[:5]))
This computes one distance at a time (because it's a low-level function).
Thanks for your reply.
I get the following error when executing: dist_comp.set_query(faiss.swig_ptr(x_norm[0]))
TypeError: in method 'DistanceComputer_set_query', argument 2 of type 'float const *'
I also tried the following, which does not give an error, but unsure why does it output only 0. I expected it to output 5 distances since I compare a query with 5 different encodings :
dist_comp = index_pq.get_FlatCodesDistanceComputer()
dist_comp.set_query = faiss.swig_ptr(x_norm[0])
dist_comp.distance_to_code(faiss.swig_ptr(codes[:5]))
Is there a way to compute the asymmetric distance of a query with respect to encoded (using PQ) database items? I figured out that I needed to use the
get_FlatCodesDistanceComputer
method of the index. Hereunder is my attempt:However, I get the following error:
Could you please let me know what I am missing?
Thanks.