research(nightly): adaptive-ef-ann — per-query beam-width adaptation with difficulty estimation#687
Draft
ruvnet wants to merge 2 commits into
Draft
research(nightly): adaptive-ef-ann — per-query beam-width adaptation with difficulty estimation#687ruvnet wants to merge 2 commits into
ruvnet wants to merge 2 commits into
Conversation
Scans 2025-2026 SOTA (Ada-ef SIGMOD 2026, DARTH PACMMOD 2025, Distance Adaptive Beam Search arxiv:2505.15636, Steiner-Hardness PVLDB 2025) and identifies the unoccupied production gap: no vector database does per-query adaptive ef. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01S8Ld29ZwnRw92dhiwZxHsG
Implements adaptive beam-width ANN search with distance-ratio difficulty estimation. Three variants over a shared ProximityGraph: - FixedEfSearch (baseline, ef=32) - TwoStageSearch (ef=16 probe, escalate to ef=64 if difficulty > 0.70) - AdaptiveEfSearch (continuous ef ∈ [16,64] from difficulty score) Measured: AdaptiveEf 4.4% fewer ops than TwoStage at 97% of its recall. Both adaptive variants achieve 1.51-1.56× recall of FixedEf(32). All 4 acceptance gates pass. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01S8Ld29ZwnRw92dhiwZxHsG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
crates/ruvector-adaptive-ef: a zero-dependency Rust crate implementing per-query adaptive beam-width ANN search using a distance-ratio difficulty estimatordocs/research/nightly/2026-07-13-adaptive-ef-ann/README.md: full research document with SOTA survey, 10–20 year thesis, architecture, implementation notes, and real benchmark resultsdocs/adr/ADR-272-adaptive-ef-ann.md: architectural decision record for production integration pathdocs/research/nightly/2026-07-13-adaptive-ef-ann/gist.md: SEO-optimised public articleProblem
Standard HNSW and proximity-graph ANN search use a fixed beam width (
ef) for every query. No production vector database (Qdrant, Weaviate, Milvus, LanceDB) implements per-query adaptive ef. This wastes compute on easy queries and drops recall on hard ones — a critical problem for agent memory workloads where factual lookups (easy) and cross-modal reasoning (hard) coexist.Approach
Three strategies over a shared
ProximityGraph(HNSW layer-0 analogue), all implementing theAnnSearchtrait:Difficulty score:
d₁ / d_k— ratio of nearest to k-th candidate distance. Zero extra distance computations, zero offline learning.Benchmark Results (N=5000 × D=128, k=10, 200 queries, release build)
All 4 acceptance gates pass. AdaptiveEf uses 4.4% fewer ops than TwoStage at 97% of its recall, and achieves 1.51× the recall of FixedEf(32).
Test Plan
cargo build --release -p ruvector-adaptive-ef— greencargo test -p ruvector-adaptive-ef— 13/13 tests passcargo run --release -p ruvector-adaptive-ef --bin benchmark— all 4 gates passcargo fmt -p ruvector-adaptive-ef— cleanFiles
crates/ruvector-adaptive-ef/— new crate (4 source files, all <350 lines each, zero deps)docs/research/nightly/2026-07-13-adaptive-ef-ann/README.md— research documentdocs/research/nightly/2026-07-13-adaptive-ef-ann/gist.md— public articledocs/adr/ADR-272-adaptive-ef-ann.md— ADR proposing integration pathCargo.toml— addscrates/ruvector-adaptive-efto workspace membersResearch Links
docs/research/nightly/2026-07-13-adaptive-ef-ann/README.mddocs/adr/ADR-272-adaptive-ef-ann.md🤖 Generated with claude-flow
https://claude.ai/code/session_01S8Ld29ZwnRw92dhiwZxHsG
Generated by Claude Code