Branched RAG: split the question, search in parallel, merge the answers

Branched RAG breaks a question into several sub-questions or readings, retrieves for each in parallel, then merges the results. Use it when one query cannot capture everything the user asked.

Branched RAG in 60 seconds

  • What: split one question into several branches, retrieve and answer each branch in parallel, then merge.
  • Why: a single query embeds a blend of ideas and often finds passages about only the strongest one.
  • Two kinds of branch: sub-questions (different parts of the task) and interpretations (different readings of an ambiguous question).
  • Merge rule: report disagreements between branches instead of averaging them into a vague answer.
  • Cost: more retrieval and model calls, but latency stays near one branch because branches run in parallel.

Where this type fits

Branched RAG is part of the multi-step family, with agentic, adaptive and speculative RAG. Unlike agentic RAG, its plan is fixed before retrieval starts, which makes it easier to predict and to run in parallel. It is closely related to the practices called multi-query retrieval and query decomposition. No single paper defines it, so this page describes the common pattern. See the overview of RAG types for the wider map.

The problem it solves

Search engines, whether keyword or vector, score each passage against one query. When the query mixes several ideas, the score favours passages that sit near the blend, or near whichever idea dominates the wording. Ask 'How do the refund rules differ between our UK and German stores, and which one has the longer window?' and the top results will probably be general refund pages. They will rarely hold both country policies side by side.

A second problem is ambiguity. 'What is our policy on contractors?' might mean employment law, security access, expense claims or procurement. A single retrieval picks one reading silently, usually the one that the words match best. The user then gets a confident answer to a question they did not ask.

Think of a librarian who is asked a two-part question. A hurried librarian grabs one book that mentions both topics a little. A careful one walks to two shelves, pulls the best book from each, and then puts them together on the desk. Branched RAG is the careful librarian, and it also asks the shelves in parallel so the user does not wait twice as long.

How it works

  • Decide whether to branch: a cheap check asks whether the question has several parts or several readings. If not, use a normal single pass.
  • Split: the model writes two to five branches. Each is a self-contained query, with any shared context repeated so it makes sense alone.
  • Retrieve per branch: each branch runs its own search, often with its own filters. Branches run in parallel.
  • Answer per branch: each branch gets a small answer from its own passages, with citations. Keeping answers separate prevents one branch from drowning out another.
  • Merge: a final step combines the branch answers, notes where they agree, and states where they conflict or where a branch found nothing.
  • Cite and return: the merged answer carries the citations from each branch.
Branches run side by side, and the merge step is where agreement and conflict become visible.

The two kinds of branch behave differently. Sub-question branches cover different parts of the task, so the merge step is mostly assembly: put the parts together in a logical order. Interpretation branches cover different readings of the same question, so the merge step must decide what to do. It can answer all readings briefly, ask the user which they meant, or pick the most likely one and say so.

Keeping the branches independent is the core design choice. If branch B could see branch A's passages, it would be pulled toward the same documents, and you would lose the coverage that justified the extra work. The merge step is the only place where branches meet.

A worked example

A support analyst at Acme Retail asks: 'How do refund rules differ between our UK and German stores, and which has the longer window?'

  • Split: the model writes three branches. A: 'UK store refund policy and return window'. B: 'German store refund policy and return window'. C: 'Differences between UK and German consumer return rules that affect Acme'.
  • Retrieve A: top passages come from the UK policy page. They say 30 days for change of mind, 6 months for faulty goods.
  • Retrieve B: top passages come from the German policy page. They say 14 days for change of mind online, and 2 years for faulty goods.
  • Retrieve C: a legal note says online orders in the German market follow a statutory cancellation right, so the store policy cannot go below it.
  • Branch answers: each branch writes two sentences with a citation.
  • Merge: the merger compares the windows. For change of mind, the UK window (30 days) is longer than the German one (14 days). For faulty goods, the German window (2 years) is longer than the UK one (6 months).
  • Output: 'It depends on the type of return. The UK is longer for change of mind (30 days against 14). Germany is longer for faulty goods (2 years against 6 months). Sources: UK policy, German policy, legal note.' The merge step has caught that the word 'longer' has no single answer.
What the splitter returns for this question (illustrative) (json)
{
  'kind': 'sub_questions',
  'branches': [
    {'id': 'A', 'query': 'UK store refund policy and return window', 'filters': {'region': 'UK'}},
    {'id': 'B', 'query': 'German store refund policy and return window', 'filters': {'region': 'DE'}},
    {'id': 'C', 'query': 'UK and German consumer return rules affecting Acme', 'filters': {'type': 'legal'}}
  ]
}

Building it

The sketch below splits, retrieves in parallel with a timeout per branch, answers each branch alone, and merges. Embedding, the store and the model are placeholders. Note the cap on branch count, which keeps cost bounded, and the way a failed branch is reported rather than hidden.

Branch, retrieve in parallel, merge (illustrative) (python)
from concurrent.futures import ThreadPoolExecutor, TimeoutError as FutureTimeout

MAX_BRANCHES = 4       # more branches means more cost and a harder merge
BRANCH_TIMEOUT_S = 8   # one slow branch must not hold up the whole request

# Placeholders: llm.generate, embed and vector_store stand in for real components.
def split(question):
    out = llm.generate_json(split_prompt(question, max_branches=MAX_BRANCHES))
    branches = out['branches'][:MAX_BRANCHES]   # enforce the cap even if the model ignores it
    return branches or [{'id': 'A', 'query': question, 'filters': {}}]  # fall back to one branch

