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.
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.
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:
Cohere’s Rerank models have been trained for performance across 100+ languages.
When choosing the model, please note the following language support:
rerank-v4.0-pro and rerank-v4.0-fast)rerank-v3.5)rerank-english-v3.0 and rerank-multilingual-v3.0)The following table provides the list of languages supported by the Rerank models. Please note that performance may vary across languages.