---
title: "Advanced RAG: rewrite, route, filter, rerank, and compress"
chapter: "13"
---

# Advanced RAG: rewrite, route, filter, rerank, and compress

Advanced RAG improves one measured bottleneck at a time. Complexity without an
evaluation gain is technical debt.

## Query transformation

Rewrite conversational questions into standalone search queries, expand
acronyms, or create multiple subqueries. Preserve original intent and protected
identifiers. Evaluate rewrite drift.

## Query routing

Route policy questions, account lookups, SQL analytics, web freshness, and
document search to different retrievers. Use deterministic rules where the
intent is obvious and a classifier only where measured.

## Hybrid and rerank

Fuse lexical and semantic candidates, then apply a cross-encoder or
LLM-assisted reranker. Keep candidate/relevance traces. A reranker must never
override authorization filters.

## Contextual compression

Extract relevant sentences or summarize long evidence before generation.
Compression can remove qualifications, dates, or exceptions, so retain a link
to original chunks and evaluate claim support.

## Corrective and agentic RAG

A corrective flow evaluates retrieval quality and tries a bounded fallback.
Agentic retrieval lets a model choose sources iteratively. Bound query count,
time, token budget, allowed corpora, and stop conditions. More searches can
increase noise and exposure.

## Graph and relational retrieval

Use SQL or graph queries for exact relationships and vector search for fuzzy
language. An agent can call both, but application code defines schemas,
parameterization, timeouts, and row-level authorization.

## Feynman check

Advanced RAG is a research assistant who can rewrite the question, visit
specialized shelves, and rank notes—but has a timer, permission badge, and
audit trail.
