Learning AWS and RAG: How AI Answers Questions from Your Documents
A beginner’s look at how RAG works, where Amazon S3 and Amazon Bedrock fit, and what I’m learning while building a financial document project.
I’m learning AWS alongside Retrieval-Augmented Generation (RAG). Working on a financial document project has helped me connect the concepts to a practical question: how can an AI application answer questions using a specific report?
Here is how I understand it so far.
Why do we need RAG?
A language model may know general information about a company, but that does not mean it has access to the exact report we want to use.
Imagine asking:
“What was this company’s net revenue in 2025?”
We want an answer supported by the report, with a source we can check. RAG helps by finding relevant information and giving it to the model before it generates an answer.
It feels a little like an open-book exam. The model gets reference material to help answer the question. Having the book available helps, but finding and interpreting the right passage still matters.
What happens inside a RAG application?
A common approach has five steps:
- Read the documents. Extract text from files such as PDFs.
- Split the text into chunks. These are smaller sections that can be searched individually.
- Create embeddings. An embedding represents text as a list of numbers that captures aspects of its meaning.
- Retrieve relevant chunks. The application searches for sections related to the user’s question.
- Generate an answer. The language model receives the question and retrieved text, then uses that context to respond.
This does not retrain the model on the documents. The retrieved information is supplied when answering the question. Amazon Bedrock Knowledge Bases supports this approach to building applications with document context.
Where does AWS fit?
For a document-based RAG application, these components have different jobs:
Component | Its role |
|---|---|
Amazon S3 | Stores the original documents, such as PDF reports. |
Amazon Bedrock Knowledge Bases | Helps manage document ingestion and retrieval. |
Embedding model and vector store | Represent and index chunks so relevant text can be found. |
A foundation model through Amazon Bedrock | Generates a response using the retrieved context. |
An S3 bucket can be connected as a data source for a Bedrock knowledge base. The documents then need to be ingested and indexed before they can support retrieval. Uploading a PDF to S3 alone does not make it searchable by the model.
A simple financial example
Suppose a sample report contains these figures:
- Net revenue in 2024: $100 million
- Net revenue in 2025: $112 million
The user asks, “How much did revenue grow?”
The application should retrieve the section containing both figures. The percentage increase is:
(112 − 100) ÷ 100 × 100 = 12%
A useful answer would state that revenue increased by $12 million, or 12%, and identify the source section. For financial applications, calculations can also be handled in code to make them easier to verify.
What I’m learning from building the basics
In my own project, I’ve been working through PDF text extraction, page searching, ranking, and tokenization. These steps have helped me understand what needs to happen before a model can give a useful answer.
A page might contain the words “net revenue” without containing the figures needed to answer the question. A table might lose its structure during extraction. A chunk might separate a number from its year or unit.
RAG can help ground an answer in evidence, but it does not guarantee accuracy. I still need to check whether the retrieved passage answers the question and whether the final response matches that passage.
My next goal is to connect these local experiments with AWS. I want to understand each component well enough to explain why it is there and spot where something went wrong when an answer is incorrect.
For others learning RAG, which part took you the longest to understand: chunking, embeddings, or retrieval?
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article