{"slug": "rag-is-simpler-than-you-think", "title": "RAG Is Simpler Than You Think", "summary": "Most RAG implementations are over-engineered, and a simple full-text search (BM25) often suffices, according to a technical guide that outlines a recipe-based approach. The guide recommends starting with full-text search only, then adding agentic query rewriting with an LLM (costing ~$0.001 per query using GPT-4o-mini) before considering embeddings or vector databases. It emphasizes matching the approach to data freshness, corpus characteristics, query patterns, scale, and team capabilities.", "body_md": "Nowadays, most people seem to over-engineer their RAG stack. They jump straight to embeddings, vector databases, and reranking pipelines. Meanwhile, their users just want to find the doc that says *“How to reset my password.”*\n\nIn engineering, there’s always the right tool for the right problem. In AI Retrieval Systems it’s not different.\n\n### The Decision Factors\n\nBefore we dive into recipes, let’s establish when you should use each approach. The key factors are:\n\n**1. Data Freshness Requirements** - Real-time updates (news, social media) favor approaches with easy re-indexing. Daily or weekly updates work well with hybrid approaches. A stable corpus (monthly or quarterly updates) makes pre-embedding sensible.\n\n**2. Corpus Characteristics** - High churn (more than 10% changes daily) means you should avoid full pre-embedding. Stable documents work fine with pre-embedding. Long-tail distribution (90% never accessed) means on-the-fly wins.\n\n**3. Query Patterns** - Keyword-heavy queries should start with full-text search. Semantic or conversational queries benefit from embeddings. Mixed patterns need hybrid approaches.\n\n**4. Scale & Performance** - Less than 1000 queries per day means simple approaches are sufficient. 1K to 10K queries per day requires selective optimization. More than 10K queries per day justifies full optimization.\n\n**5. Team Capabilities** - No ML expertise means stay with full-text plus query rewriting. Some ML experience makes hybrid search manageable. Having an ML team available makes advanced approaches viable.\n\nNow, let’s look at the recipe book. Start at the top. Move down only when you have data proving you need to.\n\n### Recipe 1: The MVP – Full-Text Search Only\n\n#### What it is\n\nGood old BM25. Elasticsearch. Postgres full-text search. The stuff that existed before *“embedding”* became a verb.\n\n#### When to use\n\nYou’re just starting out. Your users write keyword-style queries *(”pandas merge dataframe”)*. Exact matches matter *(”invoice #12345”)*. You want zero ML complexity. Your corpus has proprietary terminology *(more on this later)*.\n\n#### Pros\n\nZero API costs. Fast (under 10ms). Easy to debug (you can see exactly why a document matched). Surprisingly effective (handles many use cases). **No chunking strategy needed** – works with full documents. **No evaluation complexity** – easy to test and validate. No model deprecation risk (BM25 doesn’t change).\n\n#### Cons\n\nMisses synonyms (”car” vs “automobile”). Fails on semantic queries (”How do I...?”). Can’t understand intent beyond keywords.\n\n#### Real talk\n\nIn my experience, this handles a significant portion of use cases. Don’t skip this step. You might be surprised how far you can get.\n\n#### Why this is underrated\n\nWhen you jump straight to embeddings, you immediately face questions like: What chunk size? (512 tokens? 1024?) What overlap? (50 tokens? 100?) Semantic chunking or fixed-size? How do I evaluate if my chunking is good?\n\nWith full-text search, you skip all of this. Your documents are your documents. Search just works.\n\n### Recipe 2: Agentic Query Rewriting\n\n#### What it is\n\nUse an LLM to transform messy user queries into clean keyword searches.\n\n#### The insight\n\nMost “semantic search” problems are actually *query formulation* problems.\n\n#### When to use\n\nUsers ask questions conversationally. Vocabulary mismatch (users say “fix bugs”, docs say “debugging”). You have internal jargon (your framework called “Atlas”). You want flexibility to iterate quickly on query strategies.\n\n#### Cost\n\n*~$0.001* per query (using GPT-4o-mini for query rewriting)\n\n#### The magic\n\nAn LLM can remove stopwords (”how do I” becomes nothing). It can add synonyms (”car” becomes “car automobile vehicle”). It can translate domain terms (”speed up code” becomes “optimize performance”). It can decompose complex queries (”read CSV and plot” becomes [”read CSV”, “plot data”]). It can learn from your glossary (via system prompt).\n\n#### Why this is more flexible than embeddings\n\nWith embeddings, if results aren’t good, you need to adjust chunking strategy, re-embed entire corpus, run regression tests on your eval set, and hope it improved.\n\nWith query rewriting, if results aren’t good, you adjust the system prompt. That’s it. Test immediately.\n\n#### Multi-turn agentic rewriting\n\nEven better, you can create a loop:\n\n``` python\ndef agentic_search(query, max_iterations=3):\n    for i in range(max_iterations):\n        # Rewrite query\n        optimized = query_rewriter.rewrite(query, iteration=i)\n        \n        # Search\n        results = bm25_search(optimized)\n        \n        # Evaluate quality\n        quality = evaluate_results(results, query)\n        \n        if quality > threshold:\n            return results\n        \n        # Agent learns and tries again\n        query = refine_based_on_feedback(query, results, quality)\n    \n    return results\n```\n\nThe agent can iterate, learn, and adapt – all without re-embedding anything.\n\n#### Example: The Proprietary Terminology Problem\n\nSay your company has a Python framework called “Atlas.” If you use general-purpose embeddings:\n\n```\nGeneral embedding model (trained on internet):\n“Atlas” = [vectors pointing toward: Greek mythology, maps, geography]\nYour actual Atlas docs = [vectors about data processing]\nSimilarity score: 0.15 (terrible!)\n```\n\nThe model has no idea your “*Atlas*” exists. It falls back to what it learned in training. But with query rewriting:\n\n```\nsystem_prompt = \"\"\"\n  Domain-specific terms (NEVER modify these, use as exact keywords):\n    - Atlas: our internal data processing framework\n    - Mercury: our messaging system\n    - Zeus: our auth service\n\n    Preserve these terms exactly and optimize the rest of the query.\n\"\"\"\n\n# User: \"How do I use Atlas for batch jobs?\"\n# Agent: \"Atlas batch jobs data processing pipeline\"\n# BM25: Perfect match on \"Atlas\" ✓\n```\n\nFor proprietary terms, exact keyword matching beats semantic understanding.\n\n### Recipe 3: Hybrid Search (Sparse + Dense Reranking)\n\n#### What it is\n\nUse BM25 to get candidates (top 50-100), then rerank with embeddings (top 10).\n\n#### Why this works\n\nBM25 is fast and great at keyword matching. Embeddings are good at semantic understanding. Together, they cover each other’s weaknesses.\n\n#### When to use\n\nUsers ask semantic questions (”*find alternatives to X”*). BM25 plus query rewriting alone isn’t cutting it (you have data proving this). You can tolerate 100-500ms latency. Your corpus is relatively stable (not changing every minute).\n\n#### The pipeline\n\n#### Cost considerations\n\nLet’s do the math with current pricing (OpenAI text-embedding-3-small at $0.02 per 1M tokens):\n\nEmbedding 50 docs per query (avg 500 tokens each) means 50 docs × 500 tokens = 25,000 tokens\n\nCost: 25,000 × $0.00002 = ~$0.0005 per query. At 1,000 queries per day × 30 days = ~$15 per month.\n\nActually pretty reasonable. But there’s a catch: **latency**.\n\nEmbedding 50 documents on-the-fly adds 200-500ms per query. For user-facing search, that’s noticeable. This is where the real trade-off lives – not cost, but speed.\n\n#### Important consideration: The chunking problem returns\n\nWhen you introduce embeddings, you need to decide how to chunk your documents (fixed-size? semantic? by section?). You need to determine what chunk size and overlap to use. You need to handle chunks that span important context.\n\nThis adds complexity that pure full-text search avoids.\n\n### Recipe 4: On-The-Fly Embedding (The Fresh Data Play)\n\n#### The insight\n\nIf your data changes frequently, why pay to re-embed everything?\n\n#### What it is\n\n#### When to use\n\n**High document churn** (more than 10% of docs updated daily). **Real-time content** (news, social media, live updates). You’re **experimenting with embedding models** (no re-indexing needed). **Data freshness is critical** (documents must be up-to-date). Small K for reranking (20-50 docs).\n\n#### Math time\n\n```\nOn-the-fly / online (1000 queries/day, 50 docs/query):\n- Embedding cost: ~$15/month (ongoing)\n- Storage: $0 (just store text)\n- Latency: 200-500ms per query\n- Freshness: Perfect (always current)\n- Model switching: Easy (just change the API call)\n```\n\n#### The model deprecation benefit\n\nHere’s something people don’t talk about enough: **embedding models get deprecated**.\n\nOpenAI deprecated text-embedding-ada-002 in favor of text-embedding-3. If you pre-embedded 10 million documents with the old model, you now need to re-embed all 10 million documents with the new model, update your vector database, run regression tests on your evaluation set, validate that quality didn’t degrade, handle the cutover period, and deal with any API changes.\n\n#### With on-the-fly / online embedding\n\nYou literally just change one line of code. Done.\n\n#### The downside\n\nLatency. You’re embedding documents on every query. This is only viable if you’re okay with 200-500ms latency, K is small (reranking 20-50 docs, not 500), and your use case favors freshness over speed.\n\n### Recipe 5: Pre-Embedding with Hot/Cold Tiers (The Pragmatic Play)\n\n#### What it is\n\nPre-embed frequently accessed documents (”hot tier”), embed rarely-accessed documents on-the-fly (”cold tier”).\n\n#### The insight\n\nAccess patterns follow Pareto distribution. 20% of docs get 80% of traffic.\n\n``` python\n# Track access patterns\naccess_counts = Counter()\n\ndef adaptive_search(query):\n    # BM25 to get candidates\n    candidates = bm25_search(query, top_k=100)\n    \n    # Separate hot and cold\n    hot = [d for d in candidates if d.id in hot_tier]\n    cold = [d for d in candidates if d.id not in hot_tier]\n    \n    # Hot docs: use pre-computed embeddings (fast)\n    hot_scores = vector_db.similarity_search(query_emb, hot)\n    \n    # Cold docs: embed on-the-fly (slower, but rare)\n    cold_scores = embed_and_score(cold, query_emb)\n    \n    return merge_and_rank(hot_scores, cold_scores)\n\n## Periodically promote frequently accessed docs to hot tier\ndef update_tiers_weekly():\n    frequently_accessed = [doc_id for doc_id, count \n                          in access_counts.items() \n                          if count > threshold]\n    \n    # Only re-embed the new hot docs\n    newly_hot = set(frequently_accessed) - set(hot_tier)\n    embed_and_index(newly_hot)\n```\n\n#### When to use\n\nClear access patterns (some docs are accessed way more than others). Medium-to-large corpus (more than 100K documents). Mix of stable and changing content. Need good latency for common queries. Want to minimize re-embedding on model updates.\n\n#### Benefits\n\nFast for 80% of queries (hit pre-embedded cache). Fresh for rarely-accessed docs. Only re-embed hot tier when switching models (20% of corpus). Adapts to changing access patterns. Best latency/cost/flexibility trade-off.\n\n#### The model update story\n\nWhen your embedding model gets deprecated:\n\n```\nFull pre-embedding: Re-embed 1M docs × $0.01 = $10,000 + downtime\nHot/cold tiers: Re-embed 200K docs × $0.01 = $2,000 + minimal downtime\nOn-the-fly: Change one line of code = $0 + zero downtime\n```\n\n### Recipe 6: Full Pre-Embedding (The Scale Play)\n\n#### What it is\n\nEmbed everything upfront. Store in vector database. Search with ANN (approximate nearest neighbors).\n\n#### When to use\n\nVery high query volume (more than 10K queries per day). Need under 50ms latency. **Very stable corpus** (under 5% churn per month). Access pattern is broad (no long tail). You have ML team to manage infrastructure.\n\n### Cost breakdown\n\n```\nPre-embedding (1M docs):\n- One-time embedding: 1M docs × 500 tokens × $0.00002 = $10\n- Storage: 1M × 1536 dims × 4 bytes = 6GB (~$10-30/month)\n- Search latency: under 50ms (blazing fast!)\n- Freshness: Only as fresh as last re-index\n```\n\n#### When NOT to use\n\nDocuments change frequently (more than 10% per week). You’re experimenting with embedding models. Low query volume (under 1K queries per day). You haven’t tried simpler approaches first.\n\n#### The model deprecation nightmare\n\nThis is where full pre-embedding hurts the most. When you need to switch models, you face **downtime** (your search is degraded while re-embedding), **compute cost** (re-embedding millions of documents), **testing burden** (full regression test suite on new embeddings), **chunking reevaluation** (maybe new model works better with different chunk sizes?), and **risk** (what if the new model is worse for your domain?).\n\nThis is overkill for most systems. I’ve seen teams spend months optimizing their vector database setup when query rewriting would have solved 90% of their problems.\n\nBut if you’re Pinterest, Shopify, or handling massive scale with a stable corpus, this is where you end up.\n\n## The Multi-Intent Query Problem\n\nHere’s where things get spicy. We’ve been discussing single-intent queries: *“How do I merge dataframes?”*\n\nBut real users ask stuff like: **“How do I read a CSV file, clean missing data, and plot the results?”**\n\nThat’s three separate intents. Searching for this as one query is like trying to find a restaurant that serves pizza, sushi, and tacos. Good luck.\n\n#### The Perplexity Playbook\n\nModern agentic RAG systems (Perplexity, ChatGPT search) handle this elegantly:\n\n#### Query Understanding Agent\n\nBreak down the query.\n\n```\n# Input: \"read CSV, clean data, plot results\"\n\n# Agent output:\n\n{\n  \"query_type\": \"complex\",\n  \"sub_queries\": [\n    \"pandas read csv file\",\n    \"pandas clean missing data\",\n    \"matplotlib plot dataframe\"\n  ],\n  \"dependencies\": [\"read > clean > plot\"]\n}\n```\n\n#### Parallel Adaptive Processing\n\nRoute each sub-query optimally\n\n```\nSub-query 1 (simple):\n  \"pandas read csv\"\n  Stopwords + lemma, then BM25\n  Cost: $0, Latency: 15ms\n\nSub-query 2 (moderate):\n  \"pandas clean missing data\"\n  Synonym expansion, then BM25\n  Cost: $0, Latency: 20ms\n\nSub-query 3 (complex):\n  \"matplotlib plot dataframe\"\n  LLM rewrite, then Multi-search\n  Cost: $0.001, Latency: 250ms\n\nTotal (parallel): $0.002, 250ms (not 285ms!)\n```\n\n#### Synthesize\n\nCombine results into coherent answer\n\n```\nHere’s a complete workflow:\n\n1. Reading CSV Files\n   [relevant docs from sub-query 1]\n   \n2. Cleaning Missing Data\n   [relevant docs from sub-query 2]\n   \n3. Plotting Results\n   [relevant docs from sub-query 3]\n\n[Code example combining all three steps]\n```\n\n#### Why this works\n\nEach sub-query is focused and precise, leading to better retrieval. Parallel execution means lower latency (max, not sum). Adaptive routing results in lower cost (only complex queries pay for LLM). Structured output provides better UX.\n\n#### Cost comparison\n\n**Without decomposition**\n\nLLM rewriting entire complex query: $0.005\n\nEmbedding 50 docs: $0.025\n\nTotal: $0.03\n\n**With decomposition**\n\nDecompose: $0.001\n\nSub-query 1 (simple): $0\n\nSub-query 2 (simple): $0\n\nSub-query 3 (complex): $0.001\n\nTotal: $0.002\n\n15x cheaper, better quality.\n\nThis is where agentic retrieval really shines. The agent can intelligently decide which sub-queries need expensive processing (embeddings) and which can be handled with cheap methods (simple preprocessing + BM25).\n\n## The Decision Tree (Or: When to Use What)\n\nOkay, you’ve read this far. You just want to know: “What should I build?”\n\n**Start here: Do you have search at all?** If not, build BM25 first. Seriously. Stop reading and build it. If you do have search, continue.\n\n**Measure your baseline.** Run your current search for 2-4 weeks and collect user feedback. Are users happy with the results? If yes, stop. You’re done. Go ship features. If no, continue.\n\n**What’s the main complaint?**\n\nIf users say “Can’t find docs that clearly exist,” try query rewriting first. At $0.001 per query with zero re-indexing, it’s worth testing. Run an A/B test for 2 weeks. If you see good improvement, keep it and you’re done. If it’s not enough, continue.\n\nIf users say “Results are okay but not great,” A/B test hybrid search (sparse plus embedding rerank). Is the added latency worth it? If yes, decide on implementation. If your data changes frequently, use on-the-fly embedding. If you have clear hot docs, use hot/cold tiers. If you have a stable corpus and high scale, use full pre-embedding. If the latency isn’t worth it, optimize query rewriting further instead.\n\nIf users say “Need better semantic understanding,” use hybrid search and choose your approach based on your situation. High churn (more than 10% per day) means on-the-fly. Medium scale with clear patterns means hot/cold tiers. Massive scale with stable data means full pre-embedding.\n\n**Key decision factors:**\n\nFull-text with query rewriting offers perfect data freshness with low setup complexity and query latency under 50ms. Model switching is trivial, no chunking is needed, and it works for most use cases.\n\nOn-the-fly embedding provides perfect data freshness with low setup complexity but higher query latency of 200-500ms. Model switching is trivial, chunking is needed, and it’s best for high churn scenarios.\n\nHot/cold tiers provide mixed data freshness with medium setup complexity and query latency of 50-100ms. Model switching is easy, chunking is needed, and it offers balanced performance for varied needs.\n\nFull pre-embedding has stale data until reindex with high setup complexity but query latency under 50ms. Model switching is painful, chunking is needed, and it’s designed for massive scale operations.\n\n**The 80/20 rule:** 60% of systems should stop at full-text plus query rewriting. 25% need hybrid with on-the-fly or hot/cold. 10% need full pre-embedding. 5% need custom solutions.\n\n**Bottomline: Don’t be the person who builds the 5% solution for a 60% problem.**", "url": "https://wpnews.pro/news/rag-is-simpler-than-you-think", "canonical_source": "https://www.lighthousenewsletter.com/p/rag-is-simpler-than-you-think", "published_at": "2026-08-26 08:39:17+00:00", "updated_at": "2026-08-26 09:14:50.189197+00:00", "lang": "en", "topics": ["artificial-intelligence", "machine-learning", "natural-language-processing", "ai-tools"], "entities": ["BM25", "Elasticsearch", "Postgres", "GPT-4o-mini"], "alternates": {"html": "https://wpnews.pro/news/rag-is-simpler-than-you-think", "markdown": "https://wpnews.pro/news/rag-is-simpler-than-you-think.md", "text": "https://wpnews.pro/news/rag-is-simpler-than-you-think.txt", "jsonld": "https://wpnews.pro/news/rag-is-simpler-than-you-think.jsonld"}}