December 2025 Update: Covers the latest RAG patterns including Agentic RAG, Graph RAG, and Multi-Vector approaches used in production systems.
The RAG Evolution
RAG has evolved far beyond simple “retrieve and generate.” Think of it like restaurant service: Basic RAG is a waiter who brings you whatever matches your order from the menu. Advanced RAG is a sommelier who understands what you really want, checks multiple sources, and curates the perfect selection. Agentic RAG is a personal chef who plans multiple courses, adjusts based on your reactions, and synthesizes a complete experience. Modern RAG systems use these sophisticated architectures to handle complex queries, maintain context, and deliver accurate, grounded responses.1. Basic RAG
What It Is Basic RAG is the simplest form: search for relevant documents using vector similarity, then feed them to an LLM to generate an answer. It is the “SELECT * WHERE similar” of AI — straightforward, predictable, and often good enough. Think of it as asking a librarian who quickly finds relevant books and summarizes them for you, but who only makes one trip to the shelves. Real-World Example Use Case: Company documentation Q&A Employee asks: “What’s our remote work policy?” System finds: 3 policy documents mentioning remote work LLM summarizes: “According to company policy, employees can work remotely up to 3 days per week with manager approval…”- Simple Q&A over documentation
- Small to medium document collections
- Well-formed, specific questions
- MVP/prototype stage
- Single retrieval step may miss context
- No query understanding or rewriting
- Limited handling of complex queries
- No reasoning over multiple documents
- Chunk Size: Keep chunks 200-500 tokens. Too small = no context for the LLM. Too large = diluted relevance scores. A good rule of thumb: each chunk should be understandable on its own.
- Embedding Model:
text-embedding-3-smallis the best cost-to-quality ratio for most use cases. Only upgrade totext-embedding-3-largeif you see retrieval quality issues. - Top-K: Start with 3-5 documents. More is not always better — irrelevant docs confuse the LLM and waste tokens.
- Temperature: Use 0.0 for factual answers. The moment you raise it, you invite creative paraphrasing — fine for chatbots, dangerous for compliance docs.
2. Advanced RAG
What It Is Advanced RAG improves accuracy by adding query processing, hybrid search (vector + keyword), and re-ranking. If Basic RAG is a single Google search, Advanced RAG is what a research analyst does: rephrase the question several ways, search multiple databases, cross-reference results, and rank everything by relevance before presenting findings. Real-World Example Use Case: Legal document search Lawyer asks: “Cases about contract breach in California” System expands to: [“contract breach California”, “contractual violations CA”, “breach of agreement California courts”] Searches using both semantic similarity AND keyword matching Re-ranks results by legal relevance Returns top 5 most relevant cases- Production systems requiring high accuracy
- Diverse queries with varying terminology
- Technical domains with specific jargon
- Ambiguous or complex user questions
- Need for better precision and recall
- Higher cost than Basic RAG (~2-3x)
- Increased latency due to multiple processing steps
- Requires more infrastructure (re-ranking models)
- More complex to implement and maintain
- May be overkill for simple use cases
- Query Expansion: Use gpt-4o-mini for cost efficiency
- Re-ranking: Only re-rank top 20 candidates to balance cost/quality
- Hybrid Search: Weight vector (0.7) and keyword (0.3) for best results
- RRF Fusion: Use k=60 for optimal ranking combination
- Caching: Cache query expansions and common re-ranking results
3. Memory RAG
What It Is Memory RAG adds conversation history and user context, enabling personalized, context-aware responses. Without memory, every question starts from scratch — the user says “what about lunch?” and the system has no idea they were just discussing diabetic-friendly breakfasts. Memory RAG is the difference between talking to a stranger every time versus talking to a colleague who remembers your past conversations. Real-World Example Use Case: Personal health assistant First conversation: “I have diabetes. What should I eat for breakfast?” System remembers: User has diabetes, prefers quick meals Later conversation: “What about lunch?” System uses memory: Suggests low-carb lunches, remembers breakfast preferences- Building chatbots or conversational assistants
- Users have repeat interactions with the system
- Personalization improves user experience
- Multi-turn conversations with context dependencies
- Need to remember user preferences and facts
- Requires memory storage infrastructure
- Privacy concerns with storing user data
- Memory can become stale or incorrect over time
- Additional cost for memory operations
- More complex state management
- Short-term Memory: Keep last 5-10 conversation turns for context
- Long-term Memory: Extract only meaningful facts, not every detail
- Memory Retrieval: Use vector search for semantic memory lookup
- Memory Updates: Batch updates to reduce database calls
- Context Window: Limit conversation history to avoid token limits
4. Agentic RAG
What It Is Agentic RAG uses iterative reasoning to answer complex, multi-step questions. While other RAG types do a single “retrieve then generate” pass, Agentic RAG operates in a loop: plan what information is needed, retrieve it, evaluate whether the answer is complete, and retrieve more if not. It is the most powerful pattern but also the most expensive — think of it as hiring a research assistant who bills by the hour rather than a librarian who fetches one book. Real-World Example Use Case: Research assistant for academic papers User asks: “Compare the effectiveness of transformer models vs RNNs for machine translation, considering recent papers from 2023-2024” System plans:- Step 1: Search for “transformer models machine translation”
- Step 2: Search for “RNN machine translation comparison”
- Step 3: Search for “transformer vs RNN 2023 2024”
- Step 4: Synthesize findings and compare System answers: Comprehensive comparison with citations from multiple sources
- Complex research questions requiring multiple sources
- Questions that need synthesis across documents
- Multi-hop reasoning (“who works at company that acquired X”)
- Comparative analysis questions
- Questions requiring iterative information gathering
- Highest cost among RAG types ($15-40 per 1000 queries)
- Slowest latency due to multiple iterations
- Can get stuck in loops if max_iterations too high
- Requires careful prompt engineering for action planning
- More complex to debug and monitor
- Max Iterations: Set to 3-5 for most use cases
- Action Planning: Use gpt-4o for better reasoning, gpt-4o-mini for cost savings
- Early Stopping: Implement confidence thresholds to stop early
- Query Generation: Cache common query patterns
- Monitoring: Track iteration count and reasoning chains for optimization
5. Multi-Vector RAG
What It Is Multi-Vector RAG uses multiple embedding types (dense, sparse, metadata) for precise retrieval. By combining semantic understanding, exact keyword matching, and structured metadata, it provides more accurate and flexible search capabilities. Real-World Example Use Case: Technical documentation search User asks: “Python async/await error handling” System searches:- Dense vectors: Find semantically similar docs about async programming
- Sparse vectors: Match exact keywords “async”, “await”, “error”
- Metadata vectors: Filter by language=“Python”, category=“error-handling” System combines: Weighted fusion returns most relevant technical docs
- Technical documentation with exact terminology
- Need both semantic and keyword matching
- Rich metadata available for filtering
- Mixed content types (code, docs, comments)
- Require fine-tuned relevance control
- Requires storing multiple embeddings per document
- More storage and indexing overhead
- Weight tuning requires experimentation
- Sparse embeddings need specialized infrastructure
- More complex than single-vector approaches
- Weight Tuning: Start with dense=0.5, sparse=0.3, metadata=0.2, adjust based on domain
- Sparse Embeddings: Use BM25 or SPLADE for production
- Metadata Indexing: Index frequently filtered fields separately
- Storage: Compress sparse embeddings to save space
- Query Optimization: Cache dense embeddings, compute sparse on-demand
6. Graph RAG
What It Is Graph RAG traverses knowledge graphs to follow relationships and discover connected information. It understands how entities relate to each other, enabling multi-hop reasoning and discovery of indirectly related information. Real-World Example Use Case: Company knowledge base User asks: “Who are the key engineers working on projects related to machine learning?” System:- Extracts entities: “engineers”, “projects”, “machine learning”
- Finds in graph: Engineers → Work On → Projects → Related To → “machine learning”
- Traverses relationships: Discovers connected engineers and projects
- Combines with vector search: Adds relevant documents System answers: Lists engineers with their ML-related projects and expertise
- Data with rich entity relationships
- Questions about connections and relationships
- Multi-hop queries (“who works at company that acquired X”)
- Knowledge bases with structured information
- Need to discover indirectly related information
- Requires graph database infrastructure
- Entity extraction and graph construction overhead
- Graph traversal can be slow for large graphs
- More complex to set up and maintain
- Requires structured data or entity extraction pipeline
- Graph Depth: Limit traversal to depth 2-3 for performance
- Entity Extraction: Use gpt-4o for accurate extraction, cache results
- Graph Indexing: Index frequently queried entity types
- Hybrid Approach: Combine graph traversal with vector search
- Caching: Cache common graph traversal paths
Choosing the Right Architecture
Selecting the appropriate RAG architecture depends on your use case, complexity requirements, and performance needs. Use this guide to make the right choice.Architecture Comparison
Decision Framework
Use this flowchart logic to pick the right RAG type:Decision Matrix
When to Upgrade
Basic → Advanced:- Accuracy < 70%
- Users complain about irrelevant results
- Technical domain with specific terminology
- Ambiguous queries are common
- Building a chatbot
- Users have repeat interactions
- Personalization improves experience
- Multi-turn conversations
- Questions require research
- Need to synthesize multiple sources
- Multi-hop reasoning required
- Questions like “compare X and Y across Z”
Production Considerations
Building production-ready RAG systems requires careful consideration of infrastructure, costs, performance, and monitoring. Here’s what you need to know.1. Vector Database Selection
Choosing the right vector database is critical for production performance and reliability.2. Cost Optimization
Understanding and managing costs is essential for sustainable RAG deployments. Typical Costs per 1000 Queries:- Basic RAG: $2-5
- Advanced RAG: $6-12
- Memory RAG: $3-8
- Agentic RAG: $15-40
- Cache common queries
- Use cheaper models for embeddings
- Implement query throttling
- Batch operations when possible
3. Performance Tuning
Different document types and use cases require different chunk sizes and retrieval settings.4. Monitoring and Metrics
Track key metrics to ensure your RAG system performs well in production.5. Common Pitfalls and Solutions
Pitfall 1: “Chunk Boundaries Cut Off Important Info” Problem: The answer spans 2 chunks, and neither chunk alone contains enough information to be retrieved. This is the most common silent failure in RAG systems — it looks like “no results found” but actually the information is there, just split across a boundary.- Similarity Threshold: Only use docs > 0.7 similarity
- Metadata Filtering: Filter by date, category, etc.
- Re-ranking: Use LLM to score relevance
- Better Chunking: Smaller, more focused chunks
- Stricter System Prompt: “ONLY use information from the provided sources. If the answer is not in the sources, say ‘I don’t have information about that in the provided sources.’ Do NOT use your general knowledge.”
- Temperature = 0: Reduces creative drift from source material
- Post-processing: Programmatically verify that key claims in the answer actually appear in the retrieved sources
- Citation Requirement: Force [Source N] citations — this makes hallucination easier to detect and catches the model when it invents references
- Use faster embedding models
- Implement caching
- Reduce top-k
- Use async operations
- Consider hybrid database with cache layer
- Timestamp all memory entries and decay old facts
- When extracting new facts, check for contradictions with existing memory and overwrite
- Allow users to explicitly view and delete their stored preferences
- Set a maximum memory age (e.g., 90 days) after which facts require re-confirmation
- Deduplicate retrieved documents across iterations — skip docs already in context
- Add a “diminishing returns” check: if the last search returned zero new documents, force an answer
- Include retrieved document count and content summaries in the planning prompt so the model knows what it already has
- Set
max_iterationsconservatively (3-5) and implement a_force_answerfallback
Summary and Next Steps
Key Takeaways:- Start Simple: Begin with Basic RAG, add complexity as needed
- Hybrid Works Best: Vector + keyword search outperforms either alone
- Memory for Conversations: Essential for chatbots and assistants
- Monitor Quality: Track metrics, iterate on poor performance
- Cost vs Quality: Advanced techniques cost more but deliver better results
Choosing the Right RAG Type
Key Takeaways
Start Simple
Begin with Basic RAG, then add complexity as needed based on failure analysis.
Hybrid is Best
Combining vector + keyword search outperforms either alone for most use cases.
Memory Matters
For conversational AI, memory context dramatically improves response relevance.
Graphs for Relationships
When entities and relationships matter, Graph RAG provides structured understanding.
What’s Next
Tool Calling
Learn how to give LLMs the ability to call functions and external APIs