AI ENGINEERING

ML Foundations

The math under the models — gradient descent, softmax, embeddings, similarity and ranking — taught as playable labs and runnable challenges, plus the research papers that build on them: reinforcement learning, generative models and graph networks.

90 pieces · 8 formats

Handbooks 6

Handbook

The Diffusion Models Handbook

How AI images are really made — generation as iterative denoising, the forward noising and reverse denoising processes, the elegant noise-prediction training objective, sampling and the steps-vs-speed dial, conditioning and classifier-free guidance, latent diffusion (Stable Diffusion), and why diffusion beat GANs and VAEs.

AI
Handbook

The Reinforcement Learning Handbook

Learning to act by trial and error — the agent-environment loop, cumulative reward and discounting, exploration vs exploitation, value functions and Q-learning, policy gradient methods (REINFORCE/PPO), why RL is unstable and reward hacking happens, model-free vs model-based, and how RLHF turned LLMs into assistants.

AI
Handbook

The Synthetic Data Handbook

Using LLMs to generate training and eval data. Why quality filtering beats raw volume (effective size = generated × pass rate), what model collapse is and why recursive training on unfiltered self-generated data shrinks diversity (Var_k = s^k · Var_0 → 0), and a safe generate-filter-mix pipeline. With worked math and runnable code.

AIEngineering
Handbook

RL from Verifiable Rewards (RLVR)

The training technique behind modern reasoning models: reinforcement learning where the reward comes from a programmatic check (a unit test passing, a math answer matching) instead of a gameable learned reward model. How it differs from RLHF, the GRPO/PPO loop, why reasoning behaviors emerge in DeepSeek R1-Zero, and where verifiable rewards run out.

AIEngineering
Handbook

World Models

What it means for AI to learn a predictive model of an environment it can imagine inside — the basis of model-based RL, planning, and controllable simulation. The three families (latent control models like Dreamer, generative interactive video like Genie/Sora, and JEPA), how a latent world model learns and acts in imagination, and the debate over whether video generators really understand physics.

AIEngineering
Handbook

ML Fundamentals

The seven concept pairs every practitioner is expected to have straight — how machines learn, what they predict, the two ways they miss, which mistake you can live with, how you validate, how you ensemble, and what a model is really modelling. Worked confusion matrices, real fold scores, and the failure mode behind each one.

AIEngineering

Roadmaps 2

AI System Designs 6

AI System Design

Design a RAG Pipeline

Build a retrieval-augmented generation pipeline. See how documents are chunked and embedded, how a vector store answers semantic search, how two-stage retrieval with reranking finds the best passages, how the prompt is grounded to stop hallucination, and how evals keep a quietly-drifting index honest.

RAGRetrievalEmbeddings
AI System Design

Design a Recommendation System

Build a large-scale recommendation system. See how a two-stage retrieve-and-rank funnel picks the best few from millions, how two-tower embeddings and ANN generate candidates fast, how a heavy ranking model scores engagement, how a feature store stays consistent between training and serving, and how the feedback loop keeps recommendations fresh.

RecommendersRankingEmbeddings
AI System Design

Design a Vector Database

Build a vector database. See why "k nearest of a billion vectors" needs its own index, how a distance metric ranks similarity, how IVF cells and an HNSW graph make search sub-linear, how product quantization fits billions in RAM, how metadata filtering and sharding hold up — and how ANN fails silently when you starve the search.

RetrievalEmbeddingsANN
AI System Design

Design Semantic Search

Build a semantic search engine. See why keyword search misses meaning, how a single shared embedding model puts documents and queries in one space, how the chunk→embed→index ingest path is built, how hybrid BM25 + vector fusion catches exact terms, how a cross-encoder reranks the shortlist — and how a model-version upgrade silently randomizes results.

RetrievalEmbeddingsSearch
AI System Design

Design a Feature Store

Build a feature store for ML. See how one feature definition kills training/serving skew, how a shared pipeline computes features once, how the offline store serves point-in-time-correct training data, how the online store serves millisecond lookups, how a versioned registry makes features reusable assets, how batch + streaming keep them fresh, and how drift monitoring catches silent decay.

MLFeature StoreRecommenders
AI System Design

Design an Embeddings Service

Build an embeddings service that powers semantic search, RAG and recommendations. See why embedding needs a shared service, how online (low-latency query) and batch (millions of docs) modes differ, what the model outputs, how a batched GPU pipeline indexes a corpus, the critical rule that query and corpus must share the same model version (so a model change re-embeds everything), and how caching by (text, version) saves cost.

