Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

3.4.3. RAG Architecture Patterns and Retrieval Optimization

💡 First Principle: In a RAG system the model can only be as good as what it is handed. Most "hallucination" complaints in RAG are retrieval failures — the right passage was never retrieved, or it was buried among irrelevant ones. So you design and tune the retrieval pipeline (chunking, embeddings, search type, filtering, reranking) as carefully as you would design features for a traditional model.

Choosing a RAG pattern:
PatternHow it works on AWSUse when
Fully managed RAGAmazon Bedrock Managed Knowledge Base — Bedrock runs the datastore, embedding and reranking models, with native connectors (S3, SharePoint, Confluence, Web Crawler, Google Drive, OneDrive, custom); query it with Retrieve (always hybrid search) or with agentic retrieval, which can also generate a grounded answer with citationsYou want the least operational overhead and many enterprise sources
Customer-managed knowledge baseAmazon Bedrock Knowledge Bases on a vector store you choose and operate (OpenSearch, Aurora PostgreSQL, S3 Vectors, Neptune Analytics, third-party stores)You need control over the vector store, chunking strategy or index configuration
Retrieve-only + your own generationKnowledge Bases Retrieve API, then your own prompt to any modelYou need control over the prompt, the model or post-processing
Custom pipelineYour own chunking and embedding code writing to OpenSearch Service, Aurora PostgreSQL (pgvector) or S3 VectorsUnusual parsing, custom ranking logic, or an existing search platform
GraphRAGKnowledge Bases with an Amazon Neptune Analytics graphQuestions span relationships between entities across documents
Structured data retrievalKnowledge Bases connected to a structured data store, generating SQLAnswers live in tables, not prose
Multimodal RAGMultimodal embeddings or a parser that converts audio, video and images to text firstThe corpus includes images, scanned pages, audio or video

Managed vs. customer-managed: a Managed Knowledge Base removes the vector-store decision entirely — Bedrock provisions and scales the datastore, supplies managed embedding and reranking models by default, and always retrieves with hybrid (keyword plus semantic) search. A customer-managed knowledge base exposes every knob below, and its RetrieveAndGenerate API returns generated answers with citations. From 30 September 2026, new Confluence, SharePoint, Salesforce and Web Crawler connectors can no longer be created on customer-managed knowledge bases (existing ones keep working); AWS points those use cases to the Managed Knowledge Base.

Choosing a vector store for a customer-managed knowledge base is a trade-off between query performance, features and cost. Hybrid search is supported on Amazon OpenSearch Serverless, Amazon RDS (Aurora PostgreSQL) and MongoDB vector stores that contain a filterable text field; OpenSearch Serverless and OpenSearch Service managed clusters are the only stores that hold binary vectors; Amazon Aurora PostgreSQL uses pgvector; Amazon S3 Vectors gives low-cost, durable vector storage with sub-second queries and is aimed at workloads queried infrequently.

Retrieval optimization levers (the full set applies to customer-managed knowledge bases; a Managed Knowledge Base offers default or fixed-size chunking and manages embedding and reranking unless you override them):

LeverOptions in Bedrock Knowledge BasesEffect
ChunkingDefault (~300 tokens, sentence boundaries), fixed-size (max tokens + overlap %), hierarchical (parent/child), semantic (meaning boundaries), noneSmall chunks embed precisely; large chunks carry context. Hierarchical retrieves precise child chunks and returns their broader parents
Embedding modelTitan Text Embeddings V2 (1,024 default, 512 or 256 dimensions; up to 8,192 tokens), Cohere Embed, multimodal embeddingsDomain fit and language coverage drive recall; fewer dimensions cut storage and cost at some accuracy cost
Search typeSemantic (vectors only) or hybrid (vectors + raw text)Hybrid helps queries with exact identifiers, product codes or rare terms
Number of resultsnumberOfResults (default 5)Too few misses evidence; too many adds noise and tokens
Metadata filteringManual filters (equals, greaterThan, in, ...), implicit filtering generated from the queryRestricts retrieval to the right product line, date range or tenant
RerankingReranker model (for example Cohere Rerank 3.5) applied after retrievalReorders chunks by relevance so fewer, better chunks reach the model — lower cost and latency
Query decompositionBreaks a multi-part question into sub-queriesImproves recall on compound questions

Embedding-model rules that break systems when forgotten: the vector index dimension must match the embedding model's output dimension, and documents and queries must be embedded with the same model. Changing the embedding model means re-embedding and re-indexing the whole corpus.

⚠️ Exam Trap: Semantic chunking and query decomposition cost more — semantic chunking invokes a foundation model during ingestion, and decomposition can run several queries per question. If the stem optimizes for least cost, they are rarely the answer; if it optimizes for retrieval accuracy on complex documents or questions, they often are.

⚠️ Exam Trap: When users search for exact part numbers or error codes and pure vector search misses them, the fix is hybrid search (keyword + semantic), not a bigger generator model. The generator cannot use a chunk that was never retrieved.

See how it connects
Alvin Varughese
Written byAlvin Varughese
Founder•20 professional certifications