重排 Rerank(文档列表按相关性重排)
POST /v1/rerank 对一组候选文档按与查询的相关性重排,用于 RAG 检索后精排、搜索结果优化。采用 Cohere 格式——Cohere SDK 兼容。
一、请求
bash
curl https://token.yaoshu.cc/v1/rerank \
-H "Authorization: Bearer sk-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"model": "<rerank-model>",
"query": "什么是自然语言处理",
"documents": ["NLP 是人工智能领域...", "计算机视觉是..."],
"top_n": 3
}'| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | ✅ | 重排模型名,以 GET /v1/models 返回为准 |
query | string | ✅ | 查询文本 |
documents | string[] | ✅ | 候选文档列表 |
top_n | number | 否 | 返回前 N 个结果 |
二、响应
Cohere 标准结构:results[] 含 index(对应输入文档序号)与 relevance_score(相关性分数,越高越相关),已按分数降序。
三、计费
按 token 计量(query + documents 合计)。单价以控制台模型价格页为准。
