Rerank
Takes a query and a list of documents and re-sorts the documents by relevance. In RAG systems it's used to rank candidate documents returned from search, from best to worst.
POST/v1/rerank
Request parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | ✓ | Rerank model (e.g. verirerag) |
query | string | ✓ | Search query |
documents | array | ✓ | List of texts to rank |
top_n | integer | Return only the top N results | |
return_documents | boolean | Also return the document text in results | |
max_chunks_per_doc | integer | Max chunks per document |
Example
bash
curl https://app.qevron.ai/v1/rerank \
-H "Authorization: Bearer $QEVRON_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "verirerag",
"query": "How does Qevron authenticate?",
"documents": [
"Qevron authenticates requests with a Bearer token.",
"The weather in Istanbul is rainy today.",
"Embedding turns text into a vector."
],
"top_n": 2,
"return_documents": true
}'python
import httpx
resp = httpx.post(
"https://app.qevron.ai/v1/rerank",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "verirerag",
"query": "How does Qevron authenticate?",
"documents": [
"Qevron authenticates requests with a Bearer token.",
"The weather in Istanbul is rainy today.",
"Embedding turns text into a vector.",
],
"top_n": 2,
"return_documents": True,
},
)
print(resp.json())Response
json
{
"id": "rerank-...",
"results": [
{
"index": 0,
"relevance_score": 0.987,
"document": { "text": "Qevron authenticates requests with a Bearer token." }
},
{
"index": 2,
"relevance_score": 0.142,
"document": { "text": "Embedding turns text into a vector." }
}
],
"meta": { "tokens": { "input_tokens": 48 } }
}| Field | Description |
|---|---|
results[].index | Original position in the input |
results[].relevance_score | Relevance score (higher = more relevant) |
results[].document | Document text if return_documents: true |
Results are returned in descending score order.