Slides · Retrieval-augmented generation

All RAG types

All RAG types

One pipeline for every question is a trap. This lesson shows how to pick the lightest RAG design that fixes a failure you can name.

By the end you can:

  • state the decision rule and walk the decision tree,
  • say when naive, advanced, modular and agentic RAG each earn their place,
  • match HyDE, parent-child, GraphRAG, Self-RAG, Corrective RAG and Adaptive RAG to the failure each fixes,
  • pick a variant for a scenario and defend it with its cost and failure mode.

Concept

Three questions, one method

  • Question 1: what is the status of a specific order?
  • Question 2: what changed in the policies this week?
  • Question 3: how long does a refund take?
  • A search that only asks “which page is about this?” treats all three the same.
  • They fail in different ways, so they may need different fixes.

“RAG” is a family of designs. Each named variant adds one step aimed at one failure of the plain pipeline.

Concept

A toolbox, not a ladder

  • The baseline is hybrid search plus a reranker. It is a good general tool.
  • Each variant is a specialist tool. You reach for it only when you can name the job.
  • Every extra LLM call adds latency, cost and a new way to fail.

The decision rule: start with the simplest thing that meets the quality bar, measure, and add complexity only for a failure you can name.

A weak answer lists ten variants. A strong answer picks one, states its cost and says how it would measure the gain.

Diagram

Walking the decision tree: questions 1 to 3

Ask about failures in order. The first “yes” points to a variant.

Diagram: From the hybrid-plus-rerank baseline, check for exact-ID misses (tune hybrid weights), a phrasing gap (query rewrite or HyDE) and missing...

Yes

No

Yes

No

Yes

No

Baseline: hybrid + rerank

Exact-ID misses?

Tune hybrid weights

Phrasing gap?

Query rewrite or HyDE

Missing context?

Parent-child

Go to questions 4 to 6

Diagram summary: From the hybrid-plus-rerank baseline, check for exact-ID misses (tune hybrid weights), a phrasing gap (query rewrite or HyDE) and missing context (parent-child). If all three answers are “no”, continue to the next slide.

Diagram

Walking the decision tree: questions 4 to 6

Diagram: Next check for multi-hop or corpus-wide questions (GraphRAG or iterative retrieval), empty or irrelevant retrieval (Corrective RAG) and...

Yes

No

Yes

No

Yes

No

Questions 1 to 3 were all no

Multi-hop or corpus-wide?

GraphRAG or iterative

Empty or irrelevant retrieval?

Corrective RAG

Mixed difficulty?

Adaptive routing

Agentic only if tools needed

Diagram summary: Next check for multi-hop or corpus-wide questions (GraphRAG or iterative retrieval), empty or irrelevant retrieval (Corrective RAG) and mixed query difficulty (adaptive routing). Agentic RAG is the last resort, used only when tools or multi-step work are needed.

Compare

Four generations of architecture

The survey by Gao et al. groups RAG work into naive, advanced and modular paradigms. Agentic RAG is newer and not part of the survey: a model chooses the steps.

GenerationWhat it addsEarns its place whenCosts
NaiveIndex, top-k retrieve, stuff the promptPrototype, small clean corpusLow precision, no rewrite or rerank
AdvancedPre-retrieval (rewrite, filters) and post-retrieval (rerank, compress)Most production useMore stages, more latency
ModularSwappable modules wired by a routerMany sources, need to test parts aloneOrchestration complexity
AgenticA model decides whether, where and when to retrieveMulti-step, multi-source questionsVariable latency and cost, loops

Boundaries between these names vary across papers and frameworks.

Source1 Retrieval-Augmented Generation for Large Language Models: A Survey

Diagram

Advanced RAG wraps the retrieve step

Diagram: Advanced RAG adds work before retrieval (rewrite, expand, filter) and after it (rerank, remove duplicates, compress), then generates.

Question

Pre-retrieval:
rewrite, expand, filter

Retrieve

Post-retrieval:
rerank, dedupe, compress

Generate

Diagram summary: Advanced RAG adds work before retrieval (rewrite, expand, filter) and after it (rerank, remove duplicates, compress), then generates. Naive RAG would go straight from the question to retrieve and generate.

