Skip to main content

weighted_sum_fuse

Function weighted_sum_fuse 

Source
pub fn weighted_sum_fuse(
    result_sets: &[Vec<SearchResult>],
    weights: &[f32],
) -> Vec<SearchResult>
Expand description

Fuse score-normalized lists by weighted sum.

Computes score(d) = Σ_i weight_i * score_i(d) across the input lists, merging duplicate ids (keeping the first text seen) and sorting the output descending by score.

§Precondition

weights.len() must equal result_sets.len() — this is enforced with a runtime assertion (a mismatch is programmer error and panics rather than silently dropping inputs). Each result set should already be normalized (e.g. via normalize_minmax) so the weighted sum is meaningful.