.f0rge/wiki/docs/capabilities/rerank.v1.md 2.9 KiB 97 lines Raw

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.

kindrolerequiredmeaning
textqueryyes, exactly onethe query that each document is scored against.
jsondocumentsyes, 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.

channelmimepayload
embeddingapplication/cborone 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 {}.

keytypemeaning
modelstringthe 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

  1. Exactly one text part with role query is required.
  2. Exactly one json part with role documents is required. Its documents array is not empty.
  3. An image, audio, video, or tokens part is invalid_part.
  4. The embedding payload is one array of float32. Its length equals the number of documents.
  5. Score i belongs to document i. The plugin never reorders the array and never drops a document.
  6. The plugin does not sort. A higher score is a better match. The client decides the order.
  7. usage.tokens_in is the number of tokens in the query and the documents.
  8. No event follows a cancel. The terminal frame is done with outcome = cancelled.
  9. The plugin emits CBOR bytes on the embedding channel. It emits nothing else for this job.

view raw