All Products
Search
Document Center

AnalyticDB:Rerank

Last Updated:Oct 23, 2026

Reranks the results of vector retrieval and full-text retrieval to address inaccurate sorting by using semantic understanding to rescore and reorder recalled data, which significantly improves result relevance and accuracy. AnalyticDB for PostgreSQL allows you to invoke rerank models to reorder retrieval results, but does not provide the models.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

gpdb:Rerank

list

*DBInstance

acs:gpdb:{#regionId}:{#accountId}:dbinstance/{#DBInstanceId}

None None

Request parameters

Parameter

Type

Required

Description

Example

DBInstanceId

string

Yes

The instance ID.

Note

You can call the DescribeDBInstances operation to view the details of all AnalyticDB for PostgreSQL instances in the specified region, including instance IDs.

gp-xxxxxxxxx

RegionId

string

Yes

The region ID of the instance.

cn-hangzhou

Query

string

No

The query statement for reranking.

What is ADBPG?

Documents

array

No

The list of documents to be reranked.

ADBPG is an Alibaba Cloud OLAP database.

string

No

The content of a single document.

ADBPG is an Alibaba Cloud OLAP database

Model

string

No

The rerank model. Valid values:

  • bge-reranker-v2-m3: provides good performance and supports up to 8,192 tokens for a single inference. Text that exceeds this limit is split into chunks, which may degrade performance. This is the default value.

  • bge-reranker-v2-minicpm-layerwise: provides better performance than bge-reranker-v2-m3 and supports up to 2,048 tokens for a single inference. Text that exceeds this limit is split into chunks, which may degrade performance.

bge-reranker-v2-m3

Instruct

string

No

The description of the custom ranking task type. This parameter can be set when RerankModel.Name is qwen3-rerank. It guides the model to use different ranking strategies.

Given a web search query, retrieve relevant passages that answer the query

TopK

integer

No

The number of most relevant documents to return.

3

ReturnDocuments

boolean

No

Specifies whether to return the document text. If this parameter is set to false, the document text is not returned. Only the indexes and rerank scores of the sorted documents are returned.

false

MaxChunksPerDoc

integer

No

The maximum number of chunks allowed when the text exceeds the model window. Valid values:

  • bge-reranker-v2-m3: 10. This is the default value.

  • bge-reranker-v2-minicpm-layerwise: 5. This is the default value.

Note

Chunking example

  • If you use the bge-reranker-v2-minicpm-layerwise model, the maximum single inference window is 2,048 tokens. If the query is 48 tokens and a single document parameter contains 9,000 tokens, the document is split into chunks: tokens 1 to 2,000 form the first chunk, tokens 2,001 to 4,000 form the second chunk, and so on. If the number of chunks exceeds the value of MaxChunksPerDoc, the subsequent text is discarded.

10

Response elements

Element

Type

Description

Example

object

Message

string

The detailed information returned in the response.

success

RequestId

string

The request ID.

ABB39CC3-4488-4857-905D-2E4A051D0521

Results

object

Results

array<object>

The rerank results.

object

The result details.

Document

string

The reranked document information.

ADBPG is an Alibaba Cloud OLAP database.

Index

integer

The index of the document in the Documents request parameter. The index starts from 0.

1

RelevanceScore

number

The rerank similarity score.

2.31412

Status

string

The execution status of the API operation. Valid values:

  • success: The operation is successful.

  • fail: The operation fails.

success

Tokens

integer

The number of tokens consumed.

100

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.