amazon web services - Reduce number of retrieved chunks when using Bedrock Agents and Knowledge Base - Stack Overflow

admin2025-05-01  0

I'm building a conversational agent with AWS Bedrock and its agents. I've linked a knowledge base to the agent to retrieve information based on user questions.

When testing its functionality, I see in the traces that the knowledge base always returns 5 chunks of information. However, I don't need that many - I only want the most relevant chunk.

How can I do this? What configuration do I need to modify?

I'm building a conversational agent with AWS Bedrock and its agents. I've linked a knowledge base to the agent to retrieve information based on user questions.

When testing its functionality, I see in the traces that the knowledge base always returns 5 chunks of information. However, I don't need that many - I only want the most relevant chunk.

How can I do this? What configuration do I need to modify?

Share Improve this question edited Jan 2 at 16:54 Alberto Soto González asked Jan 2 at 16:47 Alberto Soto GonzálezAlberto Soto González 354 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Amazon Bedrock returns up to five results in the response by default. You can change the parameter numberOfResults in the vectorSearchConfiguration (if using python). By example:

response = bedrock.update_knowledge_base(
knowledgeBaseId='tu-kb-id',
retrievalConfiguration={
    'vectorSearchConfiguration': {
        'numberOfResults': 1  # Este es el parámetro correcto
    }
}

You can see the documentation here

转载请注明原文地址:http://anycun.com/QandA/1746106576a91762.html