Skip to content

feat: Add reciprocal rank fusion to MultiRetriever#11220

Merged
sjrl merged 5 commits intomainfrom
add-rrf-multi-retriever
Apr 30, 2026
Merged

feat: Add reciprocal rank fusion to MultiRetriever#11220
sjrl merged 5 commits intomainfrom
add-rrf-multi-retriever

Conversation

@sjrl
Copy link
Copy Markdown
Contributor

@sjrl sjrl commented Apr 29, 2026

Related Issues

Proposed Changes:

Add join_mode param to MultiRetriever like in DocumentJoiner with the default set to rank and de-duplicate via reciprocal rank fusion. Makes the component's runs more consistent and reproducible and produces a decent ranking without needing to specify any additional rankers. RRF must be baked in and can't be done downstream b/c the returned list is flattened so the info needed for RRF is lost.

Created new util method to reuse in both components

How did you test it?

Added new unit tests

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@sjrl sjrl requested a review from a team as a code owner April 29, 2026 13:22
@sjrl sjrl requested review from bogdankostic and removed request for a team April 29, 2026 13:22
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Preview Apr 30, 2026 11:07am

Request Review

@sjrl
Copy link
Copy Markdown
Contributor Author

sjrl commented Apr 29, 2026

cc @julian-risch

@sjrl sjrl self-assigned this Apr 29, 2026
@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/joiners
  document_joiner.py
  haystack/components/retrievers
  multi_retriever.py 122
  haystack/utils
  misc.py
Project Total  

This report was generated by python-coverage-comment-action

@claude
Copy link
Copy Markdown

claude Bot commented Apr 29, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Copy link
Copy Markdown
Contributor

@bogdankostic bogdankostic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good in general, let's just distinguish the same name _reciprocal_rank_fusion for the utility function and the method of DocumentJoiner.

Also, in DocumentJoiner we allow to set weights for the different retrieval results, should we support that for MultiRetriever as well?

@@ -196,32 +197,8 @@ def _merge(self, document_lists: list[list[Document]]) -> list[Document]:
def _reciprocal_rank_fusion(self, document_lists: list[list[Document]]) -> list[Document]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the method shadows the name of the imported utility function, maybe we can have different names for both for better readability?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0800212

@sjrl
Copy link
Copy Markdown
Contributor Author

sjrl commented Apr 30, 2026

Also, in DocumentJoiner we allow to set weights for the different retrieval results, should we support that for MultiRetriever as well?

I think it's fine to leave out for now and we can add it later if people ask for it. I expect that most users will be sending these docs downstream to a ranker component anyways.

@sjrl sjrl requested a review from bogdankostic April 30, 2026 11:09
Copy link
Copy Markdown
Contributor

@bogdankostic bogdankostic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sjrl sjrl merged commit 744198c into main Apr 30, 2026
27 checks passed
@sjrl sjrl deleted the add-rrf-multi-retriever branch April 30, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants