- Newest
- Most votes
- Most comments
Based on the information you've provided, it seems you're experiencing an issue with your AWS Bedrock Knowledge Base where queries are not returning expected results, despite having relevant data in your data source. Here are some potential reasons and solutions for this problem:
-
Metadata Filtering: Ensure that your metadata is correctly formatted and matches the structure expected by Bedrock. For numerical values, avoid using quotes. For example, use
"caseId": 2instead of"caseId": "2". This can affect how Bedrock processes the metadata for filtering. -
Retrieval Configuration: Your retrieval configuration might need adjustment. Make sure the
numberOfResultsparameter is set high enough to capture all relevant chunks. You might want to increase this value to ensure you're not missing any relevant information. -
Query Format: The structure of your retrieval query is crucial. Make sure it follows the correct format as specified in the Bedrock documentation. For example:
{ "retrievalQuery": { "text": "Your query here" }, "retrievalConfiguration": { "vectorSearchConfiguration": { "numberOfResults": 100 } } }
-
Chunking Strategy: Review your fixed chunking strategy. If chunks are too small or too large, it might affect the relevance of retrieved information.
-
Embedding Model Access: Verify that you have proper access to the Titan embedding model (amazon.titan-embed-text-v2). Sometimes, even with general Bedrock access, you might need to explicitly request access to specific models.
-
Sync Process: Ensure that your data sync process completed successfully. Check for any sync errors in the Bedrock console or CloudWatch logs.
-
IAM Permissions: Confirm that your IAM roles have the necessary permissions to access all required services, including S3, Bedrock, and any other integrated services.
-
Region Compatibility: Make sure your S3 buckets and Bedrock resources are in the same AWS region.
If you've verified all these points and are still experiencing issues, you may want to try the following:
- Use the "Test knowledge base" feature in the Bedrock console to isolate whether the problem is with your application code or the knowledge base itself.
- Review CloudWatch logs for any error messages or unexpected behavior.
- Consider creating a new knowledge base with a subset of your data to test if the issue persists.
If none of these solutions resolve your issue, it may be worth contacting AWS Support for more detailed troubleshooting specific to your account and configuration.
Sources
Issue with metadata filtering in Amazon Bedrock | AWS re:Post
Missing records form Bedrock Knowledge Base Query , maybe chunking issue | AWS re:Post
Data sync failed error in Amazon Bedrock Knowledgebase | AWS re:Post
Bedrock knowledge base data source sync is not working | AWS re:Post
answered a year ago
Relevant content
asked 2 years ago

Hello, I have the same issue. I ran some tests and I suspect, it might be related to the custom prompt.
I have implemented a custom prompt template as described here [https://aws.amazon.com/de/blogs/machine-learning/knowledge-bases-for-amazon-bedrock-now-supports-custom-prompts-for-the-retrieveandgenerate-api-and-configuration-of-the-maximum-number-of-retrieved-results/]. Let's say my prompt template looks like this:
I use this template in the
generationConfigurationwithinretrieveAndGenerateConfiguration.In retrieve_and_generate function I supply the input:
I find the results quite unstable, when using this way. However, if I use a simple template with just one place holder for the user query, and supply that into 'input', and disable the promptTemplate in generationConfig, it works much better, results are stable. I tested both approaches with the same config, and ran each several times. I suspect the issue is with the custom prompt. Is it worth for developers to have a look?