Rerank
Rerank candidate documents by relevance to a query.
Overview
Rerank receives a query and a set of candidate documents and returns them in relevance order. It commonly follows vector, keyword, or hybrid retrieval to select the most relevant items from a limited candidate set.
API access
Base URL
https://api.agtcloud.cn/v1Rerank documents
The following examples use the Jina-style POST /v1/rerank request.
curl 'https://api.agtcloud.cn/v1/rerank' \
-H 'Authorization: Bearer your-api-key' \
-H 'Content-Type: application/json' \
--data '{
"model": "MODEL_ID",
"query": "How should I store an API key?",
"documents": [
"Store API keys in server-side environment variables or a secret manager.",
"The model marketplace lists available models.",
"Never expose a real API key in browser code or a public repository."
],
"top_n": 2
}'| Parameter | Required | Description |
|---|---|---|
model | No | Rerank model ID; whether it can be omitted depends on the selected format |
query | Yes | Query used to judge relevance |
documents | Yes | Candidate documents to reorder |
top_n | No | Number of results to return |
Read the result
Results are ordered by relevance. Use results[].index to map an item back to the source documents, and read its relevance score from results[].relevance_score.
Choose a request format
| Format | Request path | API Reference |
|---|---|---|
| Jina | POST /v1/rerank | Jina Rerank |
| Cohere | POST /v1/rerank | Cohere Rerank |
| Xinference | POST /v1/rerank | Xinference Rerank |
Understand relevance scores
- A relevance score is not a probability.
- Scores are primarily useful for comparing candidates within the same request.
- Evaluate score thresholds and
top_nwith your own application data.