RAG is not one thing: six rungs, and most questions need the bottom three

2026-12-02来源 dev.toEnglish

Meridian Foods is a made up company. Its HR assistant launched with naive RAG over policy PDFs. In launch week, staff asked about leave carryover. The index still held last year's policy, so the bot quoted a rule retired months earlier. About 214 staff planned leave on the wrong rule before HR caught it.

The model was fine. The retrieval rung was wrong for facts that change and carry exact terms.

RAG is not one thing. It is a family, and naming the variant is the design decision. Think of a librarian who fetches only the pages your question needs, and climbs to a higher shelf only when the first one fails. Six rungs. Each fixes one failure of the rung below, and each adds cost, latency, and moving parts.

Rung 1: no retrieval. Use the model's own knowledge, or context the user pastes in. It fits small, stable knowledge, a 40 page FAQ that fits in the prompt, general knowledge, and writing help. It is not for facts that change, private facts, or answers that must cite a source. Cost: zero retrieval latency, no index to keep fresh. The cheapest rung is the one you skip.

Rung 2: naive RAG. The classic shape, in four steps: split documents into chunks and embed each one, embed the question and take the top few most similar chunks, paste those chunks into the prompt, and the model answers from the chunks and cites them. It fits prototypes, one document set, and plain questions in the documents' own wording. Where it breaks: wrong chunks when wording differs, a stale index after documents change, and no permissions, so search returns documents the asker may not see. Cost: one embedding call and a larger prompt per question, plus index upkeep.

Rung 3: hybrid search plus reranking. Run keyword and vector search together, merge the lists, then let a reranker score the short list and keep the best few. It fits exact terms, codes, names, SKUs, policy numbers, mixed with normal questions. It is not for a tiny corpus, or purely conceptual questions where keyword match adds noise. Cost: a second search and a rerank call per question, plus an index holding both keyword and vector data.

Rung 4: query rewriting and multi-query. Fix the question before searching: rewrite it into the documents' terms, or generate three or four variants, search with all, and merge. It fits the vocabulary gap. Staff ask "can I carry days over?" while the policy says "annual leave rollover entitlement". It is not for questions already precise: rewriting adds latency and can drift the meaning. Cost: one extra model call before the search, plus more searches to merge.

Rung 5: agentic retrieval. The model searches, reads what came back, judges what is still missing, and searches again, inside a step budget you set. It fits multi-hop questions, where the answer joins two or more sources: "Why did signups drop after the pricing change?" It is not for single-fact lookups. Slower, costlier, and harder to debug than one search. Cost: several model and search rounds per question. Always cap the rounds.

Rung 6: structured retrieval. Some facts live in tables, not text: orders, stock, balances, due dates. The model writes a query or calls an API, your code validates it, real rows come back. It fits counts, sums, current status, anything a spreadsheet answers exactly. It is not for explanations and opinions in prose documents. Cost: no index to keep fresh, but you pay in schema design and query safety checks.

Here is the decision table in one line each. General knowledge, or small and stable: no retrieval. The user pasted the document: use the pasted context. Plain questions over prose documents: naive RAG. Exact codes, names, policy numbers: hybrid search plus reranking. Users word it unlike the documents: query rewriting, then search. Answer joins two or more sources: agentic retrieval. Counts and current status in tables: structured retrieval. Rungs combine: rewriting usually feeds hybrid search, and an agentic loop can call a structured query as one step. The table picks the main rung, not the only one.

Now the worked example, one rung change measured. Meridian's assistant covers 3,000 policy documents and 12,000 questions a month, all figures illustrative, scored on a golden set of 300 questions with known right answers.

Naive RAG scores 71 percent: 213 right, 87 wrong. Failures cluster on policy numbers and exact clause names. The team adds hybrid search and reranking. Score: 86 percent, so 258 right. That is 45 more right answers per 300, a 15 point lift.

At 12,000 questions a month, the same rates mean naive RAG gets 3,480 wrong, the hybrid version 1,680 wrong: 1,800 fewer wrong answers a month.

The price: reranking adds 250ms per question, taking a typical answer from 900ms to 1,150ms. Extra cost: $24 a month for rerank calls plus $18 for the larger index, $42 total. Cost per avoided wrong answer: $42 divided by 1,800, about $0.023. Cheap for HR facts, where one wrong leave answer costs time and trust.

Note what the team did not do: no agent loop, no bigger model. The eval named the failure, one rung fixed it. That is the discipline. Start on the lowest rung that can answer the question type, and climb only when an eval names the failure the next rung fixes. Most real traffic lands on the three lowest rungs.

Two mistakes to stop making. First, "more chunks fix wrong answers." No: if search missed, a bigger top-k returns more of the wrong neighbourhood. Second, "vector search finds exact codes." No: embeddings match meaning and blur literal tokens. Keyword search owns exact match. And a third, for the road: tables cannot just be chunked as text. Counts and status go stale and sum wrong. Query the table.

The decision rule to carry out of this: start on the lowest rung that can answer the question type, and climb only when an eval names the failure the next rung fixes. The skipped rung is free.

The full interactive chapter is free at https://deployedlab.dev/lessons/arch-05-retrieval-patterns. 79 chapters are free with no signup, and the full bundle is $5 a month or $39 a year at deployedlab.dev.

原文:https://www.a8q9.cn/en/article/rag-is-not-one-thing-six-rungs-and-most-questions-need-the-bottom-three-19ff1c.html

相关文章