Reranker
Subpackages
Submodules
llmsmith.reranker.base module
- class llmsmith.reranker.base.Reranker
Bases:
ABCAbstract base class for document rerankers.
- abstract async rerank(query: str, docs: List[str]) List[str]
Rerank documents and return the same.
- Parameters:
query (str) – query used to retrieve documents from vector DB.
docs (List[str]) – list of documents retrieved from vector DB.
- Returns:
reranked documents
- Return type:
List[str]
llmsmith.reranker.cohere module
- class llmsmith.reranker.cohere.CohereReranker(client: AsyncClient, options: CohereRerankerOptions | None = None)
Bases:
RerankerReranker based on Cohere reranking.
- Parameters:
client (
cohere.AsyncClient) – An instance of the Cohere client.options (
llmsmith.reranker.options.cohere.CohereRerankerOptions, optional) – A dictionary of options to pass to the rerank method of Cohere client.
- async rerank(query: str, docs: List[str]) List[str]
Rerank documents using Cohere API.
- Parameters:
query (str) – Query used to fetch documents from vector database.
docs (List[str]) – Documents returned by vector database.
- Returns:
Reranked documents returned by Cohere.
- Return type:
List[str]