Implementing RAG in production means building a permissioned, measurable retrieval system and putting a model at the end of it. Teams that treat retrieval-augmented generation as a data, identity and governance problem tend to ship in weeks, while teams that start with the model tend to spend months adjusting prompts against a retrieval layer that was never going to support them.
We've built data and AI systems on AWS since 2008. This playbook draws on Mactores' published retrieval work: the engagement reviews behind our RAG explainer, hybrid retrieval built for Sterne Kessler and Hibu, Linden Lab's moderation rollout and the KlearTrust claims platform. AWS, OWASP, IBM and EU figures were checked on November 25, 2026. A RAG pilot is ready for production when you can show what it retrieved, who was allowed to see it, what it cost and why the answer was right.
Most production RAG failures happen before the model writes a word. The retrieval layer misses the right passage, ignores a permission or falls behind the source system, and the model answers fluently from whatever it was handed.
Retrieval-augmented generation is a search system with a language model attached at the end, so the search half decides most outcomes. Three of the four places a RAG pipeline breaks (ingestion, indexing and retrieval) are invisible in the output, because a fluent answer reads the same whether the model saw the right passage or a plausible neighbor.
So instrument retrieval before you tune prompts. A production RAG system needs an evaluation set, source systems that can be read cleanly, permission-aware retrieval, observability and a named owner before anyone compares models.
A production RAG pipeline needs nine layers, from source readiness to operations. A vector database wired to a model covers two of them.
|
Layer |
What it must do |
What breaks without it |
|---|---|---|
|
Source readiness |
Name authoritative systems, owners, refresh rates and deletion duties |
Stale, duplicated or contradictory answers |
|
Ingestion and parsing |
Extract clean text, tables, metadata and document versions |
The answer exists but never reaches the model |
|
Chunking |
Keep headings, sections, tables and context together |
Retrieval quality is capped before search begins |
|
Indexing |
Store embeddings, keyword terms, metadata and entitlements |
Semantic search misses exact identifiers |
|
Retrieval |
Combine dense, keyword and metadata search, then rerank |
The right passage sits below the cutoff |
|
Authorization |
Enforce the user's permissions inside the query |
Passages reach people who can't open the source |
|
Generation |
Answer from retrieved evidence and cite it |
Confident answers nobody can verify |
|
Evaluation |
Test recall, precision, groundedness, citations, latency and cost |
No way to tell a retrieval problem from a model problem |
|
Operations |
Watch drift, freshness, failures, escalations and spend |
Quality degrades quietly after launch |
Decide what belongs in retrieval before you build the layers. Facts that change more than once a week belong in retrieval, stable behavior belongs in the model's weights, and live state such as an account balance or a ticket status belongs behind a tool call. Content that changes weekly, carries per-user permissions or holds personal data someone can ask you to delete stays out of a training set, which settles most RAG vs fine-tuning decisions early.
Front-load the decisions that are expensive to reverse. Settle the use case, the corpus, the permissions and the evaluation set first, then build retrieval, and add generation last so a model change becomes a cheap experiment rather than a rewrite.
|
Step |
What you produce |
Done when |
|---|---|---|
|
1. Define the use case and authority boundary |
What the system may answer, recommend and never do |
The business owner signs it |
|
2. Inventory sources and permissions |
A source register with owners, freshness, sensitivity and deletion duties |
Every source has an owner and an entitlement model |
|
3. Build the evaluation set |
A few hundred real questions with known correct passages |
Retrieval metrics compute automatically |
|
4. Chunk against real documents |
Structure-aware chunks carrying metadata |
Tested on your worst-formatted content |
|
5. Run hybrid retrieval, then rerank |
Dense plus keyword search with permission filters, then a reranker |
Recall measured before and after reranking |
|
6. Generate with citations and a refusal path |
Grounded answers that cite sources or decline |
Citation accuracy holds on the evaluation set |
|
7. Launch in stages |
Shadow mode, a pilot group, then production with an index owner |
Evaluation gates hold at each stage |
Start with one workflow where retrieval creates measurable value, such as policy lookup, claims support, contract analysis, technical support or employee onboarding. Define the user, the decision, the source systems, the acceptable latency and the action that follows the answer.
Write the authority boundary before any code. It states what the system may answer, what it may retrieve, what it may recommend, what needs human approval and what it must never do. In regulated environments that document is the first thing an auditor reads, which is why it comes before the build.
Map every source the workflow needs: documents, tickets, knowledge bases, databases, contracts, policies and product documentation. For each one, record the owner, how fresh it has to be, its sensitivity, its retention rule and any deletion obligation. A minimum metadata schema for each passage covers these fields.
Permissions have to travel with the passage as well as the index. When entitlements live only at index level, a reindex can silently widen access, so tenant identifiers, role claims and sensitivity labels go into both the metadata and the retrieval query. Effective dates and document status belong there too, because a retriever that can't filter on them will hand back a superseded policy with complete confidence.
Settle how conflicts get resolved before the system meets one. Effective date, document status and source authority are the usual tie-breakers, and they belong in metadata so retrieval can apply them.
Create a labeled evaluation set before you tune anything. Pull real questions from support queues, analysts, sales teams or operational users, and pair each with the correct source passages, the expected answer and the business rule that decides whether a response is acceptable.
A few hundred representative questions tell you more than any public benchmark. Include the hard cases: scanned PDFs, conflicting policies, expired documents, questions that span systems, and queries carrying part numbers, account identifiers or product codes. Then measure retrieval separately from generation.
|
Stage |
Metric |
What it tells you |
|---|---|---|
|
Retrieval |
Recall at k |
Whether the correct evidence was found at all |
|
Retrieval |
Context precision |
Whether the context window is filling with noise |
|
Generation |
Groundedness |
Whether the answer follows the supplied evidence |
|
Generation |
Citation accuracy |
Whether a reviewer can verify every claim |
|
System |
p95 latency |
Whether the slowest users will tolerate the experience |
|
Business |
Cost per resolved task |
Whether the workflow justifies the spend |
Run the set in CI before every index, chunking or model change, so a regression shows up as a number instead of a complaint.
Fixed-size chunking is convenient, and it destroys the structure that makes enterprise documents usable. A policy clause split from its exceptions, a table split from its definitions or a warranty term split from its effective date produces retrieval failures no reranker can repair.
Split on headings, sections, table boundaries and repeated document patterns, and keep parent-child links where a short passage needs its surrounding context. Test the chunker on a sample of your worst-formatted content rather than your cleanest. For scanned material, budget for OCR as a workstream of its own, because the OCR error rate becomes a ceiling on retrieval accuracy.
Keep tables as tables. For questions that depend on rows and columns, consider a governed query layer that generates SQL instead of retrieving flattened text.
Dense vector search captures meaning, and keyword search catches the exact tokens enterprises care about: part numbers, error codes, policy IDs, customer names, SKUs and legal citations. Production systems run both, with metadata and permission filters applied inside the query. A practical query path runs in seven moves.
Reranking improves precision, and it only sees the candidates the first stage returned, so first-stage recall stays the binding constraint. Measure recall before you add the reranker and again after, so you can attribute the gain.
It's the pattern behind Sterne Kessler's trademark classification system: hybrid retrieval over 76,000 USPTO records using Amazon OpenSearch with vector search and BM25, cross-encoder reranking for precision, and Amazon Bedrock Guardrails around the model. The seven-week assessment confirmed classification could drop from 60 to 120 minutes per application to under 10, at 85%+ accuracy.
Hibu's conversational analytics uses the same split. A purpose-built MCP connector gives Claude hybrid keyword and semantic search across an OpenSearch index of 1.82 million inbound lead calls a month, inside Hibu's own VPC, and questions that waited two to three days in an analyst queue are answered in under five minutes.
Add generation once retrieval is measured. Ground each answer in the retrieved passages, cite a source, version and section a reviewer can open, and capture provenance at generation time, because reconstructing it from logs afterwards rarely satisfies an auditor.
Give the system an explicit way to decline. When retrieval confidence is low or the evidence is stale, it should say it can't verify the answer and point to the right source or person. Grounding checks such as those in Amazon Bedrock Guardrails score an answer's faithfulness to the supplied context, which makes them a useful last check and a poor substitute for retrieval that found the right passage.
Choose the simplest architecture that meets the workflow, the risk and the latency requirement. Add agents, knowledge graphs or multi-step reasoning only when the evaluation set shows they earn their cost.
|
Architecture |
Best fit |
Trade-off |
|---|---|---|
|
Basic RAG |
Internal FAQ, single-source document search |
Fast to build, limited for complex workflows |
|
Enhanced RAG |
Enterprise search, policy lookup, support knowledge bases |
Needs hybrid search, metadata, reranking and evaluation |
|
Tool-augmented RAG |
Answers that need current system data |
Needs APIs, authorization and error handling |
|
Agentic RAG |
Multi-system research, decisions and governed actions |
Higher cost, a larger audit surface, stronger controls |
|
GraphRAG |
Relationship-heavy domains such as supply networks or provider directories |
Adds graph modeling and operational complexity |
Agentic RAG earns its cost when questions span two or more systems of record, answers often get escalated because context was missing, someone acts on the answer with money attached, the documents change every week or so, and an accountable executive can say what the agent may do. For a single-source policy lookup, enhanced RAG with hybrid search and reranking answers for a fraction of the price, and every component carries forward if you add an agent later.
Fraud rings, supply networks and provider directories are about relationships, which is where GraphRAG on Amazon Neptune Analytics pays off. Even there, we'd start with hybrid search and add the graph when the evaluation set shows it's needed.
Pick services by workload: a managed knowledge base for document Q&A, Amazon OpenSearch Service when exact identifiers and fine-grained filters matter, and Amazon Bedrock AgentCore once an agent has to call tools and systems of record.
|
Need |
AWS option |
When to choose it |
|---|---|---|
|
Managed document retrieval |
Amazon Bedrock Managed Knowledge Base |
Document Q&A with the fastest time to value; AWS runs the vector storage |
|
Your own vector store |
Customer-managed knowledge base on Amazon OpenSearch Serverless, Aurora PostgreSQL with pgvector or Amazon S3 Vectors |
You want control of chunking, index design and cost |
|
Hybrid search and fine-grained filters |
Amazon OpenSearch Service |
Exact identifiers, metadata filters and scale matter |
|
Relationship-aware retrieval |
Amazon Neptune Analytics |
Entities and relationships drive the answer |
|
Agent orchestration |
Amazon Bedrock AgentCore |
The workflow needs tools, memory, identity and tracing |
|
Policy enforcement |
AWS IAM, AWS Lake Formation, AgentCore Policy |
Permissions must hold the same way everywhere |
|
Guardrails |
Amazon Bedrock Guardrails |
Prompt attacks, sensitive data and grounding checks matter |
|
Observability |
Amazon CloudWatch with OpenTelemetry |
You need traces across retrieval, tools and generation |
Amazon Bedrock Managed Knowledge Base became generally available on June 17, 2026 as a fully managed RAG service, with hybrid search, document ranking, agentic retrieval and six native connectors: Amazon S3, SharePoint, Confluence, Google Drive, OneDrive and Web Crawler.
The managed or customer-managed choice matters more than it used to, because only Managed Knowledge Bases get third-party connectors, document-level permissions and native AgentCore Gateway integration. A customer-managed knowledge base still fits when you index into a vector store you run yourself and want control of chunking and the index lifecycle.
Beyond the service list, the decisions that shape the build are where the authoritative data lives, who may read it, how quickly it must refresh and what evidence each answer has to keep.
Enforce authorization inside the retrieval query. Pass the user's identity, role, tenant, region and entitlements into the query before anything is returned, rather than retrieving broadly and filtering afterwards.
OWASP's 2026 Top 10 for LLM applications lists vector and embedding weaknesses as LLM09, and its access-control mitigation reads "Enforce tenant scoping inside the index query, not as a post-retrieval filter, and validate it server-side." It also asks for access control at the chunk level, since a mostly public document can hold a confidential paragraph.
A managed service doesn't take that job off your hands. AWS describes the Managed Knowledge Base's ACL-aware filtering as "not a security boundary": it doesn't authenticate end users, so your application has to pass a verified identity, and when a user's email differs between systems, matching fails silently and that source returns nothing.
The exposure is real. IBM's 2026 Cost of a Data Breach research found roughly one in five organizations reported an attack on their AI models or applications, and 92 percent of those lacked proper AI access controls. The production control set we'd put in place covers the following.
Linden Lab's AI content moderation rollout shows the identity side. Mactores bound a single Claude Enterprise organization to Linden Lab's Okta identity provider, with separate groups so engineers get no Trust and Safety workspace, project or tool, and the security review narrowed the first moderation tool allowlist to index-scoped read access. Claude now handles the reading, organizing and policy lookup for each abuse report, and analysts' p95 handle time fell from about 30 minutes to about 5. Hibu's connector applies the same rule: Entra ID app roles map to read-only OpenSearch roles scoped by call type, and the agent has no write path.
Build the evidence pack before the first user logs in. Auditors ask what a system retrieved, who could see it and who approved each change, and each answer comes from a control placed at a specific step of the build.
|
Framework |
Auditor question |
Control, and the step that builds it |
|---|---|---|
|
HIPAA |
Who saw this record, and were they allowed to? |
Role-scoped retrieval and access logs (steps 2 and 5), encrypted indexes on HIPAA-eligible services |
|
SOC 2 |
What changed, when, and who approved it? |
Prompts, chunking settings, indexes and tools in version control, with an evaluation run per release (step 3) |
|
GDPR |
Is a deleted person's data gone everywhere? |
Deletion duties in the source register (step 2) that reach embeddings, indexes, caches and summaries |
|
PCI DSS v4.0.1 |
Could card data reach the index? |
Tokenization before ingestion (step 4) |
|
EU AI Act, high-risk uses |
Is there a log, and can a person overrule it? |
Automatic event logs under Article 12 and human oversight under Article 14 (steps 6 and 7) |
For European operations, Regulation (EU) 2026/1744, the Digital Omnibus amendment to the AI Act, moved high-risk obligations for Annex III systems to December 2, 2027. An internal policy-search tool usually falls outside Annex III, while one that helps decide credit, hiring, life or health insurance pricing, or access to essential services may fall inside it. Data residency is an architecture decision as well, so settle early whether embeddings, indexes, logs and model calls stay in the required Region.
In the US there's no comprehensive federal AI statute to map against, so align controls to sector regulation and the NIST AI Risk Management Framework.
The KlearTrust claims platform was built this way: PHI-safe document ingestion, clinical-knowledge retrieval with grounding and lineage capture, and audit logging captured at decision time rather than reconstructed afterwards. It reached production in twelve weeks and passed HIPAA and internal audit on first review.
Model tokens are usually the smaller share. The expensive failures are unbudgeted evaluation work, reviewer time, reindexing, integration upkeep and a pilot rebuilt once leadership asks for production controls.
|
Cost category |
What drives it |
Control |
|---|---|---|
|
Indexing |
Corpus size, parsing complexity, refresh frequency |
Incremental ingestion and freshness targets per source |
|
Retrieval |
Vector store, keyword index, reranker, query volume |
Caching, routing and index sizing |
|
Generation |
Input and output tokens, context size |
Retrieve less, rerank better, decline when evidence is weak |
|
Agent execution |
Steps, tool calls, retries, memory |
Step caps, budgets and fallback paths |
|
Human review |
Escalations, approvals, corrections |
A clear authority boundary and high-precision retrieval |
|
Platform operations |
Observability, security, evaluation, on-call |
Automation and a reusable evaluation harness |
Routing keeps the per-query bill down. Send single-source questions down the standard retrieval path and keep agentic retrieval for questions that span systems, because an agent plans several searches per question and multiplies token use.
Measure cost per resolved task rather than cost per query. An answer that creates an escalation carries the model call, the retrieval call and the time of the person who redoes the work.
Launch in stages. Start with a narrow user group, run the system in shadow mode against current practice, and widen access only while the evaluation gates hold.
Keep people on the decisions that carry risk. At Sterne Kessler's patent practice, RAG over historical Office Actions, examiner patterns and past successful arguments sits behind human-in-the-loop controls at every decision point, and average response time per Office Action dropped from 8 to 12 hours to 2 to 4.
Name the index owner before launch. That person controls ingestion schedules, chunking changes, permission synchronization and the evaluation set, because those four move together.
We implement RAG in production as part of our AI agents for apps work on AWS. We start from the authority boundary, the source systems and the evaluation set, then build permission-aware retrieval, hybrid search, guardrails and observability, and add an agent layer only where the workflow justifies it.
Aedeon, the agent platform we deliver with, handles knowledge ingestion, retrieval indexing, evaluation harnesses and observability, while forward-deployed engineers own the architecture decisions: what the system may do, what people must approve and how it behaves when it doesn't know. In our generative AI consulting engagements, the evaluation harness checks retrieval precision and recall and faithfulness to source documents, and the golden set and trace data belong to you.
When the knowledge sits inside a legacy application or database that can't expose clean, permissioned, incrementally readable content, we scope the work as application and database modernization with a retrieval outcome attached, because no chunking strategy makes up for a source system that can't be read.
Mactores has built on AWS since 2008 and is an AWS Premier Tier Services Partner. Engagements run on a fixed date, a fixed fee and customer-signed acceptance, the median time from kickoff to production is 12 weeks, and 94% of projects have been delivered on or ahead of schedule. Tell us the process you want a RAG system to own, and a forward-deployed engineer will reply with the authority boundary and the platform work it implies.