
Our BMJ study compared RAG and GraphRAG for clinical decision support on 70 simulated kidney disease cases, assessing correctness, patient specificity and clarity.

Build double machine learning in Python with cross-fitting and influence-function intervals. Measure a coverage failure and match DoubleML on 401(k) data.

Build an LSTM from scratch, check the NumPy cell against PyTorch and measure how forget bias changes recall across 100 sequence steps.

Build HNSW Python vector search, compare it with hnswlib and exact search, and measure recall against distance computations on held-out words.

Implement the Kelly criterion in Python. Simulate uncertain returns, compare fractional Kelly and inspect a GARCH allocation with explicit costs.

Build word2vec from scratch in NumPy, check its gradients against finite differences, and measure what one epoch on a small corpus can learn.

Fit a GARCH model in Python with NumPy and SciPy, verify it against arch, and compare volatility forecasts with EWMA on pinned S&P 500 returns.

PyTorch's default weight initialization gives a plain ReLU network the same output for every input by eight layers deep. One line of He init fixes it.

Set every weight by hand in NumPy. A transformer without training adds 40-digit numbers exactly, while a trained model of the same shape fails past 13.

Hamiltonian Monte Carlo in Python, built from the leapfrog up. It beats random-walk Metropolis 41 to 1 on a correlated target, and an 11% bigger step costs 18x.

Split conformal prediction in Python delivers exactly the coverage you ask for. Measured per class it gives 95% on the common ones and 29% on the rare.

Measure how five model families miscalibrate, then fix it three ways. On 200 calibration rows ECE and log loss pick different methods, and only one of them is right.

Squeeze-and-Excitation and ECA in eight lines of NumPy, then the ablation run properly. On a small CNN three seeds report a confident 0.24 point loss at 27 times its standard error, and five seeds rep...

Build Monte Carlo tree search in Python and measure it against alpha-beta at the same node count. Four phases, one formula, no evaluation function, and it wins.

Quantize a trained network in NumPy and measure where accuracy goes. At 2 bits the scale rule is worth 80 accuracy points; five bits of range are worth 0.4.

Build a diffusion model from scratch in NumPy with hand-derived gradients. Measured over three seeds: DDIM's deterministic sampler is not worse on average, it is unreliable.

Build a variational autoencoder from scratch in NumPy with hand-derived gradients. Measure what the KL term buys: without it the model can only generate 3 of 10 digits.

Build a Kolmogorov-Arnold network in Python with NumPy. Learned B-spline functions on the edges, and edges that recover a formula's terms at R-squared 0.999999.

Multi-agent orchestration in Python, measured: sequential, supervisor, fan-out and debate over one job, with token spend, wall-clock and accuracy for each.

Build an MCP server in Python with the standard library alone: JSON-RPC over stdio, six methods, and a session the official SDK client accepts unchanged.

Poincaré embeddings in Python from scratch: three hyperbolic dimensions beat five hundred Euclidean ones on the WordNet mammals tree, reproducing Nickel and Kiela, with the rim costs measured.

A worked prompt injection example: eight attacks on a tool-using agent in Python, six defences measured, and the one that closes the hole.

BM25 vs embeddings on 300 labelled queries. Build both in NumPy, measure where each one fails, and merge them with reciprocal rank fusion.

Mechanistic interpretability on a small MNIST CNN: activation maximisation, dataset examples and ablation disagree about the same neuron.

Three ways to get valid JSON from an LLM, measured on the same 16 prompts: retry until it parses, repair the string, or mask the logits with a grammar.

Multi-task learning in PyTorch: measure gradient conflict between two tasks, implement PCGrad in ten lines, and find out when projecting gradients pays.

Build a ReAct agent from scratch in Python. The reason-act-observe loop in 31 lines, its three failure modes, and what the scratchpad costs you per step.

Build GRPO from scratch in Python. The group-relative advantage that replaced PPO's critic in DeepSeek-R1, measured on a bandit, a maze and a verifier.

Why one hidden layer can fit any curve. Build a universal approximator in Python, sweep the width, watch the error collapse, and see why bumps tile anything.

Watch a Q-learning agent game a naive reward: it farms a bonus tile forever and never reaches the goal. Then two fixes and a detector, from scratch in Python.
Get notified when new tutorials and deep-dives are published. No spam, unsubscribe anytime.
Questions about these tutorials and write-ups