Rerank
Scores and reorders documents by relevance to a query. Cohere-compatible.
POST
/v1/rerank
Scores documents by how relevant they are to a query, best first. New to reranking? Start with the Reranking guide.
It follows the Cohere Rerank format, so Cohere clients work with a Pendra
base URL. It also answers at /api/v1/rerank.
Body
application/json
model
string
Required
A reranking model id. List them with /models?type=rerank.
query
string
Required
What to score the documents against.
documents
string[]
Required
The documents to score. At least one.
top_n
integer
Return only the best
top_n results, 1 or more. Leave it out to get every document back, sorted.
return_documents
boolean
default: false
Include each document's text in its result, under
document.text.
Response
results is sorted by relevance_score, highest
first. Each result has the index of the document in the list
you sent, its score, and its text if you set
return_documents.
Good to know
- Higher scores mean more relevant. Each model has its own scale, so only compare scores within one response.
- Every document is read alongside the query, so rerank a shortlist of tens of documents rather than your whole collection.