Skip to content
Welzin
← All posts

GenAI & Agents

RAG is not a feature, it's an architecture

Aman Mundra · June 30, 2026 · 9 min read

RAG is not a feature, it's an architecture
Image source
Contents

Summarize using AI

Retrieval-augmented generation gets described as "just add a vector database," and that framing is why so many RAG systems disappoint. The demo works. The pilot impresses. Then production traffic arrives, and the system starts failing in the worst possible way: silently. The API returns 200, the model answers fluently, and the answer is wrong - and you find out from a customer, not a dashboard.

The industry numbers behind that experience are stark. Naive RAG - fixed-size chunks plus single-vector similarity - fails to retrieve the correct context roughly 40 percent of the time, and when RAG fails, the failure point is retrieval about 73 percent of the time, not generation. Teams spend weeks swapping models and tuning prompts while the actual defect sits upstream, in the parts nobody demos. That is the sense in which RAG is not a feature: a production system is fifteen-plus components, not four, and the ones that determine success are decided before the model is ever called. This post walks the architecture layer by layer, in the order the failures actually happen.

Table of contents
1. Where RAG actually fails: upstream
2. Ingestion and chunking: 80% of the defects
3. Retrieval: hybrid or bust
4. Grounding: making the model use what it found
5. Evaluation: the component that must exist first
6. The operational layer nobody demos
7. When RAG is the wrong tool
8. Build order and honest costs
9. Takeaways

1. Where RAG actually fails: upstream

Trace a wrong answer backwards and the chain almost always breaks before the LLM: the right document was never ingested; it was ingested but chunked so the answer straddles two fragments; the chunk exists but embedding similarity ranked it 47th; it ranked well but a missing metadata filter excluded it; it was retrieved but the model ignored it in favor of its own priors. Five distinct failure sites, one symptom - a fluent wrong answer.

This is why "which LLM should we use" is the least consequential question in a RAG design review. Per DigitalOcean's failure analysis, the generator mostly amplifies whatever the retrieval layer hands it. Architecture, in RAG, means engineering each of those five sites deliberately - and instrumenting them separately, so a wrong answer decomposes into "retrieval miss" or "grounding miss" instead of "the AI was wrong."

2. Ingestion and chunking: 80% of the defects

Industry analysis puts 80 percent of RAG failures in the ingestion and chunking layer - the layer teams treat as a script someone wrote in week one. The load-bearing decisions:

  • Chunk by structure, not by character count. Fixed 512-token windows slice tables in half and orphan section headers from their bodies. Chunkers that respect document structure (headings, tables, list boundaries) with modest overlap outperform naive splitting on essentially every published benchmark. Keep the heading path ("Refunds > Enterprise plans > Exceptions") attached to every chunk - it is context the embedding needs and the citation the user wants.
  • Metadata is retrieval infrastructure. Source system, document date, product line, access level, version. Half of production queries need a filter before similarity even applies ("current policy", "for the EU tenant"). Missing metadata is why filtering fails, and permissions not enforced end-to-end are how a RAG system becomes a compliance incident: retrieval must respect document ACLs per user, per chunk.
  • Freshness is a pipeline, not a batch job. A document updated last month that the index never re-processed returns outdated answers with full confidence - stale context is a silent failure mode. Hash content at ingestion, detect changes, re-embed on delta, and expose an "index freshness" metric someone actually watches.

3. Retrieval: hybrid or bust

Pure vector search fails on exact matches - part numbers, error codes, names - and pure keyword search misses paraphrase. The production standard in 2026 is therefore hybrid retrieval with reranking, and the published numbers justify it: hybrid (BM25 plus vectors) reaches 66.4 percent MRR against 56.7 for semantic-only, and hybrid fused with a cross-encoder reranker cuts error rates by roughly 69 percent versus naive vector-only retrieval.

The pipeline shape that keeps showing up across the production guides:

query
  -> (optional) rewrite / decompose the question
  -> BM25 top-20            # exact terms, codes, names
  -> vector top-20           # paraphrase, concepts
  -> RRF merge (k=60) to top-30
  -> cross-encoder rerank to top-5
  -> LLM with citations

