Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Retrieving information from data sources using Amazon Bedrock Knowledge Bases

Focus mode
Retrieving information from data sources using Amazon Bedrock Knowledge Bases - Amazon Bedrock

After setting up a knowledge base, you can set up your application to query the data sources in it. To query a knowledge base, you can take advantage of the following API operations:

  • Retrieve – Retrieves the source chunks or images from your data that are most relevant to the query and returns them in the response as an array.

  • RetrieveAndGenerate – Joins Retrieve with the InvokeModel operation in Amazon Bedrock to retrieve the source chunks from your data that are most relevant to the query and generate a natural language response. Includes citations to specific source chunks from the data. If your data source includes visual elements, the model leverage insights from these images when generating a text response and provide source attribution for the images.

  • GenerateQuery – Converts natural language user queries into queries that are in a form suitable for the structured data store.

The RetrieveAndGenerate operation is a combined action that underlyingly uses GenerateQuery (if your knowledge base is connected to a structured data store), Retrieve and InvokeModel to carry out the entire RAG process. Because Amazon Bedrock Knowledge Bases also provides you access to the Retrieve operation, you have the flexibility to decouple the steps in RAG and customize them for your specific use case.

You can also use a reranking model when using Retrieve or RetrieveAndGenerate to rerank the relevance of documents retrieved during query.

To learn how to use these API operations when querying a knowledge base, see Test your knowledge base with queries and responses.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.