Skip to main content

Why RAG is the Killer App

RAG (Retrieval-Augmented Generation) is how you build AI products that actually work with real data. ChatGPT’s Browsing, Perplexity’s search, enterprise knowledge bots — all RAG. Think of it this way: an LLM without RAG is like a brilliant consultant who hasn’t read your company’s documents. They can reason and communicate well, but they don’t know your specific data. RAG gives that consultant a research assistant who instantly pulls up the right internal documents before every answer.
Industry Reality: 90% of enterprise AI projects are RAG systems. Mastering RAG means you can build products that work with any company’s data without expensive fine-tuning. The alternative — fine-tuning a model on your data — costs 10-100x more and needs to be redone every time your data changes.

The RAG Mental Model

Production RAG System

Complete Implementation

Advanced Techniques

1. Parent-Child Retrieval

The fundamental tension: small chunks embed better (more precise meaning), but small chunks lack context (the LLM can’t understand a 50-word snippet). Parent-child retrieval solves this — search on small child chunks for precision, then return the larger parent chunk for context. It’s like using an index to find the right page, then reading the whole page:

2. Agentic RAG with Query Decomposition

When a question is too complex for a single retrieval pass — “Compare our Q3 and Q4 revenue trends and explain why churn increased” — the system needs to break it into sub-questions, retrieve independently for each, then synthesize. This is the agentic pattern:

Evaluation Framework

Retrieval Strategy Decision Framework

Choosing the right retrieval strategy is the single most impactful decision in your RAG pipeline. Here is a decision table for the three main strategies and their sub-techniques: When to enable HyDE (Hypothetical Document Embeddings): HyDE is powerful but adds a full LLM call to every query. Enable it when: (1) queries are open-ended questions rather than keyword searches, (2) your documents are written in a very different register than user queries (academic papers vs. casual questions), and (3) latency budget allows an extra 200-500ms. Disable it for real-time chatbots or when queries are already well-formed.

Common Failures and Fixes

Symptoms: Low precision, answer quality poor. The LLM generates answers that are technically well-written but address the wrong topic because it was fed the wrong context.Root Cause: Usually a chunking problem. If your chunks are too large, every chunk is “kind of about everything” and similarity scores flatten. If too small, they lack enough meaning to match well.Fixes (try in this order):
  1. Improve chunking — smaller chunks with semantic boundaries, not arbitrary character splits
  2. Add query expansion — the user’s words may not match your document’s vocabulary
  3. Use hybrid search (vector + keyword) — catches what either method alone misses
  4. Add re-ranking step — a cross-encoder can catch false positives that slipped through
  5. Tune similarity threshold — raise it to cut noise, lower it if you’re missing results
Symptoms: Answer doesn’t use sources, makes up facts. This is the most dangerous RAG failure because it looks correct but is hallucinated.Root Cause: The LLM’s parametric knowledge (training data) is competing with your retrieved context. If the context is poorly formatted or buried in the prompt, the model defaults to what it “knows.”Fixes:
  1. Set temperature=0 — reduces creative drift from sources
  2. Put context closer to the question — LLMs attend more to nearby text (recency bias)
  3. Add explicit instructions: “ONLY use information from the provided sources. If not found, say so.”
  4. Use structured output to force citations — the model must produce [Source N] references
  5. Try a more capable model — GPT-4o follows grounding instructions better than GPT-4o-mini
Symptoms: Low recall, answer says “no information”Fixes:
  1. Query expansion (multiple query variations)
  2. HyDE (hypothetical document embeddings)
  3. Lower similarity threshold
  4. Increase top_k before re-ranking
  5. Improve document coverage
Symptoms: >3s total latencyFixes:
  1. Cache embeddings (most common queries)
  2. Use async database connections with pooling
  3. Stream LLM responses
  4. Use faster embedding model
  5. Pre-compute common query answers

Key Takeaways

Hybrid Search Wins

Vector + keyword search with RRF scoring outperforms either alone for most use cases.

Re-ranking Is Worth It

Cross-encoder or LLM re-ranking significantly improves precision at modest latency cost.

Query Processing Matters

Query expansion and HyDE can dramatically improve recall for ambiguous queries.

Evaluate Continuously

Track retrieval precision, answer faithfulness, and latency. What you don’t measure, you can’t improve.

What’s Next

AI Agents

Build autonomous agents that use tools, make decisions, and complete multi-step tasks