Lesson 9.7advanced3 h 40 min

Advanced RAG patterns

Grading, hierarchies, graphs, agents and structured data

Retrieve-top-five-and-answer fails in predictable ways: it trusts irrelevant chunks, cannot see themes that span a corpus, cannot chain facts, and cannot read tables, databases or slides. Each failure has a named pattern — Self-RAG and corrective RAG, RAPTOR, GraphRAG, agentic and multi-hop retrieval, text-to-SQL, multimodal RAG — and each costs something. This lesson maps symptom to pattern so you reach for complexity only when a measurement says you need it, and it is your first real contact with agent loops (10.3 Reasoning and planning for agents).

You'll be able to

  • Map RAG failure symptoms to the pattern that targets them
  • Explain Self-RAG and corrective RAG as grade-then-generate loops and implement a lightweight version
  • Describe RAPTOR and GraphRAG indexing and the global questions they answer
  • Design an agentic, multi-hop retrieval loop with routing and budgets
  • Handle structured and visual data with text-to-SQL, table tools and multimodal retrieval

Key ideas

  1. Diagnose before adding complexity: each naive-RAG symptom maps to a specific pattern with a specific cost.
  2. Self-RAG and corrective RAG grade retrieved chunks before generating and fall back (rewrite, search elsewhere) when too few pass — the adaptive-RAG loop.
  3. RAPTOR clusters and recursively summarizes chunks into a tree so thematic questions retrieve summaries while detail questions retrieve leaves.
Show 4 more key ideas
  1. GraphRAG extracts an entity–relation graph, detects communities and summarizes them; global questions become a map–reduce over community summaries, at high indexing cost.
  2. Agentic RAG wraps retrieval-as-a-tool in a plan–retrieve–read–decide loop with routing and budgets; multi-hop questions need chained, dependent queries.
  3. Text-to-SQL needs schema linking, a semantic layer, read-only execution and verification; pandas tools often beat SQL generation for small tables.
  4. Multimodal RAG uses captions, joint image–text embeddings or page-image retrieval; long-context models shift retrieval from chunks toward whole documents; agent memory is RAG over history.

Suggested path through this lesson