EmbeddingsRetrievalGPU

Paper Breakdowns 49

Paper Breakdown

Attention Is All You Need

The paper that introduced the Transformer — the architecture underneath GPT, BERT, Claude, and Gemini. Self-attention, Query/Key/Value, multi-head attention, positional encoding, and the real BLEU results, explained in depth with analogies and animated visuals, not just equations.

NLPArchitecture
Paper Breakdown

Word2Vec

How words became math. Dense word vectors learned from the company a word keeps, so king − man + woman lands near queen. Skip-gram, CBOW, the distributional hypothesis, and the origin of every embedding model powering search and RAG.

EmbeddingsNLP
Paper Breakdown

ResNet

The skip connection that made deep learning deep. Why stacking layers made networks worse, and how residual learning let them reach 150+ layers and win ImageNet — the identity shortcut every Transformer still uses inside every block.

ArchitectureComputer Vision
Paper Breakdown

Diffusion Models

How AI paints from pure noise. Add noise to an image step by step until it's static, then train a network to reverse it and sculpt pictures out of chaos — the forward and reverse processes behind Stable Diffusion, DALL·E, and Midjourney.

GenerativeComputer Vision
Paper Breakdown

CLIP

How AI learned to connect images and words. Train an image encoder and a text encoder together on 400M internet image-caption pairs so pictures and words share one space — enabling zero-shot classification and the text-to-image bridge behind modern generators.

MultimodalEmbeddings
Paper Breakdown

Vision Transformer (ViT)

When an image became 16×16 words. Cut a picture into patches, treat each patch as a token, and feed them to a plain Transformer — no convolutions. Patch embeddings, the class token, and why data scale lets attention beat the CNNs that ruled computer vision for a decade.

Computer VisionArchitecture
Paper Breakdown

Latent Diffusion

The paper behind Stable Diffusion. Compress an image into a small latent space with a VAE, run the diffusion denoising there instead of on pixels for a tens-of-times efficiency win, and steer it with text via cross-attention. The architecture that put text-to-image generation on consumer GPUs.

GenerativeComputer Vision
Paper Breakdown

DDPM

The original denoising diffusion math — the paper that made diffusion work. A fixed forward process adds Gaussian noise over many steps; a U-Net learns the reverse. The masterstroke: train the network to simply predict the added noise with a plain MSE loss. The foundation under every modern image generator.

GenerativeDiffusion
Paper Breakdown

GANs

The counterfeiter and the detective. Two networks locked in a game: a generator forging fakes from noise and a discriminator trying to catch them. The minimax objective that taught machines to imagine, its notorious instabilities and mode collapse, and how diffusion later overtook it.

GenerativeDeep Learning
Paper Breakdown

AlexNet

The paper that started the deep learning revolution. AlexNet won ImageNet 2012 by a landslide — cutting top-5 error from ~26% to ~15% — proving deep CNNs with big data and GPUs beat decades of hand-engineered features. ReLU, dropout, GPU training, and data augmentation, explained.

Computer VisionDeep Learning
Paper Breakdown

Mamba

The linear-time challenger to attention. A selective state-space model that compresses history into a fixed-size state and scales linearly with sequence length — matching Transformers on language while being far cheaper on very long sequences. Selective SSMs, the recurrent/parallel duality, and hardware-aware design.

ArchitectureSequence Models
Paper Breakdown

Whisper

Robust speech recognition from the open web. An encoder-decoder Transformer trained on 680,000 hours of diverse, weakly-labeled web audio — transcribing and translating dozens of languages robustly, often zero-shot. The data bet, the multitask token format, and why scale beat clean supervision.

SpeechMultimodal
Paper Breakdown

Segment Anything (SAM)

A foundation model for cutting out objects. Point, click, or box anything in any image and SAM returns a precise mask — zero-shot. The image-encoder / prompt-encoder / mask-decoder design, and the data engine that bootstrapped SA-1B, a dataset of 1 billion masks.

Computer VisionFoundation Models
Paper Breakdown

Adam

The optimizer that trains almost every modern network. Momentum as the first moment, RMSProp as the second, and the bias correction most explanations skip — plus the famously robust defaults (0.9 / 0.999 / 1e-8) and AdamW. Built up from scratch with worked math and runnable code you can edit in the browser.

TrainingSystems
Paper Breakdown

Dropout

