benchaplin opened a new pull request, #14085: URL: https://github.com/apache/lucene/pull/14085
### Description Playing around with some ideas from [ACORN-1](https://arxiv.org/pdf/2403.04871) 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](https://weaviate.io/blog/speed-up-filtered-vector-search) 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](https://huggingface.co/datasets/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 average 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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org