This is the usual production baseline. The price is more stages to run, log and tune.

Source1 Retrieval-Augmented Generation for Large Language Models: A Survey

Diagram

Agentic RAG: a loop with a model in charge

Diagram: The agent plans, picks a tool such as vector search, SQL or web search, observes the result and loops back until it decides it can give a...

Question

Agent:
plan and decide

Pick a tool:
vector, SQL, web

Observe results

Final grounded answer

Diagram summary: The agent plans, picks a tool such as vector search, SQL or web search, observes the result and loops back until it decides it can give a final grounded answer.
  • Gain: handles multi-step questions over mixed sources.
  • Cost: unpredictable latency and spend, possible loops, harder to evaluate and secure.
  • Needs step limits, tracing and guardrails.

Diagram

HyDE: search with an imagined answer

Fixes: the question is worded unlike the documents.

Diagram: HyDE asks a model to write a hypothetical answer, embeds that text instead of the question, and uses it to find real documents near it in...

Question

LLM writes a
plausible answer

Embed the answer,
not the question

Vector search

Real documents

Diagram summary: HyDE asks a model to write a hypothetical answer, embeds that text instead of the question, and uses it to find real documents near it in embedding space.

The authors caution that the imagined text is made up and can contain errors. Risk: a wrong imagined answer pulls retrieval toward the wrong topic. Cost: one extra LLM call per query.

Source2 Precise Zero-Shot Dense Retrieval without Relevance Labels

Concept

Parent-child: match small, read big

Fixes: the best-matching chunk is too small to answer from.

  1. Embed small child chunks, so matching stays precise.
  2. When a child matches, look up its parent section.
  3. Give the model the parent text.
Diagram: The query matches small child chunks, the system fetches each child’s parent section, and the model reads the larger parent text.

Query

Match child chunks

Look up parent section

LLM reads the parent

Diagram summary: The query matches small child chunks, the system fetches each child’s parent section, and the model reads the larger parent text.

Risk: bigger prompts and more tokens. Several children can share one parent, so de-duplicate before building the prompt.

Diagram

GraphRAG: for questions about the whole corpus

Fixes: “summarise everything” questions about the whole corpus, which top-k similarity handles poorly. Walking a graph is also a common way to answer multi-hop questions, but the paper’s focus is corpus-wide sensemaking.

Diagram: An LLM extracts entities and relations into a graph, related entities are grouped into communities and summarised ahead of time, and a...

Documents

LLM extracts
entities, relations

Knowledge graph

Communities
and summaries

Read summaries
or traverse graph

Corpus-wide question

Answer

Diagram summary: An LLM extracts entities and relations into a graph, related entities are grouped into communities and summarised ahead of time, and a corpus-wide question is answered from those summaries or by walking the graph.

Edge et al. build the graph and community summaries with an LLM, then combine partial answers from summaries. Cost: the project README warns that indexing can be expensive. Risks: stale graph, extraction errors that spread.

Sources3 From Local to Global: A Graph RAG Approach to Query-Focused Summarization4 microsoft/graphrag

Diagram

Corrective RAG: grade before you trust

Fixes: retrieval that comes back irrelevant or empty while the system answers anyway.

Diagram: A lightweight evaluator scores the retrieved documents.

Good

Ambiguous

Bad

Retrieve

Grade relevance

Refine documents

Refine and add web

Rewrite and web search

Generate

Diagram summary: A lightweight evaluator scores the retrieved documents. Good ones are refined (irrelevant parts filtered out) before generation, ambiguous ones are refined and supplemented with web results, and bad ones trigger a rewrite and a web search before generation.

The paper uses the evaluator’s confidence to choose the action, and adds web search because a fixed corpus may return only weak documents. Cost: a grader on every query. Risk: the grader can be wrong.

Source5 Corrective Retrieval Augmented Generation

Concept

Self-RAG: the model critiques itself

Fixes: retrieving when it is not needed, and unchecked output.

  • The model is trained to emit special reflection tokens.
  • They let it decide when to retrieve and reflect on retrieved passages and on its own output.
  • Retrieval happens on demand, not a fixed number of passages every time.