# Cost: ~200-400ms added latency for the rerank stage.
# Payoff: +15-30% answer quality on RAGAS-style metrics.
# Start here; add graph/agentic stages only when evals
# prove this shape insufficient.

Two notes from the field. First, bigger top-k is not a fix; it is how you trade a retrieval problem for a latency-and-noise problem - recall-boosting stages stack until the system is too slow for real users. The reranker exists precisely so you can be generous at recall and ruthless at precision. Second, embedding models drift out from under you: the corpus grows domain vocabulary the embedder never saw. Re-benchmark retrieval quarterly on your own query set, not on the embedder's leaderboard scores.

4. Grounding: making the model use what it found

Retrieval hands the model the right context; grounding determines whether the model actually uses it. The three constraints that do most of the work:

  • Citations as a hard contract. Every claim in the answer maps to a retrieved chunk ID, rendered as a source link. This is not UX garnish - it is the mechanism that makes wrong answers debuggable (which chunk misled it?) and unsupported answers visible (no citation, no claim).
  • A licensed "I don't know." The prompt must make abstention cheaper than invention: if the retrieved context does not contain the answer, say so and route to a human or a broader search. Teams that skip this ship a system that answers every question, including the ones it shouldn't.
  • Context discipline. Order matters (models over-attend to the start and end of context), contradictions matter (two versions of the same policy in one prompt produce coin-flip answers - deduplicate by document version at retrieval time), and stuffing matters (five relevant chunks beat thirty mixed ones).

5. Evaluation: the component that must exist first

Here is the sequencing error that costs teams the most: evaluation gets built last, after the pipeline "works." But without an eval harness, every one of the dozens of decisions above - chunk size, embedder, k, reranker, prompt - was made by vibes, and every future change is a gamble. The two highest-leverage decisions (chunking and embedding model) fail silently unless an evaluation harness exists from week one.

The minimum viable harness, buildable in days:

# 100-300 real questions from stakeholders/logs, each with:
#   - expected source document(s)   <- makes retrieval scoreable
#   - expected answer or key facts  <- makes generation scoreable
#
# Score two layers SEPARATELY:
retrieval:  hit@k, MRR          # did the right chunk surface?
generation: faithfulness,       # claims supported by context?
            answer relevance    # did it answer the question?
# (RAGAS et al. automate the second layer with LLM judges -
#  calibrate the judge against ~50 human-graded answers first.)
#
# Every pipeline change = a run. No run, no merge.

The separation is the point: "hit@5 dropped 12 points on policy questions after the re-chunk" is a Tuesday fix; "answers feel worse lately" is a quarter of archaeology. The eval set also doubles as the regression suite for model upgrades, embedder swaps, and prompt changes - one artifact, compounding returns.

6. The operational layer nobody demos

The components that separate a pilot from a system of record, and that never appear in the launch demo:

  • Per-stage observability. Log the query, the retrieved chunk IDs with scores, the reranker order, the final prompt, and the cited chunks - per request. When (not if) an answer goes wrong, this trace is the whole diagnosis.
  • Feedback capture. Thumbs-down with the trace attached is the cheapest training data you will ever collect; it becomes next quarter's eval questions.
  • Index lifecycle. Versioned indexes, blue-green reindexing, rollback. The day you change chunkers or embedders, you will be very glad the old index still exists.
  • Cost and latency budgets per stage. Rerankers, query rewriting, and agentic hops each carry a price; a per-stage budget is what keeps "improve recall" from quietly doubling response time (and, per our inference-cost post, the bill).

7. When RAG is the wrong tool

Honest boundaries, because retrieval-from-documents is not a universal answer:

  • Real-time operational truth. "What is the order status" is a database query with an API in front of it. Retrieving from documentation is simply the wrong approach for live state - route these to tools, not to the index.
  • Stable, bounded knowledge. If the corpus is small and changes yearly, long-context prompting or a fine-tune may beat the entire retrieval apparatus on both cost and simplicity.
  • Computation dressed as a question. "Which region grew fastest last quarter" wants SQL generation against the warehouse, not similarity search over PDFs.

