Cohere 重排序格式(Rerank)
Cohere 重排序格式(Rerank)
cohere 的 Rerank 模型接口和 Jina的Rerank模型接口格式 是一样的。
Cohere Rerank
📝 简介
💡 请求示例
基础重排序请求 ✅
{
"results": [
{
"index": 2,
"relevance_score": 0.999071
},
{
"index": 0,
"relevance_score": 0.32713068
},
{
"index": 1,
"relevance_score": 0.1867867
}
],
"id": "07734bd2-2473-4f07-94e1-0d9f0e6843cf",
"meta": {
"api_version": {
"version": "2",
"is_experimental": false
},
"billed_units": {
"search_units": 1
}
}
}
使用结构化数据 ✅
{
"results": [
{
"index": 1,
"relevance_score": 0.918472
},
{
"index": 0,
"relevance_score": 0.854321
},
{
"index": 2,
"relevance_score": 0.423156
}
],
"id": "8f734bd2-2473-4f07-94e1-0d9f0e68ebfa",
"meta": {
"api_version": {
"version": "2"
},
"billed_units": {
"search_units": 1
}
}
}
📮 请求
端点
POST /v1/rerank
鉴权方法
Authorization: Bearer $NEWAPI_API_KEY
$NEWAPI_API_KEY
是您的 API 密钥。请求头参数
X-Client-Name
请求体参数
model
query
documents
top_n
max_tokens_per_doc
📥 响应
成功响应
results
index
: 整数,对应于原始文档列表中文档的索引relevance_score
: 浮点数,相关性分数范围为[0, 1]。接近1的分数表示与查询高度相关,接近0的分数表示相关性较低id
meta
api_version
: 对象,包含API版本信息version
: 字符串,API版本号is_deprecated
: 布尔值,是否已弃用is_experimental
: 布尔值,是否为实验性功能billed_units
: 对象,包含计费信息search_units
: 浮点数,计费的搜索单位数tokens
: 对象,包含令牌使用统计input_tokens
: 浮点数,作为模型输入的令牌数output_tokens
: 浮点数,模型产生的令牌数warnings
错误响应
400 Bad Request
: 请求格式或参数错误401 Unauthorized
: 未提供有效的API密钥403 Forbidden
: 没有权限访问此资源404 Not Found
: 请求的资源不存在422 Unprocessable Entity
: 请求格式正确但包含语义错误429 Too Many Requests
: 请求频率超过限制500 Internal Server Error
: 服务器内部错误503 Service Unavailable
: 服务暂时不可用🌟 最佳实践
文档准备建议
1.
2.
3.
查询优化
1.
2.
理解相关性分数
修改于 2025-05-30 01:37:11