Expand description
Matryoshka-aware coarse-to-fine vector search for RuVector.
Three ANN search variants that trade distance-computation cost against recall:
| Variant | Stages | Distance ops |
|---|---|---|
FullDim | Single HNSW at full dim | All at D dims |
TwoStage | Coarse HNSW + full-dim rerank | Traverse at D1, rerank at D |
ThreeStage | Coarse → mid → full-dim funnel | Traverse D1, filter D2, rerank D |
The primary metric is recall@k: fraction of the true top-k (found by brute-force at full dimension) that each variant recovers.
Modules§
- dataset
- Deterministic synthetic dataset generator simulating Matryoshka embedding structure.
- hnsw
- Minimal HNSW graph parameterized by a working dimension.
Structs§
- Full
DimIndex - Standard HNSW search at the full embedding dimension. Baseline for both recall and latency.
- Matryoshka
Config - Three
Stage Index - Three-stage funnel: coarse_dim → mid_dim filter → full_dim rerank.
- TwoStage
Index - Coarse HNSW at
coarse_dim, then full-dim rerank of the candidate set.
Traits§
Functions§
- brute_
force_ knn - Brute-force exact top-k at full dimension (ground truth).
- l2_
normalize - L2-normalise a vector in-place.
- l2_sq
- prefix_
project - Return the first
dimelements, L2-normalised. - recall_
at_ k - Recall@k: fraction of ground-truth top-k that appear in the result set.