ZeroShotMind

ZeroShotMind

A neutral technical blog about AI systems, evaluation, tooling, and software practice.

Blog Post · 2026-07-17 · Revised 2026-07-17 · 7 min read

Chat & Arena Benchmarks: Human Votes Scale, MT-Bench Doesn't

MT-Bench's frontier models cluster above 9.0 — the scale is out of room. AlpacaEval 2.0's length-controlled win rate is now saturated above 95% for top models. LMArena Elo keeps separating models as long as votes keep coming in — and they do.

Blog Post · 2026-07-17 · Revised 2026-07-17 · 6 min read

Creative Writing Benchmarks: When the Rubric Runs Out of Signal

EQ-Bench CW v3 rubric scores are already saturated at the top — a 0.35-point spread across 10 models. Elo still discriminates. Here's what that gap reveals about how we evaluate creative writing.

Blog Post · 2026-07-17 · Revised 2026-07-17 · 6 min read

Formatting & Output Validation Benchmarks: IFEval Is Saturated, IFBench Isn't

IFEval's top-5 span fewer than 2 percentage points — frontier models have converged on its constraint set. IFBench exposes a 29pp gap between Grok and Claude on out-of-distribution constraints. And SOB shows that JSON schema compliance is not the same as correct field values.

Blog Post · 2026-07-17 · Revised 2026-07-17 · 6 min read

Reward Model Benchmarks: RewardBench Is Saturated, RewardBench 2 Isn't

RewardBench v1's top-6 spread is 5.7 points — small specialist models now dominate it. RewardBench 2 drops scores by 20 points and actually correlates with downstream RLHF. RM-Bench finds that style bias can push SOTA models below random performance.

Blog Post · 2026-07-10 · Revised 2026-07-10 · 4 min read

ML System Design: Applied Systems

Five applied systems — content moderation, ETA, visual search, document extraction, multimodal search — each reduced to its one interesting design decision.

Blog Post · 2026-07-10 · Revised 2026-07-10 · 4 min read

ML System Design: A Framework That Actually Works

The universal seven-step framework for any ML system design problem — and the specific mistakes that make interviewers fail strong candidates.

Blog Post · 2026-07-10 · Revised 2026-07-10 · 4 min read

ML System Design: Infrastructure

Feature stores (online/offline duality), data vs model parallelism for distributed training, and why A/B testing ML models is harder than product A/B tests.

Blog Post · 2026-07-10 · Revised 2026-07-10 · 4 min read

ML System Design: LLM Systems

Serving LLMs (KV cache, continuous batching, speculative decoding), building enterprise RAG (chunking, hybrid retrieval, reranking), and the fine-tuning pipeline.

Blog Post · 2026-07-10 · Revised 2026-07-10 · 3 min read

ML System Design: The 20-Question Practice Set

All 20 canonical ML system design questions as an interview prep set — what makes each hard, the anchoring design decision, and what a strong answer includes. Prompts, not solutions.

Blog Post · 2026-07-10 · Revised 2026-07-10 · 4 min read

ML System Design: Real-Time ML

Fraud, anomaly detection, and real-time bidding share three enemies: a tight latency SLA, concept drift, and extreme class imbalance. How production systems handle all three at once.

Blog Post · 2026-07-10 · Revised 2026-07-10 · 5 min read

ML System Design: Recommendation Systems

Candidate generation, ranking, and reranking — the three-stage funnel behind YouTube and Spotify. Two-tower retrieval, why the funnel exists, and how cold start is actually solved.

Blog Post · 2026-07-10 · Revised 2026-07-10 · 4 min read

ML System Design: Search & Feed Ranking

Learning to rank — pointwise, pairwise, listwise — plus query understanding with BERT and what feed ranking adds: engagement prediction and diversity.

Blog Post · 2026-07-02 · Revised 2026-07-02 · 5 min read

Determinants and Invertibility

The determinant measures how much a matrix stretches or squishes space — and whether it flips orientation. When it's zero, information is lost and the matrix can't be inverted.

Blog Post · 2026-07-02 · Revised 2026-07-02 · 7 min read

Eigenvalues and Eigenvectors

Most vectors get rotated and scaled when multiplied by a matrix. Eigenvectors are the special directions that only get scaled — and their scaling factors, the eigenvalues, reveal everything about a matrix's long-term behavior.

Blog Post · 2026-07-02 · Revised 2026-07-02 · 9 min read

Inner Products and Cosine Similarity

What does it mean for two vectors to be similar? Inner products measure alignment between vectors — and cosine similarity is just the dot product with magnitudes divided out.

Blog Post · 2026-07-02 · Revised 2026-07-02 · 8 min read

Matrices as Linear Maps

