Reranking
Reranking is a technique used to improve the relevance and accuracy of search results by re-evaluating and reordering them using a dedicated rerank model.
The search process works in two stages:
- Initial Retrieval: Vector search identifies the top
k
most similar documents from the collection - Reranking: A reranking model evaluates these
k
documents based on the relevance between the query and the documents and reorders them to produce the final topn
results (wheren
≤k
)
This two-stage retrieval approach significantly improves both document relevance and accuracy.
Basic Usage
PyTiDB provides the Reranker
class that allows you to use reranker models from multiple third-party providers.
-
Create a reranker instance
-
Apply reranker via
.rerank()
method
Supported Providers
Here are some examples to use reranker models from third-party providers.
Jina AI
To enable reranker provided by JinaAI, go to their website to create a API key.
For example: