AI/ML, AWS, Cloud Computing

3 Mins Read

Enhancing Retrieval-Augmented Generation with Amazon Bedrock Knowledge Bases

Voiced by Amazon Polly

Introduction

With Knowledge Bases for Amazon Bedrock, you can securely link foundation models (FMs) to your company’s data for Retrieval Augmented Generation (RAG). This integration enables the model to produce more pertinent, context-specific, and precise responses without the need for FM retraining.

Amazon Bedrock’s Knowledge Bases now offer two exciting new features for the RetrieveAndGenerate API: controlling the maximum number of results and customizing prompts.

Maximum Results Control: Now, you can decide how many search results you want, up to 100. This helps tailor the amount of background info for generating answers, improving accuracy.

Custom Prompts: You can replace the default prompt template with your own, tweak tone format, and even add industry-specific terms or instructions.

Overview and Benefits of the New Features

The maximum number of results options lets you decide how many search results are retrieved from the vector store and used by the FM to generate answers. This allows you to adjust the background information provided, offering more context for complex queries or less for simpler ones.

You can fetch up to 100 results, enhancing the likelihood of relevant context, improving accuracy, and reducing the risk of generating irrelevant responses.

This allows you to personalize the model for generating responses adjusting the tone, output format, and behavior of the FM. This option allows you to refine terminology to align better with your industry or domain, such as healthcare or legal. Additionally, you can include custom instructions and examples tailored to your specific workflows.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Prerequisites

  1. AWS Account access with permission to access the Amazon Bedrock
  2. Existing Knowledge Base in Amazon Bedrock

Step-by-Step Guide to Adjust the Maximum Number of Results using the console

Step 1: Navigate to the Knowledge Bases section on the Amazon Bedrock console’s left-hand menu.

Step 2: Pick the knowledge base you’ve established earlier.

Step 3: Opt for “Test knowledge base.”

Step 4: Click on the configuration icon.

Step 5: Select “Sync data source” before commencing testing on your knowledge base.

step5

Step 6: In the Configurations section, choose a search type that aligns with your specific use case.

In this post, we stick with the default search option for simplicity. However, you also have the flexibility to utilize semantic search or hybrid search, depending on your specific use cases. To delve deeper into hybrid search, check out the feature spotlight on Knowledge Bases for Amazon Bedrock supporting hybrid search.

Step 7: Increase the maximum number of source chunks and specify your desired maximum number of results.

step7

Step 8: We utilized Claude v3 Sonnet as the FM to produce the ultimate response by leveraging the contextual information obtained from the knowledge base. Additionally, Claude v2 and Claude 3 Haiku are compatible with generation FMs.

As depicted in the screenshot below, the response generated with this request is displayed.

step8

In this example, we successfully obtain the correct answer based on the number of retrieved results. If you wish to delve deeper into the source attribution contributing to the final output, select “Show source details” to verify the generated answer against the knowledge base.

The ‘numberOfResults’ option within the ‘retrievalConfiguration’ enables you to specify the desired number of results for retrieval. The output of the RetrieveAndGenerate API comprises the generated response, source attribution, and the retrieved text chunks.

To adjust the maximum number of results using the SDK, follow the syntax below.

Conclusion

In summary, the new custom prompts and result limit configuration features in Amazon Bedrock’s Knowledge Bases significantly enhance user experience and response accuracy. Users can tailor interactions, adjust background information, and customize responses to match their industry needs. These improvements streamline workflows and ensure more relevant, precise answers without requiring FM retraining.

Drop a query if you have any questions regarding Amazon Bedrock and we will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training PartnerAWS Migration PartnerAWS Data and Analytics PartnerAWS DevOps Competency PartnerAmazon QuickSight Service Delivery PartnerAmazon EKS Service Delivery PartnerAWS Microsoft Workload PartnersAmazon EC2 Service Delivery Partner, and many more.

To get started, go through our Consultancy page and Managed Services PackageCloudThat’s offerings.

FAQs

1. What does the maximum number of results option allow me to do?

ANS: – It enables you to decide how many search results you want, up to 100, providing flexibility in tailoring background information for generating answers.

2. Why is it important to have control over the number of retrieved results?

ANS: – Having control over the number of retrieved results helps improve the accuracy of responses by providing relevant context for both simple and complex queries.

3. Can I use different search types in Amazon Bedrock's Knowledge Bases?

ANS: – Yes, you can choose from default search, semantic search, or hybrid search, depending on your specific use case and requirements.

WRITTEN BY Aditya Kumar

Aditya Kumar works as a Research Associate at CloudThat. His expertise lies in Data Analytics. He is learning and gaining practical experience in AWS and Data Analytics. Aditya is also passionate about continuously expanding his skill set and knowledge to learn new skills. He is keen to learn new technology.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!