Skip to content

fix: accept tuple batches in rerank_pairs - #710

Open
xblwh wants to merge 1 commit into
qdrant:mainfrom
xblwh:fix/rerank-pairs-tuple-batches
Open

xblwh wants to merge 1 commit into
qdrant:mainfrom
xblwh:fix/rerank-pairs-tuple-batches

Conversation

@xblwh

@xblwh xblwh commented Sep 15, 2026

Copy link
Copy Markdown

rerank_pairs() accepts an iterable of query/document pairs, but currently wraps every tuple as a single pair. Passing ((query, doc1), (query, doc2)), a one-element tuple, or an empty tuple raises a tokenizer TypeError.

Only wrap a tuple containing two strings as the existing single-pair shorthand. Treat tuple batches like lists when choosing the small-batch path. The regression tests cover 0–3 pairs with sequential and parallel execution, plus the existing single-pair behavior, using the real MiniLM reranker and canonical scores.

Validation

  • The eight tuple-batch cases fail on unchanged main; both single-pair cases already pass.
  • pytest tests/test_text_cross_encoder.py tests/test_common.py -q: 19 passed, with both current compatible dependencies and the Python 3.12 versions selected from poetry.lock.
  • With the lockfile versions: mypy fastembed --disallow-incomplete-defs --disallow-untyped-defs --disable-error-code=import-untyped passes for all 64 source files; pyright tests/type_stub.py and ruff check fastembed tests pass.
  • The repository's pre-commit hooks pass for both changed files; git diff --check passes.

The full model suite and other OS/Python combinations were not run. Broader Ruff checks report the same existing formatting and experiment-notebook lint findings on unchanged main; resolving the newest dependencies also exposes five existing mypy errors outside this change. These are unchanged by this patch.

Prepared with AI assistance from Codex.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 90fb066a-825d-40db-be60-35c5d79de0e8

📥 Commits

Reviewing files that changed from the base of the PR and between 0dab99c and 0d07193.

📒 Files selected for processing (2)
  • fastembed/rerank/cross_encoder/onnx_text_model.py
  • tests/test_text_cross_encoder.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

_rerank_pairs now treats a two-string tuple as one pair and accepts tuples of pairs for batch processing. Tests cover empty, single, and multiple tuple-of-pairs inputs with sequential and parallel execution. Tests also verify direct single-pair tuples.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 0d071

The tuple-batch behavior is covered across supported input sizes and execution modes, with no established current-head defect.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the tuple-batch fix, preserved single-pair behavior, regression tests, and validation results. It is directly related to the changeset.
Title check ✅ Passed The title clearly and concisely identifies the main change: accepting tuple batches in rerank_pairs.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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