Randomly switch off half your neurons on every training step — and overfitting collapses. Why co-adaptation hurts, how inverted dropout scales survivors to keep expectations unchanged, and why the whole thing is secretly an ensemble of 2ⁿ networks. Worked math plus runnable code you can edit in the browser.

TrainingSystems
Paper Breakdown

Batch Normalization

The layer that made deep networks train fast and forgivingly. Normalize each feature across the batch to zero mean and unit variance, then a learnable scale and shift give the network its freedom back. Internal covariate shift, the train-vs-test running-statistics gotcha, and why it unlocks higher learning rates — worked math plus runnable code.

TrainingSystems
Paper Breakdown

ColBERT

Keep one vector per token, not one per document, and score by late interaction: each query token takes its best match anywhere in the document (MaxSim), summed. It recovers the term-level precision single-vector retrieval blurs away, at index-friendly speed. The math, the case where it clearly wins, and how it sits between dense and cross-encoder retrieval — with runnable code.

RetrievalEmbeddings
Paper Breakdown

Sentence-BERT

The model that turned BERT into fast, comparable sentence embeddings — the ancestor of every embedding model behind vector search and RAG. Why plain BERT can’t be compared without a pass per pair, the siamese fix with mean pooling, and the O(n²)→O(n) arithmetic that took a task from 65 hours to 5 seconds. Worked math plus runnable code.

EmbeddingsRetrieval
Paper Breakdown

Masked Autoencoders

BERT for images, finally working. Mask 75% of an image’s patches, encode only the visible quarter with a ViT, and reconstruct the missing pixels with a light decoder. Why images need such a high mask ratio, the asymmetric design that makes the encoder ~16× cheaper, and the strong transfer results — worked math plus runnable code.

Computer VisionPre-training
Paper Breakdown

SimCLR

Contrastive learning that rivaled supervised vision with no labels. Two augmented views of an image are a positive pair against a batch of negatives; the NT-Xent loss pulls positives together and pushes negatives apart. The temperature, why augmentation and big batches are decisive, and how contrastive compares to masked pre-training — worked math plus runnable code.

Computer VisionEmbeddings
Paper Breakdown

Product Quantization

The compression that makes billion-scale vector search fit in memory. Split a vector into subvectors, quantize each with a 256-entry codebook, and store a 512-byte vector in 8 — while m small codebooks span k^m codes. The compression math, asymmetric distance lookups, and IVFPQ — worked math plus runnable code.

RetrievalEmbeddings
Paper Breakdown

Muon

The optimizer that orthogonalizes weight-matrix updates instead of scaling them element-wise like Adam. Pushing every singular value of the momentum to 1 spreads learning across all directions, done cheaply with Newton-Schulz iteration (matmuls, no SVD). Why it pairs with Adam for 1D params, and how it scaled to trillion-parameter training — worked math plus runnable code.

TrainingSystems
Paper Breakdown

Flamingo

The visual language model that bridges a frozen vision encoder and a frozen LLM with a small trained connector. A Perceiver Resampler compresses each image into a fixed set of tokens, and gated cross-attention (tanh gate initialized at 0) injects them without breaking the language model — enabling few-shot multimodal in-context learning. The resampler and gating math — worked math plus runnable code.

MultimodalComputer Vision
Paper Breakdown

DINOv2

Label-free visual features by self-distillation: a student learns to match a teacher that is an EMA of itself, with centering and sharpening to prevent collapse. DINOv2 scaled this with curated data into a general vision backbone that works frozen across detection, segmentation, and depth. The self-distillation loop and anti-collapse math — worked math plus runnable code.

Computer VisionPre-training
Paper Breakdown

3D Gaussian Splatting

Real-time photorealistic radiance fields. Represent a scene as millions of 3D Gaussians and render by projecting and alpha-compositing them front-to-back — fast rasterization instead of NeRF's slow ray-marching, hitting 100+ FPS. The compositing equation (C = Σ cᵢαᵢTᵢ), the differentiable optimization that fits Gaussians to photos, and why explicit beats implicit — worked math plus runnable code.

Computer VisionGenerative
Paper Breakdown

NeRF

The paper that launched the radiance-field era. Store a 3D scene as a small MLP mapping (position, direction) → (color, density), and render photorealistic novel views by volume rendering along rays. The rendering integral (α = 1 − exp(−σδ), C = Σ Tᵢαᵢcᵢ), why positional encoding unlocks sharp detail, and how it set up Gaussian Splatting — worked math plus runnable code.

