09 / 16
AI Architecture
Reference architectures and the cross-cutting decisions that make AI systems hold up in production.
A production LLM app is layers around the model: client → API & auth → orchestration → context (retrieval, memory, tools) → model gateway → models, wrapped in guardrails, evals, observability and cost control.
Every AI design choice trades quality, latency and cost, plus risk. Set a bar for each, know which lever moves which corner, and pick from the measured Pareto frontier instead of arguing.
LLM providers fail loudly (outages, 429/529) and quietly (latency spikes, quality regressions). Time out fast, retry with backoff, trip circuit breakers, fail over to an evaluated backup, then degrade gracefully.
An agent acts for a user: give it short-lived, narrowly scoped, delegated tokens capped by the user's rights; authorize every tool call in code, confirm risky ones, and audit each action to the human.
One AI request can pass eight caches, from the CDN down to the GPU's KV cache. Each saves different latency or dollars; key every one by tenant, permissions and model, prompt and index version.
Hosted models retire on published schedules, so every model you ship is a future migration: pin versions, hide providers behind one interface, and move only through an eval-gated path of shadow, canary and rollback.
Turn usage into improvement: log traces and feedback, select and label the informative cases, use them for evals first and training second, ship, and let more usage feed the next turn.
At a billion vectors, memory is the design constraint: compress the vectors, move the index to SSD or object storage, shard and replicate, and rescore a small candidate set at full precision.
Run the model on the device instead of the cloud: you win latency, privacy, offline use and near-zero cost per query, and pay with small models, tight memory and a fleet to update.