协同重新排序(Co.Rerank)
POST
https://api.cohere.ai/v1/rerank该接口接受一个查询和一个文本列表,并生成一个有序数组,其中每个文本都分配了一个相关性分数。
请求参数
Body 参数application/json
return_documents
boolean
可选
- If false, returns results without the doc text - the api will return a list of {index, relevance score} where index is inferred from the list passed into the request. - If true, returns results with the doc text passed in - the api will return an ordered list of {index, text, relevance score} where index + text refers to the list passed into the request.
max_chunks_per_doc
integer
可选
从文档内部生成的最大块数
model
string
可选
要使用的模型的标识符,以下之一:rerank-english-v2.0
,rerank-multilingual-v2.0
query
string
搜索查询
documents
array[string]
必需
要重新排序的文档对象或字符串的列表。 如果提供了文档,则文本字段是必需的,所有其他字段将保留在响应中。 最大块总数(文档长度 * max_chunks_per_doc)必须小于 10000。
示例
{
"return_documents": false,
"max_chunks_per_doc": 10,
"model": "rerank-english-v2.0",
"query": "What is the capital of the United States?",
"documents": [
"Carson City is the capital city of the American state of Nevada.",
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
"Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.",
"Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states."
]
}
示例代码
返回响应
成功(200)
HTTP 状态码: 200
内容格式: JSONapplication/json
数据结构
id
string
必需
results
array [object {3}]
必需
document
object
可选
index
integer
可选
relevance_score
integer
可选
meta
object
必需
api_version
object
必需
warnings
array[string]
必需
示例
{
"id": "string",
"results": [
{
"document": {
"text": "string"
},
"index": 0,
"relevance_score": 0
}
],
"meta": {
"api_version": {
"version": "string",
"is_deprecated": true,
"is_experimental": true
},
"warnings": [
"string"
]
}
}
最后修改时间: 1 年前