Fix reranked scores not matching reranked document order in HFCrossEncoderReranker - #694
Merged
vishal-bala merged 2 commits intoAug 20, 2026
Conversation
vishal-bala
self-requested a review
August 17, 2026 09:19
vishal-bala
reviewed
Aug 17, 2026
vishal-bala
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the fix! Just one very minor optimization and I think we're good to go
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit ff4f898. Configure here.
Collaborator
|
Hi, this looks good! You just need to rebase onto |
adityaanikam
force-pushed
the
fix-cross-encoder-score-alignment-693
branch
from
August 19, 2026 18:24
ff4f898 to
919bddc
Compare
Contributor
Author
done |
vishal-bala
approved these changes
Aug 20, 2026
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.

Fixes #693.
HFCrossEncoderReranker.rank() sorted docs_with_scores by score to build reranked_docs, but then took scores from the original unsorted scores list instead of from the same sorted sequence. So reranked_docs[i] and scores[i] didn't correspond to the same document once the reranking actually changed the order. arank() delegates to rank(), so this fixes both.
Added a regression test that asserts the returned scores are sorted descending, matching the returned docs. Confirmed it fails with the old code (scores come back in the original order, not sorted) and passes with the fix, using a real cross-encoder model against the exact reproduction from the issue.
Note
Low Risk
Small, localized bugfix in reranker output pairing with a regression test; no auth, data, or API contract changes beyond correcting score alignment.
Overview
Fixes misaligned scores in
HFCrossEncoderReranker.rank()when reranking changes document order (#693).After sorting
(doc, score)pairs by score, the method now builds bothreranked_docsand the returnedscoresfrom that same sorted slice. Previously it sliced the sorted docs but still returned scores from the original prediction order, so indexiin docs and scores could refer to different hits.Adds an integration regression test that checks returned scores are in descending order when
return_scoreis true (the failure mode from the old code).Reviewed by Cursor Bugbot for commit 919bddc. Bugbot is set up for automated code reviews on this repo. Configure here.