语义相关性排序
更新时间:2025-03-12 09:45:48
基本信息
Action:/rerank
Method: POST
Content-Type:application/json
Authorization:需提前在 API 密钥管理中创建和获取。
计费方式:输入文本的 token 数量。
请求参数
参数 | 类型 | 作用 | 是否必须 | 示例 | 备注 |
---|---|---|---|---|---|
model |
string |
模型 |
是 |
bge-reranker-v2-m3 |
- |
query |
string |
查询文本 |
是 |
What is the capital of France? |
长度不超过 1600 个字符 |
documents |
list[string] |
需要重排序的文本 |
是 |
["Paris is the capital of France.", "London is the capital of England."] |
|
top_n |
int |
返回的最相关文本的数量,默认为 document 的数量 |
否 |
2 |
- |
响应参数
字段 | 类型 | 描述 |
---|---|---|
model |
string |
模型名称 |
results |
对象数组 |
- |
usage |
对象 |
- |
-
results
对象参数:字段 类型 描述 index
int
序号
relevance_score
float
相似性得分
document 对象
text
string
重排序文本内容
-
usage
对象参数:字段 类型 描述 total_tokens
int
总 token 数
请求示例
curl -i -X POST \
-H "Content-Type:application/json" \
-H "Authorization: " \
-d \
'{
"model":"bge-reranker-v2-m3",
"query": "What is the capital of France?",
"documents": [
"Paris is the capital of France.",
"London is the capital of England."],
"top_n": "2"
}' \
'https://openapi.coreshub.cn/v1/rerank'
响应示例
{
"model": "bge-reranker-v2-m3",
"results": [
{
"index": 0,
"relevance_score": 1.0,
"document": {
"text": "Paris is the capital of France."
}
},
{
"index": 1,
"relevance_score": 0.00997161865234375,
"document": {
"text": "London is the capital of England."
}
}
],
"usage": {
"total_tokens": 36
}
}