INSIGHTS
AI & Data

AWS AIP-C01: Building RAG Applications with Amazon Bedrock

Retrieval augmented generation (RAG) is not a technique for teaching a foundation model confidential facts permanently. It is an application architecture that retrieves evidence from approved sources at request

In this article
  1. Map the RAG pipeline before selecting an AWS feature
  2. Build ingestion around authoritative records
  3. Retrieve evidence for the precise business question
  4. Assemble context without promoting documents to instructions
  5. Evaluate retrieval separately from answer quality
  6. Control latency, spend and business consequences

Retrieval augmented generation (RAG) is not a technique for teaching a foundation model confidential facts permanently. It is an application architecture that retrieves evidence from approved sources at request time and uses that evidence to constrain a generated answer. On AWS, Amazon Bedrock Knowledge Bases can manage aspects of retrieval and generation, but the team remains responsible for source quality, permission enforcement, evaluation and the application’s claims about what it knows.

Take a product-support portal that must answer questions about warranty coverage. A model trained on generic product information cannot know whether a customer’s contract includes a specific repair in October 2026. The portal should identify the account, retrieve the applicable approved policy, distinguish the date of that document from the date of the contract and cite the supporting source. If no authoritative passage exists, a well-designed answer explains what is unknown rather than manufacturing coverage terms.

Map the RAG pipeline before selecting an AWS feature

A conventional flow has document ingestion, parsing, chunking, embedding, indexing, query processing, retrieval, context assembly, model inference and answer validation. Each stage can fail independently. OCR may misread a scanned contract; a chunk boundary may exclude a crucial exception; an index may contain expired policies; a retrieved passage may be correct but inaccessible to the caller. Instrument the steps that matter so a bad answer can be investigated rather than blamed vaguely on the model.

Amazon Bedrock’s Knowledge Bases service provides managed and customer-managed approaches with different control points. Depending on the selected type and available features, a developer can use retrieval operations, a retrieve-and-generate flow or additional application logic for ranking and authorization. Choose the level of control based on actual requirements. A managed convenience is not a reason to omit acceptance tests for source visibility or deletion behavior.

Build ingestion around authoritative records

A source inventory should identify the system of record, owner, approval state, effective date, tenant scope and retention obligation for every document collection. An internal policy page may be authoritative while a team chat about that policy is not. Before indexing, normalize supported formats, validate required metadata and quarantine files that cannot be parsed safely. For multilingual, scanned or table-heavy documents, compare extracted fields with the original rather than assuming text extraction preserved the relationships between columns.

Plan synchronization and deletion. When the policy owner withdraws a document, the index should stop returning it within a stated interval; when access is revoked, a future retrieval must respect the change. An index refresh job can report success while one document was skipped due to a parse failure. Keep per-source synchronization state and review exceptions. The companion analysis of embeddings and metadata filters explains why index configuration is part of the application contract.

Retrieve evidence for the precise business question

A customer asking “Can I return this?” needs more context than the word return. The application may need the product category, purchase country, order date and customer status. Collect those fields from authenticated sources and use them to constrain retrieval. If the customer has multiple active orders, request clarification rather than merging details across orders. Embeddings can find relevant passages, but they cannot establish which contract or account is authorized.

Exact identifiers and uncommon fault codes often benefit from keyword or hybrid retrieval. Reranking can prioritize more applicable passages but can also increase latency. Test a mixture of straightforward queries, paraphrases, near-duplicate policy versions and questions with no supported answer. Do not force a fixed number of retrieved chunks because that number looks tidy in a diagram; use observed recall, context budget and cost to select the retrieval depth.

Assemble context without promoting documents to instructions

The model should receive approved evidence with clear provenance and a statement of what task it is performing. A source document can contain instruction-like content, including malicious prompt injection. Keep it in a data region of the request and validate any resulting tool actions externally. Avoid prompts that allow a retrieved page to override system or developer policy. An irrelevant hidden instruction in a product manual should not cause the assistant to call an account-deletion endpoint.

Citation generation deserves its own test. Attach source IDs and location information to retrieved chunks and require the response to map important claims back to those records. A citation marker is useful only if it points to material that actually supports the statement. The application may need to refuse a claim whose evidence is missing. For security-specific failure cases, the GenAI application security design separates data trust from action authority.

Evaluate retrieval separately from answer quality

A single “the model answered correctly” score hides where the system succeeded. Measure passage recall and relevance for the retrieval layer; then measure groundedness, factual correctness, completeness and appropriate abstention for generated responses. Include false positives: the system should not confidently answer a question about a policy that does not exist. For an important business claim, reviewers need the retrieved source and the resulting statement side by side.

Build regression fixtures for changed policies, removed permissions, expired documents, duplicated documents and conflicting revisions. Track which index snapshot, prompt and model versions were used, and compare changes before release. See the predeployment model evaluation workflow for how these become actionable gates rather than optional dashboards.

Control latency, spend and business consequences

RAG adds retrieval and index cost to model inference. More context can mean more input tokens without improving the answer. Estimate cost per accepted response, including embeddings, storage, query operations, reranking and human review. Cache only responses whose freshness and permission boundaries allow it; a cached warranty decision may become wrong when a contract changes or the user signs in under a different account.

Test error paths where the knowledge base is unavailable or a document cannot be retrieved. The safest behavior may be to say that confirmation is temporarily unavailable and provide a route to an authorized representative. Never convert an inability to retrieve evidence into a fabricated commitment. RAG production readiness is measured by whether it returns the right evidence under the right permissions and whether the application knows when not to answer.

Filed under AI & Data