重排

对给定查询与一组文档进行相关性重排,返回按相关度排序的结果,常用于检索结果精排。

基本信息

方法POST 端点https://koprouter.kopglobal.com/v1/rerank 鉴权Authorization: Bearer sk-...

请求参数

参数 类型 必填 说明
model string 是 重排模型 ID
query string 是 查询文本
documents array 是 待排序的文档文本数组
top_n number 否 返回前 N 条结果,默认返回全部

请求示例

curl https://koprouter.kopglobal.com/v1/rerank \
  -H "Authorization: Bearer sk-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "query": "如何重置密码",
    "documents": [
      "找回账号的方法",
      "修改登录密码的步骤",
      "查看账单明细"
    ],
    "top_n": 2
  }'

响应示例

{
  "id": "rerank-abc123",
  "model": "MODEL_ID",
  "results": [
    { "index": 1, "relevance_score": 0.92 },
    { "index": 0, "relevance_score": 0.71 }
  ]
}
`relevance_score` 越高表示与 `query` 越相关,结果已按相关度降序排列。