Pinecone as a Knowledge Base for Amazon Bedrock
Users can now select Pinecone as a Knowledge Base for Amazon Bedrock, a fully managed service from Amazon Web Services (AWS) for building GenAI applications.
The Pinecone vector database is a key component of the AI tech stack, helping companies solve one of the biggest challenges in deploying GenAI solutions — hallucinations — by allowing them to store, search, and find the most relevant and up-to-date information from company data and send that context to Large Language Models (LLMs) with every query. This workflow is called Retrieval Augmented Generation (RAG), and with Pinecone, it aids in providing relevant, accurate, and fast responses from search or GenAI applications to end users.
With the release of Knowledge Bases for Amazon Bedrock, developers can integrate their enterprise data into Amazon Bedrock using Pinecone as the fully-managed vector database to build GenAI applications that are:
In Bedrock, users interact with Agents that are capable of combining the natural language interface of the supported LLMs with those of a Knowledge Base. Bedrock’s Knowledge Base feature uses the supported LLMs to generate embeddings from the original data source. These embeddings are stored in Pinecone, and the Pinecone index is used to retrieve semantically relevant content upon the user’s query to the agent.
Note: the LLM used for embeddings may be different than the one used for the natural language generation. For example, you may choose to use Amazon Titan to generate embeddings and use Anthropic’s Claude to generate natural language responses.
Additionally, Agents for Amazon Bedrock may be configured to execute various actions in the context of responding to a user’s query - but we won’t get into this functionality in this post.
A Bedrock Knowledge base ingests raw text data or documents found in Amazon S3, embeds the content and upserts the embeddings into Pinecone. Then, a Bedrock agent can interact with the knowledge base to retrieve the most semantically relevant content given a user’s query.
Overall, the Knowledge Base feature is a valuable tool for users who want to improve their AI models’ performance. With Bedrock’s LLMs and Pinecone, users can easily integrate their data from AWS storage solutions and enhance the accuracy and relevance of their AI models.
In this post, we’ll go through the steps required for creating a Knowledge Base for Amazon Bedrock as well as an agent that will retrieve information from the knowledge base.
The process of using a Bedrock knowledge base with Pinecone works as follows:
Create a Pinecone index.
Create a Pinecone index with an embedding model in mind.
Set up a data source.
Upload sample data to Amazon S3.
Create a Bedrock knowledge base.
Sync data with Bedrock to create embeddings saved in Pinecone.
Connect Pinecone to Bedrock.
Use the knowledge base to reference the data saved in Pinecone.
Create and link agents to Bedrock.
Agents can interact directly with the Bedrock knowledge base, which will retrieve the semantically relevant content.
The knowledge base stores data in a Pinecone index. Decide which supported embedding model to use with Bedrock before you create the index, as your index’s dimensions will need to match the model’s. For example, the AWS Titan Text Embeddings V2 model can use dimension sizes 1024, 384, and 256.
After signing up to Pinecone, follow the quickstart guide to create your Pinecone index and retrieve your apiKey
and index host from the Pinecone console.
Ensure that you create your index with the same dimensions as the model you will later select for creating your embeddings.
After setting up your Pinecone index, you’ll have to create a secret in AWS Secrets Manager:
apiKey
and the API key value.
The knowledge base is going to draw on data saved in S3. For this example, we use a sample of research papers obtained from a dataset. This data will be embedded and then saved in Pinecone.
Create a new general purpose bucket in Amazon S3.
Once the bucket is created, upload a CSV file.
The CSV file must have a field for text that will be embedded, and a field for metadata to upload with each embedded text.
Save your bucket’s address (s3://…
) for the following configuration steps.
To create a Bedrock knowledge base, use the following steps:
Now you will need to select an embedding model to configure with Bedrock and configure the data sources.
metadata
).Sync the data source whenever you add new data to the data source to start the ingestion workflow of converting your Amazon S3 data into vector embeddings and upserting the embeddings into the vector database. Depending on the amount of data, this whole workflow can take some time.
Lastly, create an agent that will use the knowledge base for retrieval:
Your agent is now set up and ready to go! In the next section, we’ll show how to interact with the newly created agent.
In order to deploy the agent, create an alias for it that points to a specific version of the agent. Once the alias is created, it will display in the agent view.
To test the newly created agent, use the playground on the right of the screen when we open the agent.
In this example, we used a dataset of research papers for our source data. We can ask a question about those papers and retrieve a detailed response, this time with the deployed version.
By inspecting the trace, we can see what chunks were used by the Agent and diagnose issues with responses.
Pinecone as a Knowledge Base for Amazon Bedrock
Users can now select Pinecone as a Knowledge Base for Amazon Bedrock, a fully managed service from Amazon Web Services (AWS) for building GenAI applications.
The Pinecone vector database is a key component of the AI tech stack, helping companies solve one of the biggest challenges in deploying GenAI solutions — hallucinations — by allowing them to store, search, and find the most relevant and up-to-date information from company data and send that context to Large Language Models (LLMs) with every query. This workflow is called Retrieval Augmented Generation (RAG), and with Pinecone, it aids in providing relevant, accurate, and fast responses from search or GenAI applications to end users.
With the release of Knowledge Bases for Amazon Bedrock, developers can integrate their enterprise data into Amazon Bedrock using Pinecone as the fully-managed vector database to build GenAI applications that are:
In Bedrock, users interact with Agents that are capable of combining the natural language interface of the supported LLMs with those of a Knowledge Base. Bedrock’s Knowledge Base feature uses the supported LLMs to generate embeddings from the original data source. These embeddings are stored in Pinecone, and the Pinecone index is used to retrieve semantically relevant content upon the user’s query to the agent.
Note: the LLM used for embeddings may be different than the one used for the natural language generation. For example, you may choose to use Amazon Titan to generate embeddings and use Anthropic’s Claude to generate natural language responses.
Additionally, Agents for Amazon Bedrock may be configured to execute various actions in the context of responding to a user’s query - but we won’t get into this functionality in this post.
A Bedrock Knowledge base ingests raw text data or documents found in Amazon S3, embeds the content and upserts the embeddings into Pinecone. Then, a Bedrock agent can interact with the knowledge base to retrieve the most semantically relevant content given a user’s query.
Overall, the Knowledge Base feature is a valuable tool for users who want to improve their AI models’ performance. With Bedrock’s LLMs and Pinecone, users can easily integrate their data from AWS storage solutions and enhance the accuracy and relevance of their AI models.
In this post, we’ll go through the steps required for creating a Knowledge Base for Amazon Bedrock as well as an agent that will retrieve information from the knowledge base.
The process of using a Bedrock knowledge base with Pinecone works as follows:
Create a Pinecone index.
Create a Pinecone index with an embedding model in mind.
Set up a data source.
Upload sample data to Amazon S3.
Create a Bedrock knowledge base.
Sync data with Bedrock to create embeddings saved in Pinecone.
Connect Pinecone to Bedrock.
Use the knowledge base to reference the data saved in Pinecone.
Create and link agents to Bedrock.
Agents can interact directly with the Bedrock knowledge base, which will retrieve the semantically relevant content.
The knowledge base stores data in a Pinecone index. Decide which supported embedding model to use with Bedrock before you create the index, as your index’s dimensions will need to match the model’s. For example, the AWS Titan Text Embeddings V2 model can use dimension sizes 1024, 384, and 256.
After signing up to Pinecone, follow the quickstart guide to create your Pinecone index and retrieve your apiKey
and index host from the Pinecone console.
Ensure that you create your index with the same dimensions as the model you will later select for creating your embeddings.
After setting up your Pinecone index, you’ll have to create a secret in AWS Secrets Manager:
apiKey
and the API key value.
The knowledge base is going to draw on data saved in S3. For this example, we use a sample of research papers obtained from a dataset. This data will be embedded and then saved in Pinecone.
Create a new general purpose bucket in Amazon S3.
Once the bucket is created, upload a CSV file.
The CSV file must have a field for text that will be embedded, and a field for metadata to upload with each embedded text.
Save your bucket’s address (s3://…
) for the following configuration steps.
To create a Bedrock knowledge base, use the following steps:
Now you will need to select an embedding model to configure with Bedrock and configure the data sources.
metadata
).Sync the data source whenever you add new data to the data source to start the ingestion workflow of converting your Amazon S3 data into vector embeddings and upserting the embeddings into the vector database. Depending on the amount of data, this whole workflow can take some time.
Lastly, create an agent that will use the knowledge base for retrieval:
Your agent is now set up and ready to go! In the next section, we’ll show how to interact with the newly created agent.
In order to deploy the agent, create an alias for it that points to a specific version of the agent. Once the alias is created, it will display in the agent view.
To test the newly created agent, use the playground on the right of the screen when we open the agent.
In this example, we used a dataset of research papers for our source data. We can ask a question about those papers and retrieve a detailed response, this time with the deployed version.
By inspecting the trace, we can see what chunks were used by the Agent and diagnose issues with responses.