feat: make initial IVF filter expansion configurable - #68
Conversation
|
Please rebase main. |
|
Overall, this approach is aligned with common industry practice for filtered IVF search: start with a bounded probe budget and expand progressively when the filtered result set is too short. Keeping the option unset by default also preserves existing behavior. I think two documentation changes are still needed before merge:
|
700575d to
3d3ca6b
Compare
|
@JingsongLi @jerry-024 Addressed the review feedback in 3d3ca6b:
Revalidated with workspace tests, Clippy, Maven tests, Java/JNI native validation, panic-boundary and handle-safety tests, formatting, license headers, and diff checks. |
Purpose
Filtered automatic IVF search currently expands the initial
nprobeby inverse selectivity without a configurable bound. For selective filters, that can make the first search round much wider than desired even though the progressive search path can retry with a larger width when needed.Changes
max_initial_filter_expansion_factorfor automatic IVF search in Rust and Java.1as no filter-driven initial expansion; for example, with basenprobe = 16, factor4caps the initial width at64.top_k.The capped automatic calculation is:
Recall trade-off
The factor is an optional workload-specific tuning knob, not a recommended default. Lower factors reduce initial search work but may reduce Recall@K compared with uncapped automatic search. Progressive expansion occurs only when fewer than
top_kvalid results are returned; if the capped round already fillstop_k, search stops even though probing more lists could improve recall.The primary Rust and Java examples therefore continue to use
automatic(10). Factor4appears only in a clearly marked optional tuning example and should be selected using representative latency and Recall@K measurements.Compatibility
nprobebehavior is unchanged.Tests
cargo test --workspacecargo clippy --workspace --all-targets -- -D warningscargo fmt --all -- --checkmvn -f java/pom.xml test -qpython3 tools/check_license_headers.pygit diff --check