person asks “When is that this coverage efficient?”. The retrieval returns 5 candidate row home windows, all of that are handed to the LLM with one immediate. LLM reads all 5 and extracts the identical date that the primary candidate already had. Chunks 2-5 have been paragraphs about signatures, footnotes, and historic dates. Nothing was paid. Submit your prime 1 first, ask the LLM if it is ok, and cease if they are saying sure. Steady feed reduces token price by 80% for this class of questions. The remainder of the article catalogs the place the successful streak lies, whether or not one name for all Ok is the right default, and the way the query parser is dispatched between the 2.
This text is a associated article Enterprise doc intelligencewhose philosophy is defined in Amplify the Professional, a collection that builds enterprise RAGs from 4 bricks: doc parsing, query parsing, search, and technology. It sits between Articles 8 (Era) and 9 (Upgrading mini-RAG) and revolves round one particular determination: How do you feed the highest Ok searched candidates into the technology brick?. The reply for many pipelines is: “All Ok directly”. On this article, we’ll talk about the second regime (Sequentially, from prime 1) and point out when every gained.
The straightforward baseline advocated by this text
Naive RAG Ship batch by default. Search returns the top 5, LLM retrieves all 5 and returns the answer. This works and is the right choice for difficult questions (comparisons, lists). But on all other questions there is a price to pay for silence. That is, simple fact-based questions for which the top 1 already has an answer. This article describes the second regime and question-by-question dispatch.

📓 The executable notebook for this article is on GitHub: doc-intel/notebooks-vol1. Submit the identical questions for each batch and sequential technology, with a token price per query and two sufficiency booleans (answer_found, complete_answer_found) Cease the loop and recreate the dispatch desk in your machine.

1. Two programs for supplying TOP Ok to the subsequent technology
The search produces an ordered top-Ok. There are two methods to produce it, and the prices differ broadly.
1.1 Mounted Prime Ok Pipeline and What It Wastes
The default sample for many RAG tutorials appears like this:
top_k = retrieval(query, okay=5)
reply = technology(query, top_k)
Every query is carried out in two steps. The price of the token is roughly generation_cost(query + 5 context chunks). Latency is roughly Acquisition + 1 LLM name. And LLM handles 5 chunks simply tremendous, even when prime 1 is already sufficient and chunks 2..5 add zero data.
Particularly: customers ask “When is that this coverage efficient?”. The search returns a 5-row window. Right here, the key phrase "efficient" will likely be displayed. The primary one is the reply (“Efficient from January 1, 2026”). Chunk 2..5 is a paragraph about signatures, footnotes, and historic efficient dates for previous insurance policies. LLM reads all 5 and extracts the date that’s the identical as the primary. For a corpus of 1 doc, the price is rounding error. For a corpus of fifty,000 insurance coverage insurance policies, this corresponds to an actual quantity per thirty days.
1.2 Sequential: prime one first, sufficiency predicate, escalation as needed
The sequential technique treats the Ok candidates as an ordered listing and asks the producing brick to confirm sufficiency at every step.
for i, candidate in enumerate(top_k):
reply = technology(query, [candidate])
if reply.answer_found and reply.complete_answer_found:
break
Adequacy indicators exist inside typed contracts launched in Article 8A. of AnswerWithEvidence Schema uncovered answer_found (Did the knowledge in query exist for this candidate?) and complete_answer_found (Did the reply exist as an entire and never in fragments?). The loop reads these fields moderately than customized heuristics.
in Efficient date Above instance: Era is carried out as soon as for the highest 1 candidate and LLM returns a return worth. answer_found = True, complete_answer_found = Truethe loop ends. Tokens consumed: Era price (query + 1 chunk of context). In different phrases 1/5 A part of the batch price for this query in a pipeline that processes 1000’s of comparable searches per day.
1.3 Batch: Ship all Ok directly and let LLM arbitrate.
Batch mode retains the default habits. A single LLM name shows all Ok candidates and produces a single reply for the enter. This case is constructed round three query varieties that we analyze sequentially.
- listing questions: “Please listing all exclusions from this contract.”. The reply is each Matching candidates as a substitute of first. Sequential stops at prime 1 (one exclusion discovered) and misses the opposite 4. Batch is the one right mode.
- Comparability questions: “Are your insurance coverage premiums increased than final yr?”. To get a solution, each candidates (this yr and final yr) should be on the identical name in order that the LLM can evaluate them. Sequential extracts every individually and loses the be a part of.
- Getting a decent rating: If the relevance scores of the highest Ok candidates are inside 5% of one another, search can not reliably promote the highest 1 place to the highest. Batch permits LLMs to arbitrate with full proof.
Value evaluation: Batch is all the time generation_cost(query + Ok context chunks) one time. sequential funds Era price (query + 1 chunk of context) Within the simple case (prime 1 is sufficient), Era price (query + 1 chunk) Worst case × Ok (all candidates are inadequate). For a typical enterprise corpus with Ok = 5, sequential is on common cheaper for truth retrieval (about 80% of normal visitors) and costly for lists/comparisons (about 20%).
2. Dispatch selections: per query, not per pipeline
A clear structure doesn’t choose batch or sequential globally. Choose for every query utilizing the parsed question_df Strains from Bricks 2. The form of the query, the decomposition sample, and the intent decide the selection.

