Skip to content

reranking in retrieveAndGenerateConfiguration API is not working

0

Hello, I have a developed a Chatbot using RAG. I use Knowledgebase and Claude 4.5 model to retrieve and generate results respectively. To optimize search results, I am trying to add bedrockRerankingConfiguration inside retrieveAndGenerateConfiguration request. But, I keep getting the following error: "Error calling RDS Knowledge Base: Parameter validation failed: Unknown parameter in retrieveAndGenerateConfiguration.knowledgeBaseConfiguration.retrievalConfiguration.vectorSearchConfiguration: "rerankingConfiguration", must be one of: filter, numberOfResults, overrideSearchType"

I also tried to separate the reranking from generation and tried to use two-step approach as below. This approach also fails.

Step 1: Retrieve with reranking

retrieve_response = bedrock_agent_runtime.retrieve( knowledgeBaseId=kb_id, retrievalQuery={'text': prompt}, retrievalConfiguration={ 'vectorSearchConfiguration': { 'numberOfResults': 6, 'rerankingConfiguration': { 'type': 'BEDROCK_RERANKING_MODEL', 'bedrockRerankingConfiguration': { 'modelConfiguration': { 'modelArn': 'arn:aws:bedrock:us-east-1::foundation-model/cohere.rerank-v3-5:0' }, 'numberOfRerankedResults': 3 } } } } )

Step 2: Use retrieved documents with generate or invoke model directly

Please help.

Thanks!

2 Answers
0

Hey,

Hope you're keeping well.

The error indicates that rerankingConfiguration is not a supported field within vectorSearchConfiguration for the retrieveAndGenerateConfiguration API in Amazon Bedrock Knowledge Bases. In the current Bedrock API contract, reranking is only available through the standalone Retrieve API when you set retrievalConfiguration.rerankingConfiguration at the top level of the request, not nested inside vectorSearchConfiguration.

Thanks and regards,
Taz

answered a year ago

  • Hi Taz, Thanks for your quick response! We followed your recommendation and used retrievalConfiguration.rerankingConfiguration at the top level of the request as below. But, it still doesn't work.

    Version 1 - Request: request_payload = { "input": { "text": prompt }, "retrieveAndGenerateConfiguration": { "type": "KNOWLEDGE_BASE", "knowledgeBaseConfiguration": { "knowledgeBaseId": kb_id, "modelArn": "arn:aws:bedrock:us-east-1:029309145300:inference-profile/us.anthropic.claude-sonnet-4-5-20250929-v1:0", "retrievalConfiguration": { "vectorSearchConfiguration": { "numberOfResults": 10, "overrideSearchType": "HYBRID" }, "rerankingConfiguration": { "type": "BEDROCK_RERANKING_MODEL", "bedrockRerankingConfiguration": { "modelConfiguration": { "modelArn": "arn:aws:bedrock:us-east-1::foundation-model/cohere.rerank-v3-5:0" }, "numberOfRerankedResults": 5 } } } } } }

    Error: Error calling RDS Knowledge Base: Parameter validation failed: Unknown parameter in retrieveAndGenerateConfiguration.knowledgeBaseConfiguration.retrievalConfiguration: "rerankingConfiguration", must be one of: vectorSearchConfiguration

  • Version 2 - Request (using bedrock_agent_client.retrieve):

    retrieve_response = bedrock_agent_client.retrieve( knowledgeBaseId=kb_id, retrievalQuery={ "text": prompt }, retrievalConfiguration={ "vectorSearchConfiguration": { "numberOfResults": 20 }, "rerankingConfiguration": { "type": "BEDROCK_RERANKING_MODEL", "bedrockRerankingConfiguration": { "numberOfResults": 5, "modelConfiguration": { "modelArn": "arn:aws:bedrock:us-east-1::foundation-model/cohere.rerank-v3-5:0" } } } } )

    Error: Error calling RDS Knowledge Base: Parameter validation failed: Unknown parameter in retrievalConfiguration: "rerankingConfiguration", must be one of: vectorSearchConfiguration

  • Version 3 (reranking outside of retrieveAndGenerateConfiguration): request_payload = { "retrieveAndGenerateConfiguration": { "type": "KNOWLEDGE_BASE", "knowledgeBaseConfiguration": { "knowledgeBaseId": kb_id, "modelArn": "arn:aws:bedrock:us-east-1:029309145300:inference-profile/us.anthropic.claude-sonnet-4-5-20250929-v1:0", "retrievalConfiguration": { "vectorSearchConfiguration": { "numberOfResults": 10 } } } }, "rerankingConfiguration": { "type": "BEDROCK", "bedrockRerankingConfiguration": { "modelConfiguration": { "modelArn": "arn:aws:bedrock:us-east-1::foundation-model/cohere.rerank-v3-5:0" }, "numberOfResults": 3 } } }

    Error: Error calling RDS Knowledge Base: Parameter validation failed: Missing required parameter in input: "input" Unknown parameter in input: "rerankingConfiguration", must be one of: input, retrieveAndGenerateConfiguration, sessionConfiguration, sessionId

    Hope you will be able to help!

    Thanks in advance!

0

The issue you're encountering is related to how reranking is configured in Amazon Bedrock Knowledge Bases.

For the RetrieveAndGenerate API, reranking is not configured within the vectorSearchConfiguration parameter as you've attempted. Instead, reranking should be enabled through a setting available in the RetrieveAndGenerate API directly.

For your two-step approach using the Retrieve operation, the structure of your reranking configuration appears incorrect. When using a reranker model with Amazon Bedrock Knowledge Bases, you need to ensure:

  1. Your service role has the proper permissions for reranking, specifically the bedrock:Rerank and bedrock:InvokeModel actions.

  2. The reranker model you're trying to use (Cohere Rerank 3.5) is available in your region. This model is available in US West (Oregon), Canada (Central), Europe (Frankfurt), and Asia Pacific (Tokyo). If you're in US East (N. Virginia), you should check if this specific model is available there.

  3. The correct syntax is used for the API call. The error message suggests that "rerankingConfiguration" is not a valid parameter within vectorSearchConfiguration.

To use reranking with Amazon Bedrock Knowledge Bases, make sure you're using the latest SDK version and check the documentation for the exact parameter structure required for enabling reranking in the Retrieve or RetrieveAndGenerate operations.

Remember that reranking models help prioritize the most relevant content from your retrieved documents, ensuring that the most useful information is sent to the foundation model for response generation.
Sources
Improve the relevance of query responses with a reranker model in Amazon Bedrock - Amazon Bedrock
Amazon Bedrock now supports Rerank API to improve accuracy of RAG applications - AWS
Permissions for reranking in Amazon Bedrock - Amazon Bedrock

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.