Computer VisionGenerative
Paper Breakdown

LLaVA

Visual instruction tuning the simple way. Connect CLIP to an LLM with a single linear projection, prepend the image tokens to the prompt, and instruction-tune on data a text-only GPT-4 generated — a capable visual assistant on a shoestring. The minimal connector (a matrix, <0.1% of the LLM), the synthetic-data trick, and two-stage training — worked math plus runnable code.

MultimodalFine-tuning
Paper Breakdown

AlphaGo

The system that beat a Go world champion by fusing Monte Carlo Tree Search with deep networks: a policy network to propose moves and a value network to judge positions. How PUCT selection balances exploiting good moves against exploring promising ones, the supervised-then-self-play training, and the test-time-search idea it seeded — worked math plus runnable code.

ReasoningSystems
Paper Breakdown

MuZero

Planning without knowing the rules. MuZero learns its own model — representation, dynamics, and prediction networks — and runs tree search entirely in a learned latent space, so it works where no simulator exists (like Atari). The three networks, the value-equivalence idea (a model trained to be useful for planning, not to reconstruct observations), and the n-step return — worked math plus runnable code.

ReasoningSystems
Paper Breakdown

AlphaFold 2

The system that solved the 50-year protein-folding problem — by reading evolution. Residues that touch in a folded protein mutate together across related sequences, so covarying columns of a multiple-sequence alignment reveal 3D contacts; the Evoformer refines them with attention and a structure module predicts coordinates. The coevolution insight, the Evoformer, and pLDDT confidence — worked math plus runnable code.

ArchitectureSystems
Paper Breakdown

Sora

Text-to-video by treating video as a diffusion transformer over spacetime patches. Sora compresses a video into a latent volume, cuts it into patches — one token each — and denoises the sequence, so resolution, aspect ratio, and duration are all just different patch counts. Why that unifies any shape into one model, and why patch count (linear in duration, quadratic in resolution) sets the compute — worked math plus runnable code.

GenerativeArchitecture
Paper Breakdown

V-JEPA

A self-supervised video world model that predicts in representation space, not pixels. V-JEPA masks regions of a video and predicts their features (encoder outputs) rather than reconstructing pixels — so the target drops the unpredictable detail a reconstruction loss is forced to model. Why abstraction beats reconstruction, and how a stop-gradient EMA target encoder avoids representation collapse — worked math plus runnable code.

Computer VisionPre-training
Paper Breakdown

RT-2

A Vision-Language-Action model that controls a robot by emitting actions as text tokens. RT-2 discretizes each dimension of a continuous action into bins — one vocabulary token per dimension — so a web-pretrained vision-language model co-trains on internet data and robot trajectories and its semantic knowledge transfers to control, generalizing to objects and commands never seen in robot data. Action-as-token, quantization precision, and emergent generalization — worked math plus runnable code.

MultimodalAgents
Paper Breakdown

Genie

A generative interactive environment that turns an image into a frame-by-frame playable world — trained on unlabeled video with no action labels. A latent action model infers a small discrete set of actions from consecutive frames, and a dynamics model turns them into control, so a tiny codebook forces consistent, reusable latent actions to emerge unsupervised. Latent-action inference and controllable generation — worked math plus runnable code.

GenerativeAgents
Paper Breakdown

Dense Passage Retrieval

The dual-encoder method that made dense retrieval beat BM25 for open-domain QA. DPR encodes questions and passages into a shared vector space and matches by dot product; its efficiency trick is in-batch negatives — a batch of B pairs yields a B×B similarity matrix whose diagonal is the positive and whose off-diagonal gives B×(B−1) negatives for free. Why matching on meaning beats keywords, and how the free-negatives trick trains it — worked math plus runnable code.

RetrievalEmbeddings
Paper Breakdown

VAE

The Variational Autoencoder — how to turn a compressor into a generator. A plain autoencoder's latent space is full of holes you can't sample; the VAE encodes each input to a Gaussian cloud and pulls all the clouds toward a standard-normal prior, making the space smooth and samplable. Trained by maximizing the ELBO (reconstruction minus KL), with the KL in closed form and the reparameterization trick z = μ + σ·ε making sampling differentiable. The foundation of the latent space under latent diffusion — worked math plus runnable code.

Generative ModelsML Foundations
Paper Breakdown

PPO

