part II · chapter 9 of 17
Model routing and caching
Sending each request to the right model, and not paying twice for the same answer.
why it matters
Cuts cost and latency sharply, using the Redis and performance skills a backend engineer already has.
before this: chapter 8, Guardrails and AI security
being written
This chapter is being written. Here is what it will cover; until then, the full topic list is in our notes.
- rule, complexity and semantic routing
- fallback, cascading and failover
- exact, semantic and prompt caches
- streaming, batching, backoff
you reached the end of the chapter
build this
A router (easy to a small model, hard to a strong one, failure to a fallback) with Redis caching; measure the savings.
the maths underneath
maths note 6
Softmax and sampling
Temperature, top-k and top-p, every generation setting an API takes, are this one function.
maths note 10
Production numbers: percentiles, throughput, cost
Dashboards, budgets, routing and caching decisions are all these numbers.
check yourself
Tick what you could explain to someone else, out loud, without notes.