def run_branch(branch, user):
    # Filters include the user's access rights so each branch respects permissions.
    passages = vector_store.search(embed(branch['query']), top_k=4,
                                   filters={**branch['filters'], 'acl': user.groups})
    if not passages:
        return {'id': branch['id'], 'answer': None, 'sources': [], 'note': 'nothing found'}
    # Each branch answers alone so it cannot be pulled toward another branch's documents.
    ans = llm.generate(branch_prompt(branch['query'], passages))
    return {'id': branch['id'], 'answer': ans.text, 'sources': [p.id for p in passages]}

def branched_rag(question, user):
    branches = split(question)
    results = []
    with ThreadPoolExecutor(max_workers=len(branches)) as pool:
        futures = {b['id']: pool.submit(run_branch, b, user) for b in branches}
        for bid, fut in futures.items():
            try:
                results.append(fut.result(timeout=BRANCH_TIMEOUT_S))
            except FutureTimeout:
                # Report the gap instead of silently answering from fewer branches.
                results.append({'id': bid, 'answer': None, 'sources': [], 'note': 'timed out'})
    merged = llm.generate(merge_prompt(question, results))
    return {'answer': merged.text, 'branches': results}
A merge prompt that keeps disagreement visible (illustrative) (python)
def merge_prompt(question, results):
    parts = '\n'.join(
        f"[{r['id']}] {r['answer'] or '(no answer: ' + r['note'] + ')'} sources={r['sources']}"
        for r in results)
    return (
        'Answer the question using only the branch answers below.\n'
        'If branches disagree, say so and cite both. Do not average them.\n'
        'If a branch has no answer, say what is missing.\n\n'
        f'Question: {question}\n\nBranches:\n{parts}')

Design decisions

  • Branch cap: default to a maximum of four branches. Beyond that, merging gets noisy and cost rises faster than quality.
  • Parallel execution: run branches concurrently with a per-branch timeout. Total latency is then roughly the slowest branch plus the split and merge calls, not the sum of the branches.
  • Shared index, separate filters: branches usually query one index with different metadata filters, which avoids duplicate storage. Use separate indexes only when the sources differ in kind.
  • Rate limits and cost: a request now fans out into several searches and model calls. Budget for the multiplier and apply rate limits per user rather than per branch. Cache branch results where queries repeat.
  • Access control: apply the user's permissions to every branch. A branch generated from a clever rewrite must not reach documents the original question could not.
  • Failure handling: a failed or empty branch is reported in the merged answer. Do not drop it silently, because the user would read a partial answer as a full one.
  • Routing: put a cheap classifier in front so simple questions skip branching. Splitting every question wastes money and sometimes lowers quality.

Measuring it

  • Coverage: for questions with known parts, the share of required parts that appear in the final answer. This is the main benefit, so measure it first.
  • Branch precision: for each branch, the share of retrieved passages that a reviewer marks relevant to that branch's query. Poor splits show up here.
  • Redundancy: the overlap between passages retrieved by different branches. High overlap means the branches are near duplicates and you are paying for nothing.
  • Conflict handling: on a test set with deliberately conflicting sources, the share of answers that state the conflict instead of choosing silently.
  • Cost multiplier and latency: model calls and tokens per request against a single-pass baseline, plus the 95th percentile of end-to-end time.
Measuring coverage of required parts (illustrative) (python)
def coverage(answer_text, required_facts):
    # required_facts: strings a correct answer must contain, written by a reviewer.
    # grader.contains is a placeholder for a human label or a checked grader model.
    hits = sum(1 for fact in required_facts if grader.contains(answer_text, fact))
    return hits / len(required_facts)

When to use it, and when not to

SituationUse this type?Why
Comparison questions across regions, products or periodsYesEach side needs its own retrieval or the better-documented side dominates.
Ambiguous questions with several plausible readingsYesBranches cover each reading and the merge can ask the user to choose.
Questions with a single clear topicNoOne query already finds the right passages, and branching adds cost.
Questions where step two depends on the result of step oneNoBranches are planned up front. Use agentic RAG for dependent steps.
Tight cost limits at high volumeOnly with a routerThe fan-out multiplies calls, so send only suitable questions to it.
Compliance answers that need all applicable rules listedYesSeparate branches per rule set make gaps visible.

Trade-offs

DimensionEffectWhat to do about it
QualityBetter coverage on multi-part and ambiguous questionsMeasure coverage on a test set and cap the number of branches.
LatencyClose to one branch plus split and merge, if run in parallelSet per-branch timeouts and run branches concurrently.
CostSeveral searches and model calls per request, a multiple of single passRoute simple questions away and cache repeated branch queries.
ComplexityA splitter, a merger and concurrency to maintainKeep branch format fixed and test the merger with conflicting inputs.
Failure modesBad splits, near duplicate branches, a merge that hides conflicts, silent branch failuresLog every branch, report gaps and test the merge prompt on disagreement.

Agentic RAG plans one step at a time and can react to what it finds, while branched RAG plans all branches before retrieval starts. Branching is cheaper to predict and easier to parallelise, but it cannot handle a question where the second search depends on the first answer. Advanced RAG often includes query rewriting, which produces one better query. Branched RAG produces several queries and keeps their results apart.

HyDE also changes the query, but it writes one imagined answer to search with, not several separate questions. The two can be combined: a branch may use a hypothetical answer as its search text. Adaptive RAG can decide when a question deserves branching at all.

What this means for your role

Common mistakes

Further reading

Branched RAG trades extra calls for coverage. It works best when the question really has parts or readings, the branches stay independent, and the merge step is honest about what each branch found.

Search topics

↑↓ to move · Enter to open · Esc to close