RAG
Advanced 15 min read RAG

Advanced RAG Patterns

Patterns for hard retrieval problems

Beyond basic RAG: multi-hop chains, query rewriting, self-reflection, and structured data retrieval. Each pattern addresses a specific failure class — know which problem you're solving before you adopt one.

advanced RAGquery rewritingmulti-hopself-reflectionhypothetical questionsgraph RAGstructured retrieval
Before we start

What you will learn

  • Match advanced patterns to failure classes
  • Implement query rewriting and routing
  • Evaluate whether an advanced pattern earned its complexity
Introduction

What is this?

Advanced RAG layers solve specific weaknesses: query rewriting rescues vague questions; multi-hop chains split questions that need several documents; self-reflection re-retrieves when answers choke; structured/graph memory handles relational facts. Every pattern adds latency and surface — apply it only where its named failure actually bites.

Motivation

Why do you need it?

  • Vague user questions genuinely cost retrieval recall.
  • Multi-hop answers need multiple retrievals, not one top-k.
  • Self-reflection catches its own low-confident generations.
  • Structured needs (numbers, joins, people) beat pure text retrieval.
Think about it

Mental model

Imagine

A toolbox of specialty drills

Think of

Advanced RAG

Basic RAG is the standard drill. Query rewriting is the countersink, multi-hop the extended bit, reflection the re-measure, structured retrieval the masonry bit. Buying all of them 'because they exist' adds weight; you pick the drill your wall actually needs.

Mechanics

How it works

  • Query rewriting: rephrase/expand the question into better retrieval terms.
  • Routing: judge whether a query needs text, SQL, or multimodality — send to the right vector.
  • Multi-hop: chain retrieval+generation over intermediate results.
  • Self-reflection: generation produces sub-questions; retrieval re-runs to close gaps.
  • Structured/graph: tables and relations retrieved alongside text to answer joins.

Advanced pattern routing.

Query
Rewrite
Retrieve
Check
Re-retrieve
Answer
Real world

In production

  • Data-dense products pair text RAG with SQL retrieval for exact numbers.
  • Cross-doc research bots rewrite vague probes before search.
  • Support escalation bots self-reflect: low-confidence → more context → re-answer.
Guidelines

Best practices

  • Adopt one pattern per measured weakness, and gate it on eval lift.
  • Keep simple RAG as the baseline in every eval.
  • Make pattern usage observable; A/B survivors stick.
  • Watch latency: every rewrite/reflection loop multiplies calls.
Watch out

Common mistakes

  • Building the whole toolbox 'for production' before any problem exists.
  • Rewriting queries that were already clear — adding drift.
  • Unbounded self-reflection loops blowing latency and cost.
Root cause analysis

Common issues

Error
Reflection loop runs hot
Root cause

Coverage check too strict

Fix

Cap loop depth, loosen thresholds, force fallback answer.

Error
Rewriting garbles precise queries
Root cause

Rewrite model too aggressive

Fix

Route only low-confidence/ambiguous queries to rewriting.

When things break

Debugging tips

  • Pattern doesn't help → confirm the actual failure class (measure with stage metrics).
  • Rewrite hurt → the original query was precise; log & A/B.
  • Multi-hop answers worse than single-prompt → the intermediate hops lose grounding; verify.
Interviews

Interview checkpoint

Test yourself

Quick quiz

0/2
1

Multi-hop RAG is for…

2

Every RAG system should ship query rewriting from day one.

Go deeper

Official documentation