A matrix is not just a grid of numbers — it's a function that transforms space. This post builds the geometric intuition for matrix-vector multiplication as rotation, scaling, and shearing.

Blog Post · 2026-07-02 · Revised 2026-07-02 · 5 min read

Linear Algebra in Neural Networks

Every layer of a neural network is a matrix multiplication followed by a nonlinearity. Understanding what these matrices do geometrically — how they stretch, rotate, and project — explains why deep learning works.

Blog Post · 2026-07-02 · Revised 2026-07-02 · 5 min read

Positive Definite Matrices and the Geometry of Optimization

Positive definite matrices define 'bowl-shaped' quadratic forms with a unique minimum. They show up everywhere optimization problems have unique solutions — from least squares to neural network loss landscapes.

Blog Post · 2026-07-02 · Revised 2026-07-02 · 6 min read

Putting It All Together — From Vectors to Transformers

A tour through the whole series: how vectors, matrices, eigendecomposition, SVD, and least squares combine to explain the mathematical machinery inside modern ML systems — from PCA to attention to gradient descent.

Blog Post · 2026-07-02 · Revised 2026-07-02 · 4 min read

The Spectral Theorem

Symmetric matrices can always be diagonalized by an orthogonal matrix — their eigenvectors form a natural coordinate system for the data. This is the spectral theorem, and it underlies PCA, kernel methods, and graph Laplacians.

Blog Post · 2026-07-02 · Revised 2026-07-02 · 8 min read

Vectors: Direction, Magnitude, and the Geometry of Space

Vectors are the atoms of linear algebra — everything else is built on them. This post builds intuition for what a vector is, how addition and scaling work geometrically, and why norms give us a way to measure the world.

Blog Post · 2026-06-20 · Revised 2026-06-20 · 10 min read

The Bradley–Terry Model: From ELO Scores to Reward Models

Chatbot Arena ranks LLMs with ELO, InstructGPT trains a reward model on pairwise preferences, and chess has rated players for seventy years. All three rest on the same one-line probabilistic model — Bradley–Terry — which turns out to be logistic regression over comparisons.

Blog Post · 2026-06-20 · Revised 2026-06-20 · 10 min read

Low-Rank Approximation: From SVD to LoRA and Beyond

Eckart–Young says the truncated SVD is the optimal low-rank approximation. This post turns that theorem into engineering — factorized layers, truncated-SVD compression, LoRA and its descendants QLoRA, DoRA, and GaLore, and nuclear-norm minimization for matrix completion.

Blog Post · 2026-06-20 · Revised 2026-06-20 · 9 min read

SVD: The Geometry of Every Matrix

Every matrix, no matter how ugly, factors into a rotation, a scaling, and another rotation. That single fact — the singular value decomposition — is the engine behind PCA, image compression, latent semantic analysis, and the low-rank tricks that let us fine-tune giant models cheaply.

Blog Post · 2026-06-20 · Revised 2026-06-20 · 10 min read

The Bradley–Terry Model: From ELO Scores to Reward Models

Chatbot Arena ranks LLMs with ELO, InstructGPT trains a reward model on pairwise preferences, and chess has rated players for seventy years. All three rest on the same one-line probabilistic model — Bradley–Terry — which turns out to be logistic regression over comparisons.

Blog Post · 2026-06-20 · Revised 2026-06-20 · 10 min read

Low-Rank Approximation: From SVD to LoRA and Beyond

Eckart–Young says the truncated SVD is the optimal low-rank approximation. This post turns that theorem into engineering — factorized layers, truncated-SVD compression, LoRA and its descendants QLoRA, DoRA, and GaLore, and nuclear-norm minimization for matrix completion.

Blog Post · 2026-06-20 · Revised 2026-06-20 · 9 min read

SVD: The Geometry of Every Matrix

Every matrix, no matter how ugly, factors into a rotation, a scaling, and another rotation. That single fact — the singular value decomposition — is the engine behind PCA, image compression, latent semantic analysis, and the low-rank tricks that let us fine-tune giant models cheaply.

Blog Post · 2025-06-20 · Revised 2025-06-20 · 13 min read

GRPO Variants: From GRPO to DAPO, Dr. GRPO, and Beyond

A systematic comparison of GRPO and its descendants — CLIP-DAPO, CISCO, DAPO, Dr. GRPO, GDPO, REINFORCE++ — what each fixes, what trade-offs each makes, and when to use which.

Blog Post · 2025-06-20 · Revised 2025-06-20 · 12 min read

Circuits: How Transformers Implement Algorithms

How to identify the minimal subgraph of attention heads and MLP layers that implements a specific behavior — and what we've learned from the indirect object identification circuit in GPT-2.

