fix(python): limit hybrid candidate floor to the default RRF reranker

Custom and model rerankers receive every candidate (OpenaiReranker sends
them all in one prompt), so they keep the caller's limit + offset budget
per side. An empty page (limit 0) no longer gets the floor and is
rejected before any candidates are fetched or scored, as on main.

Adds regression tests for the reranker input sizes (sync and async,
custom reranker and default RRF) and for limit(0), and updates
test_query_sync_hybrid to expect k=50 for the default RRF request.
This commit is contained in:
Sudhir Vissa
2026-11-27 09:29:39 -06:00
parent 4f45aa45ba
commit 2fbfd13166
4 changed files with 193 additions and 18 deletions
+9 -6
View File
@@ -283,12 +283,15 @@ Set `limit()` to the number of results your application needs. The default is 10
A larger candidate set can help a reranker find relevant records, but adds work.
</Info>
In the Python API, each side of a hybrid query (vector and full-text) fetches
at least 50 candidates before rank fusion — `max(limit + offset, 50)` — so for
windows where `limit + offset <= 50`, asking for fewer results returns a
shorter list, not a different ranking. This candidate floor is separate from
`limit()`, which only controls how many fused results are returned (default
10). The Rust and TypeScript APIs retain their existing candidate limits.
In the Python API, with the default RRF reranker, each side of a hybrid query
(vector and full-text) fetches at least 50 candidates before rank fusion —
`max(limit + offset, 50)` — so for windows where `limit + offset <= 50`, asking
for fewer results returns a shorter list, not a different ranking. This
candidate floor is separate from `limit()`, which only controls how many fused
results are returned (default 10). Custom and model rerankers keep receiving
`limit + offset` candidates per side, so raise `limit()` if you want them to
score a wider window. The Rust and TypeScript APIs retain their existing
candidate limits.
### Returning row IDs {#returning-row-ids}