Amazon Bedrock Knowledge Bases provides a fully managed RAG (Retrieval Augmented Generation) service for querying uploaded data. By specifying the location of your data in Amazon S3, the service will:
There’s also an API for building applications that use the Knowledge Base.
In this module, we’ll create a Knowledge Base using a portion of the AWS Well-Architected Framework documentation.
Creating a Knowledge Base takes a few minutes. Don’t leave this page.
While waiting, you can complete the survey at: https://pulse.aws/survey/UBCJUUZV
When your Knowledge Base is ready, you can test it directly in the console interface:
Can you explain what a VPC is?
Try different questions to explore further!
You can also query via API with 2 methods:
retrieve
: Returns documents relevant to the question.retrieve_and_generate
: Performs the RAG workflow with a model.rag_examples/kb_rag.py
file in your IDE.KB_ID
variable with your Knowledge Base ID (found in the Overview section).python3 rag_examples/kb_rag.py
QUERY
variable on line 4 to see different responses.The code is executing the RAG process: converting the question to an embedding, retrieving relevant documents, and answering with the model.
After creating a Knowledge Base, the next step will be embedding this Knowledge Base into an Amazon Bedrock Agent to build a more intelligent automated response system.