Conversation
Every docstring on this reranker (rerank(), arerank(), and _process_response() itself) promises results "sorted by relevance score (descending)", but the implementation just appended results in whatever order the API response listed them -- no sort() call anywhere. Nothing in the test suite exercised this at all; the only existing tests cover credential validation. Added the sort and two tests covering both an out-of-order response and an already-sorted one.
Collaborator
|
Thank you for this — good catch that every docstring promised score-descending order but nothing actually enforced it, plus solid test coverage for both the out-of-order and already-sorted cases. This fix has been incorporated into #53, which just merged into main (commit 9437e4c). Closing this in favor of that — appreciate the contribution! |
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.
Every docstring on
CloudflareWorkersAIReranker(rerank(),arerank(), and_process_response()itself) promises results sorted by relevance score descending, but the implementation just appended results in whatever order the API response listed them — nosort()call anywhere, and nothing in the test suite exercised this.Tested against the live Workers AI API directly: the default model (
@cf/baai/bge-reranker-base) does already return results sorted by score, so this isn't causing wrong output for the default model today. But the code shouldn't depend on an undocumented assumption about API/model behavior — the sort is one line, and it's what the docstrings already promise regardless of what a given model happens to do.Added the sort plus two tests (an out-of-order response and an already-sorted one). Full unit suite: 138 passed, 2 skipped, 0 regressions.