Reranking is the process of re-ordering search results to improve relevance, often using a different model than the one used for the initial search. LanceDB has built-in support for reranking with models from Cohere, Sentence-Transformers, and more.Documentation Index
Fetch the complete documentation index at: https://lancedb-bcbb4faf-docs-namespace-typescript-examples.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Quickstart
To use a reranker, you perform a search and then pass the results to thererank() method.
Supported Rerankers
LanceDB supports several rerankers out of the box. Here are a few examples:| Reranker | Default Model |
|---|---|
CohereReranker | rerank-english-v2.0 |
CrossEncoderReranker | cross-encoder/ms-marco-MiniLM-L-6-v2 |
ColbertReranker | colbert-ir/colbertv2.0 |
SDK coverage differs across languagesThe provider-specific rerankers in the table above
(
CohereReranker, CrossEncoderReranker, ColbertReranker, and others under lancedb.rerankers)
are currently Python-only. The TypeScript and Rust SDKs currently expose the generic Reranker
interface (rerankHybrid / rerank_hybrid) and the built-in RRFReranker. To use a
model-based reranker from TypeScript or Rust, you must implement the Reranker interface yourself.Multi-vector reranking
Most rerankers support reranking based on multiple vectors. To rerank based on multiple vectors, you can pass a list of vectors to thererank method. Here’s an example of how to rerank based on multiple vector columns using the CrossEncoderReranker:
- Passing
deduplicate=Truetorerank_multivector(...)raises aValueErrorif any of the input result sets is missing the_rowidcolumn. Therefore, it’s recommended to add.with_row_id(True)to everytable.search(...)call before reranking, or omitdeduplicate=Trueif you don’t need it. RRFReranker.rerank_multivector(...)always requires_rowidon its inputs, regardless of thededuplicateflag.
Creating Custom Rerankers
LanceDB also allows you to create custom rerankers by extending the baseReranker class. The custom reranker
should implement the rerank method that takes a list of search results and returns a reranked list of
search results. This is covered in more detail in the creating custom rerankers section.