mirror of
https://github.com/lancedb/lancedb.git
synced 2026-12-03 07:45:17 +00:00
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:
@@ -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`<`any`>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`RecordBatch`<`any`>>
|
||||
|
||||
***
|
||||
|
||||
### 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`<`any`>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Schema`<`any`> \| `Promise`<`Schema`<`any`>>
|
||||
|
||||
***
|
||||
|
||||
### rerankHybrid()
|
||||
|
||||
```ts
|
||||
@@ -28,3 +49,23 @@ rerankHybrid(
|
||||
#### Returns
|
||||
|
||||
`Promise`<`RecordBatch`<`any`>>
|
||||
|
||||
***
|
||||
|
||||
### 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`<`any`>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`RecordBatch`<`any`>>
|
||||
|
||||
Reference in New Issue
Block a user