CertBrain
CoursesBlog
Sign in
← Back to decks
Sign in to save your progress, vote, and build your own decks.Sign in

Retrieval Augmented Generation

Retrieval Augmented Generation (RAG) gives a foundation model access to your own information at the moment it answers. Instead of retraining the model, the application looks up relevant passages from your documents and adds them to the prompt, so the answer is based on current, company-specific…

10 cards
Study this deck

Retrieval Augmented Generation

Retrieval Augmented Generation (RAG) gives a foundation model access to your own information at the moment it answers. Instead of retraining the model, the application looks up relevant passages from your documents and adds them to the prompt, so the answer is based on current, company-specific facts. RAG is one of the most tested designs on the exam because it solves a very common business problem cheaply.

The Problem RAG Solves

A foundation model only knows what was in its training data, and that data stops at a cutoff date. It has never seen your price list, your HR policies or last week's product update. Asked about them, it may guess and produce a confident but wrong answer, a hallucination. Retraining the model every time a document changes would be slow and very expensive. RAG keeps the model as it is and brings the right facts to it on each request.

How RAG Works

RAG has two phases.

Preparing the data (done once, then refreshed):

  1. Documents are converted to text and split into chunks.
  2. An embedding model turns each chunk into a vector, a list of numbers that captures its meaning.
  3. The vectors and their text are stored in a vector database.

Answering a question (every request):

  1. The user's question is turned into a vector with the same embedding model.
  2. The vector database returns the chunks whose meaning is closest to the question.
  3. Those chunks are added to the prompt as context.
  4. The model writes an answer using that context.

When a document changes, you update its chunks and vectors. The model itself never changes.

Amazon Bedrock Knowledge Bases

Building this pipeline by hand takes real work. Amazon Bedrock Knowledge Bases provides it as a managed feature. You point it at a data source, such as documents in Amazon S3, choose an embedding model and a vector store, and it handles chunking, embedding and storage. At query time you can use:

  • RetrieveAndGenerate: runs the whole RAG flow and returns a generated answer with citations pointing to the source chunks.
  • Retrieve: returns only the most relevant chunks, so your own code decides what to do with them.

A reranking model can also be applied to re-order retrieved chunks by relevance before they reach the model.

Business Applications

RAG fits wherever answers must come from a specific, changing body of knowledge:

  • Employee assistants that answer questions from HR policies and internal wikis.
  • Customer support bots grounded in product manuals and help articles.
  • Legal, compliance or medical research tools where users need cited sources they can check.

Because answers can include citations, users can verify where a claim came from, which builds trust in the system.

On the Exam

When a scenario says the model must answer from company documents, stay current as documents change, cite sources, or avoid the cost of retraining, the answer is usually RAG, and on AWS that usually means Amazon Bedrock Knowledge Bases. RAG adds knowledge; it doesn't change the model's style or teach it a new skill.

Quiz me on this
In a RAG application, what happens after the user's question is turned into a vector?
  1. The model's weights are updated using the question
  2. ✓ The closest document chunks are retrieved and added to the prompt
  3. The question is sent straight to the model with no extra context added
  4. A new embedding model is trained on the user's question
A logistics company updates its shipping rules every week. Its assistant must answer from the latest rules, and the company won't retrain a model each week. Which approach meets these requirements?
  1. Pre-train a new foundation model on the shipping rules
  2. Fine-tune the model again after every weekly update
  3. Raise the model's temperature so it adapts to the new rules each week
  4. ✓ Use RAG with the rules in a Bedrock knowledge base
A compliance team's assistant answers questions from internal policy documents. Staff must be able to check which document each answer came from. Which Amazon Bedrock Knowledge Bases capability supports this?
  1. ✓ Citations from RetrieveAndGenerate
  2. A lower temperature setting on the answering model
  3. A larger maximum output length for answers
  4. Batch inference over the policy documents
A development team uses an Amazon Bedrock knowledge base, but wants its own application code to build the final prompt and choose which model writes the answer. It only needs the knowledge base to return the most relevant passages. Which API fits?
  1. RetrieveAndGenerate
  2. InvokeModel with no retrieval step
  3. ✓ Retrieve
  4. A batch inference job
A retailer's RAG assistant finds the right documents, but the most useful passage is often ranked low among the retrieved chunks, so answers miss key details. Which change addresses this MOST directly?
  1. Fine-tune the answering model on the product catalog
  2. ✓ Apply a reranking model to the retrieved chunks
  3. Raise the temperature of the answering model
  4. Remove citations from the generated answers
Retrieval Augmented Generation (RAG)
Retrieves relevant passages from your data at question time and adds them to the prompt, so the model answers from current facts without retraining.
Amazon Bedrock Knowledge Bases
Managed RAG. Connects a data source, chunks and embeds documents, stores vectors, and retrieves relevant passages at query time.
Retrieve vs RetrieveAndGenerate
Retrieve returns only the relevant chunks. RetrieveAndGenerate also writes the answer and includes citations to the sources.
Reranking model
Re-orders retrieved chunks by relevance to the question before they reach the model, improving which context is used.
What RAG doesn't do
It adds knowledge at query time. It doesn't change the model's weights, style or skills; that needs fine-tuning.