Blog Post · 2025-06-20 · Revised 2025-06-20 · 8 min read

Logit Lens: How Predictions Form Layer by Layer

Applying the unembedding matrix at intermediate layers to watch how a transformer's prediction evolves — and what direct logit attribution tells us about which components matter.

Blog Post · 2025-06-20 · Revised 2025-06-20 · 12 min read

Open Problems in Mechanistic Interpretability

Faithfulness vs. plausibility, scaling to frontier models, the composition problem, automated interpretability, and what it would take to actually understand a large language model.

Blog Post · 2025-06-20 · Revised 2025-06-20 · 9 min read

What Each Transformer Component Actually Does

Attention heads as information-routing circuits, MLP layers as key-value memories, and the residual stream as a shared communication bus.

Blog Post · 2025-06-20 · Revised 2025-06-20 · 13 min read

GRPO Variants: From GRPO to DAPO, Dr. GRPO, and Beyond

A systematic comparison of GRPO and its descendants — CLIP-DAPO, CISCO, DAPO, Dr. GRPO, GDPO, REINFORCE++ — what each fixes, what trade-offs each makes, and when to use which.

Blog Post · 2025-06-20 · Revised 2025-06-20 · 12 min read

Circuits: How Transformers Implement Algorithms

How to identify the minimal subgraph of attention heads and MLP layers that implements a specific behavior — and what we've learned from the indirect object identification circuit in GPT-2.

Blog Post · 2025-06-20 · Revised 2025-06-20 · 8 min read

Logit Lens: How Predictions Form Layer by Layer

Applying the unembedding matrix at intermediate layers to watch how a transformer's prediction evolves — and what direct logit attribution tells us about which components matter.

Blog Post · 2025-06-20 · Revised 2025-06-20 · 12 min read

Open Problems in Mechanistic Interpretability

Faithfulness vs. plausibility, scaling to frontier models, the composition problem, automated interpretability, and what it would take to actually understand a large language model.

Blog Post · 2025-06-20 · Revised 2025-06-20 · 9 min read

What Each Transformer Component Actually Does

Attention heads as information-routing circuits, MLP layers as key-value memories, and the residual stream as a shared communication bus.

Blog Post · 2025-06-01 · Revised 2025-06-01 · 13 min read

Why Your Norms Are Screaming at You

Activation norms, gradient norms, weight norms — what they tell you, why they explode or vanish, and every practical cause from hyperparameters to data bugs.

Blog Post · 2025-06-01 · Revised 2025-06-01 · 13 min read

Why Your Norms Are Screaming at You

Activation norms, gradient norms, weight norms — what they tell you, why they explode or vanish, and every practical cause from hyperparameters to data bugs.

Blog Post · 2025-01-17 · Revised 2025-01-17 · 8 min read

Memory-Bound vs Compute-Bound: Where LLM Inference Really Spends Its Time

Every LLM operation is either limited by how fast you can move bytes or how fast you can multiply. The roofline model tells you which — and understanding it explains why decode is slow, why batching helps, why prefill is fast, and why Flash Attention exists.

Blog Post · 2025-01-17 · Revised 2025-01-17 · 8 min read

Memory-Bound vs Compute-Bound: Where LLM Inference Really Spends Its Time

Every LLM operation is either limited by how fast you can move bytes or how fast you can multiply. The roofline model tells you which — and understanding it explains why decode is slow, why batching helps, why prefill is fast, and why Flash Attention exists.

Blog Post · 2025-01-10 · Revised 2025-01-10 · 3 min read

Cheatsheet: LLM Architectures

Five LLM architectures — GPT-2, Qwen3-8B, DeepSeek-V3, DeepSeek-R1, GPT-OSS-20B/120B — shown as interactive block diagrams. Click any block to expand equations and parameters. Each model is sourced from its official HF config.json.

Blog Post · 2025-01-10 · Revised 2025-01-10 · 6 min read

Cheatsheet: Attention

Every equation in scaled dot-product attention and multi-head attention annotated term-by-term — the scaling, the softmax, the heads, RoPE, and KV cache — with links to the posts explaining each design choice.

Blog Post · 2025-01-10 · Revised 2025-01-10 · 10 min read

Cheatsheet: LLM Forward Pass Equations

The full forward pass, written out as equations, for GPT-2, Qwen3-8B, DeepSeek-V3, and GPT-OSS. Every matrix, every norm, every residual — in the order the computation actually happens.

Blog Post · 2025-01-10 · Revised 2025-01-10 · 6 min read

Cheatsheet: RL Loss Functions

PPO and GRPO loss functions annotated term-by-term — the clipped surrogate, GAE, value loss, entropy bonus, and group-normalised advantages — with links to the posts explaining each design choice.

