fix(cross-encoder): don't crash OpenAI reranker when a response lacks logprobs#1598
Open
ly-wang19 wants to merge 2 commits into
Open
fix(cross-encoder): don't crash OpenAI reranker when a response lacks logprobs#1598ly-wang19 wants to merge 2 commits into
ly-wang19 wants to merge 2 commits into
Conversation
… logprobs OpenAIRerankerClient.rank() collected scores in a separate list, skipping any response whose top_logprobs were empty, then paired them back with zip(passages, scores, strict=True). A single empty/truncated response made scores shorter than passages, so the strict zip raised 'zip() argument 2 is shorter than argument 1' and the entire rank() failed instead of just dropping the unscoreable passage. Pair each passage with its own response while iterating so the lists can't desync, keeping the skip behaviour without the crash. Adds unit tests for the OpenAI reranker (previously untested).
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: wly999666@gmail.com |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
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
OpenAIRerankerClient.rank()crashes withValueError: zip() argument 2 is shorter than argument 1when any passage's chat-completion response has no usabletop_logprobs. It collected scores in a separate list,continue-ing past empty-logprob responses, then re-paired them withzip(passages, scores, strict=True)— so a single skipped response desyncs the two lists and the strict zip raises, failing the entire rerank instead of just dropping the one unscoreable passage.Type of Change
Objective
A single empty/truncated reranker response (possible with
max_tokens=1+logit_bias) shouldn't take down the whole reranking. Pair each passage with its own response while iterating so the lists can't desync — keeping the existing "skip the unscoreable passage" behaviour, without the crash.Testing
Added
tests/cross_encoder/test_openai_reranker_client.py(the OpenAI reranker was previously untested): one test feeds an empty-logprobs response in the middle and asserts the other passages still rank (fails before the change with the strict-zipValueError, passes after); one covers the normal all-scored path.ruffclean.Breaking Changes
Checklist
ruffpasses)