All Products
Search
Document Center

AnalyticDB:Rerank

Last Updated:Jan 24, 2025
This topic is generated by a machine translation engine without any human intervention. ALIBABA CLOUD DOES NOT GUARANTEE THE ACCURACY OF MACHINE TRANSLATED CONTENT. To request a human-translated version of this topic or provide feedback on this translation, please include it in the feedback form.

Score and re-order documents using a model

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
gpdb:Reranklist
*DBInstance
acs:gpdb:{#regionId}:{#accountId}:dbinstance/{#DBInstanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
DBInstanceIdstringYes

Instance ID.

Note You can call the DescribeDBInstances API to view details of all AnalyticDB PostgreSQL instances in the target region, including the instance ID.
gp-xxxxxxxxx
RegionIdstringYes

Region ID where the instance is located.

cn-hangzhou
QuerystringYes

Query statement for Rerank.

What is ADBPG?
DocumentsarrayYes

List of documents to be re-ordered.

stringYes

Content of a single document.

ADBPG is the OLAP database of Alibaba Cloud.
ModelstringNo

Rerank model, currently supports:

  • bge-reranker-v2-m3: (default), better performance, supports 8192 tokens per inference, if exceeded, it will be split, which may reduce the effect.
  • bge-reranker-v2-minicpm-layerwise: better performance than v2-m3, supports 2048 tokens per inference, if exceeded, it will be split, which may reduce the effect.
bge-reranker-v2-m3
TopKintegerNo

Number of most relevant documents to return.

3
ReturnDocumentsbooleanNo

If set to false, does not return the Documents text, only returns the index of the document order and the rerank score.

false
MaxChunksPerDocintegerNo

Maximum number of chunks allowed when the text exceeds the model window:

  • bge-reranker-v2-m3: default value is 10.
  • bge-reranker-v2-minicpm-layerwise: default value is 5:
Note Example of splitting
  • If using the bge-reranker-v2-minicpm-layerwise model, the maximum single inference window is 2048 tokens. If the query is 48 tokens and the content of a single document parameter is 9000 tokens, it will be divided as follows: 1-2000 for the first, 2001-4000 for the second, and so on. If the number of splits exceeds MaxChunksPerDoc, the remaining sentences will be discarded.
  • 10

    Response parameters

    ParameterTypeDescriptionExample
    object
    RequestIdstring

    Request ID.

    ABB39CC3-4488-4857-905D-2E4A051D0521
    Messagestring

    Detailed information returned by the interface.

    success
    Statusstring

    API execution status, value description:

    • success: Execution succeeded.
    • fail: Execution failed.
    success
    Tokensinteger

    Number of consumed tokens.

    100
    Resultsarray<object>

    Rerank results.

    Resultsobject

    Details of the results.

    Documentstring

    Re-ordered document information.

    ADBPG is the OLAP database of Alibaba Cloud.
    Indexinteger

    Index of this document in the request parameter Documents, starting from 0.

    1
    RelevanceScorefloat

    Rerank similarity score.

    2.31412

    Examples

    Sample success responses

    JSONformat

    {
      "RequestId": "ABB39CC3-4488-4857-905D-2E4A051D0521",
      "Message": "success",
      "Status": "success",
      "Tokens": 100,
      "Results": {
        "Results": [
          {
            "Document": "ADBPG is the OLAP database of Alibaba Cloud.",
            "Index": 1,
            "RelevanceScore": 2.31412
          }
        ]
      }
    }

    Error codes

    For a list of error codes, visit the Service error codes.