A well-architected assistant is usually a router in front of all three: RAG for document knowledge, tools for live state, structured query generation for analytics. Forcing everything through the vector index is the second most common design error after skipping evals.

8. Build order and honest costs

The consensus build order from the 2026 production guides, which matches our engagement experience: structure-aware chunking with metadata, hybrid retrieval, cross-encoder reranking, citations plus abstention, and the eval harness - then stop. Add query decomposition, GraphRAG, or agentic retrieval loops only when the eval numbers prove the simple shape insufficient for specific query classes. Complexity added ahead of evidence is how RAG systems become unmaintainable.

And the costs, stated plainly: this is a real system with a real operational load - index infrastructure, reranker latency (200-400ms), quarterly re-benchmarking, permission plumbing, and an eval set that needs curation as the product evolves. Budget it like a search product, because that is what it is. The teams that budget it like a prompt are the ones writing the "why our RAG failed" retrospectives.

9. Takeaways

  • RAG failures are retrieval failures ~73 percent of the time, and 80 percent of defects live in ingestion and chunking. Engineer upstream first.
  • Chunk by document structure, carry metadata and ACLs per chunk, and treat index freshness as a monitored pipeline.
  • Hybrid retrieval plus a cross-encoder reranker is the production standard: ~69 percent error reduction over naive vector search for 200-400ms of latency.
  • Ground with mandatory citations and a licensed "I don't know" - fluency without either is a liability generator.
  • Build the eval harness first: 100-300 real questions, retrieval and generation scored separately, a run on every change.
  • Route around RAG where it's wrong: tools for live state, SQL for analytics, long context for small stable corpora.

References

  1. Building production RAG: architecture, chunking, evaluation, monitoring (Prem AI)
  2. Production RAG: why retrieval fails and how to fix it (Mudassir Khan)
  3. RAG in production 2026: GraphRAG, hybrid retrieval, and evals (AI Learning Guides)
  4. Why RAG systems fail in production (DigitalOcean)
  5. Hybrid search: BM25, vector, and reranking reference (Digital Applied)
  6. Hybrid search for RAG: vector + keyword + reranking guide (BuildMVPFast)
  7. RAG chunking strategies: a 2026 retrieval playbook (Digital Applied)

Hero image: Zetong Li on Unsplash.

We build retrieval systems that hold up under real queries. Explore our other insights or get in touch if you would like to talk it through.

  • GenAI & Agents

    Evaluate Your Large Language Model

    Large Language Models (LLMs) like GPT-4, LLaMA, and Claude now power critical real-world applications - from customer support bots that might accidentally...

    17 min read
  • GenAI & Agents

    LangChain vs LangGraph vs LangSmith

    Large Language Models(LLMs) are changing how we create AI-powered applications. However, the actual impact depends on the frameworks we use to manage and...

    7 min read
  • GenAI & Agents

    Building a RAG Pipeline

    How to build a RAG (Retrieval-Augmented Generation) pipeline: chunking, embedding, vector databases (Chroma, Pinecone, Weaviate, Qdrant, Neo4j), and...

    10 min read
  • GenAI & Agents

    Every model has a point of view

    The research is in: models carry measurably different value profiles, refusal habits, and defaults - and they don

    9 min read
  • GenAI & Agents

    Agents that do the work, not just chat

    A 95%-per-step agent completes a 10-step workflow 60% of the time - that math, not model quality, is why agents fail. Where agents genuinely work in 2026, and the verification-first architecture that gets them there.

    9 min read
  • Engineering

    Supercharge Your Frontend with Lovable AI

    In this article, we’ll guide you step by step to build your very first React project using Lovable AI, connect it to Supabase, and publish it online. By the...

    9 min read
  • Engineering

    How To Optimize the Performance of a Web App

    A fast and smooth app keeps users happy, lowers bounce rates, and encourages people to come back. But if your app is slow, users quickly lose patience,...

    7 min read