Reduce number of retrieved chunks when using Bedrock Agents and Knowledge Base

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?

Upvotes: 0

Views: 179

Answers (1)

Gerardo Arroyo
Gerardo Arroyo

Reputation: 151

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

Upvotes: 0

Related Questions