fix(retrievers): apply retriever_weights in reciprocal_rerank_fusion mode#21467
Closed
VANDRANKI wants to merge 1 commit into
Closed
fix(retrievers): apply retriever_weights in reciprocal_rerank_fusion mode#21467VANDRANKI wants to merge 1 commit into
VANDRANKI wants to merge 1 commit into
Conversation
…mode
_reciprocal_rerank_fusion iterated over results.values(), discarding the
(query_str, retriever_idx) key. As a result, every retriever contributed
1.0 / (rank + k) regardless of its configured weight; retriever_weights was
silently ignored when mode="reciprocal_rerank".
_relative_score_fusion already extracts retriever_idx = query_tuple[1] and
multiplies by self._retriever_weights[retriever_idx]. Apply the same
pattern in _reciprocal_rerank_fusion: iterate over results.items(), extract
the retriever index from the key, and scale the RRF score by the weight:
fused_scores[hash] += weight / (rank + k)
Fixes run-llama#21444
Contributor
|
hi @VANDRANKI there is already a PR i created along with the issue #21445. Please review existing work before mass opening AI PRs :) Infact, you even commented on my PR saying LGTM lol |
Author
|
Closes as duplicate of #21445 by @gautamvarmadatla, which was already open before this PR was created. Apologies for the noise - I should have checked for existing open PRs before opening this. To make it worse, I had already reviewed #21445 and left LGTM on it, then opened this competing PR. That was a serious oversight. Please disregard this PR and consider #21445 instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Setting
retriever_weightson aQueryFusionRetrieverwithmode="reciprocal_rerank"has no effect — all retrievers are weighted equally. The weights are silently ignored.Root cause
_reciprocal_rerank_fusioniterates overresults.values(), discarding the(query_str, retriever_idx)key. Each node always gets1.0 / (rank + k)regardless of its retriever's weight:_relative_score_fusionalready does this correctly withretriever_idx = query_tuple[1]andself._retriever_weights[retriever_idx].Fix
Switch to
results.items(), extractretriever_idxfrom the key, and scale the RRF contribution byself._retriever_weights[retriever_idx]:This mirrors the weight application in
_relative_score_fusionand was introduced in PR #11667 but not carried through to the RRF path.Fixes #21444