reranker_retriever#
Reranking model using modelclient as a retriever.
Classes
|
A retriever that uses a reranker model to rank the documents and retrieve the top-k documents. |
- class RerankerRetriever(model_client: ModelClient, model_kwargs: Dict = {}, top_k: int = 5, documents: Sequence[RetrieverDocumentType] | None = None, document_map_func: Callable[[Any], str] | None = None)[source]#
Bases:
Retriever
[str
,str
|Sequence
[str
]]A retriever that uses a reranker model to rank the documents and retrieve the top-k documents.
- Parameters:
top_k (int, optional) – The number of top documents to retrieve. Defaults to 5.
model_client (ModelClient) – The model client that has a reranker model, such as
CohereAPIClient
orTransformersClient
.model_kwargs (Dict) – The model kwargs to pass to the model client.
documents (Optional[RetrieverDocumentsType], optional) – The documents to build the index from. Defaults to None.
document_map_func (Optional[Callable[[Any], str]], optional) – The function to map the document of Any type to the specific type
RetrieverDocumentType
that the retriever expects. Defaults to None.
Examples: