rankops
Operations on ranked lists: fuse multiple retrievers, then rerank. Pairs with rankfns (scoring kernels).
rankops covers the post-retrieval pipeline:
- Fusion -- combine ranked lists from heterogeneous retrievers (BM25, dense, sparse)
- Reranking -- MaxSim/ColBERT late interaction, MMR/DPP diversity, Matryoshka two-stage
- Evaluation -- NDCG, MRR, recall@k, fusion parameter optimization
Quickstart
[]
= "0.1.0"
Fusion
Fuse two ranked lists with Reciprocal Rank Fusion (score-agnostic, works across incompatible scales):
use rrf;
let bm25 = vec!;
let dense = vec!;
let fused = rrf;
// doc_b ranks highest: appears in both lists
assert_eq!;
Score-based fusion when scales are comparable:
use combmnz;
let fused = combmnz;
// CombMNZ: sum of normalized scores * overlap count
Select the algorithm at runtime via FusionMethod:
use FusionMethod;
let method = Rrf ;
let result = method.fuse;
Diversity reranking (requires rerank feature, on by default)
use ;
let candidates = vec!;
let similarity = vec!;
let config = default.with_lambda.with_k;
let selected = mmr;
// Picks d1 (highest relevance), then d3 (diverse from d1)
Fusion algorithms
| Function | Uses scores | Description |
|---|---|---|
rrf |
No | Reciprocal Rank Fusion -- rank-based, works across incompatible scales |
isr |
No | Inverse Square Root fusion -- gentler rank decay than RRF |
borda |
No | Borda count -- (N - rank) voting points |
condorcet |
No | Pairwise Condorcet voting -- outlier-robust |
combsum |
Yes | Sum of min-max normalized scores |
combmnz |
Yes | CombSUM * overlap count -- rewards multi-list presence |
combmax |
Yes | Max score across lists |
combmin |
Yes | Min score -- conservative, requires all retrievers to agree |
combmed |
Yes | Median score -- robust to outliers |
weighted |
Yes | Weighted combination with per-list weights |
dbsf |
Yes | Distribution-Based Score Fusion (z-score normalization) |
standardized |
Yes | ERANK-style z-score fusion with clipping |
All two-list functions have *_multi variants for 3+ lists. Explainability variants (rrf_explain, combsum_explain, etc.) return full provenance.
Reranking (feature: rerank)
| Module | Description |
|---|---|
rerank::colbert |
MaxSim late interaction scoring (ColBERT, ColPali, Jina-ColBERT) |
rerank::diversity |
MMR and DPP diversity selection |
rerank::matryoshka |
Two-stage reranking with nested (Matryoshka) embeddings |
rerank::embedding |
Normalized vectors, masked token MaxSim |
rerank::quantization |
int8 quantization/dequantization for token embeddings |
Features
| Feature | Default | Description |
|---|---|---|
rerank |
Yes | MaxSim, diversity, Matryoshka reranking (depends on innr for SIMD) |
hierarchical |
No | Hierarchical ColBERT clustering (depends on kodama) |
serde |
No | Serialization for configs and types |
Examples
See also
- rankfns -- scoring kernels (BM25, TF-IDF, cosine) that pair with
rankops - innr -- SIMD dot product and MaxSim primitives used by the
rerankfeature
License
MIT OR Apache-2.0