Risk: it depends on a model trained for this, so it is not a setting you can switch on for any model.

Source6 Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection

Diagram

Adaptive RAG: spend effort where it is needed

Fixes: wasted cost and latency when most queries are easy.

Diagram: A router classifies each query and sends it to the cheapest strategy that can cope: no retrieval, one retrieval, or a multi-step loop.

simple, model knows it

factual lookup

complex

Query

Router: how hard?

No retrieval

Single-shot RAG

Multi-step RAG

Answer

Diagram summary: A router classifies each query and sends it to the cheapest strategy that can cope: no retrieval, one retrieval, or a multi-step loop.

Jeong et al. use a smaller language model as the complexity classifier. Risk: a misrouted hard query takes the weak path.

Source7 Adaptive-RAG: Learning to Adapt Retrieval-Augmented Large Language Models through Question Complexity

Concept

Variants by data shape

The failure sometimes sits in the data, not the search.

  • Multimodal RAG: images, tables, charts. Convert to text first (captions, OCR) or use multimodal embeddings. Watch table structure loss and OCR errors.
  • Text-to-SQL or structured RAG: send questions about numbers and records to SQL or an API. Guardrails: read-only access, limited schema, validated queries.
  • Conversational RAG: rewrite follow-ups into standalone queries and skip retrieval on chit-chat.

Compare

Failure, cost, risk in one table

VariantFixesAdded costMain risk
HybridExact-token missesSecond indexFusion tuning
HyDEPhrasing gapOne more LLM callBiased retrieval
Parent-childMissing contextLarger promptToken cost
GraphRAGCorpus-wide (and multi-hop)Heavy indexingStale graph, extraction errors
CorrectiveBad retrievalA graderGrader errors
AdaptiveCost on easy queriesA routerMisrouting
Self-RAGUnneeded retrievalA trained modelTraining dependency
AgenticMulti-step, multi-sourceMany callsLoops, unpredictability

Learn this as defaults: a failure points to a first tool to try, and every tool has a price.

Worked example

Worked example: pricing a grader

Scenario: a product-support assistant over a docs set that is often incomplete, because new features reach the docs weeks late. Users ask about them and get confident answers built from loosely related pages. Failure named: weak or empty retrieval with no fallback, so a web-search fallback is the point. Variant: Corrective RAG.

Illustrative assumptions, not measurements: 5,000 queries a day, one grader call per query with an 800-token input and a 20-token output. The grader here is an LLM prompted to grade relevance; the CRAG paper uses a small fine-tuned evaluator, which would be cheaper per call.

extra tokens per day=5,000×(800+20)=4,100,000\text{extra tokens per day} = 5{,}000 \times (800 + 20) = 4{,}100{,}000
  • Extra latency: one more model call on every query, before generation.
  • Risk to watch: the grader marks a good page as bad, or the reverse, and a bad grade triggers an outside web search.
  • Proof it worked: on a labelled set that includes questions the docs cannot answer, the share of answers judged unsupported, before and after.

Call prices vary by model, so convert the token count to money with your own provider’s current rate.

Source5 Corrective Retrieval Augmented Generation

Worked example

Worked example: when HyDE is, and is not, the answer

Scenario: a medicines-information bot. Patients type “stomach pain after tablets”; the leaflets say “gastrointestinal discomfort”.

  1. Likely failure: phrasing gap between question and documents.
  2. Simplest fix first: query rewriting or synonym expansion in the baseline.
  3. If a labelled set still shows misses: HyDE, at the price of one more call.
  4. Danger: a wrong imagined answer retrieves the wrong leaflet, and in medicine that matters. Keep citations on and test with unanswerable questions.

The lesson is the order of moves: cheapest fix, then measure, then the heavier tool.

Source2 Precise Zero-Shot Dense Retrieval without Relevance Labels

Concept

Common mistakes

  • Building the most elaborate version first. Every extra call costs latency and adds a failure mode.
  • Naming a variant without the failure it fixes.
  • Treating agentic RAG as the upgrade for everything. It is the last resort and needs step limits, tracing and guardrails.
  • Assuming every variant can be added without changing the model or the data.
  • Adding two or three variants at once, so you cannot tell which one helped.

