Skip to content

Advanced RAG Patterns

Last reviewed: September 2026 | This is a fast-moving area subject to quarterly review.

Simply “document → embedding → retrieve → pass to LLM” is insufficient for production quality. Common problems cited by Azure and AWS official guides:

  • Poor chunking breaks context, degrading retrieval quality.
  • Without re-ranking, the LLM references irrelevant context from retrieved results.
  • Ambiguous user queries (pronouns, abbreviations) defeat vector search alone.

Sources:

How much and how documents are split determines retrieval quality.

Method Description Best For
Fixed-size Split at fixed token count (e.g., 512) General text, blogs
Sentence-based Split by sentence boundaries Natural language documents
Recursive Hierarchical: paragraph → sentence → word Structured documents
Semantic Group semantically similar sentences Long explanatory text
Document-structure Split by headings/sections Manuals, wikis, technical docs

Azure recommends trying Fixed-size → Recursive → Document-structure in order of increasing sophistication (see the Chunking Phase guide).

  • Too small — Insufficient context; retrieved fragments lose meaning.
  • Too large — Multiple topics in one chunk degrades precision; increases token consumption.

General starting point (Azure guide):

  • Chunk size: 500–1500 tokens
  • Overlap: 10–20% between chunks to prevent context loss
Vendor Supported Methods Reference
AWS Bedrock Knowledge Bases Default, fixed-size, hierarchical, semantic KB Chunking Options
Azure AI Search (Foundry IQ) Auto-chunking with integrated vectorization, customizable Azure AI Search Chunking
Vertex AI RAG Engine Chunk size/overlap configuration, RagManagedDb auto-management RAG Engine

Instead of building chunking, embedding, retrieval, and re-ranking yourself, managed services handle the entire pipeline.

Vendor Service Strengths
AWS Bedrock Managed Knowledge Base GA June 2026. 6 native data connectors (S3, SharePoint, Confluence, Web Crawler, Google Drive, OneDrive), Smart Parsing (automatic multi-format parsing), Agentic Retriever (agent decomposes and searches complex multi-step queries), managed vector store. AgentCore Gateway MCP integration
Azure Azure AI Search (Foundry IQ) Integrated vectorization, built-in semantic ranker, custom skill pipeline. Also serves as managed knowledge layer in the Microsoft Foundry portal
Google Cloud RAG Engine (Gemini Enterprise Agent Platform) Source → embedding → retrieval unified. Cross Corpus Retrieval (simultaneous retrieval across multiple RAG corpora, Preview). RagManagedDb for automatic infra management

Vector search is fast but doesn’t rank by true relevance. Re-ranking re-scores the top-N results with a separate model.

graph LR
    Q[Query] --> V[Vector Search<br/>Top 50]
    V --> R[Re-ranker<br/>Relevance Re-score]
    R --> T[Top 5]
    T --> L[LLM]
Vendor Service Reference
AWS Bedrock Knowledge Bases Reranker (Amazon Rerank, Cohere Rerank) Reranker Guide
Azure Azure AI Search Semantic Ranker Semantic Ranker
Google Cloud Vertex AI Ranking API Ranking API
OCI Cohere Rerank (OCI Enterprise AI) OCI Enterprise AI Models

Vector search is weak at exact string matching (product codes like SKU-12345, proper nouns). Hybrid search combines vector search with traditional keyword search (BM25).

Vendor Hybrid Approach Reference
AWS OpenSearch Vector + BM25 (RRF algorithm) Hybrid Search
Azure Azure AI Search hybrid query Hybrid Search
Google Cloud Vertex AI Search (auto hybrid) Vertex AI Search
OCI OCI AI Vector Search with SQL combination OCI AI Vector Search

Enterprise Access Control (ACL-aware Retrieval)

Section titled “Enterprise Access Control (ACL-aware Retrieval)”

A commonly overlooked point when running RAG in a customer environment is document access permissions. Source documents (SharePoint, file shares, databases) carry per-user and per-group access control lists (ACLs); ignoring them and putting everything into a single index can expose confidential content to users who lack permission.

The pattern that vendor official guides commonly present has three steps.

  • Sync permissions at ingestion — store the source ACLs (allowed/denied users and groups) or metadata (department, classification level, etc.) in the index alongside the document body and embeddings.
  • Filter by identity at query time — the application passes the authenticated user identity (including groups and roles) with the search request, and the retrieval layer returns only the documents that user is permitted to access.
  • The application owns authentication — this filter only assists access control; it is not authentication or authorization itself. User authentication and identity verification must be handled by the upstream application, and the retrieval layer’s ACL filter must not be treated as the sole security boundary.
Vendor Document-level access control Reference
AWS Bedrock Managed Knowledge Base — ACL-aware retrieval (pre-retrieval filter + real-time verification), metadata filtering ACL-aware retrieval
Azure Azure AI Search — Entra-based ACL/RBAC indexing (preview) and a string-based security-trimming filter (GA) Document-level access control
Google Cloud Gemini Enterprise — matches data-source acl_info against the authenticated principal for query-time access checks Configure access controls
OCI Generative AI Agents RAG — access enforced at the database layer (mTLS and DB authentication by default), policy applied before retrieved evidence reaches the model OCI Generative AI Agents RAG

For the delivery perspective of landing this pattern as production code in network-isolated/air-gapped or customer-specific permission environments, see Field Deployment.

When user queries are short or ambiguous, use an LLM to rewrite or expand the query.

  • Query Rewriting — Resolve pronouns/abbreviations explicitly (e.g., “that” → “policy X discussed in the last meeting”).
  • Multi-Query — Generate multiple query versions and search each.
  • HyDE (Hypothetical Document Embeddings) — LLM generates a hypothetical answer, then embeds that answer for retrieval.

Official guides:

RAG systems require measuring retrieval quality and response quality separately.

Metric Meaning
Recall@K Fraction of relevant docs in top-K results
MRR (Mean Reciprocal Rank) Average reciprocal rank of correct document
NDCG Ranking quality with position-weighted scoring
Metric Meaning
Faithfulness Is the generated answer grounded in retrieved documents?
Answer Relevance Does the answer actually address the question?
Context Precision/Recall How accurate and sufficient is the retrieved context?
Tool Description
RAGAS Open-source RAG evaluation framework
Azure AI Evaluation SDK Built-in Faithfulness, Relevance metrics
Bedrock Evaluations Integrated model/RAG evaluation
Vertex AI Evaluation Service Gen AI evaluation framework
  • Setting chunk size once and never adjusting — Without measuring retrieval quality on representative queries, chunks may be too fragmented or mixed-topic.
  • Passing vector search results directly to LLM without re-ranking — Irrelevant docs in top results cause hallucinations.
  • Not considering hybrid search — Product codes and proper nouns requiring exact string matching won’t be found by vector search alone.
  • Chunk size and overlap tuned by measuring retrieval quality with representative queries
  • Re-ranking (Semantic Ranker, Cohere Rerank, etc.) applied to improve result accuracy
  • RAG evaluation metrics (Faithfulness, Answer Relevance) measured regularly