Skip to main content
POST
/
paas
/
v4
/
rerank
文本重排序
curl --request POST \
  --url https://open.bigmodel.cn/api/paas/v4/rerank \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "rerank",
  "query": "查询候选文本A",
  "top_n": 4,
  "documents": [
    "需要打分的候选文本A",
    "需要打分的候选文本B"
  ]
}'
{
  "created": 1732083164,
  "id": "20241120141244890ab4ee4af84acf",
  "request_id": "1111111111",
  "results": [
    {
      "document": "Washington, D.C. is the capital of the United States.",
      "index": 1,
      "relevance_score": 0.99866986
    }
  ],
  "usage": {
    "prompt_tokens": 72,
    "total_tokens": 72
  }
}

Authorizations

Authorization
string
header
required

使用以下格式进行身份验证:Bearer <your api key>

Body

application/json
model
enum<string>
required

要调用的模型编码,默认为rerank

Available options:
rerank
Example:

"rerank"

query
string
required

查询文本,用于与候选文本进行匹配query,最大长度为 4096 字符。

Example:

"查询候选文本A"

documents
string[]
required

需要打分的候选文本数组,最多容纳 128 条。单条最大长度为 4096 字符。

Example:
["需要打分的候选文本A", "需要打分的候选文本B"]
top_n
integer

返回得分最高的前 n 条结果,默认0返回所有。

return_documents
boolean

是否返回原始文本,默认值为FALSE

return_raw_scores
boolean

是否返回原始分数。默认 FALSE

request_id
string

由用户端传参,需保证唯一性,用户传空会默认生成

user_id
string

终端用户的唯一ID

Response

业务处理成功

id
string
required

智谱开放平台生成的任务序号,调用请求结果接口时请使用此序号

Example:

"20241120141244890ab4ee4af84acf"

results
object[]
required
usage
object
required
created
integer
Example:

1732083164

request_id
string

用户在客户端请求时提交的任务编号或者平台生成的任务编号

Example:

"1111111111"

I