rerank.v1
docs/capabilities/rerank.v1.md · wiki index
rerank.v1
Status: v1. A published shape is frozen by spec.md section 20.1.
Capability key: rerank
Route: POST /rerank
Parts in
One row for each part kind that this capability accepts. A kind that is not in
this table is invalid_part.
| kind | role | required | meaning |
|---|---|---|---|
| text | query | yes, exactly one | the query that each document is scored against. |
| json | documents | yes, exactly one | {"documents": ["<string>"]}. The array is not empty. |
Parameters
This capability has no parameters. A value in params is ignored (R26). The
score array has one entry for each document, in input order. The client sorts
it.
Channels out
One row for each channel that this capability can emit.
| channel | mime | payload |
|---|---|---|
| embedding | application/cbor | one array of float32 scores. One score per document, in input order. |
Terminal metadata
done.meta is vocabulary-defined. The core stores it and never reads it.
done without meta means {}.
| key | type | meaning |
|---|---|---|
model | string | the served name that ran the job |
model is present when outcome is completed. It is absent when the outcome
is cancelled or expired.
Request
POST /rerank
{
"model": "<served-name>",
"input": [
{"kind": "text", "role": "query", "text": "What keeps a device free?"},
{"kind": "json", "role": "documents", "json": {"documents": [
"A ledger records reserved bytes per device.",
"A queue holds jobs until a device is ready."
]}}
],
"params": {"top_n": 1, "normalize": false},
"stream": false
}
Response, no stream
{"job": "019...", "outcome": "completed",
"embedding": {"mime": "application/cbor", "inline": "<cbor array of scores>"},
"usage": {"tokens_in": 3},
"meta": {"model": "<served-name>"}}
Stream
rerank is not a streamed capability. stream = true still gives one artifact
in one done frame. No event frame precedes it.
done outcome=completed
artifacts=[{"channel":"embedding","mime":"application/cbor","inline":"<cbor>"}]
meta={"model": "<served-name>"}
Rules
- Exactly one
textpart with rolequeryis required. - Exactly one
jsonpart with roledocumentsis required. Itsdocumentsarray is not empty. - An
image,audio,video, ortokenspart isinvalid_part. - The
embeddingpayload is one array of float32. Its length equals the number of documents. - Score
ibelongs to documenti. The plugin never reorders the array and never drops a document. - The plugin does not sort. A higher score is a better match. The client decides the order.
usage.tokens_inis the number of tokens in the query and the documents.- No event follows a
cancel. The terminal frame isdonewithoutcome = cancelled. - The plugin emits CBOR bytes on the
embeddingchannel. It emits nothing else for this job.