Skip to content

fix(cross-encoder): don't crash OpenAI reranker when a response lacks logprobs#1598

Open
ly-wang19 wants to merge 2 commits into
getzep:mainfrom
ly-wang19:fix/openai-reranker-empty-logprobs
Open

fix(cross-encoder): don't crash OpenAI reranker when a response lacks logprobs#1598
ly-wang19 wants to merge 2 commits into
getzep:mainfrom
ly-wang19:fix/openai-reranker-empty-logprobs

Conversation

@ly-wang19

Copy link
Copy Markdown

Summary

OpenAIRerankerClient.rank() crashes with ValueError: zip() argument 2 is shorter than argument 1 when any passage's chat-completion response has no usable top_logprobs. It collected scores in a separate list, continue-ing past empty-logprob responses, then re-paired them with zip(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

  • Bug fix

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

  • Unit tests added/updated
  • All existing tests pass

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-zip ValueError, passes after); one covers the normal all-scored path. ruff clean.

Breaking Changes

  • This PR contains breaking changes

Checklist

  • Code follows project style guidelines (ruff passes)
  • Self-review completed
  • No secrets or sensitive information committed

… 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).
@zep-cla-assistant

zep-cla-assistant Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ly-wang19

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: wly999666@gmail.com

@ly-wang19

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@ly-wang19

Copy link
Copy Markdown
Author

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant