Retrieval Augmented Generation using Amazon Bedrock
Sample code and a CloudFormation template for building a question-answering application with Amazon Bedrock, using a knowledge base backed by Amazon OpenSearch Serverless for retrieval-augmented generation.
This repository shows how to build a retrieval-augmented-generation question-answering application on Amazon Bedrock. A data pipeline, implemented through Amazon Bedrock Agents for Knowledge Base, ingests documents such as HTML, PDF and text files from an Amazon S3 bucket, chunks them, converts the chunks into embeddings with the Amazon Titan Embeddings model, and stores them in an Amazon OpenSearch Serverless vector collection. An application then takes a user's question, looks up relevant context in the knowledge base, and passes the question and context to a large language model to generate an answer.
Setup uses an included AWS CloudFormation template that provisions the vector collection, an S3 bucket, IAM roles and a SageMaker notebook with the repository already cloned. The project notes that Amazon Bedrock now also offers Managed Knowledge Bases, which remove the need to set up a separate vector store.
It is released under the MIT-0 license.