Blog Post · 2025-01-10 · Revised 2025-01-10 · 6 min read

Cheatsheet: Soft Metrics

Perplexity, negative log-likelihood, entropy, KL divergence, and cross-entropy annotated term-by-term — what each measures, how they relate, and what values to expect during training.

Blog Post · 2025-01-10 · Revised 2025-01-10 · 3 min read

Cheatsheet: LLM Architectures

Five LLM architectures — GPT-2, Qwen3-8B, DeepSeek-V3, DeepSeek-R1, GPT-OSS-20B/120B — shown as interactive block diagrams. Click any block to expand equations and parameters. Each model is sourced from its official HF config.json.

Blog Post · 2025-01-10 · Revised 2025-01-10 · 6 min read

Cheatsheet: Attention

Every equation in scaled dot-product attention and multi-head attention annotated term-by-term — the scaling, the softmax, the heads, RoPE, and KV cache — with links to the posts explaining each design choice.

Blog Post · 2025-01-10 · Revised 2025-01-10 · 10 min read

Cheatsheet: LLM Forward Pass Equations

The full forward pass, written out as equations, for GPT-2, Qwen3-8B, DeepSeek-V3, and GPT-OSS. Every matrix, every norm, every residual — in the order the computation actually happens.

Blog Post · 2025-01-10 · Revised 2025-01-10 · 6 min read

Cheatsheet: RL Loss Functions

PPO and GRPO loss functions annotated term-by-term — the clipped surrogate, GAE, value loss, entropy bonus, and group-normalised advantages — with links to the posts explaining each design choice.

Blog Post · 2025-01-10 · Revised 2025-01-10 · 6 min read

Cheatsheet: Soft Metrics

Perplexity, negative log-likelihood, entropy, KL divergence, and cross-entropy annotated term-by-term — what each measures, how they relate, and what values to expect during training.

Blog Post · 2024-06-20 · Revised 2024-06-20 · 9 min read

CUDA Fundamentals for ML Engineers

CUDA exposes GPU parallelism through a three-level thread hierarchy: grid, block, and warp. Understanding how these map to hardware — SMs, register files, shared memory — is the prerequisite for writing fast kernels.

Blog Post · 2024-06-20 · Revised 2024-06-20 · 8 min read

Writing Fused Kernels with Triton

Kernel fusion eliminates the HBM round-trips between chained operations. Triton makes this practical in Python. This post builds a fused online softmax from scratch, then extends it to a fused RMSNorm + linear projection — the kind of kernel that actually speeds up LLM inference.

Blog Post · 2024-06-20 · Revised 2024-06-20 · 9 min read

CUDA Fundamentals for ML Engineers

CUDA exposes GPU parallelism through a three-level thread hierarchy: grid, block, and warp. Understanding how these map to hardware — SMs, register files, shared memory — is the prerequisite for writing fast kernels.

Blog Post · 2024-06-20 · Revised 2024-06-20 · 8 min read

Writing Fused Kernels with Triton

Kernel fusion eliminates the HBM round-trips between chained operations. Triton makes this practical in Python. This post builds a fused online softmax from scratch, then extends it to a fused RMSNorm + linear projection — the kind of kernel that actually speeds up LLM inference.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

DDIM: Deterministic Sampling in Fewer Steps

DDPM needs 1000 steps to generate a sample. DDIM reframes the reverse process as an ODE and gets the same quality in 50. The model weights are identical — only the sampling procedure changes.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

DDPM: The Diffusion Process, Forward and Reverse

DDPM defines a fixed forward process that gradually destroys an image into noise, then trains a neural network to reverse it. The math is tractable because each step is Gaussian.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

DiT: Replacing the U-Net with a Transformer

DDPM, DDIM, and latent diffusion all use a U-Net backbone. DiT replaces it with a transformer — and finds that diffusion scales with model size the same way language models do.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Flow Matching: The Cleaner Generalization of Diffusion

Diffusion models learn to reverse a specific noise process. Flow matching learns to transport any source distribution to any target distribution along straight paths — simpler math, faster sampling, and better training signal.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Latent Diffusion: Why You'd Compress Before You Denoise

Running DDPM in pixel space at 512×512 is expensive. Latent diffusion compresses the image into a small latent space first, runs the diffusion process there, and decodes back. The same quality, a fraction of the compute.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Score Matching: The Math Behind Diffusion

Diffusion models learn to reverse a noise process. The key insight is that you don't need to know the data distribution — you only need to learn its score function, the gradient of the log-density.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 4 min read

Why Dropout Disappeared from Large Language Models

