GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • docs
  • DASHBOARD
  • PLAYGROUND
  • COMMUNITY
  • LOG IN
  • Guides and concepts
  • API Reference
  • Release Notes
  • LLMU
  • Cookbooks
  • Inference
  • rerank
  • Previous
  • Embed API (v2)Next

This view

  • Original page
  • New address

GeezerVison is showing docs.cohere.com — Cohere Documentation

Skip to navigation
This page is for version v2 API (default). For other versions, use one of these documentation indexes: - v2 API (default): https://docs.cohere.com/v2/llms.txt - v1 API: https://docs.cohere.com/v1/llms.txt
POST
/v2/rerank
import cohere
co = cohere.ClientV2()
docs = [
"Carson City is the capital city of the American state of Nevada.",
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
"Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.",
"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.",
"Capital gains are profits from the sale of an asset such as stocks or real estate. In the United States, long-term capital gains are taxed at lower rates than ordinary income.",
]
response = co.rerank(
model="rerank-v5.0-pro",
query="What is the capital of the United States?",
documents=docs,
top_n=3,
relevant_spans={"mode": "enabled", "threshold": 0.1, "max_spans": 3},
)
print(response)
{
"results": [
{
"index": 2,
"relevance_score": 0.8428898,
"relevant_spans": [
{
"start": 0,
"end": 139,
"score": 0.9997249
},
{
"start": 139,
"end": 165,
"score": 0.33812714
}
]
},
{
"index": 0,
"relevance_score": 0.085889876,
"relevant_spans": [
{
"start": 0,
"end": 64,
"score": 0.33498195
}
]
},
{
"index": 4,
"relevance_score": 0.04667134,
"relevant_spans": [
{
"start": 0,
"end": 82,
"score": 0.15934227
},
{
"start": 82,
"end": 175,
"score": 0.118320465
}
]
}
],
"id": "9f75d94c-5047-4f9f-ad14-4a42ef5d3ff3",
"meta": {
"api_version": {
"version": "2"
},
"billed_units": {
"input_tokens": 192
}
}
}
This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Headers

X-Client-NamestringOptional
The name of the project that is making the request.

Request

This endpoint expects an object.
modelstringRequired

The identifier of the model to use, eg rerank-v5.0-pro.

querystringRequired
The search query
documentslist of stringsRequired

A list of texts that will be compared to the query. For optimal performance we recommend against sending more than 1,000 documents in a single request.

Note: long documents will automatically be truncated to the value of max_tokens_per_doc.

Note: structured data should be formatted as YAML strings for best performance.

top_nintegerOptional>=1
Limits the number of returned rerank results to the specified value. If not passed, all the rerank results will be returned.
max_tokens_per_docintegerOptional

Defaults to 4096. Long documents will be automatically truncated to the specified number of tokens.

relevant_spansobjectOptional
When enabled, the API response will include the relevant spans of each document that contributed to its rank. This feature is only supported for Rerank v5 and newer models.
priorityintegerOptional0-999Defaults to 0

Controls how early the request is handled. Lower numbers indicate higher priority (default: 0, the highest). When the system is under load, higher-priority requests are processed first and are the least likely to be dropped.

Response

OK
resultslist of objects
An ordered list of ranked documents
idstringOptional
metaobjectOptional

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
422
Unprocessable Entity Error
429
Too Many Requests Error
498
Invalid Token Error
499
Client Closed Request Error
500
Internal Server Error
501
Not Implemented Error
503
Service Unavailable Error
504
Gateway Timeout Error
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.