ruvector/crates/ruvector-adaptive-ann
rUv a4f9991d9d
feat: add k-scoped adaptive ANN calibration (#718)
* research: add nightly survey for adaptive-recall-ann

Identifies adaptive recall-targeted ANN as the 2026-07-23 nightly topic.
Connects vector search, agent memory, edge AI, MCP tool latency SLAs,
and ruFlo workflow recall budgets. No prior nightly covered this angle.

* feat: add ruvector-adaptive-ann Rust proof of concept

Implements RecallTargetedSearch trait with three variants:
- FixedEfSearch (baseline): constant ef=64, ignore recall target
- BinarySearchCalibrated: binary-search ef per query with ground truth
- TableCalibratedSearch: O(1) ef lookup from offline calibration table

Core insight: calibration queries must match production query distribution.
CalibrationTable is a monotone ef→recall mapping from 50-100 held-out queries.

Benchmark: N=3000×D=64, recall_target=0.90
- FixedEf(64): 0.778 recall, 9,497 QPS (misses target)
- BinarySearch: 0.902 recall, 738 QPS (oracle, 13x slower)
- TableCalibrated: 0.940 recall, 4,390 QPS (exceeds target, O(1) ef)

* test: add 7 integration tests for ruvector-adaptive-ann

- beam search at ef=N achieves near-perfect recall
- recall is monotone in ef
- FixedEf(128) achieves minimum recall threshold
- CalibrationTable returns valid ef
- TableCalibratedSearch achieves recall within distribution-mismatch tolerance
- BinarySearchCalibrated achieves per-query target on 12/15 queries
- effective_ef_for_target returns Some for Table, None for Fixed

All 7 tests pass.

* docs: add ADR-272 for adaptive-recall-ann

Documents the calibration table approach, distribution matching constraint,
three implementation variants, benchmark evidence, failure modes, security
considerations, and migration path for adopting recall-targeted search.

ADR-272 status: Proposed.

* bench: capture adaptive-recall-ann benchmark results

cargo run --release -p ruvector-adaptive-ann --bin benchmark
x86_64 Linux, release build, N=3000 D=64 300 queries

FixedEf(64): recall=0.778, mean=105.3µs, QPS=9497
BinarySearch: recall=0.902, mean=1355µs, QPS=738
TableCalibrated: recall=0.940, mean=227.8µs, QPS=4390
All acceptance tests PASSED.

* fix adaptive ANN calibration scope

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-27 09:57:49 -07:00
..
src feat: add k-scoped adaptive ANN calibration (#718) 2026-07-27 09:57:49 -07:00
tests feat: add k-scoped adaptive ANN calibration (#718) 2026-07-27 09:57:49 -07:00
Cargo.toml feat: add k-scoped adaptive ANN calibration (#718) 2026-07-27 09:57:49 -07:00
README.md feat: add k-scoped adaptive ANN calibration (#718) 2026-07-27 09:57:49 -07:00

ruvector-adaptive-ann

Research implementations of empirical ef calibration for graph-based approximate nearest-neighbour search.

Calibration tables are specific to the result count (k), graph, and sampled query distribution. They estimate mean recall observed during calibration and do not provide a per-query recall guarantee. Recalibrate and audit whenever the data, graph, or workload shifts.

cargo test -p ruvector-adaptive-ann
cargo run --release -p ruvector-adaptive-ann --bin benchmark

See docs/adr/ADR-272-adaptive-recall-ann.md and the associated nightly report for methodology and limitations.