BERT used dropout everywhere. LLaMA uses none. The reason isn't that regularization stopped mattering — it's that at trillion-token scale, data diversity IS the regularizer.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

GRPO vs PPO: Why Removing the Value Head Changes Everything

GRPO achieves competitive alignment results without a value function. Here's exactly what changes in the math and implementation, and why that matters for training efficiency and stability.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 4 min read

Continuous Batching: How vLLM Serves Thousands of Requests

Static batching wastes GPU capacity whenever sequences finish at different times. Continuous batching fixes this by treating the decode loop as a queue — adding new requests the moment a slot opens up.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

GPU Architecture for LLM Inference

LLM inference is shaped by GPU hardware: HBM bandwidth, SRAM per SM, tensor core throughput, and the roofline that connects them. This post maps the memory hierarchy from HBM to tensor core, shows where decode and prefill sit on the roofline, and explains why FlashAttention exists.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

PagedAttention: Virtual Memory for the KV Cache

Contiguous KV cache allocation wastes GPU memory through fragmentation and over-reservation. PagedAttention fixes this by treating the KV cache as paged virtual memory — small fixed-size blocks assigned on demand, freed immediately, and reused without copying.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Prefill and Decode: The Two Phases of LLM Inference

LLM inference has two fundamentally different compute phases. Prefill processes the prompt in parallel and is compute-bound. Decode generates tokens one at a time and is memory-bandwidth-bound. Understanding both determines how you optimize.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

LLM Serving at Scale: Throughput, Latency, and System Design

A single GPU is the easy part. Serving LLMs at production scale involves tensor parallelism, pipeline parallelism, load balancing, SLO enforcement, and hardware heterogeneity. Here's how it fits together.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

The Lifecycle of a KV Cache: From Prefill to Last Token

A request-level walkthrough of how the KV cache is populated, grown, and read during LLM inference — covering prefill, decode, memory layout, and why decode is memory-bandwidth-bound.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

The LLM Alignment Pipeline: SFT, Reward Models, and RL End to End

Training a helpful, harmless, honest LLM requires three sequential stages that each build on the previous one. Here's how SFT, reward modeling, and RL fit together as a system — and where each stage can fail.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 18 min read

From Likelihood to Perplexity: One Unified Reference

Probability, likelihood, log-likelihood, NLL, expectation, entropy, cross-entropy, KL divergence, and perplexity are constantly confused for one another. They are not the same thing — but they are all the same thing seen from different angles. This is the definitive deep-dive that names each one precisely and shows exactly how they connect for LLMs.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

Activation Functions: The Nonlinearity That Makes Neural Networks Work

Without nonlinearity, stacking layers collapses to a single matrix multiplication. Activation functions break that linearity — and the choice of which one determines expressivity, gradient flow, and training efficiency.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

Evaluation Metrics: Precision, Recall, Calibration, and Confidence

How do you measure whether a model is actually good? The answer is a set of metrics — precision, recall, F1, perplexity, calibration, confidence intervals — each measuring something different and failing in a different way.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Linear Algebra for LLMs: Vectors, Matrices, and What They Do

Every forward pass is a sequence of matrix multiplications. Understanding what those matrices do — rotate, scale, project — is the foundation for understanding why transformers work.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Loss Functions: What You Optimize Is What You Get

The loss function is the specification. Everything the model learns is in service of minimizing it. Here's the math behind every major loss used in LLM training and fine-tuning.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Optimization for LLMs: Gradient Descent to Adam

Training a neural network is an optimization problem: minimize a loss function over billions of parameters. The journey from vanilla gradient descent to Adam reveals why each step was necessary.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Probability for LLMs: Distributions, Entropy, and KL Divergence

A language model is a probability distribution over sequences. Training it means pushing that distribution toward the data distribution. The math of how you measure and minimize that gap is what this post covers.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

Putting It Together: The Mathematics of a Training Run

A single training step involves linear algebra, probability, information theory, optimization, and statistical estimation — all at once. Here's how the pieces fit.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

Statistical Foundations: Distributions, Estimation, and Sampling

Language models are probabilistic systems. Understanding the statistical machinery behind maximum likelihood estimation, Bayesian inference, and sampling algorithms clarifies why training and decoding work the way they do.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

SVD and Low-Rank Approximation: The Math Behind LoRA

LoRA works because weight matrices are empirically low-rank. SVD explains why, and the math of low-rank approximation explains how LoRA exploits it to fine-tune billion-parameter models on a laptop.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

What Actually Happens to Padding Tokens During LLM Pretraining

Padding wastes GPU compute. Sequence packing eliminates it — but introduces cross-document attention contamination unless you explicitly mask it. Here's what the attention mask actually looks like.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

