You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handle vector outputs from ONNX cross-encoders - #945
Checked for existing issues and pull requests covering this change.
A custom ONNX cross-encoder can emit one score per pair as a vector with shape [batch]. FastEmbed currently indexes that vector as a matrix, raising IndexError instead of returning scores.
Use the vector directly when the first ONNX output is one-dimensional. For matrix outputs, keep selecting the first column.
Validation
Two tiny local ONNX models exercise vector and column outputs through rerank, serial rerank_pairs, and parallel rerank_pairs. On the original implementation, the three vector cases fail and the three column controls pass. All six pass with the change.
On macOS arm64 with Python 3.13.15, 11 offline custom-model tests passed, both Ruff pre-commit hooks passed, and mypy reported no issues in 71 source files. GitHub Actions covers the model-backed suite, Pyright, and the OS/Python matrix.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
No actionable comments were generated in the recent review.
Walkthrough
The ONNX cross-encoder scoring path now accepts one-dimensional model output as scores. For outputs with additional dimensions, it continues to select the first column. Parameterized tests cover vector and column outputs through rerank and sequential and parallel rerank_pairs.
qdrant/fastembed#882: Addresses the same vector-shaped ONNX score output case in the scoring path.
Merge Risk: Minimal · up to a5576
Custom cross-encoders whose first output is a per-pair score vector now work instead of failing with an IndexError, and matrix outputs behave as before. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: ONNX cross-encoder outputs that are one-dimensional vectors are now handled. The raw summary and objectives confirm that onnx_embed_pairs uses one-dimensional output d…
Description check
The description states the problem (a one-dimensional [batch] ONNX output raises IndexError), the fix (use the vector directly, keep first-column selection for matrices), and the validation performed.…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: ONNX cross-encoder outputs that are one-dimensional vectors are now handled. The raw summary and objectives confirm that onnx_embed_pairs uses one-dimensional output directly and keeps first-column selection for matrix outputs.
Full details: Description check
Explanation
The description states the problem (a one-dimensional [batch] ONNX output raises IndexError), the fix (use the vector directly, keep first-column selection for matrices), and the validation performed. This matches the raw summary and objectives.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 698c92d6-8fd7-49bb-834e-e2cb5321fcd4
Commits
Reviewing files that changed from the base of the PR and between ac9ab5c and a55761a.
Files selected for processing: 4
fastembed/rerank/cross_encoder/onnx_text_model.py
tests/misc/reranker_scores_column.onnx
tests/misc/reranker_scores_vector.onnx
tests/test_custom_models.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This branch has not been deployed
No deployments
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
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.
All Submissions
A custom ONNX cross-encoder can emit one score per pair as a vector with shape
[batch]. FastEmbed currently indexes that vector as a matrix, raisingIndexErrorinstead of returning scores.Use the vector directly when the first ONNX output is one-dimensional. For matrix outputs, keep selecting the first column.
Validation
rerank, serialrerank_pairs, and parallelrerank_pairs. On the original implementation, the three vector cases fail and the three column controls pass. All six pass with the change.Developed and tested with Codex assistance.