dispatcher reads question_df.answer_shape and question_df.decomposition And the foundation. Naive RAG has no parsed inquiries to learn, so there isn’t a method to make this distinction.
The identical routing desk is maintained throughout sectors and professions. Totally different domains have the identical form sample and ship the identical steady/batch determination move from it.

In each row, consecutive columns are single typed values (quantity, date, boolean) and profit from a top-one cease. A batch column is a listing or a comparability that requires all Ok candidates to be displayed directly. The dispatcher’s desk covers all 5 sectors with the identical logic.
3. Sufficiency indicators
Sequential mode depends on one factor. It is a technology brick that reviews whether or not the candidates it reads are enough. Listed below are the indicators and the principles to cease the loop.
3.1 The place sufficiency indicators exist in typed contracts
Sequential mode solely works if producing bricks are potential. self-report Does the candidate you simply checked out comprise the reply? Article 8A typed contracts make this potential.
class AnswerWithEvidence(BaseModel):
worth: Any
proof: listing[Span]
answer_found: bool
complete_answer_found: bool
confidence: float = Subject(ge=0, le=1)
caveats: listing[str] = []
Studying sequential loops answer_found and complete_answer_foundnot confidence floats or customized heuristics. A transparent separation of the 2 boolean values (from Article 8:3, sample 4) makes the loop deterministic. discovered + incomplete say “Proceed to the subsequent candidate”; Discovered + Accomplished say “Cease”; not discovered say “Ought to I proceed with Ok or quit?”.
Belief float enforces thresholds (e.g. “Cease at 0.8”), which can drift from mannequin to mannequin relying on its threshold. Two Boolean values don’t drift.

3.2 Bounded iteration: have to cease even when sequential
Sequential loops have three exits as a substitute of 1.
- enough:
answer_found and complete_answer_foundIn regards to the candidates. Please cease and ship me a solution. - Exhausted: I’ve checked all Ok candidates, however there are usually not sufficient. Cease, return
answer_found = False(First-class reply handed by validators). - funds: Token or time funds set by the dispatcher. Helpful when the corpus is giant and a runaway steady loop can exceed the higher restrict. Bounded Iteration M4 (Loop Engineering) Similar form as identify.
A easy sequential implementation would skip the third exit and burn the token eternally in edge circumstances. Within the collection model, you set a funds prematurely and the dispatcher data the funds on a call-by-call foundation.
4. Prices and collection endings
Two regimes, two price profiles, and one boundary that the collection don’t intersect.
4.1 Particular price comparability for 100 query batches
To make the trade-offs a actuality, this is an outline of business insurance coverage Q&A workloads.
- 100 questions/day, Ok = 5, common chunk measurement = 600 tokens.
- batch baseline:100× Era price (Query + 5×600 tokens) = As much as 330,000 enter tokens are generated per day.
- Sequential (80% prime 1 is sufficient):80× Era price (query + 600) +20× Era price (query + 5×600) (worst case of 20% advanced questions) = as much as 115,000 enter tokens per day.
The ratio is Save 65% on enter tokens for technology Relating to this workload. The precise ratio relies on the straightforward query ratio and chunk measurement. As a normal rule, as soon as a typed contract is established, sequential turns into a budget default. Batches are reserved for required query varieties.
4.2 The agent’s temptation and the top of the collection
A pure subsequent step is to let the LLM resolve for every query whether or not to batch or sequentially (agent dispatch). This collection ends earlier than we attain this level. The dispatchers in part 2 are: deterministic dispatcher (one of many three approaches listed in Article 6C), it’s not. LLM determination. The reason being the identical that applies to the whole collection: audit. Similar questions on the identical day needs to be routed the identical manner. LLM, which reschedules dispatch on each name, can not present that assure.
In order for you a extra highly effective agent loop (LLM chooses which candidates to look at, in what order, and to what extent), the bigger article on adaptive RAG loops is for you. On this article, we hold the vary deterministic. sequential and batch A choice is made by the parsed query.
5. Selections belong to the parser, not the LLM
A set Prime Ok+ batch pipeline is an effective default for query varieties the place all candidates are necessary. That is the false default for truth searches that make up most company visitors. Two elements are added to this collection: Typed sufficiency indicators (answer_found, complete_answer_found) Mix Clause 8A with Part 2 Dispatch Desk. Combining these, the technology brick will cease after the primary candidate if enough, and course of all Ok if the query sort requires it. This determination is made by the parser, not LLM, and the audit path stays intact.
6. Additional studying and data sources
Sequential/batch selections sit on the boundary between search and technology. Articles that make up every facet:

