[Feature] Native support for hybrid retrieval scoring fusion
Description
When using hybrid retrieval (dense + sparse), combining scores from different retrievers requires manual implementation of fusion methods like RRF or weighted combination. Built-in support would simplify production setups.
Proposed API
from haystack.components.rankers import ScoreFusion
fusion = ScoreFusion(method='rrf', weights={'dense': 0.7, 'sparse': 0.3})
This would help standardize hybrid retrieval patterns across the community.
Hi @reallyticsai ,
I'd like to help implement this feature. Here's my full proposal:
Component Design
Add a ScoreFusion component under haystack/components/rankers/ that accepts outputs from multiple retrievers and merges them into a single ranked list.
Supported Methods
rrf(Reciprocal Rank Fusion) — rank-based, avoids score normalization issues across dense/sparse retrievers. Best default.linear— weighted sum of scores, useful when scores are already normalized (e.g. cosine similarity in [0,1])
Proposed API
from haystack.components.rankers import ScoreFusion
# Simple case — equal weights, RRF
fusion = ScoreFusion(method='rrf')
# Weighted linear combination
fusion = ScoreFusion(method='linear', weights={'dense': 0.7, 'sparse': 0.3})
Key Behaviours
- Accepts a list of
Documentlists from multiple retrievers - Deduplicates documents that appear in multiple retriever results
- Defaults to equal weighting so zero config works out of the box
- Slots naturally into a Haystack pipeline after multiple retrievers
Out of Scope (for now)
- Borda count, CombMNZ and other advanced fusion strategies (can be added later)
Let me know if this direction works or if there are design constraints I should be aware of. Happy to open a draft PR once I get a thumbs up!
Hey @reallyticsai thanks for opening the issue!
We do in fact have a component that already does what you'd like. Check out the DocumentJoiner https://docs.haystack.deepset.ai/docs/documentjoiner which is specifically designed to accept multiple different lists of documents and has different fusion scoring methods including reciprocal rank fusion.
You can see how to use it in a pipeline here https://docs.haystack.deepset.ai/docs/documentjoiner#hybrid-retrieval
I'll close this for now. Feel free to re-open if this doesn't fully cover your use case.