# AI Retrieval Patterns Retrieval patterns describe how AI systems fetch relevant information from external sources to augment their context. [[Retrieval-Augmented Generation (RAG)]] is the umbrella, but within it, several distinct patterns have emerged. ## Core patterns **Naive RAG**: embed documents, store in a [[Vector Store]], retrieve top-k similar chunks on query, inject into prompt. Simple but limited: no reranking, no query transformation, no iterative refinement. **Advanced RAG**: adds preprocessing and postprocessing stages: - **Query transformation**: rewrite the user's query for better retrieval (expansion, decomposition, hypothetical document generation) - **[[Semantic chunking]]**: split documents at meaning boundaries rather than arbitrary token counts - **Hybrid search**: combine vector similarity with keyword search (BM25) for better recall. Vector search finds semantically similar content; keyword search finds exact matches - **Reranking**: after initial retrieval, use a cross-encoder or LLM to re-score and reorder results by relevance - **Metadata filtering**: narrow the search space using structured metadata before vector search **Agentic RAG**: the agent decides when and what to retrieve, can reformulate queries based on initial results, and iterates until it has enough context. This is retrieval integrated into the [[Agentic loops|agentic loop]] rather than as a one-shot preprocessing step. **Graph RAG**: traverse a [[Knowledge Graph (KG)]] to find structurally connected information that vector similarity would miss. Build community summaries at different levels of abstraction for hierarchical retrieval. ## The quality chain Retrieval quality cascades through the entire system. Bad chunking produces bad embeddings. Bad embeddings produce bad retrieval. Bad retrieval produces bad context. Bad context produces bad output. Each stage amplifies or dampens the signal, making [[Context Engineering]] at the retrieval level critical. ## References - ## Related - [[Retrieval-Augmented Generation (RAG)]] - [[RAG Pipelines]] - [[Semantic Search]] - [[Semantic chunking]] - [[Knowledge Graph (KG)]] - [[Embeddings]] - [[Vector Store]] - [[Context Engineering]] - [[Agentic loops]] - [[AI context is finite with diminishing returns]]