AWS Builder Center

What Is RAG? Retrieval-Augmented Generation Explained Simply

Another look at RAG for AWS Certification this is the second article I’ve written on RAG. with a simple explanation, the technique that lets AI models answer using your own documents, written by a student preparing for the AWS AI Practitioner exam.

This is post 3 of my series on the AWS Certified AI Practitioner exam (AIF-C01), and the first part of Domain 3, "Applications of Foundation Models", which is 28% of the scored content. RAG sounds complicated, but the idea is simple.

The problem

A language model only knows what it learned during training. It doesn't know your company documents or yesterday's news, and it can sound confident while being wrong.

The idea: an open-book exam

Imagine two students taking the same test. One answers from memory. The other can look things up in the textbook first. RAG gives the AI the second option.

How it works

Before any question is asked:
  • Chunking: your documents are split into small pieces
  • Embeddings: each piece is turned into a list of numbers that represents its meaning
  • Vector database: those numbers are stored so similar pieces can be found quickly
When someone asks a question:
  • Retrieve: the system finds the pieces closest in meaning to the question
  • Augment: those pieces are added to the prompt
  • Generate: the model writes an answer using that information

RAG vs fine-tuning

This comparison is easy to mix up, so here is how I remember it:
  • RAG gives the model new information to read, without changing the model. Good for private or fast-changing data.
  • Fine-tuning changes the model itself with extra training. Good for teaching a style, format or specialty.

Limits to remember

RAG can reduce made-up answers, but it doesn't remove them. If the system retrieves the wrong pieces, the answer can still be wrong. The quality of your documents matters.

Where AWS fits

Amazon Bedrock Knowledge Bases is the AWS feature that helps connect a model to your own data for RAG, handling steps like chunking, embeddings and retrieval. I haven't built one yet, so for now I'm learning the concept.
Features change often, so check the official page:  https://aws.amazon.com/what-is/retrieval-augmented-generation/ 
When would you choose RAG over fine-tuning?
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article