Skip to content

fix: apply retriever weights in reciprocal rank fusion#22171

Closed
fengjikui wants to merge 1 commit into
run-llama:mainfrom
fengjikui:fix/query-fusion-rrf-weights
Closed

fix: apply retriever weights in reciprocal rank fusion#22171
fengjikui wants to merge 1 commit into
run-llama:mainfrom
fengjikui:fix/query-fusion-rrf-weights

Conversation

@fengjikui

Copy link
Copy Markdown

Summary

Root cause

_reciprocal_rerank_fusion() iterated over results.values(), which discarded the (query, retriever_idx) key. Without retriever_idx, the reciprocal rank score always used an implicit equal weight.

Fix

The method now iterates over results.items(), reads the retriever index from the key, and scales each reciprocal-rank contribution by self._retriever_weights[retriever_idx].

Validation

  • uv run --frozen --project llama-index-core pytest llama-index-core/tests/retrievers/test_fusion_retriever.py -q
  • uv run --frozen --project llama-index-core ruff format --check llama-index-core/llama_index/core/retrievers/fusion_retriever.py llama-index-core/tests/retrievers/test_fusion_retriever.py
  • uv run --frozen --project llama-index-core ruff check llama-index-core/llama_index/core/retrievers/fusion_retriever.py llama-index-core/tests/retrievers/test_fusion_retriever.py

AI assistance

I used AI assistance to help trace the narrow code path and draft this small patch, then manually reviewed the diff and validated it with the commands above.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 27, 2026
@gautamvarmadatla

gautamvarmadatla commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Hi @fengjikui, please check existing open PRs before mass opening new ones. Most of your PRs are duplicating existing work, and I’ve already left comments on multiple other PRs of yours. Even for this PR there is #21445 :)

@fengjikui

Copy link
Copy Markdown
Author

Thanks for pointing this out. I re-checked #21445 and confirmed it already covers the same #21444 issue, the same QueryFusionRetriever reciprocal-rank weighting path, and the same test area. Closing this PR as duplicate so review can stay focused on the earlier PR.

@fengjikui fengjikui closed this Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: QueryFusionRetriever ignores retriever_weights when mode="reciprocal_rerank"

2 participants