The Full PPO Training Step: Value Loss, Entropy, and GAE

ppo-loss-per-token covered the clipped surrogate objective. This post covers what surrounds it: how the value function is trained, where the advantage estimates come from, and why the entropy bonus exists.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

How PPO Computes Loss Over a Language Model Output

Most explanations of PPO stay at the algorithm level. This post goes one level deeper: how the surrogate loss is actually computed token by token for a language model response.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 10 min read

RL for Agentic Systems

Single-turn RL teaches a model to produce good responses. Agentic RL teaches it to complete multi-step tasks in an environment — with delayed rewards, partial observability, and real consequences.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

Learning from Feedback: RLHF, RLAIF, and Beyond

RLHF is three steps: supervised fine-tuning, reward model training, and policy optimization. Each step has a specific failure mode. Here's the full picture.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Policy Gradients: The Math Behind RLHF

The policy gradient theorem lets you differentiate through a reward signal you can't backprop through. Here's the derivation and why it works.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

RL as a Skill Acquisition Engine

The reward signal determines what the model learns to do. Swap the reward, swap the capability. Here's how RL elicits reasoning, code generation, math, and tool use.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Why Language Models Need Reinforcement Learning

Supervised fine-tuning teaches a model to imitate. Reinforcement learning teaches it to optimize. The difference turns out to matter enormously.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

Contrastive SSL: SimCLR, MoCo, and DINO

Contrastive learning teaches a model that two views of the same image should be close in representation space, and views of different images should be far apart. The details of how you enforce this determine everything.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 4 min read

I-JEPA: Self-Supervised Vision at Scale

I-JEPA applies the JEPA idea to images: predict the representations of target patches from a context region, without any view-level augmentations. The result transfers better to semantic tasks than pixel-level methods.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

JEPA: Predicting in Representation Space

MAE predicts pixels. Contrastive methods match views. JEPA predicts representations of target regions from context regions — in an abstract space where irrelevant details have already been discarded.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Masked Autoencoders: Learning by Filling in the Blanks

Mask 75% of an image's patches. Train a model to reconstruct them. The result is a rich visual representation — and the recipe works because pixels are redundant and structure is not.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 4 min read

V-JEPA: Predicting the Future in Representation Space

V-JEPA extends JEPA to video: predict the representations of future or masked frames from context frames. No pixel reconstruction, no contrastive loss — just abstract prediction across time.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Why Self-Supervised Learning? The Label Bottleneck

Supervised learning requires labels. Labels require humans. At scale, that's the bottleneck. Self-supervised learning sidesteps it by constructing supervision from the data itself.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

World Models: The Bigger Picture Behind JEPA

JEPA is a learning architecture. World models are the goal it points toward — internal simulators that can predict the consequences of actions and support planning without interacting with the real world.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

How Decoder-Only Transformers Evolved Since GPT-2

GPT-2 established the decoder-only transformer as the dominant paradigm. What followed was six years of systematic improvements — in scale, efficiency, alignment, and reasoning. Here's the arc.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Attention Variants: MHA, MQA, GQA, and the Memory Math Behind Them

Multi-head attention was the original. Multi-query attention was the efficient approximation. Grouped-query attention is the synthesis that modern LLMs converged on — and the reason is bandwidth, not FLOPs.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 13 min read

Debugging Transformer Training Runs: Reading the Curves

Most training failures leave signatures in the metrics before they fully manifest. Here's how to read loss curves, gradient norms, learning rate schedules, and activation statistics to diagnose what's going wrong.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 4 min read

Normalization in Transformers: Why Pre-LN Became the Default

Post-LN dominated the original transformer. Pre-LN dominates everything since GPT-2. The reason comes down to gradient flow — and the math is clean enough to be worth understanding.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 10 min read

Positional Encodings: From Sinusoids to RoPE

Attention is permutation-invariant. Positional encodings break that symmetry. The choice of encoding method determines whether your model can generalize to longer sequences than it trained on.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

DDIM: Deterministic Sampling in Fewer Steps

DDPM needs 1000 steps to generate a sample. DDIM reframes the reverse process as an ODE and gets the same quality in 50. The model weights are identical — only the sampling procedure changes.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

DDPM: The Diffusion Process, Forward and Reverse

DDPM defines a fixed forward process that gradually destroys an image into noise, then trains a neural network to reverse it. The math is tractable because each step is Gaussian.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

DiT: Replacing the U-Net with a Transformer

DDPM, DDIM, and latent diffusion all use a U-Net backbone. DiT replaces it with a transformer — and finds that diffusion scales with model size the same way language models do.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Flow Matching: The Cleaner Generalization of Diffusion

