Multi-stage Pipeline Design

Sequential, parallel, routed: decomposition buys debuggability — and costs latency, money and compounding errors.

Mastery—
Quiz
—
Exercises
—
Challenge
—

Why this matters

One giant prompt that does everything is simple to build and impossible to debug. A of focused stages — normalize, extract, classify, collect evidence, verify — lets you measure and improve each part separately.

But every stage adds latency and cost, and errors compound: five stages at 95% each are ≈77% end-to-end if errors are independent (and correlated errors on noisy calls make it worse). Good pipeline design uses parallelism for independent stages, to spend effort where it matters, and verification to catch errors before decisions.

Core concept

Technical explanation + simple intuition + example

Sequential, parallel and routed topologies

  • Sequential (A → B → C → D): each step uses the previous result. Simple, but latency adds up.
  • Parallel (A → {B, C, E} → D): independent steps run at the same time; latency is set by the slowest branch.
  • Routing (Input → Router → Simple / Complex / Ambiguous): cheap path for easy cases, expensive path or humans for hard ones.

Decomposition and error propagation

Splitting a task makes each piece easier and measurable — but each handoff is a place for errors to enter and travel downstream. Decompose where it buys you measurability or accuracy; don't add stages because it “feels” more rigorous.

The 10 questions

Every important concept should answer all of these

1What is it?

Designing a system as a graph of components (code, models, LLM calls, humans) with explicit inputs/outputs.

2Why does it exist?

Complex tasks mix skills; one monolithic call is hard to debug, evaluate and optimize.

3What problem does it solve?

It enables per-stage evaluation, targeted fixes, parallelism, routing and cost control.

4How does it work internally?

Define stage contracts (schemas), wire a DAG, parallelize independent stages, route by difficulty/confidence, verify before decisions, log everything.

5What does it look like on real transcript data?

Noisy calls fail several stages at once (correlated errors); most calls are easy and could use a cheap path.

6What can go wrong?

Latency explosion from long sequential chains, compounding errors, stages that discard needed context, routers that misroute, verifiers that rubber-stamp.

7How do I evaluate it?

Per-stage metrics on gold stage outputs, end-to-end metrics by slice, latency p50/p95, cost per decision, review rates.

8When should I use it?

When sub-tasks are separable and measurable, or when routing can save cost on easy inputs.

9When should I NOT use it?

When a single well-grounded call meets requirements; when the latency budget can't absorb extra stages.

10How does it affect downstream systems?

Topology determines where errors enter, how fast decisions are made, and how much each decision costs.

Interactive lab: Architecture builder

Load sequential, parallel and routing presets or wire your own pipeline on a canvas. 2,000 simulated transcripts flow through it to estimate end-to-end accuracy, errors caught, p50/p95 latency, cost and LLM calls per transcript.

SIMULATED MODEL
Loading lab…

Try it yourself

Conceptual (A), applied (B) and engineering (C) exercises

Q1Type B · AppliedIntermediate
Four sequential stages with accuracies 0.98, 0.95, 0.92, 0.96. Assuming independent errors and no recovery, what is the end-to-end accuracy? (3 decimals)
Q2Type B · AppliedIntermediate
Stages: normalize 20 ms → speaker 150 ms → {NER 400 ms, classify 900 ms, evidence 800 ms in parallel} → verify 1,100 ms. End-to-end latency in ms?
ms
Q3Type C · EngineeringAdvanced
Design a routing strategy for intent classification where 70% of calls are short and clean, 25% noisy, 5% extremely ambiguous.

Graded by a transparent keyword rubric (not an LLM) — it checks for the key ideas, then shows a model answer for self-assessment.

Q4Type A · ConceptualIntermediate
When does adding a pipeline stage make the system WORSE end to end?

Real-world application

A seven-stage pipeline (each stage an LLM call) hit 11 seconds p95 and $9 per 1k calls. Analysis showed three stages were independent (NER, objections, evidence) and one (normalization) could be deterministic code. After parallelizing and replacing the LLM normalizer, p95 fell to 4 seconds and cost to $5.40 — with identical accuracy. Adding a router that sent clean, short calls to a small model cut cost further to $3.10 with a 0.4-point macro-F1 loss, which the business accepted.

Common mistakes

Chaining LLM calls that could run in parallel

Latency adds up for no benefit.

Fix: Identify independent stages; run them concurrently.

Using an LLM where code suffices

Adds cost, latency and variance.

Fix: Deterministic steps (number parsing, schema checks) in code.

Trusting products of stage accuracies

Errors correlate with hard inputs.

Fix: Measure end-to-end on slices.

Unvalidated routers

Misrouted hard cases get cheap, wrong answers.

Fix: Evaluate the router like any classifier; monitor per-route quality.

Engineering decision

Single call or multi-stage pipeline?

Use it when
  • You need per-stage measurability (speaker, entities, intent, evidence)
  • Some sub-steps are deterministic or reusable
  • Input difficulty varies enough to justify routing
Avoid it when
  • A single grounded call meets quality and latency targets
  • Extra stages can't be evaluated on their own gold labels
Trade-offs
More LLM calls vs Better decomposition
Each call costs money and latency; add stages that measurably fix errors.
Single model vs Multi-stage pipeline
Simplicity vs debuggability and targeted optimization.
Sequential vs Parallel
Parallel cuts latency at equal cost when stages are independent.

Quiz

Pass mark 60%. Missed questions go to your mistake log and spaced review.

0/5 answered
Q1Beginner
In a DAG pipeline, end-to-end latency is determined by…
Q2Intermediate
Why is Π(stage accuracies) often optimistic for real transcripts?
Q3Intermediate
The main purpose of a router is to…
Q4Intermediate
Which stage is the best candidate to replace an LLM call with code?
Q5Advanced
Adding a verification stage that catches 50% of upstream errors changes a 0.80-accurate pipeline to roughly…

Advanced challenge

Type B · AppliedExpert
Router sends 70% to a path with 0.93 accuracy and 30% to a path with 0.88 accuracy. The router itself misroutes 5% of calls, and misrouted calls are correct only 60% of the time. Expected end-to-end accuracy? (3 decimals)
Key terms in this lesson