Library
Designing Large Language Model Applications · 7 of 12
Designing Large Language Model Applications
ai CRITICAL

Multi-LLM System Architecture

cascades routers confidence dspy system-design

Key Principle

Production LLM applications should not be treated as standalone LLM components. They require multi-model systems with routers, cascades, guardrails, verifiers, and orchestration. "Treating an LLM-based application as just a standalone LLM component is inadequate if we intend to deploy it as a production-grade system" (Chapter 13).

The cost-performance curve of LLMs is sharply nonlinear — a model 10x more expensive may only be 10-20% better on average. Multi-LLM architectures exploit this by routing inputs to appropriately-sized models.

Why This Matters

This chapter is the culmination of the book's arc from ingredients to systems. Every technique from prior chapters (K-V caching, distillation, embeddings, RAG) feeds into the multi-model patterns described here. Without systems thinking, teams either overpay (using the largest model for everything) or under-deliver (using a single small model that fails on hard inputs).

Good Examples

  • LLM Cascades: Inputs start at the smallest model and escalate to larger ones only when confidence falls below a threshold. Works when: (1) input difficulty follows a skewed distribution where most inputs are easy, and (2) the confidence signal is trustworthy (Chapter 13).
  • Routers: Dispatch each input directly to a single model by difficulty or intent classification. Eliminate redundant compute of cascades but sacrifice the fallback safety net (Chapter 13).
  • Confidence strategies: (1) Encoder-only models output probability scores directly, (2) Self-consistency: multiple generations + agreement measurement — preferred but multiplies cost, (3) Margin sampling: probability gap between top-two first tokens — elegant but reduces confidence to a single-token signal (Chapter 13).

Counterpoints

  • Self-assessed confidence fails: "Beware of asking the LLM to verify its own work in any form!" (Chapter 13). An LLM has no internal mechanism to distinguish what it knows from what it does not — this connects to the grounding problem (Ch. 2).
  • Routers vs. cascades tradeoff: In a cascade, a misclassified hard input still reaches the large model eventually. With a router, it gets one shot at the wrong-tier model and fails silently. High-stakes domains (legal, medical) favor cascades; latency-sensitive, lower-stakes applications favor routers (Chapter 13).
  • LLM programming frameworks are immature: DSPy's conceptual insight (prompt engineering as automated search) is sound, but "more often than not, you will find yourself writing your own optimizers" (Chapter 13). These tools are experimental, not production-ready.

Key Quotes

"Treating an LLM-based application as just a standalone LLM component is inadequate if we intend to deploy it as a production-grade system." — Suhas Pai, Chapter 13

"Beware of asking the LLM to verify its own work in any form!" — Suhas Pai, Chapter 13

"More often than not, you will find yourself writing your own optimizers." — Suhas Pai, Chapter 13

Rules of Thumb

  • Use cascades for high-stakes domains; routers for latency-sensitive, lower-stakes applications
  • Never trust LLM self-assessed confidence — use external signals (logits, self-consistency, margin sampling)
  • The cascade architecture hinges on confidence calibration — invest in getting this right
  • K-V caching (Ch. 9) makes cascades economically viable by reducing redundant compute
  • Treat DSPy/LMQL as experimental; verify effectiveness before adopting in production

Related References