Proximal Policy Optimization — the RL algorithm behind RLHF. Naive policy gradients take steps that collapse the policy; PPO caps the step with a clipped surrogate objective, min(r·A, clip(r, 1−ε, 1+ε)·A), where r = π_new/π_old is the probability ratio and A the advantage. Once the ratio leaves the trust region 1±ε in the helpful direction the objective flattens — TRPO-level stability from a first-order clip, no hard constraint. The optimizer InstructGPT and RLHF pipelines used. Worked math plus runnable code.

Reinforcement LearningTraining
Paper Breakdown

DQN

The Deep Q-Network that learned Atari from raw pixels and launched deep reinforcement learning. A neural net approximates the Q-function, trained toward the Bellman target y = r + γ·max Q(s′,a′) — immediate reward plus discounted best future value (just r on a terminal step). Two stabilizers made neural Q-learning trainable: experience replay (random minibatches from a buffer break frame correlation) and a frozen target network (a stationary goal so the net doesn't chase itself). The ancestor of AlphaGo and modern deep RL. Worked math plus runnable code.

Reinforcement LearningML Foundations
Paper Breakdown

Classifier-Free Guidance

The "guidance scale" slider behind every diffusion image tool. A conditional diffusion model predicts the noise twice each step — with the prompt (ε_cond) and without it (ε_uncond) — then extrapolates: ε = (1+w)·ε_cond − w·ε_uncond, equivalently ε_uncond + (1+w)·(ε_cond − ε_uncond). w=0 is plain conditioning, larger w pushes further along the conditional direction for tighter prompt-following (too far → over-saturation). No separate classifier — trained with condition-dropout — and the source of negative prompts. Worked math plus runnable code.

Generative ModelsDiffusion
Paper Breakdown

Knowledge Distillation

How to compress a big, accurate "teacher" into a small, fast "student" — by training on the teacher's soft probability distribution, not just the hard label. A one-hot label is a thin signal; the teacher's full distribution encodes "dark knowledge" (a 2 looks a bit like a 7, nothing like a cat). The trick: a temperature-scaled softmax, p_i = exp(z_i/T) / Σ exp(z_j/T), softens the distribution as T grows so those tiny wrong-class probabilities become a strong training signal — without ever changing the top class. The student minimizes KL to the softened teacher plus cross-entropy on the labels. The "Distil" in DistilBERT and a first-line model-compression tool. Worked math plus runnable code.

ML FoundationsEfficiency
Paper Breakdown

VQ-VAE

The autoencoder that made the latent DISCRETE — and quietly became the tokenizer behind image generation. The encoder outputs a continuous vector, but it is quantized to the nearest entry in a learned codebook {e_1..e_K}: k = argmin_j ‖z_e − e_j‖², so each latent position becomes one of K discrete tokens. The non-differentiable argmin is trained with a straight-through estimator (copy the decoder gradient back to the encoder), plus a three-part loss: reconstruction + codebook ‖sg[z_e]−e‖² + β·commitment ‖z_e−sg[e]‖². Discrete codes let a Transformer or diffusion prior model images/audio as tokens — the lineage behind VQ-VAE-2, DALL·E, and VQGAN. Worked math plus runnable code.

Generative ModelsRepresentation Learning
Paper Breakdown

Graph Neural Networks

How a neural network learns on graphs — molecules, social networks, citation webs — where a convolution has nothing to slide over. The Graph Convolutional Network reduces it to message passing: each node updates itself by mixing its own feature with a degree-normalized average of its neighbors. One layer is H' = σ( H W) with  = D̃^(-1/2)(A+I)D̃^(-1/2) — self-loops (A+I) keep a node's own feature and the symmetric normalization stops high-degree hubs from dominating. Stack layers to reach further; too deep and features over-smooth. The template (gather, aggregate, update) behind GraphSAGE and GAT — and attention is message passing on a fully connected graph. Worked math plus runnable code.

ML FoundationsGraphs
Paper Breakdown

GloVe

Word vectors from GLOBAL co-occurrence statistics — the count-based cousin of word2vec. Build a co-occurrence matrix X (X_ij = how often word j appears in the context of word i), then learn vectors so a dot product recovers the LOG count: w_i·w̃_j + b_i + b̃_j ≈ log(X_ij). The insight: co-occurrence RATIOS (P(solid|ice)/P(solid|steam)) carry meaning, and taking logs turns multiplicative ratios into differences a vector space represents — which is why king−man+woman≈queen works. Fit with weighted least squares, J = Σ f(X_ij)(…−log X_ij)², where f(x)=(x/xmax)^0.75 caps frequent pairs and f(0)=0 skips the empty matrix. The standard pretrained word embedding for years. Worked math plus runnable code.

NLPEmbeddings
Paper Breakdown

The Lottery Ticket Hypothesis

The finding that a dense, randomly-initialized network hides a small "winning ticket" — a sparse subnetwork that, trained in isolation FROM THE SAME INITIAL WEIGHTS, matches the full model's accuracy. You find it by iterative magnitude pruning: train, drop the smallest-magnitude weights (a binary mask), RESET survivors to their original init, repeat. The famous twist: randomly reinitializing the same sparse structure trains worse — structure and lucky initialization are entangled. After k rounds at prune fraction p, only (1−p)^k of the weights remain. A new lens on why over-parameterization helps, and the seed of sparse-training research. Worked math plus runnable code.

ML FoundationsEfficiency
Paper Breakdown

DDIM

Denoising Diffusion Implicit Models — the trick that made diffusion sampling deterministic and 10–50× faster, using the SAME trained DDPM network (no retraining). Each step predicts the clean image x̂0 = (x_t − √(1−ᾱ_t)·ε)/√ᾱ_t, then re-projects to an earlier step: x_{t−1} = √ᾱ_{t−1}·x̂0 + √(1−ᾱ_{t−1}−σ²)·ε + σ·z. A single knob σ = η·√((1−ᾱ_{t−1})/(1−ᾱ_t))·√(1−ᾱ_t/ᾱ_{t−1}) unifies the two samplers: η=1 recovers stochastic DDPM, η=0 gives σ=0 and the deterministic DDIM that can skip timesteps. Determinism unlocks reproducibility, latent interpolation, and DDIM inversion for editing — and reframed sampling as an ODE. Worked math plus runnable code.

Generative ModelsDiffusion
Paper Breakdown

Self-Instruct

How to bootstrap a large instruction-tuning dataset from a language model's OWN generations, starting from just 175 human-written seed tasks. The generate→filter→add loop: sample existing tasks as examples, prompt the model to write new instructions + input/output instances, filter, add survivors back, repeat — 175 seeds bloom into ~52K diverse tasks. The quantitative heart is a diversity filter: keep a new instruction only if its ROUGE-L similarity (longest-common-subsequence overlap) to every existing one is below 0.7, so the pool never collapses into near-duplicates. The seed of Alpaca and the open instruction-tuning wave, and a landmark in synthetic data. Worked math plus runnable code.

LLMsTraining
Paper Breakdown

mixup

The two-line data augmentation that trains on CONVEX COMBINATIONS of example pairs — blending both inputs and labels: x̃ = λ·x_i + (1−λ)·x_j, ỹ = λ·y_i + (1−λ)·y_j, with λ ~ Beta(α,α). A 70/30 blend of a cat and a dog is trained with the soft label "0.7 cat, 0.3 dog." This "vicinal risk minimization" makes the network behave linearly between training points, smoothing its decision boundary. The payoffs, for near-zero cost and no architecture change: better generalization, honest calibration, resistance to label noise, and adversarial robustness. A default augmentation for ResNets and ViTs (often with CutMix). Worked math plus runnable code.

ML FoundationsRegularization
Paper Breakdown

AlphaZero

The single algorithm that mastered Go, chess, and shogi from ZERO human data — pure self-play, same code for all three. A single deep net outputs a policy prior P(s,a) and a value v(s); Monte Carlo Tree Search uses them to look ahead, selecting moves by the PUCT rule: maximize Q(s,a) + c·P(s,a)·√(ΣN)/(1+N(s,a)) — exploit the mean value Q, explore high-prior under-visited moves via the bonus that fades with visits. Search yields an improved policy (visit counts), self-play yields outcomes z, and both train the net (loss = (z−v)² − π·log p). Generalized AlphaGo into a domain-agnostic recipe; the seed of MuZero and the self-play-plus-search paradigm. Worked math plus runnable code.

Reinforcement LearningSearch
Paper Breakdown

wav2vec 2.0

Self-supervised speech: learn from raw, untranscribed audio, then fine-tune on as little as TEN MINUTES of labels. A CNN encodes the waveform into latent frames; a span is masked; a Transformer context net must identify each masked frame's TRUE quantized latent among K distractors via a contrastive InfoNCE loss (cosine similarity / temperature): L = −log[exp(sim(c,q_true)/κ) / Σ exp(sim(c,q̃)/κ)]. Targets are discretized through a learned codebook (product quantization + Gumbel-softmax) so the model discovers phone-like units. Brought BERT-style masked pretraining and CLIP-style contrastive learning to audio; the basis of HuBERT and multilingual XLS-R. Worked math plus runnable code.

SpeechSelf-Supervised Learning

Algorithm Games 2

Coding Challenges 5

Labs 17

Lab

Gradient Descent: The Descent

Don't read about gradient descent — play it. Roll a ball into the valley of a loss landscape by hand and waste steps, then let the algorithm read the slope and step downhill on its own. Crank the learning rate until it overshoots and explodes, dial it down until it crawls, then switch on momentum to escape a local minimum. Four acts — descend it, follow the gradient, tune the learning rate, escape the trap.

AIOptimizationNeural Networks
Lab

The Gravity Wells: K-Means

Don't read about k-means — watch the clusters form. Drop three centroids into a cloud of thirty unlabeled points, then run two moves on repeat: assign every point to its nearest centroid, then slide each centroid to the mean of its crowd. Watch the mess snap into clean groups and the inertia drop each round. Unsupervised clustering, made playable, with theory, a runnable challenge and a quiz.

AIMachine LearningClustering
Lab

The Meaning Map: Embeddings

Don't read about embeddings — explore the map. Every word becomes a point in space, placed so that closeness means similar meaning. Click a word to rank its nearest neighbours by cosine similarity, then run the famous vector arithmetic — king − man + woman lands right on queen, paris − france + japan lands on tokyo. Word embeddings and cosine similarity, made playable, with theory and a quiz.

AIEmbeddingsNLP
Lab

The Sliding Stencil: Convolution

Don't read about convolution — slide the stencil yourself. A 3×3 kernel glides over an image and, at each spot, multiplies the pixels underneath by its weights and sums them into one output pixel. Swap kernels — identity, edge-detect, blur, sharpen, emboss, Sobel — and watch the same image become edges, or blur, or sharpened. The single operation inside every CNN, made playable, with theory, a runnable challenge and a quiz.

AIComputer VisionCNNs
Lab

Out of the Static: Diffusion

Don't read about diffusion — watch the picture climb out of the static. Diffusion models generate by starting from pure random noise and removing a little of it, step by step, until a shape appears. Step through the reverse process and watch a heart emerge from random pixels as the noise level drops to zero. The idea behind Stable Diffusion and DALL·E, made playable, with theory and a quiz.

AIGenerativeDiffusion
Lab

The Bend: Activation Functions

Don't read about activations — bend the curve yourself. A neural network is just linear algebra until you add a non-linear activation on each neuron. Plot sigmoid, tanh, ReLU, leaky ReLU, and GELU with their derivatives, and slide a point to read the gradient — watching sigmoid's slope vanish at the edges while ReLU's stays a flat 1. The reason deep nets learn, made playable, with theory and a quiz.

AINeural NetworksDeep Learning
Lab

The Line-Drawer: Perceptron

Don't read about the perceptron — watch it draw the line. The simplest neural network, one neuron from 1958, learns to separate two classes of points by nudging a straight boundary every time it gets one wrong. Step through the updates and watch the line swing from a bad guess into a perfect split — then meet the XOR wall that a single line can't cross. The seed of every neural network, made playable, with theory, a runnable challenge and a quiz.

AINeural NetworksClassification
Lab

The Taste Trainer: RLHF & DPO

Don't read about RLHF — do the aligning. A base model can write but doesn't know what people prefer, so you teach it taste: pick which of two answers is better, over and over, and watch a reward model learn your preferences. Then turn up the optimization pressure and watch the policy chase that reward — and reward-hack it into sycophancy — while a KL penalty pulls it back. Finally see how DPO skips the whole reward model. Three acts — teach the taste, chase and hack the reward, the DPO shortcut.

AIAlignmentRLHF
Lab

The Blame Machine: Backpropagation

Don't read about backpropagation — run it. A network guesses and gets it wrong; the hard question is which weight is to blame, and by how much. Push a number forward through a tiny network, measure the loss, then watch the error flow backward assigning a gradient to every weight via the chain rule. Train it to convergence (or crank the learning rate until it explodes), then slide network depth to watch gradients vanish and explode. Three acts — forward and back, learn a step, vanish and explode.

AINeural NetworksOptimization
Lab

The Optimizer Race

Don't read about optimizers — race them down the same hill. Training a neural network is gradient descent on a loss surface, and the optimizer decides the path. On an ill-conditioned ravine, plain SGD zigzags and crawls, momentum builds speed along the valley floor, and Adam adapts its step size per direction to head almost straight for the bottom. Step the three optimizers down the same surface and watch their paths and losses diverge — made playable, with theory and a quiz.

AITrainingDeep Learning
Lab

The Loss Landscape

Don't read about local minima — drop a ball and watch. Training is gradient descent on a loss landscape, and the shape decides whether descent finds the best answer, gets trapped in a worse one, or crawls to a halt. Roll a ball down a convex bowl (always finds the bottom), a double-well surface (where the start decides which minimum), and a flat plateau (where the gradient vanishes and progress stalls). See why the surface's shape governs training — made playable, with theory and a quiz.

AITrainingDeep Learning
Lab

Inside a Transformer: Self-Attention

Don't read about attention — compute it, token by token. At the heart of every transformer is self-attention: each token forms a query, compares it against every token's key to get scores, softmaxes those into weights, and builds its new representation as a weighted sum of every token's value. That's how a model lets 'it' look back at 'robot.' Pick a query token and watch its scores become softmax weights become a context vector — with the real dot-product math, a quiz, and theory.

AITransformersDeep Learning
Lab

RoPE: Position by Rotation

Don't read about rotary position embeddings — rotate the vectors yourself. Attention has no built-in sense of order, so RoPE injects position by rotating each token's query and key by an angle proportional to its position. Because a dot product depends only on the angle between vectors, the attention score ends up depending only on the RELATIVE distance between tokens. Slide two tokens along a sequence and watch their score depend purely on the gap — made playable, with theory and a quiz.

AITransformersDeep Learning
Lab

The Latent Walk

Don't read about latent space — walk through it. A generative model turns a vector of numbers into an image, and that space is smooth and structured: nearby codes make similar images, a straight line between two codes morphs one into the other, and specific directions correspond to meaningful attributes. Move through a toy generator's latent space, interpolate between two points, and steer a single semantic direction to see how a model organizes what it can create — made playable, with theory and a quiz.

AIGenerative ModelsDeep Learning
Lab

Precision vs Recall: Drag the Threshold

Don't read the definitions — drag the line. A spam filter scored 5,000 emails; you pick where to cut. Every bar in the chart recolours into its confusion-matrix quadrant as you move, so precision, recall and F1 stop being formulas and become regions you can see. Push it to the extremes: catch every spam and bury real mail, or never lose mail and let phishing through. Then flag nothing at all and watch the model score 85% accuracy while catching zero spam — the class-imbalance trap, in one click.

AIEvaluationMetrics
Lab

Bias vs Variance: Fit the Curve, Watch It Overfit

Don't memorize the tradeoff — cause it. Slide the polynomial degree from 1 to 12 and watch a fit go from too stiff to bend through every point. Training error falls the whole way; test error bottoms out at degree 3 and then climbs 3.5x. Then hit resample: at degree 1 the fits barely move, at degree 12 they fan across the entire frame. That fan is variance, and you made it appear.

AIModel DesignEvaluation
Lab

Cross-Validation: One Exam, or Five?

Don't take the score on faith — see how much it could have been. Slide k to repartition 20 samples into folds, rotate the held-out fold and watch the mean assemble. Then run the payoff side by side: report a single hold-out split and your number swings from 0.790 to 0.880 depending purely on which split you happened to draw, while 5-fold sits still at 0.836 ± 0.033. Plus what it costs you — k folds means k trainings.

AIEvaluationModel Design

Interactive Tools 3

About ML foundations

Under every model is a small set of ideas that repay understanding directly: how a model learns by following the gradient of a loss, how softmax turns raw scores into probabilities, how embeddings place meaning in vector space, and how similarity and ranking pick the best of many candidates.

Taught as runnable labs and hand-implemented challenges, these foundations demystify the rest of AI engineering — a recommender, a retrieval pipeline and an embedding search are all built from these same primitives. You don't need a PhD to build with ML, but you do need these few ideas in your hands, not just your head.

Alongside them sits a deep shelf of paper breakdowns that put the primitives to work: reinforcement learning (DQN, PPO, AlphaZero), generative models (VAE, VQ-VAE, DDIM, classifier-free guidance), graph neural networks and representation learning. They are here because they are built from the same few ideas — read the labs first, then the papers stop looking like a different subject.

More in AI Engineering

← Browse all topics