mirror of
https://github.com/lancedb/lancedb.git
synced 2026-08-22 05:58:20 +00:00
fix(node): rerank vector search results
This commit is contained in:
@@ -79,6 +79,18 @@ describe("rerankers", function () {
|
||||
expect(result).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("returns relevance scores when reranking a vector search", async function () {
|
||||
const result = await table
|
||||
.vectorSearch([0.1, 0.1])
|
||||
.limit(2)
|
||||
.rerank(await RRFReranker.create())
|
||||
.toArray();
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0]._relevance_score).toBeCloseTo(1 / 60);
|
||||
expect(result[1]._relevance_score).toBeCloseTo(1 / 61);
|
||||
});
|
||||
|
||||
it("does not keep process alive after rerank query", async function () {
|
||||
const script = `
|
||||
import * as lancedb from "./dist/index.js";
|
||||
|
||||
@@ -5,9 +5,9 @@ import { RecordBatch } from "apache-arrow";
|
||||
|
||||
export * from "./rrf";
|
||||
|
||||
// Interface for a reranker. A reranker is used to rerank the results from a
|
||||
// vector and FTS search. This is useful for combining the results from both
|
||||
// search methods.
|
||||
// Interface for a reranker. A reranker is used to rerank vector and hybrid
|
||||
// search results. For vector-only searches, query is empty and ftsResults is an
|
||||
// empty batch with the same schema as vecResults.
|
||||
export interface Reranker {
|
||||
rerankHybrid(
|
||||
query: string,
|
||||
|
||||
Reference in New Issue
Block a user