Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Topic 77: The Two-Week Workbook

Thirty-eight pages, one per topic, holding what you need to say and write in an interview. Each page has the equations with a plain-language gloss, code short enough to type from memory, and the questions with a spoken answer for each. Every code block on every page was executed before it was published, and where a result can be checked against a library — sklearn, PyTorch — it was checked and the agreement is stated in the text.

This is the practice material. The schedule that routes you through it is the two-week plan, and the compression pass for the last evening is the rest of topic 73.

The pages

PageCovers
Classical MLLinear and logistic regression, regularisation, bias-variance, trees, SVM, bagging and boosting.
Optimization and training dynamicsSGD through Adam and AdamW, normalisation, warmup, mixed precision, and how to read a broken loss curve.
Optimizer evolution: from SGD to AdamWThe optimizer family as a sequence of fixes: direction, per-parameter scale, memory, bias correction, and decoupled weight decay.
Activation-function evolution: from sigmoid to SwiGLUThe activation family as a sequence of gradient fixes: saturation, centring, dead units, smooth self-gating, and learned gates.
Attention mechanisms: from alignment to efficient long contextTwenty mechanisms organized by role, KV sharing, sparsity, approximation, exact kernels, and serving memory—with intuition, tradeoffs, complexity, and interview code.
Evaluation metrics and A/B testingPrecision and recall through calibration and proper scoring rules, ranking metrics, and experiment design.
Probability and statisticsBayes, expectation, MLE and MAP, KL divergence, and the scenario problems, each verified by simulation.
Transformers and attentionScaled dot-product attention, multi-head shapes, the KV cache, and where the parameters live.
Tokenization and positional embeddingsBPE, sinusoidal encoding, RoPE and ALiBi, and why tokenization causes the failures it does.
LLM training and alignmentPretraining through SFT to PPO, GRPO and DPO, reward models, LoRA and QLoRA.
LLM inference and servingPrefill versus decode, the roofline argument, PagedAttention, batching, quantisation, speculative decoding.
Retrieval-augmented generationChunking, hybrid search, reranking, the RAGAS quartet, and what breaks at a million documents.
AgentsThe ReAct loop, tool design, loop control, memory, multi-agent failure, and MCP.
Evaluating LLM and agent systemsThe four evaluation levels, trajectory scoring, LLM-as-judge and its biases, statistical deploy gates.
ML system designThe framework, capacity estimates, the tail math, monitoring and drift, canary and rollback.
LLM security and safetyThe OWASP list, direct and indirect injection, the lethal trifecta, access control at retrieval time.
The ML coding roundSix primitives to write cold — softmax, cross-entropy, attention, k-means, k-NN, the training loop.
The algorithms roundBinary search, sliding window, BFS and DFS, dynamic programming, heaps, graphs, and how to talk while coding.
Linear algebraRank, SVD, eigendecomposition, PCA, condition number, and the matrix gradients backprop is built on.
Conditional probability: worked problemsSeventeen scenario problems worked end to end, every answer confirmed by simulation.
The breadth round: machine learning68 rapid-fire questions — generative versus discriminative, the L1 and L2 priors, bias-variance, ensembles, gradient boosting.
The breadth round: NLP and deep learning79 questions — activations, normalisation, sequence models, embeddings, metrics, and the “why not just do the simple thing” family.
The breadth round: LLMs and modern systems70 questions — scaling, RLHF and GRPO, LoRA parameters, inference, retrieval, agents, safety.
Sliding window: every variationThe four templates, the at-most-k trick, 21 worked problems, and the one case where a window is the wrong pattern.
Arrays and hash tablesDeciding what to key on, prefix sums in a hash map, and 22 problems from two-sum to first missing positive.
Two pointersConverging, fast-and-slow, and cycle detection; k-sum reduction with the duplicate skipping worked out.
Binary searchOne half-open invariant used everywhere, boundary searches derived from it, and binary search on the answer.
TreesChoosing the traversal by what the node needs, and the return-one-thing-record-another shape behind four hard problems.
GraphsNaming the nodes and edges before the algorithm, the grid as a graph, multi-source BFS, topological sort, union-find, Dijkstra.
ML system design case studiesSixteen designs worked end to end with a whiteboard diagram each: survey text, driver analysis, response quality, summarisation and alerting; the classics; and six internal platform systems — benchmarking under privacy, historical re-scoring, annotation, redaction, natural-language query, survey quality.
Stack and monotonic stackNext-greater in disguise, the sentinel trick, largest rectangle, 20 problems.
Heap and priority queueWhy the k largest needs a min-heap, the two-heap median, 16 problems.
Linked listsDummy heads, pointer discipline, reversing a sublist, LRU cache, 18 problems.
Backtracking and triesThe shape of the choice, the duplicate-skip guard, pruning that actually matters, 19 problems.
Dynamic programming IDefining the state in one sentence, space reduction, 19 problems including Kadane and both coin changes.
Dynamic programming IIOne two-string table read three ways, grids, intervals, 18 problems.
Intervals and greedySort by start or by end, the sweep line, the exchange argument, 20 problems.
Matrices, maths and bit tricksThe tricks you memorise rather than derive, 22 short problems.

How to use a page

Read the equations once. Then close the page and write the code from a blank file. Then read the questions and say your own answer aloud BEFORE reading the one given. The gap between what you said and what is written is the thing to work on, and it is almost always the same two things: the failure mode you did not name, and the tradeoff you did not state.

Recognition and recall are different skills, and only recall gets tested. Reading a page twice feels like progress and is not.

The breadth round is a different exam

Pages 18 to 20 are shaped differently from the rest, because a breadth round is. The interviewer asks twenty short questions in forty minutes and wants about a minute on each: the direct answer, then the equation or the mechanism, then one sentence of consequence. Therefore those answers carry no separate spoken block — the answer is already written the way you would say it.

The habit that carries that round is to stop talking. Answer, then wait. A candidate who talks for four minutes on question one fails even when every sentence is correct.

Where a question has a real derivation or turns on a number, the answer carries two extra blocks. Walk the derivation gives the reasoning as two to four named steps, in the order you would speak them. With numbers works one small case with real arithmetic and ends with the single sentence the numbers reveal. Every figure in those blocks was computed, not recalled.

Q6 on the machine-learning page, on logistic regression, is the shape the rest follow.