Retrieval-Augmented Generation (RAG) with Amazon Bedrock

Retrieval-Augmented Generation (RAG) with Amazon Bedrock
Retrieval-Augmented Generation (RAG) with Amazon Bedrock

CLOUD LABS



Retrieval-Augmented Generation (RAG) with Amazon Bedrock

In this Cloud Lab, you’ll learn to configure an Aurora RDS cluster as a vector store. You’ll also set up an Amazon Bedrock Knowledge Base to enable advanced data retrieval techniques for RAG.

8 Tasks

beginner

1hr 30m

Certificate of Completion

Desktop OnlyDevice is not compatible.
No Setup Required
Amazon Web Services

Learning Objectives

Hands-on experience connecting to an RDS cluster and configuring it for vector data storage
An understanding of how to set up an RDS vector store database using PostgreSQL
The ability to create and manage an Amazon Bedrock Knowledge Base
The ability to synchronize a data source and test data retrieval from a Bedrock Knowledge Base
Understanding of retrieval-augmented generation (RAG) to enhance query responses using generative AI

Technologies
Bedrock
S3 logoS3
Secrets Manager
RDS
IAM logoIAM
Cloud Lab Overview

Amazon Bedrock offers a powerful platform for developers to leverage generative AI with structured data storage. It provides access to pretrained models and enables the deployment and customization of pretrained foundational modes that utilize large-scale datasets. This Cloud Lab introduces Amazon Bedrock and Knowledge Base, essential for developers looking to enhance applications with advanced analytics and AI capabilities.

You will set up an Amazon Bedrock Knowledge Base, using Amazon S3 for data storage and Amazon Aurora PostgreSQL for the vector store. AWS Secrets Manager will securely store and manage the database credentials and a user’s secret, ensuring enhanced security and easy access. You’ll configure a service role, enable specific models for text generation and embeddings, and integrate these models to transform unstructured data into a queryable format. Next, you’ll create the knowledge base, configure data sources, select models, and test the knowledge base using different prompts.

By the end of this Cloud Lab, you will understand how to implement the Amazon Bedrock Knowledge Base using Amazon Aurora as a vector store. This will significantly improve your ability to develop scalable, AI-driven applications, potentially advancing your career in cloud-based machine learning technologies.

The following is the high-level architecture diagram of the infrastructure you’ll create in this Cloud Lab:

A RAG workflow using Amazon Bedrock and Aurora PostgreSQL
A RAG workflow using Amazon Bedrock and Aurora PostgreSQL

What is RAG, and why do teams use it?

Retrieval-augmented generation (RAG) is a design pattern that improves LLM answers by first retrieving relevant information from your own data and then using that retrieved context to generate a response. Instead of relying on the model’s general knowledge (which can be incomplete or wrong), RAG gives the model the exact, up-to-date source material it should reference.

Teams adopt RAG because it helps with:

  • Accuracy: Fewer hallucinations, more grounded answers.

  • Freshness: Your answers can reflect current docs and policies.

  • Domain specificity: The model can respond using your product, internal, or customer knowledge.

  • Control: You can curate and update what the model is allowed to draw from.

The core stages of a RAG pipeline

Most RAG systems follow a repeatable pipeline:

  • Document ingestion: You collect data from sources such as PDFs, Markdown docs, knowledge bases, tickets, or web pages, and store it in a format you can process.

  • Chunking and preprocessing: Documents are split into smaller chunks (and often cleaned), so retrieval can be precise. Chunk size and overlap matter a lot: too small and you lose context; too large and you retrieve noise.

  • Embeddings and indexing: Each chunk is converted into an embedding (a vector representation of meaning) and stored in a searchable index. This is what enables semantic retrieval, finding “similar meaning,” not just keyword matches.

  • Retrieval: When a user asks a question, you embed the question and retrieve the most relevant chunks from your index. This step is where you tune relevance, filtering, and ranking.

  • Generation with context: Finally, you pass the retrieved chunks into a prompt along with the user question, and the model generates an answer grounded in that context.

Common RAG design decisions that affect quality

A few practical choices usually make or break RAG quality:

  • Chunking strategy: Section-based chunks often beat fixed-size chunks for structured docs.

  • Top-k retrieval and reranking: Retrieving more candidates and reranking can improve precision.

  • Metadata filters: Narrowing retrieval by product area, date, user role, or doc type can reduce noise.

  • Prompt framing: Explicitly instructing the model to use only the provided context improves faithfulness.

  • Fallback behavior: Define what happens when retrieval confidence is low (ask a clarifying question, return “I don’t know,” or escalate).

When RAG is the right tool (and when it isn’t)

RAG is a strong choice when you need answers grounded in your own knowledge, especially for support, documentation, Q&A, internal assistants, compliance-heavy domains, or any place where hallucinations are costly.

RAG is less effective when:

  • The problem is mostly about freeform creativity.

  • The knowledge changes extremely quickly, and ingestion/indexing can’t keep up.

  • You need deterministic outputs and strong guarantees (you may need rules, structured search, or human review).

How RAG fits with Amazon Bedrock

Amazon Bedrock can serve as the model layer in a RAG system, providing access to foundation models you can use for generation (and, depending on your setup, embeddings). The bigger idea is that Bedrock helps you operationalize RAG on AWS by integrating model access with the rest of your cloud architecture.

Cloud Lab Tasks
1.Introduction
Getting Started
2.Set Up AWS Storage and Database
Create an S3 Bucket
Create an RDS Cluster
3.Bedrock Knowledge Base
Set Up the RDS for the Knowledge Base
Create the Amazon Bedrock Knowledge Base
Test the Knowledge Base
4.Conclusion
Clean Up
Wrap Up
Labs Rules Apply
Stay within resource usage requirements.
Do not engage in cryptocurrency mining.
Do not engage in or encourage activity that is illegal.

Relevant Courses

Use the following content to review prerequisites or explore specific concepts in detail.

Hear what others have to say
Join 1.4 million developers working at companies like