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

Fix bug of HNSW #2771

Closed
wants to merge 1 commit into from
Closed

Fix bug of HNSW #2771

wants to merge 1 commit into from

Conversation

hhy3
Copy link
Contributor

@hhy3 hhy3 commented Mar 17, 2023

No description provided.

@mdouze
Copy link
Contributor

mdouze commented Mar 20, 2023

Could you explain what this is?

@hhy3
Copy link
Contributor Author

hhy3 commented Mar 20, 2023

Could you explain what this is?

When popping the first element of the heap, it could be invalid. So in this case nvalid should not decrease by 1. So it should be checked first. Otherwise, the performance would be impaired.

@mdouze
Copy link
Contributor

mdouze commented Mar 24, 2023

I believe this can happen only if a -1 id gets pushed on the heap, which does never happen, correct?

@hhy3
Copy link
Contributor Author

hhy3 commented Mar 25, 2023

I believe this can happen only if a -1 id gets pushed on the heap, which does never happen, correct?

It'll be set to -1 when popping the min element. https://github.com/facebookresearch/faiss/blob/main/faiss/impl/HNSW.cpp#L877
And after I made this modification the recall improved a lot.

@facebook-github-bot
Copy link
Contributor

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

@alexanderguzhva
Copy link
Contributor

alexanderguzhva commented Apr 8, 2023

Confirmed for both the bug and the recall rate improvement.

@facebook-github-bot
Copy link
Contributor

@alexanderguzhva merged this pull request in 159641a.

@mdouze
Copy link
Contributor

mdouze commented Apr 11, 2023

Thanks a lot for this fix! it increases the accuracy of HNSW by a lot!

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.

4 participants