Production systems are commonly advanced RAG with one or two additions chosen from evaluation results.

Check yourself

Check: which variant?

A user-manual assistant finds the right step every time, but answers stop mid-procedure because the matching chunk is one step of a ten-step procedure. Which variant fits, what does it cost, and what would you measure?

Answer

Parent-child retrieval: keep matching on small chunks but return the parent section. Cost: a larger prompt, plus de-duplicating parents shared by several children. Measure whether answers to procedure questions become complete (for example, the share judged complete by a reviewer on a labelled set).

Check yourself

Check: what changes, what it costs

(a) A chat assistant gets many messages like “thanks” and “hello” next to real policy questions, and a fixed top-k pipeline retrieves five passages for every message. What does Self-RAG’s on-demand retrieval change, and what is the price? (b) A teammate says: “Agentic RAG is just advanced RAG with a bigger model.” What is wrong?

Answer

(a) The model decides per message whether retrieval is needed, so chit-chat skips retrieval and its tokens and latency. The price is dependence on a model trained for reflection tokens. (b) The difference is who controls the steps. Advanced RAG follows fixed stages. Agentic RAG lets a model decide whether, where and when to retrieve in a loop, bringing variable latency and cost and the need for step limits and tracing.

Summary

Recap

  • Simplest thing that meets the bar, measure, add complexity for a named failure.
  • Advanced RAG is the usual baseline; modular and agentic add flexibility at a cost.
  • HyDE: phrasing gap. Parent-child: missing context. GraphRAG: corpus-wide. Corrective: bad retrieval. Adaptive: mixed difficulty. Self-RAG: needs a trained model.
  • In an interview: failure, variant, cost, risk, metric.

References

References & Sources (1 of 2)

  1. Retrieval-Augmented Generation for Large Language Models: A Survey (opens in a new tab)

    Yunfan Gao, Yun Xiong, Xinyu Gao, Kangxiang Jia, et al.2023Preprint

    Used for The review of RAG work organises it into Naive RAG, Advanced RAG and Modular RAG paradigms.

  2. Precise Zero-Shot Dense Retrieval without Relevance Labels (opens in a new tab)

    Luyu Gao, Xueguang Ma, Jimmy Lin, Jamie Callan2023ACL 2023Paper

    Used for HyDE has an instruction-following model write a hypothetical document, embeds it, and retrieves real documents near it; the generated text is unreal and may contain false details.

  3. From Local to Global: A Graph RAG Approach to Query-Focused Summarization (opens in a new tab)

    Darren Edge, Ha Trinh, Newman Cheng, Joshua Bradley, et al.2024Preprint

    Used for Graph RAG builds an entity knowledge graph with an LLM, pregenerates community summaries, and answers global questions by combining partial answers from them.

  4. microsoft/graphrag (opens in a new tab)

    Microsoft2026Repository

    Used for The README warns that GraphRAG indexing can be an expensive operation.

  5. Corrective Retrieval Augmented Generation (opens in a new tab)

    Shi-Qi Yan, Jia-Chen Gu, Yun Zhu, Zhen-Hua Ling2024Preprint

    Used for Corrective RAG uses a lightweight retrieval evaluator whose confidence triggers a retrieval action, with web search to extend weak results.

References

References & Sources (2 of 2)

  1. Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection (opens in a new tab)

    Akari Asai, Zeqiu Wu, Yizhong Wang, Avirup Sil, et al.2024ICLR 2024Paper

    Used for Self-RAG trains a language model with reflection tokens that decide when to retrieve and critique passages and its own output.

  2. Adaptive-RAG: Learning to Adapt Retrieval-Augmented Large Language Models through Question Complexity (opens in a new tab)

    Soyeong Jeong, Jinheon Baek, Sukmin Cho, Sung Ju Hwang, et al.2024NAACL 2024Paper

    Used for Adaptive-RAG uses a smaller language model to classify query complexity and choose among no retrieval, single-step and iterative retrieval.