# Retrieval-Augmented Generation

Retrieval-Augmented Generation is an application pattern that retrieves relevant external information and supplies it as context to a generative model when producing an answer.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/retrieval-augmented-generation

> RAG connects a foundation model to information outside its learned parameters, such as enterprise documents, product catalogs, or operational records. It helps applications answer questions using organization-specific or recently updated information without retraining the model, although accuracy still depends on retrieval quality and how the model uses the evidence.

Practice exams covering Retrieval-Augmented Generation: [AIB-C01 (beta) AWS Certified AI Business Strategist](https://blowstack.com/practice-exams/aws-certified-ai-business-strategist), [AIF-C01 AWS Certified AI Practitioner](https://blowstack.com/practice-exams/aws-certified-ai-practitioner), [DEA-C01 AWS Certified Data Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate), [AIP-C01 AWS Certified Generative AI Developer - Professional](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional), [MLA-C02 (beta) AWS Certified Machine Learning Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 6 key aspects of Retrieval-Augmented Generation

Effective RAG combines relevant retrieval, deliberate context construction, evidence-grounded generation, layered evaluation, and secure management of external knowledge.

1. **External knowledge at inference time**: RAG supplies relevant information when a request is processed rather than relying only on knowledge stored in model parameters. Updating the knowledge source and its index can change available evidence without retraining the generation model.
2. **Retrieval quality determines available evidence**: Chunking, embeddings, keyword matching, metadata filters, and reranking influence which information reaches the model. Test retrieval independently because a fluent answer cannot compensate for missing or incorrect evidence.
3. **Context engineering**: Select and organize retrieved passages alongside instructions, conversation history, and tool results within the model's context budget. Define how the model should respond when evidence is missing or contradictory instead of simply adding more text.
4. **Grounding and traceability**: Responses can include references to retrieved source passages so users can inspect the supporting evidence. Citation presence alone is insufficient; verify that the cited material supports the associated claim.
5. **Layered application evaluation**: Measure retrieval relevance, answer correctness, faithfulness, citation support, latency, and cost using representative test cases. For agentic or multi-step implementations, also test tool use, workflow execution, and successful completion of the user's task.
6. **Security and knowledge lifecycle**: Enforce source-level permissions during retrieval and prevent unauthorized passages from entering model context. Maintain index freshness, propagate deletions, and treat retrieved text as potentially malicious input rather than trusted instructions.

## Cloud services for Retrieval-Augmented Generation

A typical AWS implementation stores source documents in Amazon S3, retrieves indexed evidence through Amazon OpenSearch Service or a suitable Amazon Aurora PostgreSQL vector configuration, and invokes models through Amazon Bedrock. Amazon Bedrock Knowledge Bases can manage ingestion and retrieval for supported configurations, reducing custom pipeline code. OpenSearch and Aurora are alternative retrieval-store choices rather than mandatory components used together. Across either design, the application must enforce access controls, synchronize source changes, assemble useful context, and evaluate both retrieved evidence and generated answers.

- **[Amazon Bedrock](https://blowstack.com/tools/cloud-services-hub/amazon-bedrock)**: Amazon Bedrock provides access to foundation models for embeddings and generation. Amazon Bedrock Knowledge Bases provides managed RAG capabilities for supported data sources and retrieval stores, while engineers remain responsible for data selection, authorization design, and application evaluation.
- **[Amazon OpenSearch Service](https://blowstack.com/tools/cloud-services-hub/amazon-opensearch-service)**: Amazon OpenSearch Service can index document text, metadata, and vectors for keyword, vector, or hybrid retrieval. It supplies relevant evidence to a RAG application; the generation model is a separate component.
- **[Amazon S3](https://blowstack.com/tools/cloud-services-hub/amazon-s3)**: Amazon S3 can store source documents and ingestion artifacts for a RAG pipeline. Source updates and deletions must be reflected in the retrieval index before queries reliably use the changed information.
- **[Amazon Aurora](https://blowstack.com/tools/cloud-services-hub/amazon-aurora)**: Amazon Aurora PostgreSQL-Compatible Edition supports the pgvector extension for storing and searching embeddings alongside relational data. This can support RAG retrieval where application records, metadata filtering, and vector search need to share a database.

## Retrieval-Augmented Generation exam questions

Real practice exam questions on Retrieval-Augmented Generation, with the correct answer and its explanation.

### Question 1 (AIB-C01 (beta))

**Question:**

A market research company uses a generative AI assistant to answer analysts' questions from industry reports. Amazon OpenSearch Service retrieves 30 candidate passages, but the application sends only the five highest-ranked passages to the foundation model to control cost and input size. Reviewers find that passages directly answering the questions are usually among the 30 candidates, but broad discussions of the same industry often occupy the first five positions. The company must retain the five-passage limit. Which change would BEST improve the assistant's answers?

**Correct answer:** Rerank the retrieved candidates for relevance to the analyst's specific question, then supply the five best-ranked passages to the foundation model.

**Explanation:** Reranking adds a relevance-assessment step before selecting the grounding evidence. It can promote directly useful passages over broadly related material, improving retrieval-augmented generation while preserving the five-passage limit.

### Question 2 (MLA-C02 (beta))

**Question:**

A company maintains a support assistant that uses Knowledge Bases for Amazon Bedrock. An AWS Step Functions release workflow refreshes a staging knowledge base from approved manuals and then evaluates the assistant before promotion. Some releases replace troubleshooting procedures and withdraw obsolete safety instructions.

The current evaluation checks only whether generated answers match expected conclusions. A release passed even though the assistant cited a withdrawn procedure: the generation model produced the expected conclusion despite receiving outdated retrieval context. Each release includes a manifest of approved document revisions and a set of test questions with expected supporting passages.

Which change should the ML engineer make to the release workflow to detect this problem before promotion?

**Correct answer:** After ingestion succeeds, call the Retrieve API with the test questions. Compare returned passages and document-revision metadata with the release expectations, reject results containing withdrawn procedures, and use a Choice state to block promotion if any retrieval check fails.

**Explanation:** This validates the retrieval stage independently of generation. Checking expected supporting passages and approved revision metadata detects missing current evidence and obsolete retrieved content even when the model generates a correct conclusion. The Choice state makes these checks a required release gate.

### Question 3 (SAP-C03)

**Question:**

A regulated company is building a policy assistant with an Amazon Bedrock knowledge base that uses an Amazon S3 data source. Policy owners publish revisions daily and occasionally withdraw policies. Every published revision must remain immutable for seven years after publication for audit purposes. Only the currently published revision of each active policy may be available for retrieval after a successful ingestion refresh.

The company also requires the ability to rebuild the entire knowledge base immediately from active source documents without restoring archived objects. Superseded and withdrawn revisions should move to lower-cost archival storage. Scheduled ingestion refreshes are acceptable, and the company wants to minimize custom ingestion and document-management code.

Which solution best meets these requirements?

**Correct answer:** Use a versioned S3 bucket with a default seven-year S3 Object Lock compliance retention period. Overwrite a stable object key for each policy, and withdraw policies by deleting their keys without specifying version IDs. Keep current versions in S3 Standard and transition only noncurrent versions to S3 Glacier Flexible Retrieval. Run knowledge base ingestion jobs after publication and withdrawal batches.

**Explanation:** Overwriting a stable key creates a new current version while Object Lock protects historical versions. An ordinary deletion creates a delete marker without deleting the protected versions. A successful knowledge base synchronization processes changed current documents and removes content for deleted source documents. Archiving only noncurrent versions preserves immediately readable active documents for a complete rebuild while reducing the storage cost of historical revisions.

### Question 4 (AIF-C01)

**Question:**

A software company uses an Amazon Bedrock foundation model to help customers write commands for its developer tools. The assistant sometimes invents command-line flags for newly released versions. The company updates its official command reference weekly and needs answers to reflect the customer's installed version without retraining the model. Which approach best addresses this problem?

**Correct answer:** Retrieve relevant passages from the current official reference for the installed version, include them in the prompt, and instruct the model to acknowledge when the passages do not support an answer.

**Explanation:** Retrieval-augmented generation supplies authoritative, version-specific information at request time without retraining. Restricting answers to that evidence and acknowledging gaps reduces the risk of invented flags, although it does not guarantee accuracy.

### Question 5 (DEA-C01)

**Question:**

A company is adding generated answers to an internal search application for supplier security bulletins. New bulletins arrive throughout the day. The application uses an Amazon Bedrock knowledge base, and testing confirms that retrieval returns passages from the latest relevant bulletins. However, the application sends only the user's question to a foundation model and displays the retrieved passages separately from the generated answer. The generated answers frequently omit recent supplier announcements.

Which change should a data engineer make so that generated answers use the relevant bulletins without updating the foundation model's parameters?

**Correct answer:** Include the retrieved passage text and source identifiers with the user's question in the generation request, and instruct the model to ground its answer in those passages.

**Explanation:** This supplies external evidence to the foundation model at request time. The model can use the latest retrieved bulletins to generate a grounded answer without changing its parameters. Source identifiers also allow the application to associate statements with supporting bulletins.

### Question 6 (AIP-C01)

**Question:**

A company is redesigning retrieval for a generative AI research assistant. Amazon OpenSearch Service will store passage embeddings and identifiers, while Amazon DynamoDB will store the passage text and citation metadata. Each passage is an immutable DynamoDB item of approximately 160 KiB, identified by a tenant-specific partition key and a passage-specific sort key. OpenSearch results include both keys.

Each retrieval request returns 120 ranked passage candidates. Before reranking, the application must hydrate all candidates from DynamoDB and preserve their original semantic-search ranks. The application must use bulk reads rather than one request per passage, avoid table scans, and tolerate successful DynamoDB responses that return only some requested items. All requested items exist, and ingestion makes them available before publishing their identifiers to OpenSearch.

Which implementation best meets these requirements?

**Correct answer:** Divide the candidate keys into groups of no more than 100 and use BatchGetItem. Associate returned items with candidates by their complete primary keys, retry UnprocessedKeys with exponential backoff until all candidates are hydrated, and reconstruct the original rank order before reranking.

**Explanation:** BatchGetItem supports up to 100 requested items and a response size of up to 16 MiB. These passage sizes can cause partial responses even for a valid group of 100 keys. Retrying UnprocessedKeys completes hydration without rereading successfully returned items. Because BatchGetItem does not preserve request order, mapping by complete primary key is necessary to restore the OpenSearch ranking.

## Practice Retrieval-Augmented Generation in a full exam

Questions on Retrieval-Augmented Generation in each practice exam, with every answer option and an explanation for each:

- [AIF-C01](https://blowstack.com/practice-exams/aws-certified-ai-practitioner): 29 questions
- [MLA-C02 (beta)](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate): 18 questions
- [AIP-C01](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional): 18 questions
- [AIB-C01 (beta)](https://blowstack.com/practice-exams/aws-certified-ai-business-strategist): 15 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 3 questions
- [DEA-C01](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate): 1 question

## What is Retrieval-Augmented Generation

Retrieval-Augmented Generation (RAG) combines information retrieval with generative inference. An application retrieves information relevant to a user's request, includes that information in the model's input context, and asks the model to produce a response grounded in the retrieved evidence. The retrieval step does not, by itself, change the model's weights. This distinction matters when choosing between RAG, prompt engineering, and fine-tuning: RAG supplies external knowledge at request time, while fine-tuning changes model parameters to influence behavior or task performance.

A typical document-based implementation has ingestion and query stages. During ingestion, documents are parsed, divided into chunks, and indexed with metadata such as document identifiers, update timestamps, and access restrictions. Many systems create vector embeddings that represent semantic meaning. At query time, the application searches for relevant chunks using vector similarity, keyword search, or a hybrid approach. It may rerank results before supplying selected passages to the generation model. RAG does not require a vector database; retrieval can also use conventional search, databases, or other knowledge sources.

In the cloud, object storage can hold source files, a search service or database can maintain an index, and a managed model service can provide embeddings and text generation. Managed capabilities such as Amazon Bedrock Knowledge Bases can coordinate ingestion, retrieval, and generation. Engineers still need to choose source data, configure retrieval behavior, enforce permissions, and evaluate the resulting answers. Updating a source document does not necessarily update its indexed representation immediately, so ingestion schedules and deletion propagation affect freshness.

Business applications include employee policy assistants, customer-support tools, technical documentation search, and product-selection assistants. For example, a support application can retrieve troubleshooting instructions for a specific device model and firmware version, then generate an explanation with references to the relevant manual. A policy assistant can retrieve the policy applicable to an employee's location instead of relying on general information learned during model training.

RAG is an important part of context engineering: deliberately selecting and organizing the instructions, evidence, conversation history, and tool outputs available to a model. Chunk size, metadata filters, query rewriting, reranking, and context ordering all affect whether the model receives useful evidence. Adding more documents is not automatically better. Irrelevant or conflicting passages consume context capacity, increase token costs, and can distract the model. Instructions should specify how to handle insufficient evidence, conflicting sources, and requests for citations.

Evaluate retrieval and generation separately, then test the complete application. Retrieval evaluation can measure whether relevant evidence appears among the top results, using metrics such as recall at k and ranking quality. Generation evaluation should examine correctness, relevance, completeness, faithfulness to retrieved evidence, and whether citations actually support the claims. Use representative questions, expected answers, and reference passages, including unanswerable questions and permission-sensitive cases. Human review and calibrated model-based judges can complement automated checks. For agents and workflows, also evaluate tool selection, intermediate steps, and final task completion rather than scoring only the last response.

RAG reduces some causes of hallucination but does not guarantee factual answers. A model can misinterpret evidence, invent unsupported details, or cite an irrelevant passage. Retrieved documents can also contain prompt-injection instructions, so treat their contents as untrusted data rather than authoritative commands. Apply document-level authorization before retrieved content reaches the model, protect sensitive context, and monitor latency, cost, retrieval failures, and answer quality. RAG introduces search and indexing overhead, but it can make knowledge updates more manageable than repeatedly retraining a model.

## Learn Retrieval-Augmented Generation in lessons

13 short lessons on Retrieval-Augmented Generation in 6 certification courses.

- AIB-C01 (beta): Fine-Tuning vs. Retrieval-Augmented Generation (Premium), https://app.blowstack.com/lessons/fine-tuning-vs-retrieval-augmented-generation-aib-c01
- MLA-C02 (beta): Retrieval-Augmented Generation: source corpus preparation (Premium), https://app.blowstack.com/lessons/retrieval-augmented-generation-source-corpus-preparation-mla-c02
- SAP-C03: Retrieval-Augmented Generation: designing the evidence pipeline (Premium), https://app.blowstack.com/lessons/retrieval-augmented-generation-designing-the-evidence-pipeline-sap-c03
- AIF-C01: Retrieval-Augmented Generation: external knowledge in model context (Premium), https://app.blowstack.com/lessons/retrieval-augmented-generation-external-knowledge-in-model-context-aif-c01
- DEA-C01: Retrieval-Augmented Generation vs. Vector Search (Premium), https://app.blowstack.com/lessons/retrieval-augmented-generation-vs-vector-search-dea-c01
- AIP-C01: Retrieval-Augmented Generation: retrieval quality testing (Premium), https://app.blowstack.com/lessons/retrieval-augmented-generation-retrieval-quality-testing-aip-c01
