feat: support vector-only and FTS-only reranking (#3024)

Add rerank_vector() and rerank_fts() methods to Reranker trait, allowing
rerankers to work with single search modes instead of only hybrid
search.

Implemented for:
- RRFReranker (Rust and Python)
- LinearCombinationReranker (Python)

Resolves TODO at rust/lancedb/src/rerankers.rs:55

Changes:
- Extended Reranker trait with default implementations
- Added unit tests for new methods
- Updated documentation with examples

---------

Co-authored-by: Xuanwo <github@xuanwo.io>
This commit is contained in:
KeeProMise
2026-12-01 17:07:02 +08:00
committed by GitHub
co-authored by Xuanwo
parent 22ed284031
commit a85cb92ffd
19 changed files with 1404 additions and 131 deletions
+2
View File
@@ -668,6 +668,8 @@ distance between the query vector and the actual uncompressed vector.
rerank(reranker): VectorQuery
```
Apply a reranker to this vector or hybrid query.
#### Parameters
* **reranker**: [`Reranker`](../namespaces/rerankers/interfaces/Reranker.md)
@@ -33,6 +33,26 @@ rerankHybrid(
***
### rerankVector()
```ts
rerankVector(query, results): Promise<RecordBatch<any>>
```
Score vector search results by their one-based rank.
#### Parameters
* **query**: `string`
* **results**: `RecordBatch`&lt;`any`&gt;
#### Returns
`Promise`&lt;`RecordBatch`&lt;`any`&gt;&gt;
***
### create()
```ts
@@ -6,8 +6,29 @@
# Interface: Reranker
Reranks vector or hybrid search results.
## Methods
### outputSchema()?
```ts
optional outputSchema(input): Schema<any> | Promise<Schema<any>>
```
Declare the output fields for vector reranking. The default keeps the
input fields and appends a non-nullable Float32 `_relevance_score` field.
#### Parameters
* **input**: `Schema`&lt;`any`&gt;
#### Returns
`Schema`&lt;`any`&gt; \| `Promise`&lt;`Schema`&lt;`any`&gt;&gt;
***
### rerankHybrid()
```ts
@@ -28,3 +49,23 @@ rerankHybrid(
#### Returns
`Promise`&lt;`RecordBatch`&lt;`any`&gt;&gt;
***
### rerankVector()?
```ts
optional rerankVector(query, results): Promise<RecordBatch<any>>
```
Rerank one vector result list. The query string is empty for vector queries.
#### Parameters
* **query**: `string`
* **results**: `RecordBatch`&lt;`any`&gt;
#### Returns
`Promise`&lt;`RecordBatch`&lt;`any`&gt;&gt;