AAI 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 function built from layers of weighted sums and non-linearities whose weights are learned from examples by gradient descent; the machinery under every LLM.

Parameters & weightsBudding

The learned numbers (weights and biases) inside a model. '70B' means 70 billion of them; they set memory and compute cost, not quality on their own.

TransformerBudding

The architecture behind nearly all modern LLMs: stacked attention and feed-forward blocks that process every token of a sequence in parallel.

PretrainingBudding

The first and most expensive training phase: a model learns language and world knowledge by predicting the next token across trillions of tokens.

Next-token predictionBudding

The single task an LLM is trained on and runs at inference: given the text so far, assign a probability to every possible next token.

Training dataBudding

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

Scaling lawsMid

Empirical power laws: loss falls predictably as parameters, data and compute grow, with diminishing returns per extra 10× of compute.

Instruction tuningMid

Supervised fine-tuning on (instruction, good response) pairs that turns a base model that continues text into an assistant that follows requests.

RLHF (reinforcement learning from human feedback)Mid

Reinforcement learning from human feedback: train a reward model on human preference comparisons, then optimise the LLM to score highly on it.

Preference optimization (DPO)Senior

Methods like DPO that train directly on chosen-vs-rejected answer pairs, getting RLHF-like alignment without a reward model or RL loop.

LoRA & parameter-efficient fine-tuningMid

Low-Rank Adaptation: fine-tune by training small add-on matrices while the original weights stay frozen; cheap, fast, swappable per task or tenant.

In-context learningBudding

A model adapting to a task purely from instructions and examples in its prompt, with no change to its weights.

Few-shot promptingBudding

Including a handful of worked input-output examples in the prompt so the model copies the format, labels and style you want.

Chain-of-thoughtMid

Having a model write intermediate reasoning steps before its final answer, which improves accuracy on multi-step problems at a token cost.

Reasoning models & extended thinkingMid

Models trained with RL to think at length before answering, trading latency and output tokens for accuracy on maths, code and multi-step work.

Temperature & samplingBudding

A sampling setting that sharpens (low) or flattens (high) next-token probabilities, trading consistency for variety; it does not change what the model knows.

Top-p (nucleus) samplingMid

Nucleus sampling: sample only from the smallest set of tokens whose probabilities add up to p (e.g. 0.9), cutting off the unlikely tail.

Logits & probabilitiesMid

The raw scores a model outputs for every token in its vocabulary; softmax turns them into next-token probabilities.

InferenceBudding

Running a trained model to produce output. For LLMs: a compute-bound prefill over the prompt, then a memory-bound decode loop, one token per step.

KV cacheMid

Stored attention keys and values for past tokens, so each new token skips recomputing the sequence; at long context it fills GPU memory.

Model quantizationMid

Storing weights (and sometimes activations or KV) in 8 or 4 bits instead of 16 to cut memory and speed up inference, at a quality cost you must measure.

Time to first token (TTFT)Mid

Latency from sending a request until the first output token arrives; the main driver of how responsive a streaming LLM app feels.

Batching & throughputSenior

Running many requests through the GPU together so one weight read serves many tokens: throughput and cost per token improve, per-stream speed falls.

Speculative decodingSenior

A cheap draft proposes several tokens and the big model verifies them in one pass: same output distribution, fewer sequential big-model steps.

Mixture of experts (MoE)Senior

An architecture where each token is routed to a few of many expert sub-networks, so a huge model computes like a much smaller one per token.

Open-weights vs closed modelsMid

Open-weights models publish their parameters for self-hosting; closed models are API-only. The choice trades control and residency for convenience.

Knowledge cutoffBudding

The date after which a model's training data ends; it knows nothing newer unless you supply it in the prompt or through tools.

IdempotencyMid

Running an operation twice leaves the same state as running it once. It is the property that makes retries and at-least-once queues safe.

BackpressureMid

Pushing back on producers when a consumer is saturated: bounded queues, 429s and load shedding instead of unbounded buffering until latency or memory collapses.

Dead-letter queue (DLQ)Mid

A side queue where messages land after N failed attempts, so one poison message stops blocking the pipeline and can be inspected and replayed later.

Exponential backoffBudding

Wait longer after each failed retry (1 s, 2 s, 4 s…) plus random jitter, so clients don't hammer a struggling service in sync.

Blue-green deploymentSenior

Run the new version (green) beside the old (blue), verify it on real infra, then switch all traffic at once, keeping blue warm for instant rollback.

Dual-writeSenior

Writing the same change to two stores, e.g. Postgres and a vector index. Done naively it drifts; the outbox pattern plus CDC makes it reliable.

Shadow trafficSenior

Copy real production requests to a new version whose responses users never see, then compare outputs, latency and cost before risking live traffic.

Canary & ramped rolloutMid

Release to a small slice of real traffic first (1%, then 5%, 25%…), compare against the old version, and roll back automatically if metrics degrade.

Feature flagBudding

A runtime switch that turns code paths, models or prompts on or off per user, tenant or percentage without a redeploy.

Index aliasSenior

A stable name (e.g. products-read) that points to a physical index, so you can rebuild a new index and repoint readers atomically with no client change.

Compaction & soft deleteSenior

Background rewriting of an index's segments to drop deleted and overwritten entries, reclaiming space and restoring search speed and recall.

Observability & tracesMid

Being able to answer new questions about production from its telemetry. For LLM systems: traces per request with prompts, tool calls, tokens, cost and quality.

TTL & cache invalidationBudding

Time to live: how long a cached or stored item is valid before it expires. Too long serves stale data; too short throws away savings.

Reconciliation jobSenior

A scheduled job that compares the source of truth with derived stores (index, cache, ACLs) and repairs drift that events and retries missed.

Graceful degradation & load sheddingMid

When a dependency fails, serve a reduced but useful response (smaller model, cached answer, sources only) instead of an error page.

PostmortemMid

A blameless written review after an incident: timeline, impact, root causes, what went well, and owned action items with due dates.

STAR methodBudding

Situation, Task, Action, Result: a structure for behavioural interview answers. Spend most of the time on what you did and what changed, with numbers.

Trade-off framingMid

Choosing one option knowing what it costs you on another axis. Senior answers name the axes, the deciding constraint, and when they'd switch.

Staff engineer scopeStaff

A senior IC level whose scope spans teams: sets technical direction, de-risks big bets, and multiplies others, mostly through writing and influence.