Send a Reranking Request
Use the /v1/rerank endpoint to submit a query and a list of
documents. The service returns the documents sorted by relevance.
curl --location 'https://localhost:9091/v1/rerank' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $API_KEY" \
--cacert "$SECRETS_DIR/cert.pem" \
--data '{
"model": "mxbai-rerank-base-v2",
"query": "What is the capital of France?",
"documents": [
"The capital of Brazil is Brasilia.",
"The capital of France is Paris.",
"Horses and cows are both animals."
]
}'The request body includes the following parameters:
model: The name of the reranking model to use.query: The query text used to rank the documents.documents: An array of document strings to rank against the query.
The response includes the ranked results. Each result includes the original document index, the document text, and a relevance score. For example:
{
"id": "rerank-b389becfb1070107",
"model": "mxbai-rerank-base-v2",
"usage": {
"prompt_tokens": 56,
"total_tokens": 56
},
"results": [
{
"index": 1,
"document": {
"text": "The capital of France is Paris.",
"multi_modal": null
},
"relevance_score": 0.9985467791557312
},
{
"index": 0,
"document": {
"text": "The capital of Brazil is Brasilia.",
"multi_modal": null
},
"relevance_score": 0.0005859603406861424
},
{
"index": 2,
"document": {
"text": "Horses and cows are both animals.",
"multi_modal": null
},
"relevance_score": 3.7307050661183894e-05
}
]
}The highest-scoring results is the document that the model determined to be most relevant to the query.
Parent topic: Use the Reranking Service