Document reranking
Score how well each retrieved document answers the query, sort candidates by a 0–1 rerank score and drop the irrelevant ones, with the Document Reranking template.
Goal: send your LLM only the documents that answer the question, best first.
Create the decision
Templates → Document reranking → Create decision:
| Part | Content |
|---|---|
| State | query (string, required), document (string, required) |
relevance | score — unrelated, same topic, no answer, partial answer, direct answer, complete answer |
answers_query | probability — could the query be answered from this document alone? |
| Composite | rerank_score = 2 × relevance + 1 × answers_query, 0 to 1 |
| Policies | rerank_score < 0.2 → block (drop the document) |
Call it
curl -X POST https://api.dcision.io/v1/decisions/document-reranking \
-H "Authorization: Bearer $DCISION_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"state": {
"query": "What is the refund window for annual plans?",
"document": "Annual plans can be refunded within 30 days of purchase. Monthly plans are not refundable."
}
}'{
"schema": "document-reranking",
"result": { "relevance": "complete answer", "answers_query": 0.95 },
"scores": { "relevance": 4.86 },
"composites": { "rerank_score": 0.96 },
"action": "continue"
}Act on it
Each candidate is one decision; run them in parallel and sort:
const scored = await Promise.all(docs.map(async (doc) => ({ doc, d: await dcisionDecide("document-reranking", { query, document: doc.text }) })));
const top = scored
.filter(({ d }) => d.action !== "block")
.sort((a, b) => b.d.composites.rerank_score - a.d.composites.rerank_score)
.slice(0, 3)
.map(({ doc }) => doc);Tune it
- Rerank a shortlist: one call per document, so score the top 5–10 results of your vector search, not the whole index.
- Change the weights of
rerank_scoreif partial answers matter more in your corpus. - Turn off
storeInputif documents are private.
Model routing
Send each prompt to the cheapest model that is enough — fast, balanced or frontier — and play safe when the tier is unclear, with the Model Routing template.
Tool-call gating
Before an agent runs a tool, decide whether to run it, ask the user to confirm or refuse — with more confidence required for risky actions — with the Tool-call Gating template.