Skip to content

文档重排序

POST /v1/rerank

根据查询对文档列表进行相关性重排序

基本信息

项目内容
Base URLhttps://www.yunzhuhub.cn
标签重排序(Rerank)
Operation IDcreateRerank

认证

  • BearerAuth:使用 Bearer Token 认证。 格式: Authorization: Bearer sk-xxxxxx

密钥安全

请只使用你自己的 API Key。示例中的 <YOUR_API_KEY> 必须在本地替换,不要把真实密钥提交到代码仓库或发送给他人。

参数

无额外路径或查询参数。

请求体

Content-Type: application/json

json
{
  "title": "RerankRequest",
  "type": "object",
  "required": [
    "model",
    "query",
    "documents"
  ],
  "properties": {
    "model": {
      "type": "string",
      "example": "<MODEL_ID>"
    },
    "query": {
      "type": "string",
      "description": "查询文本"
    },
    "documents": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "properties": {}
          }
        ]
      },
      "description": "要重排序的文档列表"
    },
    "top_n": {
      "type": "integer",
      "description": "返回前 N 个结果"
    },
    "return_documents": {
      "type": "boolean",
      "default": false
    }
  }
}

请求示例

以下示例只用于复制到本地终端,不会从文档站发送请求。

bash
curl --request POST 'https://www.yunzhuhub.cn/v1/rerank' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '<REQUEST_JSON>'

响应

200 成功重排序

json
{
  "title": "RerankResponse",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "index": {
            "type": "integer"
          },
          "relevance_score": {
            "type": "number"
          },
          "document": {
            "type": "object",
            "properties": {}
          }
        }
      }
    },
    "meta": {
      "type": "object",
      "properties": {}
    }
  }
}

云筑Hub 文档。底层项目基于 New API