Reranker

Prev Next

Available in Classic and VPC

Reranker evaluates the relevance of retrieved documents to a query to select the most relevant documents, which are then summarized and condensed to generate RAG answers. By selectively using only documents that are highly relevant to the user query, rather than the entire search document, you can efficiently reduce token consumption while still achieving highly reliable results.

Request

This section describes the request format. The method and URI are as follows:

Method URI
POST /v1/api-tools/reranker

Request headers

The following describes the request headers.

Field Required Description
Authorization Required API key for authentication Example: Bearer nv-************
X-NCP-CLOVASTUDIO-REQUEST-ID Optional Request ID for the request
Content-Type Required Request data format
  • application/json
  • Request body

    You can include the following data in the body of your request:

    Field Type Required Description
    documents Array[Object] Required List of searched documents
    query String Required User query
    maxTokens Integer Optional Maximum number of tokens to be created
    • maxTokens < 4096

    Searched document

    The following describes the searched document.

    Field Type Required Description
    id String Required Searched document ID
    doc String Required Searched document original

    Request example

    The request example is as follows:

    curl --location --request POST 'https://clovastudio.stream.ntruss.com/v1/api-tools/reranker' \
    --header 'Authorization: Bearer {API Key}' \
    --header 'X-NCP-CLOVASTUDIO-REQUEST-ID: {Request ID}' \
    --header 'Content-Type: application/json' \
    --data '{
        "documents": [
            {
                "id": "id1",
                "doc": "VPC deletion error - The VPC can't be deleted. When deleting a VPC, the message \"The deletion can't be completed because not all endpoints have been terminated. \" appears.CauseIf resources exist under the VPC, then the VPC can't be deleted.SolutionYou must return or delete all resources associated with the VPC you are deleting.** Delete all resources in Server, Network Interface, Cloud Functions, Load Balancer, Auto Scaling, and NAT Gateway associated with the VPC you are deleting.** Delete the route table associated with the VPC.** Delete the subnet associated with the VPC.** You can't return and delete network interfaces assigned to server eth0. To delete network interfaces assigned to server eth0, terminate the server first.",
            },
            {
                "id": "id2",
                "doc": "Delete VPC You can delete a VPC that has been created and is in operation. The following describes how to delete a VPC.NoteIf resources remain in the VPC, it won't be deleted. When you delete a VPC, the services associated with the VPC are also deleted, and they can't be restored after deletion.** In the VPC environment of the NAVER Cloud Platform console, click the Services > Networking > VPC menus, in that order.** Click the VPC Management menu.** Click the VPC you want to delete, and then click the [Delete] button.** When the Delete VPC pop-up window appears, click the [Yes] button.** Check the status of the VPC in the VPC list on the VPC Management page. Stopping: status in which the VPC is being deleted*** Stopping: status in which the VPC is being deleted",
            },
            {
                "id": "id3",
                "doc": "Delete subnet You can delete a subnet that has been created and is in operation. The following describes how to delete a subnet. Note - If resources remain in the subnet, it won't be deleted. Once deleted, and subnets can't be restored.** In the VPC environment of the NAVER Cloud Platform console, click the Services > Networking > VPC menus, in that order.** Click the Subnet Management menu.** Click the subnet you want to delete, and then click the [Delete subnet] button.** When the Delete subnet pop-up window appears, click the [Yes] button.** Check the status of the subnet in the subnet list on the Subnet Management page. Stopping: status in which the subnet is being deleted*** Stopping: status in which the subnet is being deleted",
            }
        ],
        "query": "Tell me how to delete a VPC"
      } ]
    }'
    

    Response

    This section describes the response format.

    Response headers

    The following describes the response headers.

    Headers Required Description
    Content-Type - Response data format
    • application/json

    Response body

    The response body includes the following data:

    Field Type Required Description
    status Object - Response status
    result Object - Response result
    result.result String - Model output response
    result.citedDocuments Array[Object] - List of cited documents among searched documents
    result.suggestedQueries Array[String] - List of suggested search keywords for re-searching
    • Displayed when the reranker model didn't find an answer in the documents it searched
    result.usage Object - Token usage
    result.usage.completionTokens Integer - Generated token count
    result.usage.promptTokens Integer - Number of input (prompt) tokens
    result.usage.totalTokens Integer - Total number of tokens
  • Number of generated tokens + number of input tokens
  • Cited document

    The following describes the cited document.

    Field Type Required Description
    id String - Cited document ID
    doc String - Cited document original

    Response example

    The response example is as follows:

    Succeeded

    The following is a sample response upon a successful call.

    • If an answer is found in the searched document
      {
          "status": {
              "code": "20000",
              "message": "OK"
          },
          "result": {
              "result": "Answer: To delete a VPC, you must first <doc1>terminate or delete all resources associated with the VPC</doc1>. This includes all resources in <doc1>Server, Network Interface, Cloud functions, Load Balancer, Auto Scaling, NAT Gateway,</doc1> as well as <doc1>route tables and subnets</doc1>. In particular, <doc1>the network interface assigned to server eth0 can't be terminated and deleted, so you need to terminate that server first.</doc1>\n\nThe deletion procedure is as follows:\n1. <doc2>In the VPC environment of NAVER Cloud Platform console, click the Services > Networking > VPC menu.</doc2>\n2. <doc2>Click the VPC Management menu, select the VPC you want to delete, and click the [Delete] button.</doc2>\n3. <doc2>In the Delete VPC pop-up window, click [Yes] to proceed with the deletion.</doc2>\n4. <doc2>Check the VPC status on the VPC Management page to confirm that the deletion is complete.</doc2>\n\nYou can safely delete the VPC through this process. However, <doc2>proceed carefully because you can't restore the VPC after deleting it.</doc2>",
              "citedDocuments": [
                  {
                      "id": "id1",
                      "doc": "VPC deletion error - The VPC can't be deleted. When deleting a VPC, the message \"The deletion can't be completed because not all endpoints have been terminated. \" appears.CauseIf resources exist under the VPC, then the VPC can't be deleted.SolutionYou must return or delete all resources associated with the VPC you are deleting.** Delete all resources in Server, Network Interface, Cloud Functions, Load Balancer, Auto Scaling, and NAT Gateway associated with the VPC you are deleting.** Delete the route table associated with the VPC.** Delete the subnet associated with the VPC.** You can't return and delete network interfaces assigned to server eth0. To delete network interfaces assigned to server eth0, terminate the server first."
                  },
                  {
                      "id": "id2",
                      "doc": "Delete VPC You can delete a VPC that has been created and is in operation. The following describes how to delete a VPC.NoteIf resources remain in the VPC, it won't be deleted. When you delete a VPC, the services associated with the VPC are also deleted, and they can't be restored after deletion.** In the VPC environment of the NAVER Cloud Platform console, click the Services > Networking > VPC menus, in that order.** Click the VPC Management menu.** Click the VPC you want to delete, and then click the [Delete] button.** When the Delete VPC pop-up window appears, click the [Yes] button.** Check the status of the VPC in the VPC list on the VPC Management page. Stopping: status in which the VPC is being deleted*** Stopping: status in which the VPC is being deleted"
                  }
              ],
              "suggestedQueries": [],
              "usage": {
                  "promptTokens": 777,
                  "completionTokens": 281,
                  "totalTokens": 1058
              }
          }
      }
      
    • If an answer is not found in the searched document
      {
          "status": {
              "code": "20000",
              "message": "OK"
          },
          "result": {
              "result": "Answer: The search results don't provide information about the weather, so we can't give you any information about the weather.",
              "citedDocuments": [],
              "suggestedQueries": [
                  "Current weather",
                  "Weather forecast"
              ],
              "usage": {
                  "promptTokens": 774,
                  "completionTokens": 57,
                  "totalTokens": 831
              }
          }
      

    Failure

    The following is a sample response upon a failed call.