rankops
Rank fusion and reranking.
Quickstart
[]
= "0.1.4"
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)
MMR selects the next document by balancing relevance against redundancy:
$$\text{MMR} = \arg\max_{d_i \in R \setminus S}\left[\lambda \cdot \text{rel}(d_i) - (1-\lambda) \cdot \max_{d_j \in S} \text{sim}(d_i, d_j)\right]$$
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
15 fusion methods: rank-based (rrf, isr, borda, condorcet, copeland, median_rank) and score-based (combsum, combmnz, combmax, combmin, combmed, combanz, weighted, dbsf, standardized). All two-list functions have *_multi variants for 3+ lists. Explainability variants (rrf_explain, combsum_explain, etc.) return full provenance. Score normalization via Normalization enum (MinMax, ZScore, Quantile, Sigmoid, Sum, Rank).
Evaluation
Standard IR metrics: ndcg_at_k, map, mrr, precision_at_k, recall_at_k, hit_rate. Plus optimize_fusion for grid search over fusion parameters.
Diagnostics
The diagnostics module (diagnose, overlap_ratio, complementarity, rank_correlation) helps decide whether fusion is beneficial, based on Louis et al., "Know When to Fuse" (2024).
Adapters
The adapt module converts retriever outputs (distances, similarities, logits, inner products) to rankops format with optional ID mapping.
Pipeline
The pipeline module provides composable post-retrieval operations:
use Pipeline;
use ;
let result = new
.add_run
.add_run
.normalize
.fuse
.top_k
.execute;
Also: compare() for method comparison, fuse_multi_query() for the N-queries x M-retrievers RAG pattern.
Reranking (feature: rerank)
ColBERT MaxSim scoring, MMR/DPP diversity selection, Matryoshka two-stage reranking, and int8 quantization for token embeddings. On by default; also available: hierarchical (ColBERT clustering) and serde.
Examples
License
MIT OR Apache-2.0