Overview
Good reranking model, consumes both a query and a list of documents to be ranked in relevance against the query. Is a closed source model that can be used via Cohere’s API.
Reranking models are designed to provide superior accuracy over retriever models but are much slower — so this model should not be used with more than a few hundred documents. Due to the slowness of rerankers, we recommend using them in a two-stage retrieval system, ie use a retrieval to pull in a smaller number of documents from a larger database and then rerank the smaller number of documents using a reranker.
Using the Model
Installation:
pip install -qU cohere==4.34
Rerank:
import cohere
co = cohere.Client("<<YOUR_COHERE_API_KEY>>")
reranked_docs = co.rerank(
query=query_str,
documents=docs,
top_n=5, # controls how many reranked docs to return
model="rerank-english-v2.0"
)