Skip to main content

hybrid_merge

Function hybrid_merge 

pub fn hybrid_merge(
    vector_results: &[(String, f32)],
    keyword_results: &[(String, f32)],
    vector_weight: f32,
    keyword_weight: f32,
    limit: usize,
) -> Vec<ScoredResult>
Expand description

Hybrid merge: combine vector and keyword results with weighted fusion.

Normalizes each score set to [0, 1], then fuses each candidate using only the modalities it actually has. The contributing weights are normalized so a keyword-only candidate is not penalized merely because another candidate has a vector score (and vice versa).

Deduplicates by id, keeping the best score from each source.