Skip to main content

Crate rerank_blend

Crate rerank_blend 

Source
Expand description

§rerank-blend

Blend N reranker score streams into one final ranking.

Two strategies:

  • blend_weighted — min-max-normalize each stream, multiply by its weight, sum, return sorted descending.
  • blend_rrf — Reciprocal Rank Fusion (Cormack et al. 2009): each stream contributes 1 / (k + rank), default k = 60. Score-free; works across heterogeneous score scales.

§Example

use rerank_blend::{blend_weighted, blend_rrf, RrfOpts};

let dense = vec![("a", 0.91), ("b", 0.88), ("c", 0.55)];
let bm25  = vec![("a", 12.3), ("c", 8.1), ("b", 3.4)];

let blended = blend_weighted(&[(&dense, 0.7), (&bm25, 0.3)]);
assert_eq!(blended[0].0, "a");

let rrf = blend_rrf(&[&dense, &bm25], RrfOpts::default());
assert_eq!(rrf[0].0, "a");

Structs§

RrfOpts
Options for Reciprocal Rank Fusion.

Functions§

blend_rrf
Reciprocal Rank Fusion. Streams must be pre-sorted by rank (best first).
blend_weighted
Weighted blend with per-stream min-max normalization. Streams whose max == min contribute zero to ensure the normalization is well-defined.