Adaptive RAG: match the effort to the question
Adaptive RAG classifies each question by complexity and picks no retrieval, one search, or an iterative search. Use it when your traffic mixes easy and hard questions and cost matters.
Adaptive RAG in 60 seconds
- What: a classifier predicts how complex a question is and routes it to one of several strategies.
- Three routes: answer directly with no retrieval, retrieve once, or retrieve in several steps.
- Why: simple questions stay cheap and fast, while hard questions get the effort they need.
- Key part: the classifier, usually a smaller language model, whose accuracy decides the quality of the whole system.
- Risk: a wrong route either wastes money (over-investing) or gives a weak answer (under-investing).
Where this type fits
Adaptive RAG belongs to the multi-step family, which also holds agentic, branched, and speculative retrieval. It is the router of the group: it chooses how much of the multi-step machinery to use for each request. See the overview of RAG types for the family map.
The problem it solves
A single strategy rarely suits all questions. If every request goes through a heavy multi-step pipeline, simple ones such as what is the office wifi name? waste time and tokens. If every request goes through one search, hard ones such as which of our two vendors had the larger price increase between 2022 and 2024? fail, because no single passage holds the answer and the first search cannot know what to look for next.
Think of a hospital front desk. Someone with a splinter does not need a specialist team, and someone with a complex condition should not be handled at the desk. A triage nurse sorts people quickly, so that each gets the right level of care. Adaptive RAG is the triage nurse for questions.
Without triage you must pick one level for everyone. Pick too low and hard questions get poor answers. Pick too high and the bill and the wait grow for the majority that never needed it. Routing lets you tune the average cost while protecting quality on the hard tail.
How it works
The approach comes from Adaptive-RAG: Learning to Adapt Retrieval-Augmented Large Language Models through Question Complexity (Jeong et al., 2024, NAACL 2024). The paper describes a smaller language model acting as a classifier. It predicts the complexity of the incoming query and selects among three strategies: no retrieval, single-step retrieval, and iterative multi-step retrieval.
- Classify: the classifier reads the question and outputs a label: simple, moderate, or complex.
- Route simple: the model answers directly from its own knowledge, with no search.
- Route moderate: one retrieval, then one answer, as in a single-pass pipeline.
- Route complex: an iterative loop. Retrieve, reason about what is still missing, form the next query, retrieve again, and stop when the evidence is enough or a step limit is reached.
- Answer: the chosen path returns an answer, and the system logs the route and outcome.
- Learn: logs of routes and outcomes become new training data to improve the classifier over time.
The most interesting detail is how the classifier gets its training labels. The paper reports that labels were collected automatically, from the actual outcomes of the models and from biases in the datasets, instead of being written by hand. In plain terms: if the direct answer was right, the question can be labelled simple. If one retrieval fixed it, moderate. If only the iterative route worked, complex. This means you can bootstrap a router from your own logs.
Some descriptions also present adaptive RAG as a system that learns from experience over time, adjusting its behaviour as it sees what works. That fits the feedback arrow in the diagram: routing improves when outcomes flow back into training.
A practical point is that the three labels are about the evidence a question needs, not about how clever it sounds. A short question can be complex if its answer is spread across documents, and a long one can be simple if it only asks the model to rewrite text. A good classifier learns this from outcomes. A poor one learns surface cues such as length, which is why it should be tested on real traffic and not on tidy examples.
A worked example
Acme runs an assistant for sales staff. Three questions arrive.
- Q1: Translate this email greeting into French. Classifier output: simple, confidence 0.97. No retrieval. The model answers in about one second.
- Q2: What is the discount limit for the Starter plan? Classifier output: moderate, confidence 0.88. One search returns the pricing policy, and the model quotes the 10 percent limit with a citation.
- Q3: Which region had the larger drop in renewals last quarter, and what did the account notes say about why? Classifier output: complex, confidence 0.81.
- Q3, step 1: search the sales dashboard summaries. Result: the Northern region dropped 6 points, the Southern region 2 points. Missing: the reasons.
- Q3, step 2: the model forms a new query, Northern region renewal churn reasons last quarter, and searches account notes. Result: three notes mention a competitor's price cut.
- Q3, step 3: the model judges the evidence enough and answers: Northern dropped more, and notes point to a competitor price cut. Three steps, two searches, within the step limit of four.
[
{ "q": "Translate this email greeting into French", "route": "direct", "confidence": 0.97, "searches": 0 },
{ "q": "Discount limit for the Starter plan", "route": "single", "confidence": 0.88, "searches": 1 },
{ "q": "Which region had the larger drop in renewals and why", "route": "iterative", "confidence": 0.81, "searches": 2 }
]Building it
# Placeholders: small_llm, llm, embed(), vector_store. Replace with your own.
MAX_STEPS = 4 # hard cap on the iterative loop
MIN_CONFIDENCE = 0.6 # below this, take the safer middle route
CLASSIFY_PROMPT = '''Classify the question by how much lookup it needs.
A = answerable without documents
B = needs one search
C = needs several searches that depend on each other
Reply as: LABEL confidence(0-1)
Question: {q}'''
def classify(question):
raw = small_llm.generate(CLASSIFY_PROMPT.format(q=question)) # placeholder
try:
label, conf = raw.split()
return label, float(conf)
except ValueError:
return 'B', 0.0 # unreadable output: use the middle route
def single_step(question):
docs = vector_store.search(embed(question), k=5) # placeholder
ctx = '\n'.join(d.text for d in docs)
return llm.generate('Answer from the context. Cite it.\n' + ctx + '\nQ: ' + question)
def iterative(question):
notes, query = [], question
for _ in range(MAX_STEPS):
docs = vector_store.search(embed(query), k=4)
notes += [d.text for d in docs]
# Ask what is still missing; stop when nothing is.
nxt = llm.generate('Question: ' + question + '\nNotes:\n' + '\n'.join(notes)
+ '\nIf the notes suffice reply DONE, else give the next search query.')
if nxt.strip() == 'DONE':
break
query = nxt.strip()
return llm.generate('Answer from the notes. Cite them.\n' + '\n'.join(notes) + '\nQ: ' + question)
def answer(question):
label, conf = classify(question)
if conf < MIN_CONFIDENCE:
label = 'B' # when unsure, a single search is the safe default
route = {'A': lambda q: llm.generate(q), 'B': single_step, 'C': iterative}[label]
result = route(question)
log_route(question, label, conf) # placeholder: keep data to retrain the router
return resultTwo safeguards matter. The confidence floor sends unsure cases to the middle route, which is rarely terrible. And the step cap guarantees the iterative branch ends.
Design decisions
- Classifier size: use a small, fast model so that routing adds little latency and cost. If the router costs as much as a search, you have saved nothing.
- Default route: make single-step retrieval the fallback for low confidence or errors. It is the safest middle position.
- Number of routes: start with three, as in the paper. Add more only when logs show a distinct class of question that none of them serves.
- Step and cost budgets: cap iterations, tokens, and wall-clock time for the complex route, and return a best-effort answer with a note when a cap is hit.
- Training data: log the route, the outcome, and a quality signal for each request. Retrain on a schedule and keep a fixed test set to catch regressions.
- Access control: apply permission filters on every search in every route, including each iteration.
- Observability: trace the route chosen and the steps taken. Without traces, a bad answer cannot be traced to a bad routing decision.
Measuring it
- Router accuracy: compare predicted labels to labels derived from running all three routes on a sample and picking the cheapest one that answers correctly.
- Confusion pattern: count under-routing (complex sent to simple) and over-routing (simple sent to complex) separately, since they cost different things.
- Answer quality by route: correctness and faithfulness for each route, to see where quality is lost.
- Cost and latency per route: median and 95th percentile, plus the weighted average using your actual traffic mix.
- Savings against always-complex: the average cost difference against sending everything to the iterative route, at equal or similar answer quality.
from collections import Counter
def confusion(examples):
# examples: (question, true_label) where true_label is A, B or C.
counts = Counter()
for question, true_label in examples:
predicted, _ = classify(question)
counts[(true_label, predicted)] += 1
under = sum(n for (t, p), n in counts.items() if p < t) # A<B<C order
over = sum(n for (t, p), n in counts.items() if p > t)
return {'under_routed': under, 'over_routed': over, 'table': dict(counts)}When to use it, and when not to
| Situation | Use this type? | Why |
|---|---|---|
| Traffic mixes small talk, lookups, and hard research questions | Yes | Routing gives each class the right effort and keeps average cost down. |
| Most questions are hard | Probably not | The router will send nearly everything to the costly route, so the saving is small. |
| Most questions are simple lookups | Not yet | A single-pass pipeline is cheaper to build and run. |
| You have logs of past questions and outcomes | Yes | They provide training labels for the router. |
| You have no traffic data and little time | Use rules first | Simple keyword or length rules can approximate routing until you have data. |
| Wrong routing is costly and hard to detect | With care | Add confidence floors and monitor under-routing closely. |
Trade-offs
| Dimension | Effect | What to do about it |
|---|---|---|
| Quality | Hard questions get iterative effort; easy ones avoid needless noise. | Track quality per route and fix the weakest one. |
| Latency | Adds a classification step, but removes search time for easy questions. | Use a small classifier and measure the net effect. |
| Cost | Lower on average if most traffic is easy; higher if routing errs upward. | Watch over-routing and the traffic mix. |
| Complexity | A classifier, three pipelines, and a retraining loop. | Start with rules and graduate to a model. |
| Failure modes | Misrouting; a stale classifier after the content or users change. | Log routes, set confidence floors, and retrain on a schedule. |
Compared with related types
Self-RAG also decides whether to retrieve, but it decides during writing and judges its own output. Adaptive RAG decides before any work starts and uses a separate classifier. The two can be combined: route first, then self-check on the routes that retrieve.
Agentic RAG is what the complex route often turns into, with planning and several tools. Simple RAG is the middle route. Adaptive RAG can be seen as the layer that chooses between them, which is why it is a natural next step once you run both.
What this means for your role
Common mistakes
Further reading
- Adaptive-RAG: Learning to Adapt Retrieval-Augmented Large Language Models through Question Complexity by Jeong et al., 2024, the paper behind the classifier-and-routes design.
- Gateway, cost and reliability for budgets, routing, and fallbacks across model calls.
- Orchestrator types for how multi-step flows are controlled.
Adaptive RAG spends effort where it pays. Begin with simple rules, log everything, and move to a learned router once the logs can teach it.