Skip to content

Reranking

A reranker scores how well each document answers a query. Unlike embeddings, it sees the query and the document together, which makes it considerably more accurate — and more expensive per comparison, which is why it is used to reorder a shortlist rather than search a corpus.

The usual pattern: retrieve perhaps 50 candidates with embeddings, rerank them, keep the top 5, pass those to a model.

Terminal window
curl https://api.resetdata.ai/api/v1/rerank \
-H "Authorization: Bearer $RESETDATA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "RERANK_MODEL",
"query": "How is usage billed?",
"documents": [
"Invoices are emailed with a PDF attached.",
"Each request is charged against the workspace wallet.",
"Passkeys can be registered from the security page."
],
"top_n": 2
}'

Returns results with an index into your original array and a relevance_score. Reorder your own list using index — don’t assume the response echoes your documents back.

Terminal window
curl https://api.resetdata.ai/api/v1/reranking \
-H "Authorization: Bearer $RESETDATA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "RERANK_MODEL",
"query": { "text": "How is usage billed?" },
"passages": [
{ "text": "Invoices are emailed with a PDF attached." },
{ "text": "Each request is charged against the workspace wallet." }
]
}'

Same idea, different envelope: the query is an object with text, and documents are objects in passages.

  • Scores are relative, not absolute. A model’s scores are comparable within one response, not across queries or models. Don’t hard-code a threshold from a single sample — calibrate on your own data.
  • Rerank a shortlist. Cost and latency scale with the number of documents, so retrieve broadly and rerank narrowly.
  • Mind document length. Rerankers have limited context; long documents may be truncated. Rerank the same chunks you embedded.
  • top_n saves bandwidth, not compute. Every document is still scored.