> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bedrock Knowledge Bases Introduction Part 1

> Explains Amazon Bedrock Knowledge Bases and how they simplify building managed retrieval augmented generation pipelines by handling ingestion, embeddings, vector storage, retrieval, and prompt augmentation.

In this lesson you'll learn what Amazon Bedrock Knowledge Bases are and how they simplify building retrieval-augmented generation (RAG) applications. Instead of implementing ingestion, embeddings, vector storage, and retrieval yourself, Bedrock Knowledge Bases provide a managed pipeline that makes your application logic much simpler and more maintainable.

We’ll cover:

* The real-world problems RAG systems solve.
* Why building a RAG pipeline from scratch is complex.
* How Bedrock Knowledge Bases address those complexities.
* The runtime request flow and a simple pseudocode example.
* The configuration items required to create a knowledge base.

Why building a RAG system yourself is hard
Implementing a full RAG stack involves many moving parts that become application-level responsibilities:

| Challenge | What you must implement |
| - | - |
| Ingestion | Read, normalize, and keep many source documents up to date |
| Chunking / parsing | Split large documents into semantically coherent chunks before embedding |
| Embeddings | Call and manage an embeddings model for each chunk |
| Vector storage | Run or maintain a vector store with similarity search capabilities |
| Retrieval | Embed queries, search the vector store, and select relevant chunks |
| Prompt augmentation | Combine retrieved chunks with the user query to create a grounded prompt |

Each of these components adds engineering, operational, and scaling overhead across teams and use cases.

How Bedrock Knowledge Bases solve these problems
Bedrock Knowledge Bases provide a managed, end-to-end RAG pipeline so you can focus on application logic rather than infrastructure. They cover:

* Document ingestion and automatic chunking.
* Conversion of chunks into embeddings with a configured embeddings model.
* Managed vector storage for persistent vectors.
* Similarity search and retrieval at query time.
* Assembly of an augmented prompt that is passed to a foundation model for generation.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/4OlDw81IoiRnJTCQ/images/Introduction-to-Amazon-Bedrock/Introduction-to-Retrieval-Augmentation-With-Bedrock-Knowledge-Bases/Bedrock-Knowledge-Bases-Introduction-Part-1/bedrock-knowledge-base-workflow-tiles.jpg?fit=max&auto=format&n=4OlDw81IoiRnJTCQ&q=85&s=73a3a341f6c808a3223913ee1e912e77" alt="A slide titled &#x22;Solution: Bedrock Knowledge Base&#x22; showing six blue tiles labeled Document Ingestion, Chunking, Embeddings, Vector Storage, Retrieval, and Prompt Augmentation, each with a simple icon. The layout presents a visual workflow for building a knowledge base." width="1920" height="1080" data-path="images/Introduction-to-Amazon-Bedrock/Introduction-to-Retrieval-Augmentation-With-Bedrock-Knowledge-Bases/Bedrock-Knowledge-Bases-Introduction-Part-1/bedrock-knowledge-base-workflow-tiles.jpg" />
</Frame>

With Bedrock Knowledge Bases you simply configure the data source, select an embeddings model and a vector store (for example, Titan Text Embeddings with an S3-backed vector store), and Bedrock takes care of ingestion, embedding computation, vector persistence, and retrieval.

How the request flow fits with your application
A RAG system still requires pre-ingested vectors for documents. At query time your application triggers retrieval and generation. Bedrock exposes a RetrieveAndGenerate operation (via the AWS SDK or Runtime) that orchestrates these steps.

High-level runtime flow:

1. Your application calls RetrieveAndGenerate with:
   * The user prompt (question).
   * The knowledge base identifier to use for retrieval.
   * The foundation model name for final generation.
2. Bedrock Runtime sends the prompt to the configured Knowledge Base.
3. The Knowledge Base embeds the prompt using the aligned embeddings model and performs a vector similarity search against the configured vector store.
4. It selects the most relevant document chunks and constructs an augmented, grounded prompt.
5. The augmented prompt is returned to Bedrock Runtime, which forwards it to the specified foundation model (for example, `meta.llama3-8b-instruct`).
6. The model returns a grounded response that your application receives.

This workflow keeps application-side code concise while Bedrock handles embedding computation, retrieval logic, and prompt augmentation.

Example (pseudocode)

```python theme={null}
# Example pseudocode showing a RetrieveAndGenerate call
response = retrieve_and_generate(
    input="How do I reset billing?",
    knowledgeBaseId="kb-123",
    model="meta.llama3-8b-instruct"
)
print(response.output)
```

Creating a knowledge base: required configuration
When creating a knowledge base you must provide several configuration items. The table below outlines each item with a short description and an example.

| Configuration item | Purpose | Example |
| - | -: | - |
| Name | Friendly identifier for the knowledge base | `customer-support-kb` |
| `IAM role` | Grants the knowledge base permissions to access data or vector stores | See [AWS - IAM](https://learn.kodekloud.com/user/courses/aws-iam) |
| Data source | Where source documents live (e.g., S3, other connectors) | `s3://my-company-docs/` |
| Parsing strategy | How documents are parsed and chunked on ingestion | `semantic-split` |
| Embedding model | Model used to convert text chunks into vectors | `titan-text-embedding` |
| Vector store | Managed storage for vectors used at retrieval time | `bedrock-managed-vector-store` |

<Callout icon="lightbulb" color="#1CB2FE">
  Ensure the `IAM role` you provide follows least-privilege principles. Grant only the necessary permissions to access specific resources (for example, particular S3 buckets or encryption keys) so the knowledge base can ingest data securely. See [AWS - IAM](https://learn.kodekloud.com/user/courses/aws-iam) for more on roles and policies.
</Callout>

Quick comparison: RAG DIY vs. Bedrock Knowledge Bases

| Area | DIY RAG | Bedrock Knowledge Bases |
| - | -: | - |
| Ingestion | You implement and maintain ingestion pipelines | Managed ingestion and chunking |
| Embeddings | You operate embedding model calls | Managed embeddings via configured model |
| Vector store | You deploy or operate vector DBs | Managed vector storage with retrieval APIs |
| Retrieval logic | Application-level code for search & ranking | Built-in retrieval and prompt assembly |
| Prompt augmentation | You assemble grounded prompts | Automatic augmented prompt construction |

Summary and next steps
Amazon Bedrock Knowledge Bases automate the end-to-end RAG pipeline—ingestion, chunking, embeddings, vector storage, retrieval, and prompt augmentation—so you can build grounded question-answering and retrieval-enabled applications with less engineering overhead. The runtime RetrieveAndGenerate API lets you request grounded responses with a simple call.

Next steps (hands-on):

* Create a knowledge base and connect a data source (for example, an S3 bucket).
* Choose an embeddings model and a vector store.
* Ingest documents and test queries using RetrieveAndGenerate to observe retrieval and grounded generation in action.

Links and references

* [AWS - IAM](https://learn.kodekloud.com/user/courses/aws-iam)
* [Amazon S3 (Simple Storage Service)](https://learn.kodekloud.com/user/courses/amazon-simple-storage-service-amazon-s3)
* [Amazon Bedrock documentation](https://docs.aws.amazon.com/bedrock)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/introduction-to-amazon-bedrock/module/282d7660-0e67-4e7d-a498-291bc16784e5/lesson/01220819-736e-46f8-9284-2fa26e6eda82" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.