AI Agentic Handbook
Volume V

System Design & Interview Loops

End-to-end AI system design with capacity maths, ML infrastructure, estimation and debugging drills, and behavioural rounds by level.

Sections

Interview questions answered at staff level

01

AI system design

Design ChatGPT-style serving, an eval platform, a coding agent, enterprise search — with numbers.

10 questions
02

ML infrastructure & serving

Parallelism, GPU scheduling, multi-LoRA serving, autoscaling and prefix-aware routing.

10 questions
03

Estimation & debugging drills

Back-of-envelope maths and production debugging scenarios, timed like the real round.

10 questions
04

Behavioural & leadership

Conflict, influence, killing a project, owning a failure — answered at Mid, Senior and Staff.

10 questions

Key terms

46 pages with diagrams and quizzes

Neural networkBudding

A program that learns a pattern from examples instead of being given rules. The machinery under every model on this site.

Parameters & weightsBudding

The learned numbers inside a model. '70B' means 70 billion of them — which sets memory and cost, and on its own says little about quality.

TransformerBudding

The design inside nearly every modern model: stacked layers where each word gathers context from the others, then refines itself.

PretrainingBudding

The first and most expensive training stage, where a model learns language and world knowledge by guessing the next word, trillions of times.

Next-token predictionBudding

The one task a model is trained on and runs every time it answers: given the text so far, score every possible next token.

Training dataBudding

The text, code and examples a model learned from. Its mix, quality, recency and licensing decide what the model knows and how it behaves.

Scaling lawsMid

The measured pattern that error falls predictably as parameters, data and compute grow — with each step costing many times more than the last.

Instruction tuningMid

Training a base model on pairs of 'instruction' and 'good response', which turns a text continuer into something that answers you.

RLHF (reinforcement learning from human feedback)Mid

Training on human preferences: people pick the better of two answers, those picks train a scoring model, and the model learns to score well.

Preference optimization (DPO)Senior

Methods like DPO that train straight from 'chosen vs rejected' answer pairs — RLHF-like results without the reward model or the RL loop.

LoRA & parameter-efficient fine-tuningMid

Fine-tune by training a small add-on while the original weights stay frozen. Cheap, fast, and swappable per task or customer.

In-context learningBudding

A model picking up a task purely from the instructions and examples in your prompt, with nothing about it changed.

Few-shot promptingBudding

Showing the model a handful of worked examples in the prompt so it copies the format, labels and tone you want.

Chain-of-thoughtMid

Having the model write its working before the answer. Better on multi-step problems, paid for in tokens.

Reasoning models & extended thinkingMid

Models trained to think at length before answering: much better at hard maths, code and planning, slower and pricier per answer.

Temperature & samplingBudding

The dial between predictable and adventurous when the model picks its next word. It changes variety, not knowledge.

Top-p (nucleus) samplingMid

Sample only from the smallest group of likely words that together cover p of the probability — 90%, say — and ignore the weird tail.

Logits & probabilitiesMid

The raw scores a model gives every possible next word, before they are turned into probabilities.

InferenceBudding

Running a trained model to get output. Training happens occasionally; this happens on every single request.

KV cacheMid

The saved intermediate results for earlier words, so each new word doesn't re-read the whole conversation. It eats GPU memory.

Model quantizationMid

Storing a model's weights in 8 or 4 bits instead of 16, to cut memory and speed things up — at a quality cost you have to measure.

Time to first token (TTFT)Mid

How long the user waits before any words appear. With streaming, this is what 'fast' actually means to them.

Batching & throughputSenior

Running many requests through the GPU together, so one read of the weights serves lots of tokens. More throughput, slightly slower per stream.

Speculative decodingSenior

A small model guesses the next few words and the big model checks them all in one pass. Same output, fewer slow steps.

Mixture of experts (MoE)Senior

A model made of many sub-networks where each word only uses a few, so a huge model computes like a much smaller one.

Open-weights vs closed modelsMid

Models whose trained numbers you can download and run yourself. Closed models live behind an API. You are trading control for convenience.

Knowledge cutoffBudding

The date a model's training data stops. Anything after it is unknown — and the model usually doesn't realise that.

IdempotencyMid

Doing something twice leaves things exactly as doing it once. This is the property that makes retries safe.

BackpressureMid

How a busy system tells its callers to slow down — bounded queues and honest 429s, instead of buffering until everything falls over at once.

Dead-letter queue (DLQ)Mid

A parking spot for messages your workers keep failing on, so one bad item stops blocking everything behind it.

Exponential backoffBudding

Wait longer after each failed retry — 1s, 2s, 4s — plus a little randomness, so a struggling service isn't hammered by everyone at once.

Blue-green deploymentSenior

Run the new version beside the old one, check it on real infrastructure, switch all traffic at once, and keep the old one warm for an instant rollback.

Dual-writeSenior

Writing the same change into two stores. Done the obvious way it drifts apart; the outbox pattern plus change data capture makes it stick.

Shadow trafficSenior

Send a copy of real requests to the new version, show nobody the results, and compare outputs, latency and cost before risking live traffic.

Canary & ramped rolloutMid

Release to a small slice of real traffic first — 1%, then 5%, then 25% — compare against the old version, and roll back if anything gets worse.

Feature flagBudding

A switch outside the code that turns a path, model or prompt on or off — per user, per customer, per percentage — with no redeploy.

Index aliasSenior

A nickname that points at a real index, so you can build a new one and repoint every reader in a single step.

Compaction & soft deleteSenior

The background tidy-up that rewrites an index without its deleted entries, winning back space and speed.

Observability & tracesMid

Being able to work out why production did something, without shipping new code to find out.

TTL & cache invalidationBudding

Time to live: how long a stored or cached item stays valid. Too long serves stale answers; too short throws the savings away.

Reconciliation jobSenior

A scheduled audit comparing the source of truth with everything derived from it — index, cache, permissions — and repairing the gaps.

Graceful degradation & load sheddingMid

When a dependency dies, serve something smaller but still useful — a lighter model, a cached answer, the sources alone — instead of an error page.

PostmortemMid

The blameless write-up after an incident: timeline, impact, causes, what went well, and owned actions with dates.

STAR methodBudding

Situation, Task, Action, Result: a shape for interview stories. Spend most of it on what you did and what changed — with numbers.

Trade-off framingMid

A choice where getting more of one thing costs you another. Good answers name the axes, the deciding constraint, and when they'd switch.

Staff engineer scopeStaff

A senior individual-contributor level whose scope crosses teams: setting direction, de-risking big bets, and making other people better — mostly in writing.