An Overview of Cohere's Rerank Model
How Rerank Works
The Rerank API endpoint, powered by the Rerank models, is a simple and very powerful tool for semantic search. Given a query and a list of documents, Rerank indexes the documents from most to least semantically relevant to the query.
Get Started
Example with Texts
In the example below, we use the Rerank API endpoint to index the list of documents from most to least relevant to the query "What is the capital of the United States?".
Request
In this example, the documents are being passed in as a list of strings:
We’ll get back a V2RerankResponse object that will look like this:
Note that the index works as it does in Python, with index=0 being the first document. Also, the V2RerankResponse object will be more compact, the example above was reformatted to make reading easier.
Example with Structured Data:
If your documents contain structured data, for best performance we recommend formatting them as YAML strings.
Request
In the documents parameter, we are passing in a list YAML strings, representing the structured data.
As before, we get back a V2RerankResponse object that will look like this:
Multilingual Reranking
Cohere’s Rerank models have been trained for performance across 100+ languages.
When choosing the model, please note the following language support:
- Rerank 4.0 (both ‘fast’ and ‘pro’): A single multilingual model (
rerank-v4.0-proandrerank-v4.0-fast) - Rerank 3.5: A single multilingual model (
rerank-v3.5) - Rerank 3.0: Separate English-only and multilingual models (
rerank-english-v3.0andrerank-multilingual-v3.0)
The following table provides the list of languages supported by the Rerank models. Please note that performance may vary across languages.