Skip to main content

rrf_fuse

Function rrf_fuse 

Source
pub fn rrf_fuse(
    semantic: &[(usize, f32)],
    bm25: &[(usize, f32)],
    k: f32,
) -> Vec<(usize, f32)>
Expand description

Reciprocal Rank Fusion of two ranked lists.

Each entry in semantic and bm25 is (chunk_index, _score). The fused score for a chunk is the sum of 1 / (k + rank + 1) across every list the chunk appears in, where rank is 0-based.

Returns all chunks that appear in either list, sorted descending by fused RRF score.

k should typically be 60.0 — a conventional constant that smooths the ranking boost for the very top results.