Cohere
    Cohere
    • 关于 Cohere
    • 团队和角色
    • 版本控制
    • 错误
    • 协同生成(Co.Generate)
      POST
    • 协同嵌入(Co.Embed)
      POST
    • 协同聊天(Co.Chat (Beta))
      POST
    • 协同分类(Co.Classify)
      POST
    • 协同分词(Co.Tokenize)
      POST
    • 协同合并分词(Co.Detokenize)
      POST
    • 协同语言检测(Co.Detect_language)
      POST
    • 协同摘要(Co.Summarize)
      POST
    • 协同重新排序(Co.Rerank)
      POST

      协同重新排序(Co.Rerank)

      开发环境
      https://api.cohere.ai/v1
      开发环境
      https://api.cohere.ai/v1
      POST
      https://api.cohere.ai/v1/rerank
      该接口接受一个查询和一个文本列表,并生成一个有序数组,其中每个文本都分配了一个相关性分数。
      请求示例请求示例
      Shell
      JavaScript
      Java
      Swift
      curl --location --request POST 'https://api.cohere.ai/v1/rerank' \
      --header 'Content-Type: application/json' \
      --data-raw '{
        "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."
        ]
      }'
      响应示例响应示例
      {
        "id": "string",
        "results": [
          {
            "document": {
              "text": "string"
            },
            "index": 0,
            "relevance_score": 0
          }
        ],
        "meta": {
          "api_version": {
            "version": "string",
            "is_deprecated": true,
            "is_experimental": true
          },
          "warnings": [
            "string"
          ]
        }
      }

      请求参数

      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。
      示例

      返回响应

      🟢200成功
      application/json
      Body
      id
      string 
      必需
      results
      array [object {3}] 
      必需
      document
      object 
      可选
      index
      integer 
      可选
      relevance_score
      integer 
      可选
      meta
      object 
      必需
      api_version
      object 
      必需
      warnings
      array[string]
      必需
      上一页
      协同摘要(Co.Summarize)
      Built with