kayzhu / LSHash

A fast Python implementation of locality sensitive hashing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there any way to also obtain the indices in result of query?

mehrrsaa opened this issue · comments

Hi,

I was wondering if there is any way to also obtain the indices of the results of a query since a lot of times we may need to for example go back to some sort of embedding and see what element it is representing.

Thank you so much for the amazing work!

Hi mehrrsaa,

you can add the index to the extra_data argument of the index function.
For instance:

        for i in range(0, X.shape[0]):
            self.model.index(X[i,:], extra_data=(i))

where i add all rows of a matrix to the hash table. I also add the the associated index i to each element (row).
The additional data in extra_data is attached to the results returned by the function query.

Best wishes,
André

Thank you for the explanation!