Knowledge Base with Amazon Bedrock and MongoDB Atlas
Setup a Knowledge Base in Amazon Bedrock with MongoDB Atlas Vector Store to start building your RAG application.
Domenica Siviglia
Amazon Employee
Published Jul 25, 2024
Building a robust and scalable knowledge base is a key requirement for many modern AI and machine learning applications. Amazon Bedrock, a fully managed foundation model service, provides an easy way to create and deploy knowledge bases powered by large language models. When paired with the MongoDB Atlas Vector Store, a cloud-hosted vector database, you can build a highly capable and flexible knowledge base solution.
In this blog post, I'll walk through the process of setting up a knowledge base using Amazon Bedrock and MongoDB Atlas Vector Store entirely from the AWS Management Console.
Prerequisites
You must have the following:
- An Atlas cluster running MongoDB version 6.0.11, 7.0.2 or later.
- An AWS account
- An S3 bucket with some pdf documents in it
Getting Started with Amazon Bedrock
First of all you need to enable model access. In AWS Console, navigate to Amazon Bedrock|Model Access. Select as region North Virginia or Oregon because in these regions MongoDB Atlas Vector Store is available from AWS Console. Click on Manage Model Access and select all models under Amazon. Click on Request model to proceed
Configure an Endpoint Service
Atlas Vector Search supports connecting to your knowledge base through AWS Private Link endpoint service so you can privately connect and your data will not be exposed on the public internet. Follow these instructions to setup the private connection:
Create Atlas Vector Search Index
Select an existing collection or create a new one from Atlas console.
Go to the Atlas Search page from the sidebar and then click the Create Search Index button.
Select the database and collection. Enter an index name. Replace the default definition with the following sample index definition.
Then click on Create Search Index.
Create a Secret in Secrets Manager
In AWS console, navigate to Secret Manager and click on Store new secret.
Choose Other type of secret and in the Plaintext tab provide the connection string of the MongoDB Atlas Cluster.
proceed in the next page where you supply secret name and then store the secret.
Create the Knowledge Base
Navigate to Amazon Bedrock management console and select Knowledge Base in the left navigation
- Choose a name for your knowledge base and select Amazon S3 as data source
- Click next, then choose the S3 buck you previously created
- Click Next and select Titan Text embeddings as embedding model and in the Vector Database section select Choose a Vector Store you have created and then MongoDB Atlas
- Configure the following options for MongoDB Atlas:
- If you configured an endpoint service, enter the name of your Private Link Service Name
- Review and create your knowledge base
- After the knowledge base creation, sync the data source and load it into Atlas. When the sync complete you can view your vector embeddings in the Atlas UI navigating to the collection.
Test your Knowledge Base
After your setup your knowledge base you can test its behaviour selecting Test knowledge Base in the console.
Conclusions
You can then build applications that leverage this knowledge base, such as chatbots, question-answering systems, or content recommendation engines.
The beauty of this approach is that it allows you to harness the power of large language models through Amazon Bedrock while also benefiting from the scalability and flexibility of the MongoDB Atlas Vector Store - all without having to manage the underlying infrastructure.
I hope this guide has given you a good starting point for building your own knowledge bases.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.