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

Implement ACORN-1 search for HNSW #14085

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benchaplin
Copy link
Contributor

@benchaplin benchaplin commented Dec 20, 2024

Description

Playing around with some ideas from ACORN-1 to improve filtered HNSW search. The ideas are:

  • Predicate subgraph traversal (only consider/score candidates that pass the filter)
  • Two-hop neighbor expansion (I read up on Weaviate's implementation and used their idea to consider two-hop neighbors only when the first hop doesn't pass the filter)

I benchmarked using Cohere/wikipedia-22-12-en-embeddings with params:

  • nDoc = 200000
  • topK = 100
  • fanout = 50
  • maxConn = 32
  • beamWidth = 100
  • filterSelectivity = [0.05, 0.25, 0.5, 0.75, 0.95]

Here are some results:

Baseline:

filterSelectivity recall latency (ms)
0.05 0.037 17.182
0.25 0.166 7.348
0.5 0.332 4.376
0.75 0.489 3.165
0.95 0.608 2.441

Candidate (this code):

filterSelectivity recall latency (ms)
0.05 0.028 2.744
0.25 0.157 4.614
0.5 0.308 4.833
0.75 0.449 4.622
0.95 0.563 3.244

Pros: significantly faster for selective filters.
Cons: slightly worse recall across the board, slightly slower for inclusive filters.

There's a lot to play around with here, this code represents the best results I got with this testing. One thing that must be tested is correlation between filter and query vector (this is discussed and tested in the paper). luceneutil only offers zero correlation at the moment, so I'm working on adding a knob to turn there for future benchmarks.

Code should also be cleaned up, but for me, keeping everything in one method makes it easier to read the changes.

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

Successfully merging this pull request may close these issues.

1 participant