Retrieve data and generate AI responses with knowledge bases
You can integrate proprietary information into your generative-AI applications with Amazon Bedrock knowledge bases. Using the Retrieval Augment Generation (RAG) technique, a knowledge base searches your data to find the most useful information and then uses it to answer natural language questions.
After you set up a knowledge base, you can then take advantage of the knowledge base in the following ways:
-
Configure your RAG application to use the RetrieveAndGenerate API to query your knowledge base and generate responses from the information it retrieves. You can also call the Retrieve API to query your knowledge base with information retrieved directly from the knowledge base.
-
Associate your knowledge base with an agent (for more information, see Automate tasks in your application using conversational agents) to add RAG capability to the agent by helping it reason through the steps it can take to help end users.
A knowledge base can be used not only to answer user queries, and analyze documents, but also to augment prompts provided to foundation models by providing context to the prompt. When answering user queries, the knowledge base retains conversation context. The knowledge base also grounds answers in citations so that users can find further information by looking up the exact text that a response is based on and also check that the response makes sense and is factually correct.
You take the following steps to set up and use your knowledge base.
-
Gather source documents to add to your knowledge base.
-
Store your source documents in a supported data source.
-
(Optional if using Amazon S3 to store your source documents) Create a metadata file for each source document to allow for filtering of results during knowledge base query.
-
(Optional) Set up your own supported vector store to index the vector embeddings representation of your data. You can use the Amazon Bedrock console to create an Amazon OpenSearch Serverless vector store for you.
-
Create and configure your knowledge base. You must enable model access to use a model that's supported for knowledge bases.
If you use the Amazon Bedrock API, take note of your model Amazon Resource Name (ARN) that's required for converting your data into vector embeddings and for knowledge base retrieval and generation. Copy the model ID for your chosen model for knowledge bases and construct the model ARN using the model (resource) ID, following the provided ARN examples for your model resource type.
If you use the Amazon Bedrock console, you are not required to construct a model ARN, as you can select an available model as part of the steps for creating a knowledge base.
-
Set up your application or agent to query the knowledge base and return augmented responses.
Topics
- How Amazon Bedrock knowledge bases work
- Supported models and regions for Amazon Bedrock Knowledge Bases
- Chat with your document without a knowledge base configured
- Build and manage knowledge bases for retrieval and responses
- Connect to your data repository for your knowledge base
- Test your knowledge base with queries and responses
- Deploy your knowledge base for your AI application