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
+4 -3
View File
@@ -6,8 +6,7 @@ use std::sync::Arc;
use crate::error::NapiErrorExt;
use crate::error::convert_error;
use crate::iterator::RecordBatchIterator;
use crate::rerankers::RerankHybridCallbackArgs;
use crate::rerankers::Reranker;
use crate::rerankers::{RerankHybridCallbackArgs, RerankVectorCallbackArgs, Reranker};
use crate::util::{parse_distance_type, schema_to_buffer};
use arrow_array::{
Array, Float16Array as ArrowFloat16Array, Float32Array as ArrowFloat32Array,
@@ -404,8 +403,10 @@ impl VectorQuery {
pub fn rerank(
&mut self,
rerank_hybrid: Function<RerankHybridCallbackArgs, Promise<Buffer>>,
rerank_vector: Option<Function<RerankVectorCallbackArgs, Promise<Buffer>>>,
output_schema: Option<Function<Buffer, Promise<Buffer>>>,
) -> napi::Result<()> {
let reranker = Reranker::new(rerank_hybrid)?;
let reranker = Reranker::new(rerank_hybrid, rerank_vector, output_schema)?;
self.inner = self.inner.clone().rerank(Arc::new(reranker));
Ok(())
}