Diffusion models learn to reverse a specific noise process. Flow matching learns to transport any source distribution to any target distribution along straight paths — simpler math, faster sampling, and better training signal.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Latent Diffusion: Why You'd Compress Before You Denoise

Running DDPM in pixel space at 512×512 is expensive. Latent diffusion compresses the image into a small latent space first, runs the diffusion process there, and decodes back. The same quality, a fraction of the compute.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Score Matching: The Math Behind Diffusion

Diffusion models learn to reverse a noise process. The key insight is that you don't need to know the data distribution — you only need to learn its score function, the gradient of the log-density.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 4 min read

Why Dropout Disappeared from Large Language Models

BERT used dropout everywhere. LLaMA uses none. The reason isn't that regularization stopped mattering — it's that at trillion-token scale, data diversity IS the regularizer.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

GRPO vs PPO: Why Removing the Value Head Changes Everything

GRPO achieves competitive alignment results without a value function. Here's exactly what changes in the math and implementation, and why that matters for training efficiency and stability.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 4 min read

Continuous Batching: How vLLM Serves Thousands of Requests

Static batching wastes GPU capacity whenever sequences finish at different times. Continuous batching fixes this by treating the decode loop as a queue — adding new requests the moment a slot opens up.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

GPU Architecture for LLM Inference

LLM inference is shaped by GPU hardware: HBM bandwidth, SRAM per SM, tensor core throughput, and the roofline that connects them. This post maps the memory hierarchy from HBM to tensor core, shows where decode and prefill sit on the roofline, and explains why FlashAttention exists.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

PagedAttention: Virtual Memory for the KV Cache

Contiguous KV cache allocation wastes GPU memory through fragmentation and over-reservation. PagedAttention fixes this by treating the KV cache as paged virtual memory — small fixed-size blocks assigned on demand, freed immediately, and reused without copying.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Prefill and Decode: The Two Phases of LLM Inference

LLM inference has two fundamentally different compute phases. Prefill processes the prompt in parallel and is compute-bound. Decode generates tokens one at a time and is memory-bandwidth-bound. Understanding both determines how you optimize.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

LLM Serving at Scale: Throughput, Latency, and System Design

A single GPU is the easy part. Serving LLMs at production scale involves tensor parallelism, pipeline parallelism, load balancing, SLO enforcement, and hardware heterogeneity. Here's how it fits together.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

The Lifecycle of a KV Cache: From Prefill to Last Token

A request-level walkthrough of how the KV cache is populated, grown, and read during LLM inference — covering prefill, decode, memory layout, and why decode is memory-bandwidth-bound.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

The LLM Alignment Pipeline: SFT, Reward Models, and RL End to End

Training a helpful, harmless, honest LLM requires three sequential stages that each build on the previous one. Here's how SFT, reward modeling, and RL fit together as a system — and where each stage can fail.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 18 min read

From Likelihood to Perplexity: One Unified Reference

Probability, likelihood, log-likelihood, NLL, expectation, entropy, cross-entropy, KL divergence, and perplexity are constantly confused for one another. They are not the same thing — but they are all the same thing seen from different angles. This is the definitive deep-dive that names each one precisely and shows exactly how they connect for LLMs.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

Activation Functions: The Nonlinearity That Makes Neural Networks Work

Without nonlinearity, stacking layers collapses to a single matrix multiplication. Activation functions break that linearity — and the choice of which one determines expressivity, gradient flow, and training efficiency.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

Evaluation Metrics: Precision, Recall, Calibration, and Confidence

How do you measure whether a model is actually good? The answer is a set of metrics — precision, recall, F1, perplexity, calibration, confidence intervals — each measuring something different and failing in a different way.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Linear Algebra for LLMs: Vectors, Matrices, and What They Do

Every forward pass is a sequence of matrix multiplications. Understanding what those matrices do — rotate, scale, project — is the foundation for understanding why transformers work.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Loss Functions: What You Optimize Is What You Get

The loss function is the specification. Everything the model learns is in service of minimizing it. Here's the math behind every major loss used in LLM training and fine-tuning.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Optimization for LLMs: Gradient Descent to Adam

Training a neural network is an optimization problem: minimize a loss function over billions of parameters. The journey from vanilla gradient descent to Adam reveals why each step was necessary.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Probability for LLMs: Distributions, Entropy, and KL Divergence

A language model is a probability distribution over sequences. Training it means pushing that distribution toward the data distribution. The math of how you measure and minimize that gap is what this post covers.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

Putting It Together: The Mathematics of a Training Run

A single training step involves linear algebra, probability, information theory, optimization, and statistical estimation — all at once. Here's how the pieces fit.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

Statistical Foundations: Distributions, Estimation, and Sampling

