mirror of
https://github.com/lancedb/lancedb.git
synced 2026-12-03 07:45:17 +00:00
## Summary A vector, full-text or hybrid search can return a row whose reranking text is null. `WatsonxReranker` sent that null in the `inputs` list it passes to `Rerank.generate`, although watsonx.ai reranks a list of strings, so one row with missing text broke reranking for every other row. Filter rows with null text out of the Arrow table before building the request, so the indices watsonx.ai returns still select the right rows and keep their original columns. When every candidate has null text, return an empty scored table without calling the API. The class docstring now says that rows with a null `column` value are left out of the reranked results. This is the same change as #5283 (Cohere) and #5296 (Jina), applied to the watsonx.ai reranker. [watsonx.ai text rerank API](https://cloud.ibm.com/apidocs/watsonx-ai#text-rerank) ## Verification - Added `test_watsonx_reranker_nullable_documents`, run through a real local table and `table.search(...).rerank(...)`, with two cases: - a null between two valid documents, where the mocked client returns reordered indices: only the two valid texts are sent, and the result keeps the correct row IDs, scores, `_distance` column and `float32` `_relevance_score`; - all-null input, where the client is never called and an empty typed result comes back. - Both cases fail on `main` and pass with this change. - Ran against LanceDB 0.42.1 with the changed reranker module copied over the installed one. The installed `watsonx.py` is identical to `main`. I did not call the live watsonx.ai API. - Repository Ruff lint and format checks pass.