rerank

Improve search performance with a single line of code

Rerank provides a powerful semantic boost to the search quality of any keyword or vector search system without requiring any overhaul or replacement.

Code sample that runs the Cohere API rerank endpoint with only a few lines
Using Cohere to the search quality of any keyword

What's possible with Rerank

Improve search results

Greatly enhance search precision when integrated with ElasticSearch or OpenSearch.
Read the docs

Optimize eCommerce search

Boost customer conversion with greater search accuracy and lighting-fast response times.
Read the docs

Boost knowledge base search

Eliminate frustration and wasted time by ensuring that semantic context is always understood.
Read the docs

Implement Rerank in just a few minutes

Implementation can take as little as ten minutes (we’ve seen it!) and only a few lines of code. The code here implements Rerank.

1import cohere
2co = cohere.Client('{apiKey}')
3
4query = 'What is the capital of the United States?'
5docs = ['Carson City is the capital city of the American state of Nevada.',
6     'The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.',
7     'Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district. ',
8     'Capital punishment (the death penalty) has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.'
9     ]
10results = co.rerank(query=query, documents=docs, top_n=3, model='rerank-english-v2.0')
1Document Rank: 1, Document Index: 2
2Document: Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district. 
3Relevance Score: 0.98
4
5
6Document Rank: 2, Document Index: 3
7Document: Capital punishment (the death penalty) has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.
8Relevance Score: 0.28
9
10
11Document Rank: 3, Document Index: 0
12Document: Carson City is the capital city of the American state of Nevada.
13Relevance Score: 0.10

Why Rerank

1

Industry-leading accuracy

Cohere’s embedding performance ensures accurate reranking, even with noisy datasets


2

Customization (fine-tuning)

Cohere’s rerank model can be fine-tuned to further improve domain performance

3

Scalability

Cohere’s powerful inference frameworks optimize throughput and reduce compute requirements

4

Flexible deployment

Cohere’s models can be accessed through a SaaS API, on cloud services (e.g. OCI, AWS SageMaker, Bedrock) and soon through private deployments (VPC and on-premise)

Rerank resources

Cohere docs

Reranking

Continue in docs

Cohere docs

Reranking Best Practices

Continue in docs

Get started with Cohere today!

Reach out to us and let’s discuss how to improve your search performance.