Language models are probabilistic systems. Understanding the statistical machinery behind maximum likelihood estimation, Bayesian inference, and sampling algorithms clarifies why training and decoding work the way they do.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

SVD and Low-Rank Approximation: The Math Behind LoRA

LoRA works because weight matrices are empirically low-rank. SVD explains why, and the math of low-rank approximation explains how LoRA exploits it to fine-tune billion-parameter models on a laptop.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

What Actually Happens to Padding Tokens During LLM Pretraining

Padding wastes GPU compute. Sequence packing eliminates it — but introduces cross-document attention contamination unless you explicitly mask it. Here's what the attention mask actually looks like.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

The Full PPO Training Step: Value Loss, Entropy, and GAE

ppo-loss-per-token covered the clipped surrogate objective. This post covers what surrounds it: how the value function is trained, where the advantage estimates come from, and why the entropy bonus exists.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

How PPO Computes Loss Over a Language Model Output

Most explanations of PPO stay at the algorithm level. This post goes one level deeper: how the surrogate loss is actually computed token by token for a language model response.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 10 min read

RL for Agentic Systems

Single-turn RL teaches a model to produce good responses. Agentic RL teaches it to complete multi-step tasks in an environment — with delayed rewards, partial observability, and real consequences.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

Learning from Feedback: RLHF, RLAIF, and Beyond

RLHF is three steps: supervised fine-tuning, reward model training, and policy optimization. Each step has a specific failure mode. Here's the full picture.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Policy Gradients: The Math Behind RLHF

The policy gradient theorem lets you differentiate through a reward signal you can't backprop through. Here's the derivation and why it works.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

RL as a Skill Acquisition Engine

The reward signal determines what the model learns to do. Swap the reward, swap the capability. Here's how RL elicits reasoning, code generation, math, and tool use.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Why Language Models Need Reinforcement Learning

Supervised fine-tuning teaches a model to imitate. Reinforcement learning teaches it to optimize. The difference turns out to matter enormously.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 7 min read

Contrastive SSL: SimCLR, MoCo, and DINO

Contrastive learning teaches a model that two views of the same image should be close in representation space, and views of different images should be far apart. The details of how you enforce this determine everything.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 4 min read

I-JEPA: Self-Supervised Vision at Scale

I-JEPA applies the JEPA idea to images: predict the representations of target patches from a context region, without any view-level augmentations. The result transfers better to semantic tasks than pixel-level methods.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

JEPA: Predicting in Representation Space

MAE predicts pixels. Contrastive methods match views. JEPA predicts representations of target regions from context regions — in an abstract space where irrelevant details have already been discarded.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Masked Autoencoders: Learning by Filling in the Blanks

Mask 75% of an image's patches. Train a model to reconstruct them. The result is a rich visual representation — and the recipe works because pixels are redundant and structure is not.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 4 min read

V-JEPA: Predicting the Future in Representation Space

V-JEPA extends JEPA to video: predict the representations of future or masked frames from context frames. No pixel reconstruction, no contrastive loss — just abstract prediction across time.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

Why Self-Supervised Learning? The Label Bottleneck

Supervised learning requires labels. Labels require humans. At scale, that's the bottleneck. Self-supervised learning sidesteps it by constructing supervision from the data itself.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 5 min read

World Models: The Bigger Picture Behind JEPA

JEPA is a learning architecture. World models are the goal it points toward — internal simulators that can predict the consequences of actions and support planning without interacting with the real world.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 8 min read

How Decoder-Only Transformers Evolved Since GPT-2

GPT-2 established the decoder-only transformer as the dominant paradigm. What followed was six years of systematic improvements — in scale, efficiency, alignment, and reasoning. Here's the arc.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 6 min read

Attention Variants: MHA, MQA, GQA, and the Memory Math Behind Them

Multi-head attention was the original. Multi-query attention was the efficient approximation. Grouped-query attention is the synthesis that modern LLMs converged on — and the reason is bandwidth, not FLOPs.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 13 min read

Debugging Transformer Training Runs: Reading the Curves

Most training failures leave signatures in the metrics before they fully manifest. Here's how to read loss curves, gradient norms, learning rate schedules, and activation statistics to diagnose what's going wrong.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 4 min read

Normalization in Transformers: Why Pre-LN Became the Default

Post-LN dominated the original transformer. Pre-LN dominates everything since GPT-2. The reason comes down to gradient flow — and the math is clean enough to be worth understanding.

Blog Post · 2024-06-19 · Revised 2024-06-19 · 10 min read

Positional Encodings: From Sinusoids to RoPE

Attention is permutation-invariant. Positional encodings break that symmetry. The choice of encoding method determines whether your model can generalize to longer sequences than it trained on.