Rerank - Amazon Bedrock

Rerank

Reranks the relevance of sources based on queries. For more information, see Improve the relevance of query responses with a reranker model.

Request Syntax

POST /rerank HTTP/1.1 Content-type: application/json { "nextToken": "string", "queries": [ { "textQuery": { "text": "string" }, "type": "string" } ], "rerankingConfiguration": { "bedrockRerankingConfiguration": { "modelConfiguration": { "additionalModelRequestFields": { "string" : JSON value }, "modelArn": "string" }, "numberOfResults": number }, "type": "string" }, "sources": [ { "inlineDocumentSource": { "jsonDocument": JSON value, "textDocument": { "text": "string" }, "type": "string" }, "type": "string" } ] }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

nextToken

If the total number of results was greater than could fit in a response, a token is returned in the nextToken field. You can enter that token in this field to return the next batch of results.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: ^\S*$

Required: No

queries

An array of objects, each of which contains information about a query to submit to the reranker model.

Type: Array of RerankQuery objects

Array Members: Fixed number of 1 item.

Required: Yes

rerankingConfiguration

Contains configurations for reranking.

Type: RerankingConfiguration object

Required: Yes

sources

An array of objects, each of which contains information about the sources to rerank.

Type: Array of RerankSource objects

Array Members: Minimum number of 1 item. Maximum number of 1000 items.

Required: Yes

Response Syntax

HTTP/1.1 200 Content-type: application/json { "nextToken": "string", "results": [ { "document": { "jsonDocument": JSON value, "textDocument": { "text": "string" }, "type": "string" }, "index": number, "relevanceScore": number } ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

nextToken

If the total number of results is greater than can fit in the response, use this token in the nextToken field when making another request to return the next batch of results.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: ^\S*$

results

An array of objects, each of which contains information about the results of reranking.

Type: Array of RerankResult objects

Errors

For information about the errors that are common to all actions, see Common Errors.

AccessDeniedException

The request is denied because of missing access permissions. Check your permissions and retry your request.

HTTP Status Code: 403

BadGatewayException

There was an issue with a dependency due to a server issue. Retry your request.

HTTP Status Code: 502

ConflictException

There was a conflict performing an operation. Resolve the conflict and retry your request.

HTTP Status Code: 409

DependencyFailedException

There was an issue with a dependency. Check the resource configurations and retry the request.

HTTP Status Code: 424

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500

ResourceNotFoundException

The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.

HTTP Status Code: 404

ServiceQuotaExceededException

The number of requests exceeds the service quota. Resubmit your request later.

HTTP Status Code: 400

ThrottlingException

The number of requests exceeds the limit. Resubmit your request later.

HTTP Status Code: 429

ValidationException

Input validation failed. Check your request parameters and retry the request.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: