Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add range_search() to IndexRefine #4022

Conversation

alexanderguzhva
Copy link
Contributor

@alexanderguzhva alexanderguzhva commented Nov 8, 2024

This is very convenient to have range_seach() in IndexRefine. Unlike the plain search() method, range_search() just reevaluates the computed distances from the baseline index. The labels are not re-sorted according to new distances, because this is not listed as a requirement in a method description

faiss/faiss/Index.h

Lines 150 to 161 in adb1884

/** query n vectors of dimension d to the index.
*
* return all vectors with distance < radius. Note that many
* indexes do not implement the range_search (only the k-NN search
* is mandatory).
*
* @param n number of vectors
* @param x input vectors to search, size n * d
* @param radius search radius
* @param result result table
*/
virtual void range_search(

float* distances; ///< corresponding distances (not sorted)

@facebook-github-bot
Copy link
Contributor

@gtwang01 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@gtwang01
Copy link
Contributor

The unsuccessful check doesn't seem to be caused by this PR.
Can you add some unit tests to ensure reliability?

@alexanderguzhva
Copy link
Contributor Author

@gtwang01 will do

@gtwang01 gtwang01 requested a review from asadoughi November 20, 2024 23:40
@gtwang01
Copy link
Contributor

@alexanderguzhva Following up on this

Signed-off-by: Alexandr Guzhva <[email protected]>
@alexanderguzhva alexanderguzhva force-pushed the index_refine_range_search branch from d0d3af7 to 9b9b023 Compare December 20, 2024 17:36
Signed-off-by: Alexandr Guzhva <[email protected]>
@alexanderguzhva
Copy link
Contributor Author

@gtwang01 I've added a unit test. Please let me know if it is sufficient. Thanks.

@facebook-github-bot
Copy link
Contributor

@gtwang01 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@gtwang01 gtwang01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this

@facebook-github-bot
Copy link
Contributor

@gtwang01 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@gtwang01 merged this pull request in 162e6ce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants