research: nightly 2026-07-16 — partition-aware diverse ANN retrieval (ADR-272)#700
Draft
ruvnet wants to merge 1 commit into
Draft
research: nightly 2026-07-16 — partition-aware diverse ANN retrieval (ADR-272)#700ruvnet wants to merge 1 commit into
ruvnet wants to merge 1 commit into
Conversation
…val (ADR-272)
Introduces `ruvector-diverse-retrieval` (v0.1.0): a partition-aware diversity
layer for ANN retrieval that extends MMR with a graph-cut-inspired same-cluster
penalty, forcing result sets to span distinct semantic regions.
Algorithm (PartitionMMR):
1. Retrieve POOL_FACTOR×k candidates by L2 distance
2. Estimate connectivity threshold T = 0.55 × mean_pairwise_L2(full_pool)
3. Build candidate connectivity graph; extract components via Union-Find
4. Greedy selection: score(c) = −λ·dist_q + (1−λ)·min_dist_selected
− penalty·same_partition_count
Benchmark results (cargo run --release, x86_64 Linux, 26 tests PASS):
TopK 271µs 2.574 div 2.234 rel 3686 QPS
MMR 444µs 5.696 div 4.017 rel 2253 QPS
PartitionMMR 726µs 8.377 div 6.207 rel 1378 QPS
— 3.25× more diverse than TopK; 1.47× more diverse than MMR
Key threshold fix: use full pool for mean_d estimation, not nearest-N subset.
Nearest-N samples only intra-sub distances → threshold too small → all
singletons → penalty never fires. Full pool gives bimodal distribution whose
mean yields threshold between intra-sub (2.83) and inter-sub (13.57) modes.
Deliverables:
- crates/ruvector-diverse-retrieval/ (7 source files, 26 unit tests)
- docs/research/nightly/2026-07-16-mincut-diverse-retrieval/README.md
- docs/research/nightly/2026-07-16-mincut-diverse-retrieval/gist.md
- docs/adr/ADR-272-mincut-diverse-retrieval.md
Connects: vector search · graph primitives (union-find) · agent memory ·
ruFlo workflows · MCP tool surface
Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_017eFfHcb25Yc8UqsAPxkxbm
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-diverse-retrieval(v0.1.0): a new standalone Rust crate implementing three ANN retrieval variants —TopKRetriever,MmrRetriever, andPartitionMmrRetriever.PartitionMmrRetrieverextends standard MMR with a graph-cut-inspired partition layer: builds an ephemeral connectivity graph over the candidate pool, extracts connected components via Union-Find, and applies a per-selection penalty when a candidate shares its component with an already-chosen result.Key Files
crates/ruvector-diverse-retrieval/src/partition_mmr.rscrates/ruvector-diverse-retrieval/src/graph.rscrates/ruvector-diverse-retrieval/src/dataset.rscrates/ruvector-diverse-retrieval/src/main.rsdocs/adr/ADR-272-mincut-diverse-retrieval.mddocs/research/nightly/2026-07-16-mincut-diverse-retrieval/README.mddocs/research/nightly/2026-07-16-mincut-diverse-retrieval/gist.mdBenchmark Results (
cargo run --release, x86_64 Linux)Dataset: 10 super-clusters × 6 sub-clusters × 50 vectors = 3,000 total, 64 dims.
Algorithm Design Note
The threshold for the connectivity graph must be estimated from the full candidate pool, not a nearest-N subset. Using only the nearest N candidates yields a sample dominated by intra-sub-cluster distances, producing a threshold too small to connect within-sub pairs → all singletons → partition penalty never fires. The full pool's bimodal distribution (intra-sub ≈ 2.83, inter-sub ≈ 13.57) gives a mean (~11.94) between the two modes, and
0.55 × mean ≈ 6.57correctly connects within-sub pairs while leaving between-sub pairs separate.Ecosystem Connections
Connects three RuVector themes:
DiverseRetrievertraitgraph.rsmirrors the primitives inruvector-mincutvector/search_diversewithdiversity_modeparamTest Plan
cargo test -p ruvector-diverse-retrieval— 26 tests passcargo run --release -p ruvector-diverse-retrieval— all 4 acceptance tests passcargo fmt -p ruvector-diverse-retrieval— appliedruvector-coherence-hnsw(future PR)ruvector-diverse-retrieval-wasm(future PR)vector/search_diverse(future PR)Generated by Claude Code