Ham's guide to AI engineering
Hamish Humbert
v1.0.4, 25 October 2026
This is my book on applied AI engineering: the work of putting language models into software that people rely on. I'm writing it as I learn to do the work, one chapter per skill the job asks for. The foreword says what is here and what isn't yet.
Only the foreword is written. The chapters below are the shape of the book, so you can see where it's going. The version goes up as they land; the changelog has the list.
- 1Forewordv1.0.4
- 1.1 What this is
- 1.2 What is here so far
- 1.3 Versions
- 2Setup and toolingnot yet
- 2.1 Dev Environment
- 2.1.1 System Foundation
- 2.1.2 Python with uv
- 2.1.3 Node.js with pnpm
- 2.1.4 Rust
- 2.1.5 Julia (Optional)
- 2.1.6 GPU Setup (If You Have One)
- 2.1.7 Verify the route you want to start
- 2.2 Git and Collaboration
- 2.2.1 Configure git
- 2.2.2 The daily workflow
- 2.2.3 Branching for experiments
- 2.2.4 Working with this course repo
- 2.3 GPU Setup and Cloud
- 2.3.1 Option 1: Local NVIDIA GPU
- 2.3.2 Option 2: Google Colab
- 2.3.3 Option 3: Cloud GPU
- 2.3.4 No GPU? No problem.
- 2.4 APIs and Keys
- 2.4.1 Store API keys safely
- 2.4.2 First API call (Python)
- 2.4.3 First API call (TypeScript)
- 2.4.4 Raw HTTP (no SDK)
- 2.5 Jupyter Notebooks
- 2.5.1 Pick your interface
- 2.5.2 Keyboard shortcuts that matter
- 2.5.3 Cell types
- 2.5.4 Magic commands
- 2.5.5 Display rich output inline
- 2.5.6 Google Colab
- 2.5.7 Notebooks vs Scripts: When to use which
- 2.5.8 Common traps
- 2.6 Python Environments
- 2.6.1 Option 1: uv venv (Recommended)
- 2.6.2 Option 2: venv (Built-in)
- 2.6.3 Option 3: conda (When You Need It)
- 2.6.4 For This Course: Per-Phase Strategy
- 2.6.5 Installing globally
- 2.6.6 Mixing pip and conda
- 2.6.7 Forgetting to activate
- 2.6.8 Committing .venv to git
- 2.6.9 CUDA version mismatch
- 2.7 Docker for AI
- 2.7.1 Why AI projects need Docker more than most
- 2.7.2 Key vocabulary
- 2.7.3 Common container patterns in AI
- 2.7.4 Install Docker
- 2.7.5 Install NVIDIA Container Toolkit (Linux with NVIDIA GPU)
- 2.7.6 Understand base images
- 2.7.7 Write a Dockerfile for AI development
- 2.7.8 Volume mounts for data and models
- 2.7.9 Docker Compose for multi-service AI apps
- 2.7.10 Useful Docker commands for AI work
- 2.7.11 No GPU?
- 2.8 Editor Setup
- 2.8.1 Install VS Code
- 2.8.2 Install Essential Extensions
- 2.8.3 Configure Settings
- 2.8.4 Terminal Integration
- 2.8.5 Remote Development (SSH into GPU Boxes)
- 2.8.6 Cursor
- 2.8.7 Windsurf
- 2.8.8 Vim/Neovim
- 2.9 Data Management
- 2.9.1 Install the datasets library
- 2.9.2 Load a dataset
- 2.9.3 Stream large datasets
- 2.9.4 Dataset formats
- 2.9.5 Data splits
- 2.9.6 Download and cache models
- 2.9.7 Handle large files
- 2.9.8 Storage patterns
- 2.10 Terminal and Shell
- 2.10.1 Know your shell
- 2.10.2 Piping and redirects
- 2.10.3 Background processes
- 2.10.4 tmux
- 2.10.5 Monitoring with htop and nvtop
- 2.10.6 SSH for remote GPU boxes
- 2.10.7 Useful aliases for AI work
- 2.10.8 Common AI terminal patterns
- 2.11 Linux for AI
- 2.11.1 Moving Around
- 2.11.2 Files and Directories
- 2.11.3 Reading Files
- 2.11.4 Searching
- 2.12 Debugging and Profiling
- 2.12.1 Part 1: Print Debugging (Yes, It Works)
- 2.12.2 Part 2: Python Debugger (pdb and breakpoint)
- 2.12.3 Part 3: Python Logging
- 2.12.4 Part 4: Timing Code Sections
- 2.12.5 Part 5: cProfile and line_profiler
- 2.12.6 Part 6: Memory Profiling
- 2.12.7 Part 7: Common AI Bugs and How to Catch Them
- 2.12.8 Part 8: TensorBoard Basics
- 2.12.9 Part 9: VS Code Debugger
- 2.13 Python for AI Engineering
- 2.13.1 What the course code uses
- 2.13.2 Names refer to objects
- 2.13.3 A list holds pointers, an array holds numbers
- 2.13.4 A list holds every item, a generator holds one
- 2.13.5 Values, collections, and unpacking
- 2.13.6 Comprehensions
- 2.13.7 Functions, arguments, and closures
- 2.13.8 Classes and dataclasses
- 2.13.9 Iterators and generators
- 2.13.10 Context managers and exceptions
- 2.13.11 Type hints, modules, and the main guard
- 2.13.12 Files, JSON, CSV, and sorting
- 2.13.13 Counting, grouping, and iterator tools
- 2.13.14 Why loops over numbers are slow
- 2.13.15 A record type and a dataset loader
- 2.13.16 A seeded train and test split
- 2.13.17 A mini-batch generator
- 2.13.18 Vector math and a standardizer
- 2.13.19 A complete run
- 2.13.20 Measure speed and memory
- 2.13.21 The standard library versions
- 2.13.22 The same math with compiled arrays
- 2.13.23 Broadcasting
- 3Math foundationsnot yet
- 3.1 Linear Algebra Intuition
- 3.1.1 Vectors Are Points (and Directions)
- 3.1.2 Matrices Are Transformations
- 3.1.3 The Dot Product Measures Similarity
- 3.1.4 Linear Independence
- 3.1.5 Basis and Rank
- 3.1.6 Projection
- 3.1.7 Gram-Schmidt Process
- 3.1.8 Vectors from scratch (Python)
- 3.1.9 Matrices from scratch (Python)
- 3.1.10 Why this matters for AI
- 3.1.11 Julia version
- 3.1.12 Linear independence and projection from scratch (Python)
- 3.1.13 Rank, Projection, and QR with NumPy
- 3.1.14 PyTorch -- Tensors Are Vectors with Autodiff
- 3.2 Vectors, Matrices and Operations
- 3.2.1 Vectors: ordered lists of numbers
- 3.2.2 Matrices: grids of numbers
- 3.2.3 Why shapes matter
- 3.2.4 The operations map
- 3.2.5 Element-wise vs matrix multiplication
- 3.2.6 Broadcasting
- 3.2.7 Vector class
- 3.2.8 Matrix class with core operations
- 3.2.9 See it work
- 3.2.10 Connect to neural networks
- 3.3 Matrix Transformations and Eigenvalues
- 3.3.1 Transformations as matrices
- 3.3.2 Rotation
- 3.3.3 Scaling
- 3.3.4 Shearing
- 3.3.5 Reflection
- 3.3.6 Composition: chaining transformations
- 3.3.7 Eigenvalues and eigenvectors
- 3.3.8 Eigendecomposition
- 3.3.9 Why eigenvalues matter
- 3.3.10 Determinant as volume scaling factor
- 3.3.11 Transformation matrices from scratch (Python)
- 3.3.12 Composition of transformations
- 3.3.13 Eigenvalues from scratch (2x2)
- 3.3.14 3D rotations with NumPy
- 3.4 Calculus for ML: Derivatives and Gradients
- 3.4.1 What is a derivative?
- 3.4.2 Partial derivatives: one variable at a time
- 3.4.3 The gradient: vector of all partial derivatives
- 3.4.4 The connection to optimization
- 3.4.5 Numerical vs analytical derivatives
- 3.4.6 Derivatives by hand for simple functions
- 3.4.7 The chain rule
- 3.4.8 The Hessian Matrix
- 3.4.9 Taylor Series Approximation
- 3.4.10 Integrals in ML
- 3.4.11 Multivariable Chain Rule in a Computation Graph
- 3.4.12 The Jacobian matrix
- 3.4.13 Why this matters for neural networks
- 3.4.14 Numerical derivative from scratch
- 3.4.15 Partial derivatives and gradients
- 3.4.16 Gradient descent to find the minimum of f(x) = x^2
- 3.4.17 Gradient descent on a 2D function
- 3.4.18 Comparing numerical and analytical derivatives
- 3.4.19 Computing the Hessian numerically
- 3.4.20 Taylor approximation in action
- 3.4.21 Why this matters for a neural network
- 3.5 Chain Rule and Automatic Differentiation
- 3.5.1 The Chain Rule
- 3.5.2 Computational Graphs
- 3.5.3 Forward Mode vs Reverse Mode
- 3.5.4 Dual Numbers for Forward Mode
- 3.5.5 Building an Autograd Engine
- 3.5.6 How PyTorch Autograd Works Under the Hood
- 3.5.7 The Value class
- 3.5.8 Arithmetic operations with gradient tracking
- 3.5.9 The backward pass
- 3.5.10 More operations for a complete engine
- 3.5.11 Mini MLP from scratch
- 3.5.12 Gradient checking
- 3.5.13 Verify against manual calculation
- 3.5.14 Verify against PyTorch
- 3.5.15 A more complex expression
- 3.6 Probability and Distributions
- 3.6.1 Events, Sample Spaces, and Probability
- 3.6.2 Conditional Probability and Independence
- 3.6.3 Probability Mass Functions vs Probability Density Functions
- 3.6.4 Common Distributions
- 3.6.5 Expected Value and Variance
- 3.6.6 Joint and Marginal Distributions
- 3.6.7 Why the Normal Distribution Shows Up Everywhere
- 3.6.8 Log Probabilities
- 3.6.9 Softmax as a Probability Distribution
- 3.6.10 Sampling
- 3.6.11 Probability basics
- 3.6.12 PMF and PDF from scratch
- 3.6.13 Expected value and variance
- 3.6.14 Sampling from distributions
- 3.6.15 Softmax and log probabilities
- 3.6.16 Central Limit Theorem demonstration
- 3.6.17 Visualization
- 3.7 Bayes' Theorem and Statistical Thinking
- 3.7.1 From joint probability to Bayes
- 3.7.2 The four parts
- 3.7.3 Medical test example
- 3.7.4 Spam filter example
- 3.7.5 Naive Bayes: independence assumption
- 3.7.6 Maximum likelihood estimation (MLE)
- 3.7.7 Maximum a posteriori (MAP)
- 3.7.8 Bayesian vs frequentist: the practical difference
- 3.7.9 Why Bayesian thinking matters for ML
- 3.7.10 Bayes theorem function
- 3.7.11 Naive Bayes classifier
- 3.7.12 Train on spam data
- 3.7.13 Inspect the learned probabilities
- 3.7.14 Conjugate Priors
- 3.7.15 Sequential Bayesian Updating
- 3.7.16 Connection to A/B Testing
- 3.8 Optimization: Gradient Descent Family
- 3.8.1 What optimization means
- 3.8.2 Gradient descent (vanilla)
- 3.8.3 Learning rate: the most important hyperparameter
- 3.8.4 SGD vs batch vs mini-batch
- 3.8.5 Momentum: the ball rolling downhill
- 3.8.6 Adam: adaptive learning rates
- 3.8.7 Learning rate schedules
- 3.8.8 Convex vs non-convex
- 3.8.9 Loss landscape visualization
- 3.8.10 Define a test function
- 3.8.11 Vanilla gradient descent
- 3.8.12 SGD with momentum
- 3.8.13 Adam
- 3.8.14 Run and compare
- 3.9 Information Theory: Entropy, KL Divergence
- 3.9.1 Information Content (Surprise)
- 3.9.2 Entropy (Average Surprise)
- 3.9.3 Cross-Entropy (The Loss Function You Use Every Day)
- 3.9.4 KL Divergence (Distance Between Distributions)
- 3.9.5 Mutual Information
- 3.9.6 Conditional Entropy
- 3.9.7 Joint Entropy
- 3.9.8 Mutual Information (Deep Dive)
- 3.9.9 Label Smoothing and Cross-Entropy
- 3.9.10 Why Cross-Entropy Is THE Classification Loss
- 3.9.11 Bits vs Nats
- 3.9.12 Perplexity
- 3.9.13 Information content and entropy
- 3.9.14 Cross-entropy and KL divergence
- 3.9.15 Cross-entropy as classification loss
- 3.9.16 Cross-entropy equals negative log-likelihood
- 3.9.17 Mutual information
- 3.10 Dimensionality Reduction: PCA, t-SNE, UMAP
- 3.10.1 The curse of dimensionality
- 3.10.2 PCA: find the directions that matter
- 3.10.3 Explained variance ratio
- 3.10.4 Choosing the number of components
- 3.10.5 t-SNE: preserve neighborhoods
- 3.10.6 UMAP: faster, better global structure
- 3.10.7 When to use which
- 3.10.8 Kernel PCA
- 3.10.9 Reconstruction Error
- 3.10.10 PCA from scratch
- 3.10.11 Test on synthetic data
- 3.10.12 MNIST digits in 2D
- 3.10.13 Compare with sklearn
- 3.10.14 UMAP comparison
- 3.11 Singular Value Decomposition
- 3.11.1 What SVD does geometrically
- 3.11.2 The full decomposition
- 3.11.3 Left singular vectors, singular values, right singular vectors
- 3.11.4 Outer product form
- 3.11.5 Relationship to eigendecomposition
- 3.11.6 Truncated SVD: low-rank approximation
- 3.11.7 Image compression with SVD
- 3.11.8 SVD for recommendation systems
- 3.11.9 SVD in NLP: Latent Semantic Analysis
- 3.11.10 SVD for noise reduction
- 3.11.11 Pseudoinverse via SVD
- 3.11.12 Numerical stability advantages
- 3.11.13 Connection to PCA
- 3.11.14 SVD from scratch using power iteration
- 3.11.15 Test and compare with NumPy
- 3.11.16 Image compression demo
- 3.11.17 Noise reduction
- 3.11.18 Pseudoinverse
- 3.12 Tensor Operations
- 3.12.1 What a tensor is
- 3.12.2 Tensor shapes in deep learning
- 3.12.3 How memory layout works
- 3.12.4 Broadcasting rules
- 3.12.5 Einsum: the universal tensor operation
- 3.12.6 Tensor storage and strides
- 3.12.7 Reshape, squeeze, unsqueeze
- 3.12.8 Transpose and permute
- 3.12.9 Element-wise operations and reductions
- 3.12.10 Broadcasting with NumPy
- 3.12.11 Einsum operations
- 3.12.12 Attention mechanism via einsum
- 3.12.13 Scratch vs NumPy
- 3.12.14 Scratch vs PyTorch
- 3.12.15 Every neural network layer as a tensor operation
- 3.13 Numerical Stability
- 3.13.1 IEEE 754: How Computers Store Real Numbers
- 3.13.2 Why 0.1 + 0.2 != 0.3
- 3.13.3 Catastrophic Cancellation
- 3.13.4 Overflow and Underflow
- 3.13.5 The Log-Sum-Exp Trick
- 3.13.6 Why Softmax Needs the Max-Subtraction Trick
- 3.13.7 NaN and Inf: Detection and Prevention
- 3.13.8 Numerical Gradient Checking
- 3.13.9 Mixed Precision Training
- 3.13.10 bfloat16 vs float16: Why bfloat16 Wins for Training
- 3.13.11 Gradient Clipping
- 3.13.12 Normalization Layers as Numerical Stabilizers
- 3.13.13 Common ML Numerical Bugs
- 3.13.14 Demonstrate floating point precision limits
- 3.13.15 Implement naive vs stable softmax
- 3.13.16 Implement stable log-sum-exp
- 3.13.17 Implement stable cross-entropy
- 3.13.18 Gradient checking
- 3.13.19 Mixed precision simulation
- 3.13.20 Gradient clipping
- 3.13.21 NaN/Inf detection
- 3.14 Norms and Distances
- 3.14.1 Norms: measuring vector magnitude
- 3.14.2 L1 Norm (Manhattan distance)
- 3.14.3 L2 Norm (Euclidean distance)
- 3.14.4 Lp Norms: the general family
- 3.14.5 L-infinity Norm (Chebyshev distance)
- 3.14.6 Cosine Similarity and Cosine Distance
- 3.14.7 Dot Product Similarity vs Cosine Similarity
- 3.14.8 Mahalanobis Distance
- 3.14.9 Jaccard Similarity (for sets)
- 3.14.10 Edit Distance (Levenshtein Distance)
- 3.14.11 KL Divergence (not a distance, but used like one)
- 3.14.12 Wasserstein Distance (Earth Mover's Distance)
- 3.14.13 Why Different Tasks Need Different Distances
- 3.14.14 Connection to Loss Functions
- 3.14.15 Connection to Regularization
- 3.14.16 Nearest Neighbor Search
- 3.14.17 All norm and distance functions
- 3.14.18 Same data, different distances, different neighbors
- 3.14.19 Embedding similarity search
- 3.15 Statistics for ML
- 3.15.1 Descriptive Statistics: Summarizing Your Data
- 3.15.2 Correlation: How Variables Move Together
- 3.15.3 Covariance Matrix
- 3.15.4 Hypothesis Testing
- 3.15.5 The t-test
- 3.15.6 Chi-squared Test
- 3.15.7 A/B Testing for ML Models
- 3.15.8 Statistical Significance vs Practical Significance
- 3.15.9 Multiple Comparison Problem
- 3.15.10 Bootstrap Methods
- 3.15.11 Parametric vs Non-parametric Tests
- 3.15.12 Central Limit Theorem: Practical Implications
- 3.15.13 Common Statistical Mistakes in ML Papers
- 3.16 Sampling Methods
- 3.16.1 Why Sampling Matters
- 3.16.2 Uniform Random Sampling
- 3.16.3 Inverse CDF Method (Inverse Transform Sampling)
- 3.16.4 Rejection Sampling
- 3.16.5 Importance Sampling
- 3.16.6 Monte Carlo Estimation
- 3.16.7 Markov Chain Monte Carlo (MCMC): Metropolis-Hastings
- 3.16.8 Gibbs Sampling
- 3.16.9 Temperature Sampling (Used in LLMs)
- 3.16.10 Top-k Sampling
- 3.16.11 Top-p (Nucleus) Sampling
- 3.16.12 Reparameterization Trick (Used in VAEs)
- 3.16.13 Gumbel-Softmax (Differentiable Categorical Sampling)
- 3.16.14 Stratified Sampling
- 3.16.15 Connection to Diffusion Models
- 3.16.16 Uniform and inverse CDF sampling
- 3.16.17 Rejection sampling
- 3.16.18 Importance sampling
- 3.16.19 Monte Carlo estimation of pi
- 3.16.20 Metropolis-Hastings MCMC
- 3.16.21 Gibbs sampling
- 3.16.22 Temperature sampling
- 3.16.23 Top-k and top-p sampling
- 3.16.24 Reparameterization trick
- 3.16.25 Gumbel-Softmax
- 3.17 Linear Systems
- 3.17.1 What Ax = b means geometrically
- 3.17.2 Column picture vs row picture
- 3.17.3 Gaussian elimination
- 3.17.4 Partial pivoting: why it matters
- 3.17.5 LU decomposition
- 3.17.6 QR decomposition
- 3.17.7 Cholesky decomposition
- 3.17.8 Least squares: when Ax = b has no exact solution
- 3.17.9 Normal equations = linear regression
- 3.17.10 Pseudoinverse (Moore-Penrose)
- 3.17.11 Condition number
- 3.17.12 Iterative methods: conjugate gradient
- 3.17.13 The full picture: which method when
- 3.17.14 Connection to ML
- 3.17.15 Gaussian elimination with partial pivoting
- 3.17.16 Least squares via normal equations
- 3.18 Convex Optimization
- 3.18.1 Convex sets
- 3.18.2 Convex functions
- 3.18.3 Testing for convexity
- 3.18.4 Why convexity matters
- 3.18.5 Convex vs non-convex in ML
- 3.18.6 The Hessian matrix
- 3.18.7 Newton's method
- 3.18.8 Constrained optimization
- 3.18.9 Lagrange multipliers
- 3.18.10 KKT conditions
- 3.18.11 Regularization as constrained optimization
- 3.18.12 Duality
- 3.18.13 Why deep learning works despite non-convexity
- 3.18.14 Second-order methods in practice
- 3.18.15 Convexity checker
- 3.18.16 Newton's method for 2D
- 3.18.17 Lagrange multiplier solver
- 3.18.18 Compare first-order vs second-order
- 3.19 Complex Numbers for AI
- 3.19.1 What is a complex number?
- 3.19.2 Complex arithmetic
- 3.19.3 The complex plane
- 3.19.4 Polar form
- 3.19.5 Euler's formula
- 3.19.6 Why Euler's formula matters for ML
- 3.19.7 Connection to 2D rotations
- 3.19.8 Phasors and rotating signals
- 3.19.9 Roots of unity
- 3.19.10 Connection to the DFT
- 3.19.11 Why i is not imaginary
- 3.19.12 Complex exponentials vs trigonometric functions
- 3.19.13 Connection to transformers
- 3.19.14 Complex class
- 3.19.15 Polar conversion and Euler's formula
- 3.19.16 Rotation
- 3.19.17 DFT from complex arithmetic
- 3.19.18 Inverse DFT
- 3.20 The Fourier Transform
- 3.20.1 The DFT definition
- 3.20.2 What each coefficient means
- 3.20.3 Inverse DFT
- 3.20.4 The FFT: making it fast
- 3.20.5 Spectral analysis
- 3.20.6 Frequency resolution
- 3.20.7 The convolution theorem
- 3.20.8 Windowing
- 3.20.9 DFT properties
- 3.20.10 Connection to positional encodings
- 3.20.11 Connection to CNNs
- 3.20.12 Spectrograms and the Short-Time Fourier Transform
- 3.20.13 Aliasing
- 3.20.14 Zero-padding does not increase resolution
- 3.20.15 DFT from scratch
- 3.20.16 FFT (Cooley-Tukey)
- 3.20.17 Spectral analysis helpers
- 3.21 Graph Theory for ML
- 3.21.1 Graphs: Nodes and Edges
- 3.21.2 The Adjacency Matrix
- 3.21.3 Degree
- 3.21.4 BFS and DFS
- 3.21.5 The Graph Laplacian
- 3.21.6 Spectral Properties
- 3.21.7 Message Passing
- 3.21.8 Concepts and ML Applications
- 3.21.9 Graph class from scratch
- 3.21.10 Connected components and Laplacian eigenvalues
- 3.21.11 Spectral clustering
- 3.21.12 Message passing
- 3.21.13 numpy spectral analysis
- 3.22 Stochastic Processes
- 3.22.1 Random Walks
- 3.22.2 Markov Chains
- 3.22.3 Connection to Language Models
- 3.22.4 Brownian Motion
- 3.22.5 Langevin Dynamics
- 3.22.6 MCMC: Markov Chain Monte Carlo
- 3.22.7 Stochastic Processes in AI
- 3.22.8 Random walk simulator
- 3.22.9 Markov chain
- 3.22.10 Langevin dynamics
- 3.22.11 Metropolis-Hastings
- 3.22.12 numpy for transition matrices
- 3.22.13 Connections to real frameworks
- 3.22.14 Verifying Markov chain convergence
- 4ML fundamentalsnot yet
- 4.1 What Is Machine Learning
- 4.1.1 Learning From Data, Not Rules
- 4.1.2 The Three Types of Machine Learning
- 4.1.3 Beyond the Big Three
- 4.1.4 Classification vs Regression
- 4.1.5 The ML Workflow
- 4.1.6 Training, Validation, and Test Splits
- 4.1.7 Overfitting vs Underfitting
- 4.1.8 The Bias-Variance Tradeoff
- 4.1.9 No Free Lunch Theorem
- 4.1.10 When NOT to Use Machine Learning
- 4.1.11 Nearest Centroid Classifier from Scratch
- 4.1.12 Train on Synthetic Data
- 4.1.13 Compare Against a Baseline
- 4.1.14 Why This Matters
- 4.1.15 What the Centroid Classifier Cannot Do
- 4.2 Linear Regression from Scratch
- 4.2.1 The Model
- 4.2.2 The Cost Function (Mean Squared Error)
- 4.2.3 Gradient Descent
- 4.2.4 The Normal Equation (Closed-Form Solution)
- 4.2.5 Multiple Linear Regression
- 4.2.6 Polynomial Regression
- 4.2.7 R-Squared Score
- 4.2.8 Regularization Preview (Ridge Regression)
- 4.2.9 Generate sample data
- 4.2.10 Linear regression from scratch with gradient descent
- 4.2.11 Normal equation (closed-form solution)
- 4.2.12 Multiple linear regression
- 4.2.13 Polynomial regression
- 4.2.14 Ridge regression (L2 regularization)
- 4.3 Logistic Regression and Classification
- 4.3.1 Why Linear Regression Fails for Classification
- 4.3.2 The Sigmoid Function
- 4.3.3 Logistic Regression = Linear Model + Sigmoid
- 4.3.4 Binary Cross-Entropy Loss
- 4.3.5 Gradient Descent for Logistic Regression
- 4.3.6 The Decision Boundary
- 4.3.7 Multi-Class Classification with Softmax
- 4.3.8 Evaluation Metrics
- 4.3.9 Sigmoid function and data generation
- 4.3.10 Logistic regression from scratch
- 4.3.11 Confusion matrix and metrics from scratch
- 4.3.12 Decision boundary analysis
- 4.3.13 Multi-class with softmax
- 4.3.14 Threshold tuning
- 4.4 Decision Trees and Random Forests
- 4.4.1 What a decision tree does
- 4.4.2 Split criteria: measuring impurity
- 4.4.3 How splitting works
- 4.4.4 Stopping conditions
- 4.4.5 Decision trees for regression
- 4.4.6 Random forests: the power of ensembles
- 4.4.7 Feature importance
- 4.4.8 When trees beat neural networks
- 4.4.9 Gini impurity and entropy
- 4.4.10 Find the best split
- 4.4.11 Build the DecisionTree class
- 4.4.12 Build the RandomForest class
- 4.5 Support Vector Machines
- 4.5.1 The maximum margin classifier
- 4.5.2 Support vectors: the critical few
- 4.5.3 Soft margin: handling noise with the C parameter
- 4.5.4 Hinge loss: the SVM loss function
- 4.5.5 Training a linear SVM with gradient descent
- 4.5.6 The dual formulation and the kernel trick
- 4.5.7 SVM for regression (SVR)
- 4.5.8 Why SVMs lost to deep learning (and when they still win)
- 4.5.9 Hinge loss and gradient
- 4.5.10 Linear SVM via gradient descent
- 4.5.11 Kernel functions
- 4.5.12 Margin and support vector identification
- 4.6 KNN and Distance Metrics
- 4.6.1 How KNN works
- 4.6.2 Choosing K
- 4.6.3 Distance metrics
- 4.6.4 Weighted KNN
- 4.6.5 The curse of dimensionality
- 4.6.6 KD-trees: fast nearest neighbor search
- 4.6.7 Ball trees: better for moderate dimensions
- 4.6.8 Lazy learning vs eager learning
- 4.6.9 KNN for regression
- 4.6.10 Distance functions
- 4.6.11 KNN classifier and regressor
- 4.6.12 KD-tree for efficient search
- 4.6.13 Feature scaling
- 4.7 Unsupervised Learning: K-Means, DBSCAN
- 4.7.1 Clustering: Grouping Similar Things Together
- 4.7.2 K-Means: The Workhorse
- 4.7.3 Choosing K
- 4.7.4 DBSCAN: Density-Based Clustering
- 4.7.5 Hierarchical Clustering
- 4.7.6 Gaussian Mixture Models (GMM)
- 4.7.7 When to Use Which
- 4.7.8 Anomaly Detection with Clustering
- 4.7.9 K-Means from scratch
- 4.7.10 Elbow method and silhouette score
- 4.7.11 DBSCAN from scratch
- 4.7.12 Gaussian Mixture Model (EM algorithm)
- 4.7.13 Generate test data and run everything
- 4.8 Feature Engineering and Selection
- 4.8.1 The Feature Pipeline
- 4.8.2 Numerical Features
- 4.8.3 Categorical Features
- 4.8.4 Text Features
- 4.8.5 Missing Values
- 4.8.6 Feature Interaction
- 4.8.7 Feature Selection
- 4.8.8 Numerical transforms from scratch
- 4.8.9 Categorical encoding from scratch
- 4.8.10 Text features from scratch
- 4.8.11 Missing value imputation from scratch
- 4.8.12 Feature selection from scratch
- 4.8.13 Full pipeline and demo
- 4.9 Model Evaluation: Metrics, Cross-Validation
- 4.9.1 Train, Validation, Test
- 4.9.2 K-Fold Cross-Validation
- 4.9.3 Classification Metrics
- 4.9.4 Regression Metrics
- 4.9.5 Learning Curves
- 4.9.6 Validation Curves
- 4.9.7 Common Evaluation Mistakes
- 4.9.8 Train/validation/test split
- 4.9.9 K-fold and stratified K-fold cross-validation
- 4.9.10 Confusion matrix and classification metrics
- 4.9.11 Regression metrics
- 4.9.12 Learning curves
- 4.9.13 A simple classifier for testing, plus the full demo
- 4.10 Bias, Variance and the Learning Curve
- 4.10.1 Bias: Systematic Error
- 4.10.2 Variance: Sensitivity to Training Data
- 4.10.3 The Decomposition
- 4.10.4 Model Complexity vs Error
- 4.10.5 Regularization as Bias-Variance Control
- 4.10.6 Double Descent: The Modern Perspective
- 4.10.7 Diagnosing Your Model
- 4.10.8 Practical Strategies
- 4.10.9 Ensemble Methods and Variance Reduction
- 4.10.10 Learning Curves
- 4.10.11 How to Generate Learning Curves
- 4.10.12 Generate Synthetic Data from a Known Function
- 4.10.13 Bootstrap Sampling and Polynomial Fitting
- 4.10.14 Computing Bias^2, Variance Decomposition
- 4.10.15 Regularization Sweep
- 4.10.16 Validation Curve: Sweep Model Complexity
- 4.10.17 Learning Curve: Sweep Training Set Size
- 4.10.18 Cross-Validation with Regularization Sweep
- 4.10.19 Putting It All Together: A Complete Diagnostic Workflow
- 4.11 Ensemble Methods: Boosting, Bagging, Stacking
- 4.11.1 Why Ensembles Work
- 4.11.2 Bagging (Bootstrap Aggregating)
- 4.11.3 Boosting (Sequential Error Correction)
- 4.11.4 AdaBoost
- 4.11.5 Gradient Boosting
- 4.11.6 XGBoost: Why It Dominates Tabular Data
- 4.11.7 Stacking (Meta-Learning)
- 4.11.8 Voting
- 4.11.9 Decision Stump (Base Learner)
- 4.11.10 AdaBoost from Scratch
- 4.11.11 Gradient Boosting from Scratch
- 4.11.12 Compare against sklearn
- 4.11.13 When to Use Each Method
- 4.11.14 The Production Stack for Tabular Data
- 4.12 Hyperparameter Tuning
- 4.12.1 Parameters vs Hyperparameters
- 4.12.2 Grid Search
- 4.12.3 Random Search
- 4.12.4 Bayesian Optimization
- 4.12.5 Early Stopping
- 4.12.6 Learning Rate Schedulers
- 4.12.7 Hyperparameter Importance
- 4.12.8 Practical Strategy
- 4.12.9 Cross-Validation Integration
- 4.12.10 Practical Tips
- 4.12.11 Grid Search from Scratch
- 4.12.12 Random Search from Scratch
- 4.12.13 Bayesian Optimization (Simplified)
- 4.12.14 Compare All Methods
- 4.12.15 Optuna in Practice
- 4.12.16 Optuna with Pruning
- 4.12.17 sklearn's Built-in Tuners
- 4.12.18 Common Mistakes in Hyperparameter Tuning
- 4.13 ML Pipelines and Experiment Tracking
- 4.13.1 What a Pipeline Is
- 4.13.2 Data Leakage: The Silent Killer
- 4.13.3 sklearn Pipeline
- 4.13.4 ColumnTransformer: Different Pipelines for Different Columns
- 4.13.5 Experiment Tracking
- 4.13.6 Model Versioning
- 4.13.7 Data Versioning with DVC
- 4.13.8 Reproducible Experiments
- 4.13.9 From Notebook to Production Pipeline
- 4.13.10 Common Pipeline Mistakes
- 4.13.11 Custom Transformer
- 4.13.12 Pipeline from Scratch
- 4.13.13 Cross-Validation with Pipeline
- 4.13.14 Full Production Pipeline with sklearn
- 4.14 Naive Bayes
- 4.14.1 Bayes' Theorem (Quick Review)
- 4.14.2 The Naive Independence Assumption
- 4.14.3 Why It Still Works
- 4.14.4 The Math Step by Step
- 4.14.5 Three Variants
- 4.14.6 When to Use Each Variant
- 4.14.7 Laplace Smoothing
- 4.14.8 Log-Space Computation
- 4.14.9 Naive Bayes vs Logistic Regression
- 4.14.10 Classification Pipeline
- 4.14.11 MultinomialNB
- 4.14.12 GaussianNB
- 4.14.13 Demo: Text Classification
- 4.14.14 Demo: Continuous Features
- 4.14.15 Prediction Speed
- 4.14.16 TF-IDF with Naive Bayes
- 4.14.17 BernoulliNB for Short Text
- 4.14.18 Calibrating NB Probabilities
- 4.14.19 Common Gotchas
- 4.14.20 When Naive Bayes Fails
- 4.15 Time Series Fundamentals
- 4.15.1 What Makes Time Series Different
- 4.15.2 Components of a Time Series
- 4.15.3 Stationarity
- 4.15.4 Autocorrelation
- 4.15.5 Lag Features: Turning Time Series into Supervised Learning
- 4.15.6 Walk-Forward Validation
- 4.15.7 ARIMA Intuition
- 4.15.8 When to Use What
- 4.15.9 Forecasting Horizons and Strategies
- 4.15.10 Common Mistakes in Time Series
- 4.15.11 Lag Feature Creator
- 4.15.12 Walk-Forward Cross-Validation
- 4.15.13 Simple Autoregressive Model
- 4.15.14 Stationarity Check
- 4.15.15 sklearn TimeSeriesSplit
- 4.15.16 Evaluation Metrics
- 4.15.17 Rolling Features
- 4.15.18 Baselines You Must Beat
- 4.15.19 Practical Tips
- 4.16 Anomaly Detection
- 4.16.1 Types of Anomalies
- 4.16.2 The Unsupervised Framing
- 4.16.3 Supervised vs Unsupervised: The Tradeoff
- 4.16.4 Z-Score Method
- 4.16.5 IQR Method
- 4.16.6 Isolation Forest
- 4.16.7 Local Outlier Factor (LOF)
- 4.16.8 Comparison
- 4.16.9 Evaluation Challenges
- 4.16.10 Anomaly Detection Pipeline
- 4.16.11 Z-Score Detector
- 4.16.12 IQR Detector
- 4.16.13 Isolation Forest from Scratch
- 4.16.14 Demo Scenarios
- 4.16.15 sklearn Contamination Parameter
- 4.16.16 One-Class SVM
- 4.16.17 Autoencoder Approach (Preview)
- 4.16.18 Ensemble Anomaly Detection
- 4.16.19 Production Considerations
- 4.16.20 Choosing a Threshold
- 4.16.21 Scaling to Production
- 4.17 Handling Imbalanced Data
- 4.17.1 Why Accuracy Fails
- 4.17.2 Better Metrics
- 4.17.3 The Imbalanced Data Pipeline
- 4.17.4 SMOTE: Synthetic Minority Oversampling Technique
- 4.17.5 Sampling Strategies Compared
- 4.17.6 Class Weights
- 4.17.7 Threshold Tuning
- 4.17.8 Cost-Sensitive Learning
- 4.17.9 Decision Flowchart
- 4.17.10 Generate an imbalanced dataset
- 4.17.11 SMOTE from scratch
- 4.17.12 Random oversampling and undersampling
- 4.17.13 Logistic regression with class weights
- 4.17.14 Threshold tuning
- 4.17.15 Evaluation functions
- 4.17.16 Compare all approaches
- 4.18 Feature Selection
- 4.18.1 Three Categories of Feature Selection
- 4.18.2 Variance Threshold
- 4.18.3 Mutual Information
- 4.18.4 Recursive Feature Elimination (RFE)
- 4.18.5 L1 (Lasso) Regularization
- 4.18.6 Tree-Based Feature Importance
- 4.18.7 Permutation Importance
- 4.18.8 Comparison Table
- 4.18.9 Decision Flowchart
- 4.18.10 Generate synthetic data with known feature structure
- 4.18.11 Variance threshold
- 4.18.12 Mutual information (discrete)
- 4.18.13 Recursive Feature Elimination
- 4.18.14 L1 feature selection
- 4.18.15 Tree-based importance (simple decision tree)
- 4.18.16 Run all methods and compare
- 4.19 ML System Design — From Problem to Deployed Model
- 4.19.1 From a business goal to an ML task
- 4.19.2 When not to use ML
- 4.19.3 Three layers of metrics
- 4.19.4 Baselines
- 4.19.5 Data and label requirements
- 4.19.6 Latency, throughput, and cost budgets
- 4.19.7 Batch inference versus online inference
- 4.19.8 Deployment patterns
- 4.19.9 Feedback loops
- 4.19.10 Failure modes and safe defaults
- 4.19.11 The design document
- 4.19.12 Describe the workload and the prices
- 4.19.13 Price batch and online serving
- 4.19.14 Compare a model with its baselines
- 4.19.15 Score a design document
- 4.19.16 Run it
- 4.20 Monitoring Models in Production — Data Drift and Concept Drift
- 4.20.1 What to monitor
- 4.20.2 Three kinds of drift
- 4.20.3 Delayed labels
- 4.20.4 Reference and current windows
- 4.20.5 Population Stability Index
- 4.20.6 Kolmogorov-Smirnov statistic
- 4.20.7 Chi-square test for categorical features
- 4.20.8 Alert thresholds and false alarms
- 4.20.9 Retraining triggers
- 4.20.10 Quantile bins and PSI
- 4.20.11 The KS statistic and its p-value
- 4.20.12 The chi-square test
- 4.20.13 Windows and the drift monitor
- 4.20.14 The alert policy
- 4.20.15 A stream with injected drift
- 4.21 Feature Stores and Training-Serving Skew
- 4.21.1 Two readers of the same feature
- 4.21.2 Entities, timestamps, and TTL
- 4.21.3 Point-in-time correct joins
- 4.21.4 Causes of training-serving skew
- 4.21.5 A feature registry
- 4.21.6 Backfills
- 4.21.7 Detecting skew
- 4.21.8 Feature definitions and the registry
- 4.21.9 Backfill the offline store
- 4.21.10 The point-in-time join
- 4.21.11 Measure the leak from a naive join
- 4.21.12 The online store and materialization
- 4.21.13 The skew check
- 5Deep learning corenot yet
- 5.1 The Perceptron: Where It All Started
- 5.1.1 One Neuron, One Decision
- 5.1.2 The Decision Boundary
- 5.1.3 The Learning Rule
- 5.1.4 The XOR Problem
- 5.1.5 The Perceptron class
- 5.1.6 Train on logic gates
- 5.1.7 Watch XOR fail
- 5.1.8 Solve XOR with two layers
- 5.1.9 Train a Two-Layer Network
- 5.2 Multi-Layer Networks and Forward Pass
- 5.2.1 Layers: Input, Hidden, Output
- 5.2.2 Neurons and Activations
- 5.2.3 Forward Pass: How Data Flows
- 5.2.4 Matrix Dimensions
- 5.2.5 Universal Approximation Theorem
- 5.2.6 Composability
- 5.2.7 Sigmoid Activation
- 5.2.8 Layer Class
- 5.2.9 Network Class
- 5.2.10 XOR with Hand-Tuned Weights
- 5.2.11 Circle Classification
- 5.3 Backpropagation from Scratch
- 5.3.1 The Chain Rule, Applied to Networks
- 5.3.2 Computational Graphs
- 5.3.3 Forward vs Backward
- 5.3.4 Gradient Flow Through a Network
- 5.3.5 Vanishing Gradients
- 5.3.6 Deriving Gradients for a 2-Layer Network
- 5.3.7 The Value Node
- 5.3.8 Operations with Backward Functions
- 5.3.9 Sigmoid and Loss
- 5.3.10 Backward Pass
- 5.3.11 Layer and Network
- 5.3.12 Train on XOR
- 5.3.13 Circle Classification
- 5.4 Activation Functions: ReLU, Sigmoid, GELU and Why
- 5.4.1 Why Nonlinearity Is Necessary
- 5.4.2 Sigmoid
- 5.4.3 Tanh
- 5.4.4 ReLU: The Breakthrough
- 5.4.5 Leaky ReLU
- 5.4.6 GELU: The Modern Default
- 5.4.7 Swish / SiLU
- 5.4.8 Softmax: The Output Activation
- 5.4.9 Comparison of Shapes
- 5.4.10 Gradient Flow Comparison
- 5.4.11 Which Activation When
- 5.4.12 Implement All Activation Functions with Derivatives
- 5.4.13 Visualize Where Gradients Die
- 5.4.14 Vanishing Gradient Experiment
- 5.4.15 Dead Neuron Detector
- 5.4.16 Training Comparison -- Sigmoid vs ReLU vs GELU
- 5.5 Loss Functions: MSE, Cross-Entropy, Contrastive
- 5.5.1 Mean Squared Error (MSE)
- 5.5.2 Cross-Entropy Loss
- 5.5.3 Why MSE Fails for Classification
- 5.5.4 Label Smoothing
- 5.5.5 Contrastive Loss
- 5.5.6 Focal Loss
- 5.5.7 Loss Function Decision Tree
- 5.5.8 Loss Landscape
- 5.5.9 MSE and Its Gradient
- 5.5.10 Binary Cross-Entropy
- 5.5.11 Categorical Cross-Entropy with Softmax
- 5.5.12 Contrastive Loss (Simplified InfoNCE)
- 5.5.13 MSE vs Cross-Entropy on Classification
- 5.6 Optimizers: SGD, Momentum, Adam, AdamW
- 5.6.1 Stochastic Gradient Descent (SGD)
- 5.6.2 Momentum
- 5.6.3 RMSProp
- 5.6.4 Adam: Momentum + RMSProp
- 5.6.5 AdamW: Weight Decay Done Right
- 5.6.6 Learning Rate: The Most Important Hyperparameter
- 5.6.7 Optimizer Comparison
- 5.6.8 When Each Optimizer Wins
- 5.6.9 Vanilla SGD
- 5.6.10 SGD with Momentum
- 5.6.11 Adam
- 5.6.12 AdamW
- 5.6.13 Training Comparison
- 5.7 Regularization: Dropout, Weight Decay, BatchNorm
- 5.7.1 The Overfitting Spectrum
- 5.7.2 Dropout
- 5.7.3 Weight Decay (L2 Regularization)
- 5.7.4 Batch Normalization
- 5.7.5 Layer Normalization
- 5.7.6 RMSNorm
- 5.7.7 Normalization Comparison
- 5.7.8 Data Augmentation as Regularization
- 5.7.9 Early Stopping
- 5.7.10 When to Apply What
- 5.7.11 Dropout (Train and Eval Mode)
- 5.7.12 L2 Weight Decay
- 5.7.13 Training With and Without Regularization
- 5.8 Weight Initialization and Training Stability
- 5.8.1 The Symmetry Problem
- 5.8.2 Variance Propagation Through Layers
- 5.8.3 Xavier/Glorot Initialization
- 5.8.4 Kaiming/He Initialization
- 5.8.5 Transformer Initialization
- 5.8.6 Activation Magnitude Through 50 Layers
- 5.8.7 Choosing the Right Init
- 5.8.8 Initialization Strategies
- 5.8.9 Activation Functions
- 5.8.10 Forward Pass Through 50 Layers
- 5.8.11 The Experiment
- 5.8.12 Symmetry Demonstration
- 5.8.13 Layer-by-Layer Magnitude Report
- 5.9 Learning Rate Schedules and Warmup
- 5.9.1 Constant Learning Rate
- 5.9.2 Step Decay
- 5.9.3 Cosine Annealing
- 5.9.4 Warmup: Why You Start Small
- 5.9.5 Linear Warmup + Cosine Decay
- 5.9.6 1cycle Policy
- 5.9.7 Schedule Shapes
- 5.9.8 Decision Flowchart
- 5.9.9 Real Numbers from Published Models
- 5.9.10 Schedule Functions
- 5.9.11 Visualize All Schedules
- 5.9.12 Training Network
- 5.9.13 Compare All Schedules
- 5.9.14 LR Too High vs Too Low
- 5.10 Build Your Own Mini Framework
- 5.10.1 The Module Abstraction
- 5.10.2 Sequential Container
- 5.10.3 Training vs Evaluation Mode
- 5.10.4 Optimizer
- 5.10.5 DataLoader
- 5.10.6 Framework Architecture
- 5.10.7 Training Loop
- 5.10.8 Module Hierarchy
- 5.10.9 Module Base Class
- 5.10.10 Linear Layer
- 5.10.11 Activation Modules
- 5.10.12 Dropout Module
- 5.10.13 BatchNorm Module
- 5.10.14 Loss Functions
- 5.10.15 SGD and Adam Optimizers
- 5.10.16 Train a 4-Layer Network on Circle Classification
- 5.11 Introduction to PyTorch
- 5.11.1 Why PyTorch Won
- 5.11.2 Tensors
- 5.11.3 Autograd
- 5.11.4 nn.Module
- 5.11.5 Loss Functions and Optimizers
- 5.11.6 The Training Loop
- 5.11.7 Dataset and DataLoader
- 5.11.8 GPU Training
- 5.11.9 Comparison: Mini Framework vs PyTorch vs JAX
- 5.11.10 Load MNIST From Raw Files
- 5.11.11 Define the Model
- 5.11.12 Training Loop
- 5.11.13 Wire Everything Together
- 5.11.14 Quick Comparison: Mini Framework vs PyTorch
- 5.11.15 Saving and Loading Models
- 5.11.16 Learning Rate Scheduling
- 5.12 Introduction to JAX
- 5.12.1 The JAX Philosophy
- 5.12.2 jax.numpy: The Familiar Surface
- 5.12.3 jax.grad: Functional Autodiff
- 5.12.4 jit: Compile to XLA
- 5.12.5 vmap: Automatic Vectorization
- 5.12.6 pmap: Data Parallelism Across Devices
- 5.12.7 Pytrees: The Universal Data Structure
- 5.12.8 Functional vs Object-Oriented
- 5.12.9 The JAX Ecosystem
- 5.12.10 When to Use JAX vs PyTorch
- 5.12.11 Random Numbers in JAX
- 5.12.12 Setup and Data
- 5.12.13 Initialize Parameters
- 5.12.14 Forward Pass
- 5.12.15 JIT-Compiled Training Step
- 5.12.16 Training Loop
- 5.12.17 Flax: The Google Standard
- 5.12.18 Equinox: The Pythonic Alternative
- 5.12.19 Optax: Composable Optimizers
- 5.13 Debugging Neural Networks
- 5.13.1 The Debugging Mindset
- 5.13.2 Symptom 1: Loss Not Decreasing
- 5.13.3 Symptom 2: Loss Decreasing But Model is Bad
- 5.13.4 Symptom 3: NaN or Inf in Loss
- 5.13.5 Technique 1: Gradient Checking
- 5.13.6 Technique 2: Activation Statistics
- 5.13.7 Technique 3: Gradient Flow Visualization
- 5.13.8 Technique 4: The Overfit-One-Batch Test
- 5.13.9 Technique 5: Learning Rate Finder
- 5.13.10 Common PyTorch Bugs
- 5.13.11 The Master Debugging Table
- 5.13.12 The NetworkDebugger Class
- 5.13.13 The Overfit-One-Batch Test
- 5.13.14 Learning Rate Finder
- 5.13.15 Gradient Checker
- 5.13.16 Deliberately Broken Networks
- 5.13.17 PyTorch Built-in Tools
- 5.13.18 Weights and Biases Integration
- 5.13.19 TensorBoard
- 5.13.20 The Debug Checklist (Before Full Training)
- 6Computer visionnot yet
- 6.1 Image Fundamentals: Pixels, Channels, Color Spaces
- 6.1.1 The full preprocessing pipeline at a glance
- 6.1.2 A pixel is a sample, not a square
- 6.1.3 Why three channels
- 6.1.4 Two layout conventions: HWC and CHW
- 6.1.5 Byte ranges and dtype
- 6.1.6 Color spaces and why they exist
- 6.1.7 Aspect ratio, resizing, and interpolation
- 6.1.8 Build an image tensor and inspect its shape
- 6.1.9 Split channels and re-order layout
- 6.1.10 Grayscale and HSV conversions
- 6.1.11 Normalize, standardize, and reverse it
- 6.1.12 Resize from scratch
- 6.2 Convolutions from Scratch
- 6.2.1 One kernel, sliding
- 6.2.2 Output size formula
- 6.2.3 Padding
- 6.2.4 Stride
- 6.2.5 Multiple input channels
- 6.2.6 The im2col trick
- 6.2.7 Receptive field
- 6.2.8 Pad an array
- 6.2.9 2D convolution with nested loops
- 6.2.10 Verify with a hand-designed kernel
- 6.2.11 im2col
- 6.2.12 Fast conv via im2col + matmul
- 6.2.13 A bank of hand-designed kernels
- 6.3 CNNs: LeNet to ResNet
- 6.3.1 The four ideas that changed vision
- 6.3.2 LeNet-5 (1998)
- 6.3.3 AlexNet (2012)
- 6.3.4 VGG (2014)
- 6.3.5 Inception (2014, same year)
- 6.3.6 The degradation problem
- 6.3.7 ResNet (2015)
- 6.3.8 Why residuals matter beyond vision
- 6.3.9 LeNet-5
- 6.3.10 A VGG block
- 6.3.11 A ResNet BasicBlock
- 6.3.12 A tiny ResNet
- 6.3.13 Compare parameter-to-feature efficiency
- 6.4 Image Classification
- 6.4.1 The classification pipeline
- 6.4.2 Cross-entropy, logits, and softmax
- 6.4.3 Why augmentation works
- 6.4.4 Mixup and cutmix
- 6.4.5 Label smoothing
- 6.4.6 Evaluation beyond accuracy
- 6.4.7 A deterministic synthetic dataset
- 6.4.8 Normalisation and augmentation
- 6.4.9 Mixup
- 6.4.10 The training loop
- 6.4.11 Put it together
- 6.4.12 Read the confusion matrix
- 6.5 Transfer Learning and Fine-Tuning
- 6.5.1 Feature extraction vs fine-tuning
- 6.5.2 Why freezing works at all
- 6.5.3 Discriminative learning rates
- 6.5.4 The BatchNorm problem
- 6.5.5 Head design
- 6.5.6 Layer-wise LR decay
- 6.5.7 What to evaluate
- 6.5.8 Load a pretrained backbone and inspect it
- 6.5.9 Feature extraction — freeze everything, replace the head
- 6.5.10 Discriminative fine-tuning
- 6.5.11 BatchNorm handling
- 6.5.12 A minimal end-to-end fine-tuning loop
- 6.5.13 Progressive unfreezing
- 6.6 Object Detection — YOLO from Scratch
- 6.6.1 Detection as dense prediction
- 6.6.2 Why grids and anchors
- 6.6.3 Decoding predictions
- 6.6.4 IoU
- 6.6.5 Non-maximum suppression
- 6.6.6 The loss
- 6.6.7 Detection metrics
- 6.6.8 Non-max suppression
- 6.6.9 Box encoding and decoding
- 6.6.10 A minimal YOLO head
- 6.6.11 Ground-truth assignment
- 6.6.12 The three losses
- 6.6.13 Inference pipeline
- 6.7 Semantic Segmentation — U-Net
- 6.7.1 Semantic vs instance vs panoptic
- 6.7.2 The U-Net shape
- 6.7.3 Transposed vs bilinear upsample
- 6.7.4 Cross-entropy on a pixel grid
- 6.7.5 Dice loss and why you need it
- 6.7.6 Evaluation metrics
- 6.7.7 Input resolution trade-off
- 6.7.8 Encoder block
- 6.7.9 Down and up blocks
- 6.7.10 The U-Net
- 6.7.11 Losses
- 6.7.12 IoU metric
- 6.7.13 Synthetic dataset for end-to-end verification
- 6.7.14 Training loop
- 6.8 Instance Segmentation — Mask R-CNN
- 6.8.1 The architecture
- 6.8.2 Why RoIAlign, not RoIPool
- 6.8.3 The RPN in one paragraph
- 6.8.4 The mask head
- 6.8.5 Losses
- 6.8.6 Output format
- 6.8.7 RoIAlign from scratch
- 6.8.8 Compare to torchvision's RoIAlign
- 6.8.9 Load a pretrained Mask R-CNN
- 6.8.10 Run inference
- 6.8.11 Swap the heads for a custom class count
- 6.8.12 Freeze what does not need training
- 6.9 Image Generation — GANs
- 6.9.1 The two networks
- 6.9.2 The game
- 6.9.3 Non-saturating loss
- 6.9.4 DCGAN architecture rules
- 6.9.5 Failure modes and their signatures
- 6.9.6 Evaluation
- 6.9.7 Generator
- 6.9.8 Discriminator
- 6.9.9 Training step
- 6.9.10 Full training loop on synthetic shapes
- 6.9.11 Sampling
- 6.9.12 Spectral normalisation
- 6.10 Image Generation — Diffusion Models
- 6.10.1 The forward process
- 6.10.2 The closed-form jump
- 6.10.3 The reverse process
- 6.10.4 The training loss
- 6.10.5 The sampler (DDPM)
- 6.10.6 Why 1000 steps
- 6.10.7 DDIM: 20x faster sampling
- 6.10.8 Time conditioning
- 6.10.9 Noise schedule
- 6.10.10 Forward diffusion (q_sample)
- 6.10.11 A tiny time-conditioned U-Net
- 6.10.12 Training loop
- 6.10.13 Sampler (DDPM)
- 6.10.14 DDIM sampler (deterministic, ~20x faster)
- 6.11 Stable Diffusion — Architecture and Fine-Tuning
- 6.11.1 The pipeline
- 6.11.2 Classifier-free guidance (CFG)
- 6.11.3 Latent space geometry
- 6.11.4 The U-Net architecture
- 6.11.5 LoRA fine-tuning
- 6.11.6 Schedulers you will see
- 6.11.7 Text-to-image
- 6.11.8 Swap the scheduler
- 6.11.9 Image-to-image
- 6.11.10 Inpainting
- 6.11.11 LoRA loading
- 6.11.12 LoRA training (sketch)
- 6.12 Video Understanding — Temporal Modeling
- 6.12.1 The three architectural families
- 6.12.2 2D + pool
- 6.12.3 3D convolutions
- 6.12.4 Spatio-temporal transformers
- 6.12.5 Frame sampling
- 6.12.6 Evaluation
- 6.12.7 Datasets you will meet
- 6.12.8 Frame sampler
- 6.12.9 A 2D+pool baseline
- 6.12.10 An I3D-style inflated 3D conv
- 6.12.11 Factorised (2+1)D conv
- 6.13 3D Vision: Point Clouds, NeRFs
- 6.13.1 Point clouds
- 6.13.2 The PointNet architecture
- 6.13.3 Neural Radiance Fields (NeRFs)
- 6.13.4 Positional encoding in NeRF
- 6.13.5 Volumetric rendering
- 6.13.6 What replaced NeRFs
- 6.13.7 Datasets and benchmarks
- 6.13.8 PointNet classifier
- 6.13.9 Positional encoding
- 6.13.10 Tiny NeRF MLP
- 6.13.11 Volumetric rendering along a ray
- 6.14 Vision Transformers (ViT)
- 6.14.1 The pipeline
- 6.14.2 Patch embedding
- 6.14.3 Class token
- 6.14.4 Positional embedding
- 6.14.5 Transformer encoder block
- 6.14.6 Why pre-LN
- 6.14.7 Patch size trade-off
- 6.14.8 DeiT's recipe for training ViT on ImageNet-1k
- 6.14.9 Swin vs ConvNeXt
- 6.14.10 MAE pretraining
- 6.14.11 Transformer block
- 6.14.12 The ViT
- 6.14.13 Sanity check — single image inference
- 6.15 Real-Time Vision: Edge Deployment
- 6.15.1 The three budgets
- 6.15.2 Measurement discipline
- 6.15.3 FLOPs as a proxy
- 6.15.4 Quantisation in one paragraph
- 6.15.5 Pruning and distillation
- 6.15.6 The inference runtimes
- 6.15.7 Edge architecture picker
- 6.15.8 Measure latency correctly
- 6.15.9 Parameter and FLOP counts
- 6.15.10 Post-training static quantisation
- 6.15.11 Export to ONNX
- 6.15.12 Benchmark and compare regimes
- 6.16 Build a Complete Vision Pipeline
- 6.16.1 The pipeline
- 6.16.2 Data contracts with Pydantic
- 6.16.3 Where latency goes
- 6.16.4 Failure modes
- 6.16.5 Batching
- 6.16.6 Data contracts
- 6.16.7 A minimal Pipeline class
- 6.16.8 Wire a detector and a classifier
- 6.16.9 FastAPI service
- 6.16.10 Benchmark the pipeline
- 6.17 Self-Supervised Vision — SimCLR, DINO, MAE
- 6.17.1 Three families
- 6.17.2 Contrastive learning (SimCLR)
- 6.17.3 Teacher-student (DINO)
- 6.17.4 Masked reconstruction (MAE)
- 6.17.5 Why 75% and not 15%
- 6.17.6 Linear-probe evaluation
- 6.17.7 Two-view augmentation pipeline
- 6.17.8 InfoNCE loss
- 6.17.9 Sanity check InfoNCE
- 6.17.10 MAE-style masking
- 6.18 Open-Vocabulary Vision — CLIP
- 6.18.1 Two towers
- 6.18.2 The objective
- 6.18.3 SigLIP: a better loss
- 6.18.4 Zero-shot classification
- 6.18.5 Where CLIP-style models are used in 2026
- 6.18.6 A tiny two-tower model
- 6.18.7 Contrastive loss
- 6.18.8 Zero-shot classifier
- 6.18.9 Sanity check
- 6.19 OCR and Document Understanding
- 6.19.1 The classical pipeline
- 6.19.2 CTC in one paragraph
- 6.19.3 Modern end-to-end models
- 6.19.4 Layout parsing
- 6.19.5 Evaluation metrics
- 6.19.6 CTC loss + greedy decoder
- 6.19.7 Tiny CRNN recogniser
- 6.19.8 Synthetic OCR
- 6.19.9 Training sketch
- 6.20 Image Retrieval and Metric Learning
- 6.20.1 Retrieval at a glance
- 6.20.2 The four loss families
- 6.20.3 Triplet loss formally
- 6.20.4 Cosine similarity vs L2
- 6.20.5 Recall@K
- 6.20.6 FAISS in one paragraph
- 6.20.7 Instance-level vs category-level retrieval
- 6.20.8 Triplet loss
- 6.20.9 Semi-hard mining
- 6.20.10 Putting it together
- 6.21 Keypoint Detection and Pose Estimation
- 6.21.1 Top-down vs bottom-up
- 6.21.2 Heatmap regression
- 6.21.3 Sub-pixel localisation
- 6.21.4 Part Affinity Fields (PAFs)
- 6.21.5 COCO keypoints
- 6.21.6 2D vs 3D
- 6.21.7 Gaussian heatmap target
- 6.21.8 Tiny keypoint head
- 6.21.9 Inference — extract keypoint coordinates
- 6.21.10 Synthetic keypoint dataset
- 6.21.11 Training
- 6.22 3D Gaussian Splatting from Scratch
- 6.22.1 What a Gaussian carries
- 6.22.2 Rasterisation, not ray marching
- 6.22.3 The projection step
- 6.22.4 The alpha-compositing rule
- 6.22.5 Why this is differentiable
- 6.22.6 Densification and pruning
- 6.22.7 Spherical harmonics in one paragraph
- 6.22.8 The 2026 production stack
- 6.22.9 4D and generative variants
- 6.22.10 A 2D Gaussian
- 6.22.11 2D splatting rasteriser
- 6.22.12 A trainable 2D splat scene
- 6.22.13 Fit 2D Gaussians to a target image
- 6.22.14 From 2D to 3D
- 6.22.15 Spherical harmonics evaluation
- 6.23 Diffusion Transformers and Rectified Flow
- 6.23.1 From U-Net to transformer
- 6.23.2 Rectified flow in one paragraph
- 6.23.3 AdaLN conditioning
- 6.23.4 Text encoders in SD3 and FLUX
- 6.23.5 Classifier-free guidance still holds
- 6.23.6 Consistency, Turbo, Schnell, LCM
- 6.23.7 Model landscape in 2026
- 6.23.8 Why this phase shift matters
- 6.23.9 A DiT block with AdaLN
- 6.23.10 A tiny DiT
- 6.23.11 Rectified flow training
- 6.23.12 Euler sampler
- 6.23.13 End-to-end smoke test
- 6.24 SAM 3 and Open-Vocabulary Segmentation
- 6.24.1 The three generations
- 6.24.2 Promptable Concept Segmentation
- 6.24.3 Key architectural pieces
- 6.24.4 Training at scale
- 6.24.5 SAM 3.1 Object Multiplex
- 6.24.6 Where Grounded SAM still matters in 2026
- 6.24.7 YOLO-World vs SAM 3
- 6.24.8 SAM-MI efficiency
- 6.24.9 Output format for the three models
- 6.24.10 Prompt construction
- 6.24.11 Post-processing helpers
- 6.24.12 A unified open-vocab segmentation interface
- 6.24.13 Hugging Face SAM 3 usage (reference)
- 6.24.14 Measure what Grounded SAM 2 gave you for free
- 6.25 Vision-Language Models (ViT-MLP-LLM)
- 6.25.1 The ViT-MLP-LLM architecture
- 6.25.2 DeepStack
- 6.25.3 Three training stages
- 6.25.4 Model family comparison (early 2026)
- 6.25.5 Visual agents
- 6.25.6 Agentic capabilities + RoPE variants
- 6.25.7 The alignment problem
- 6.25.8 Fine-tuning with LoRA / QLoRA
- 6.25.9 Spatial reasoning is still weak
- 6.25.10 The projector
- 6.25.11 Assemble ViT-MLP-LLM end-to-end
- 6.25.12 CMER computation
- 6.25.13 Toy VLM classifier (runnable)
- 6.26 Monocular Depth and Geometry Estimation
- 6.26.1 Relative vs metric depth
- 6.26.2 The encoder-decoder pattern
- 6.26.3 Why a single image produces depth at all
- 6.26.4 What monocular depth cannot do
- 6.26.5 Depth Anything V3 in 2026
- 6.26.6 Marigold — diffusion for depth
- 6.26.7 Intrinsics and the pinhole camera
- 6.26.8 Evaluation
- 6.26.9 Depth metrics
- 6.26.10 Scale-and-shift alignment
- 6.26.11 Lift depth to a point cloud
- 6.26.12 Smoke test with a synthetic depth scene
- 6.26.13 Depth Anything V2 usage (reference)
- 6.27 Multi-Object Tracking and Video Memory
- 6.27.1 Tracking-by-detection
- 6.27.2 Kalman filter in one paragraph
- 6.27.3 The Hungarian algorithm
- 6.27.4 ByteTrack's key idea
- 6.27.5 SAM 2 memory-based tracking
- 6.27.6 SAM 3.1 Object Multiplex
- 6.27.7 Three metrics to know
- 6.27.8 IoU-based cost matrix
- 6.27.9 Minimal SORT-style tracker
- 6.27.10 Synthetic trajectory test
- 6.27.11 ID-switch metric
- 6.28 World Models and Video Diffusion
- 6.28.1 Three families of world-modelling
- 6.28.2 Video DiT architecture
- 6.28.3 Conditioning on actions: latent action models
- 6.28.4 Physical plausibility
- 6.28.5 Autonomous driving world models
- 6.28.6 Robotics stack: VLM + video model + inverse dynamics
- 6.28.7 Evaluation
- 6.28.8 Model landscape in 2026
- 6.28.9 3D patchify for video
- 6.28.10 3D rotary position encoding
- 6.28.11 Divided attention block
- 6.28.12 Compose a tiny video DiT
- 6.28.13 Check shapes
- 7NLP, foundations to advancednot yet
- 7.1 Text Processing: Tokenization, Stemming, Lemmatization
- 7.1.1 a regex word tokenizer
- 7.1.2 a Porter stemmer (step 1a only)
- 7.1.3 a lookup-based lemmatizer
- 7.1.4 pipe them together
- 7.1.5 NLTK
- 7.1.6 spaCy
- 7.1.7 When to pick which
- 7.1.8 The two failure modes nobody warns you about
- 7.2 Bag of Words, TF-IDF and Text Representation
- 7.2.1 build the vocabulary
- 7.2.2 bag of words
- 7.2.3 term frequency and document frequency
- 7.2.4 TF-IDF
- 7.2.5 L2-normalize rows
- 7.2.6 When TF-IDF still wins (as of 2026)
- 7.2.7 When TF-IDF fails
- 7.2.8 Hybrid: TF-IDF weighted embeddings
- 7.3 Word Embeddings: Word2Vec from Scratch
- 7.3.1 training pairs from a corpus
- 7.3.2 embedding tables
- 7.3.3 negative sampling objective
- 7.3.4 train on a toy corpus
- 7.3.5 the analogy trick
- 7.3.6 When Word2Vec still wins in 2026
- 7.3.7 Where Word2Vec fails
- 7.4 GloVe, FastText and Subword Embeddings
- 7.4.1 GloVe: factorize the co-occurrence matrix
- 7.4.2 FastText: subword-aware embeddings
- 7.4.3 BPE: learned subword vocabulary
- 7.4.4 When to pick which
- 7.5 Sentiment Analysis
- 7.5.1 a real mini-dataset
- 7.5.2 multinomial Naive Bayes from scratch
- 7.5.3 logistic regression from scratch
- 7.5.4 handling negation (the failure mode)
- 7.5.5 evaluation metrics that matter
- 7.5.6 When to reach for a transformer
- 7.5.7 The reproducibility trap (again)
- 7.6 Named Entity Recognition (NER)
- 7.6.1 BIO tagging helpers
- 7.6.2 hand-crafted features
- 7.6.3 a simple rule-based + dictionary baseline
- 7.6.4 the CRF step (sketch, not full impl)
- 7.6.5 what a BiLSTM-CRF adds
- 7.6.6 LLM-based NER (the 2026 option)
- 7.6.7 Where classical NER still wins
- 7.6.8 Where it falls apart
- 7.7 POS Tagging and Syntactic Parsing
- 7.7.1 most-frequent-tag baseline
- 7.7.2 bigram HMM tagger
- 7.7.3 why modern taggers beat this
- 7.7.4 dependency parsing sketch
- 7.7.5 Where this still matters in 2026
- 7.8 Text Classification — CNNs and RNNs for Text
- 7.8.1 TextCNN in PyTorch
- 7.8.2 LSTM classifier
- 7.8.3 the vanishing gradient demo (intuition)
- 7.8.4 why this still was not enough
- 7.9 Sequence-to-Sequence Models
- 7.9.1 an encoder
- 7.9.2 a decoder
- 7.9.3 training loop with teacher forcing
- 7.9.4 inference loop (greedy)
- 7.9.5 the bottleneck, demonstrated
- 7.9.6 When to still reach for RNN-based seq2seq
- 7.9.7 Exposure bias and its mitigations
- 7.10 Attention Mechanism — The Breakthrough
- 7.10.1 additive (Bahdanau) attention
- 7.10.2 Luong dot and general
- 7.10.3 a worked numerical example
- 7.10.4 why this is the bridge to transformers
- 7.10.5 When classical attention still matters
- 7.10.6 The attention-weight-as-explanation trap
- 7.11 Machine Translation
- 7.11.1 a pretrained MT call
- 7.11.2 BLEU and chrF
- 7.11.3 The three-tier evaluation hierarchy (2026)
- 7.11.4 what breaks in production
- 7.11.5 fine-tuning for a domain
- 7.12 Text Summarization
- 7.12.1 TextRank (extractive)
- 7.12.2 abstractive with BART
- 7.12.3 ROUGE evaluation
- 7.12.4 Beyond ROUGE (2026 summarization eval)
- 7.12.5 the factuality problem
- 7.13 Question Answering Systems
- 7.13.1 extractive QA with a pretrained model
- 7.13.2 a retrieval-augmented pipeline (sketch)
- 7.13.3 generative with RAG
- 7.13.4 evaluation that reflects the real world
- 7.13.5 RAGAS: the 2026 production eval framework
- 7.14 Information Retrieval and Search
- 7.14.1 BM25 from scratch
- 7.14.2 dense retrieval with a bi-encoder
- 7.14.3 Reciprocal Rank Fusion
- 7.14.4 hybrid search + rerank
- 7.14.5 evaluation
- 7.14.6 The hard-won lessons from 2026 production RAG
- 7.15 Topic Modeling: LDA, BERTopic
- 7.15.1 LDA via scikit-learn
- 7.15.2 BERTopic (production)
- 7.15.3 evaluation
- 7.16 Text Generation
- 7.16.1 The prediction game
- 7.16.2 trigram counts
- 7.16.3 Laplace smoothing
- 7.16.4 Kneser-Ney (bigram, interpolated)
- 7.16.5 generating text with sampling
- 7.16.6 perplexity
- 7.17 Chatbots: Rule-Based to Neural
- 7.17.1 The scripted half-century, 1950-2001
- 7.17.2 rule-based pattern matching
- 7.17.3 retrieval-based (FAQ)
- 7.17.4 neural generation (baseline)
- 7.17.5 LLM agent loop
- 7.17.6 hybrid routing
- 7.18 Multilingual NLP
- 7.18.1 zero-shot cross-lingual classification
- 7.18.2 multilingual embedding space
- 7.18.3 few-shot fine-tuning strategy
- 7.18.4 The tokenization tax (what goes wrong for low-resource languages)
- 7.19 Subword Tokenization: BPE, WordPiece, Unigram, SentencePiece
- 7.19.1 BPE from scratch
- 7.19.2 encode with the learned merges
- 7.19.3 SentencePiece in practice
- 7.19.4 tiktoken for OpenAI-compatible vocabs
- 7.20 Structured Outputs and Constrained Decoding
- 7.20.1 The counterintuitive result
- 7.20.2 The pitfall that costs you
- 7.20.3 regex-constrained generation from scratch
- 7.20.4 Outlines for JSON Schema
- 7.20.5 Instructor for provider-agnostic Pydantic
- 7.20.6 native vendor APIs
- 7.21 NLI and Textual Entailment
- 7.21.1 run a pretrained NLI model
- 7.21.2 zero-shot classification
- 7.21.3 faithfulness check for RAG
- 7.21.4 hand-rolled NLI classifier (conceptual)
- 7.22 Embedding Models Deep Dive
- 7.22.1 The MTEB leaderboard tells a partial story
- 7.22.2 The three-tier pattern
- 7.22.3 baseline — dense embeddings with Sentence-BERT
- 7.22.4 Matryoshka truncation
- 7.22.5 BGE-M3 multi-functionality
- 7.22.6 MTEB eval on a custom task
- 7.22.7 hand-rolled cosine from scratch
- 7.23 Chunking Strategies for RAG
- 7.23.1 The rule that beats every default
- 7.23.2 fixed and recursive chunking
- 7.23.3 semantic chunking
- 7.23.4 parent-document
- 7.23.5 contextual retrieval (Anthropic pattern)
- 7.23.6 evaluate
- 7.24 Coreference Resolution
- 7.24.1 pretrained neural coreference (AllenNLP / spaCy-experimental)
- 7.24.2 rule-based pronoun resolver (teaching)
- 7.24.3 using LLMs for coreference
- 7.24.4 evaluation
- 7.25 Entity Linking and Disambiguation
- 7.25.1 The two measurements
- 7.25.2 build an alias index from Wikipedia redirects
- 7.25.3 context-based disambiguation
- 7.25.4 embedding-based (BLINK-style)
- 7.25.5 generative entity linking (concept)
- 7.25.6 evaluate on AIDA-CoNLL
- 7.26 Relation Extraction and Knowledge Graph Construction
- 7.26.1 pattern-based extraction
- 7.26.2 supervised seq2seq relation extraction
- 7.26.3 LLM-prompted extraction with anchoring
- 7.26.4 canonicalize onto a closed ontology
- 7.26.5 build a small graph and query
- 7.27 LLM Evaluation: RAGAS, DeepEval, G-Eval
- 7.27.1 faithfulness with NLI (RAGAS-style)
- 7.27.2 answer relevance
- 7.27.3 G-Eval custom metric
- 7.27.4 CI gate
- 7.27.5 toy eval from scratch
- 7.28 Long-Context Evaluation: NIAH, RULER, LongBench, MRCR
- 7.28.1 What to actually report
- 7.28.2 a custom NIAH for your domain
- 7.28.3 a multi-needle variant
- 7.28.4 multi-hop variable tracing (RULER-style)
- 7.28.5 LongBench v2 on your stack
- 7.29 Dialogue State Tracking
- 7.29.1 The classic failure modes
- 7.29.2 rule-based slot extractor
- 7.29.3 state update loop
- 7.29.4 LLM-driven DST with structured output
- 7.29.5 JGA evaluation
- 7.29.6 handling correction
- 8Speech and audionot yet
- 8.1 Audio Fundamentals: Waveforms, Sampling, FFT
- 8.1.1 read a clip and plot the waveform
- 8.1.2 synthesize a sine wave from first principles
- 8.1.3 compute the DFT by hand
- 8.1.4 find the dominant frequency
- 8.1.5 demonstrate aliasing
- 8.2 Spectrograms, Mel Scale and Audio Features
- 8.2.1 frame the waveform
- 8.2.2 Hann window
- 8.2.3 STFT magnitude
- 8.2.4 mel filterbank
- 8.2.5 log-mel
- 8.2.6 MFCCs
- 8.3 Audio Classification
- 8.3.1 Class imbalance is the real challenge
- 8.3.2 Evaluation
- 8.3.3 featurize
- 8.3.4 fixed-length summary
- 8.3.5 k-NN
- 8.3.6 upgrade to CNN on log-mels
- 8.3.7 fine-tune a pretrained audio transformer (AST shown)
- 8.4 Speech Recognition (ASR)
- 8.4.1 WER: the one number
- 8.4.2 greedy CTC decode
- 8.4.3 beam-search CTC
- 8.4.4 WER
- 8.4.5 inference against Whisper
- 8.4.6 streaming with Parakeet or wav2vec 2.0
- 8.5 Whisper: Architecture and Fine-Tuning
- 8.5.1 Variants in 2026
- 8.5.2 Fine-tuning
- 8.5.3 run Whisper out of the box
- 8.5.4 chunked long-form
- 8.5.5 fine-tune with LoRA
- 8.5.6 inspect what each layer learns
- 8.6 Speaker Recognition and Verification
- 8.6.1 Scoring
- 8.6.2 Numbers you should know (2026)
- 8.6.3 Diarization
- 8.6.4 toy embedding from MFCC statistics
- 8.6.5 cosine similarity + threshold
- 8.6.6 EER from similarity pairs
- 8.6.7 production with SpeechBrain
- 8.6.8 diarize with pyannote
- 8.7 Text-to-Speech (TTS)
- 8.7.1 Vocoder evolution
- 8.7.2 Evaluation
- 8.7.3 phonemize input
- 8.7.4 run Kokoro (2026 CPU default)
- 8.7.5 run F5-TTS with voice cloning
- 8.7.6 HiFi-GAN vocoder from scratch
- 8.7.7 the full pipeline (pseudocode)
- 8.8 Voice Cloning and Voice Conversion
- 8.8.1 The ethics bit, not a bolt-on
- 8.8.2 Numbers (2026)
- 8.8.3 decompose with recognition-synthesis (code-only demo in main.py)
- 8.8.4 zero-shot clone with F5-TTS
- 8.8.5 voice conversion with KNN-VC
- 8.8.6 embed a watermark
- 8.8.7 consent gate
- 8.9 Music Generation
- 8.9.1 Token LM over neural-codec tokens
- 8.9.2 Diffusion over mels or latents
- 8.9.3 Hybrid (production) — Suno, Udio, Lyria
- 8.9.4 Evaluation
- 8.9.5 generate with MusicGen
- 8.9.6 melody conditioning
- 8.9.7 FAD evaluation
- 8.9.8 adding to the LLM-music workflow
- 8.10 Audio-Language Models
- 8.10.1 The three-component template
- 8.10.2 The 2026 model map
- 8.10.3 Benchmark reality check (2026)
- 8.10.4 Where LALMs are useful in 2026
- 8.10.5 Where they are NOT (yet) useful
- 8.10.6 query Qwen2.5-Omni
- 8.10.7 the projector pattern
- 8.10.8 benchmarking MMAU / LongAudioBench
- 8.11 Real-Time Audio Processing
- 8.11.1 Common gotchas
- 8.11.2 ring buffer
- 8.11.3 VAD gate
- 8.11.4 streaming ASR
- 8.11.5 interruption handler
- 8.12 Build a Voice Assistant Pipeline
- 8.12.1 The seven components
- 8.12.2 The three failure modes you will hit
- 8.12.3 2026 production reference stacks
- 8.12.4 mic capture with chunking (pseudocode)
- 8.12.5 VAD-gated turn capture
- 8.12.6 streaming STT → LLM → TTS
- 8.12.7 tool calling inside the LLM loop
- 8.12.8 interruption handling
- 8.13 Neural Audio Codecs — EnCodec, SNAC, Mimi, DAC
- 8.13.1 The core trick: Residual Vector Quantization (RVQ)
- 8.13.2 The four codecs that matter in 2026
- 8.13.3 Frame rates matter for language modeling
- 8.13.4 Semantic vs acoustic tokens
- 8.13.5 2026 reconstruction quality (bits per sec, lower bitrate is better)
- 8.13.6 encode with EnCodec
- 8.13.7 decode and measure reconstruction
- 8.13.8 the semantic-acoustic split (Mimi-style)
- 8.13.9 why AR LM over codec tokens works
- 8.14 Voice Activity Detection and Turn-Taking
- 8.14.1 The three-tier VAD cascade
- 8.14.2 Key parameters and their defaults
- 8.14.3 The flush trick (Kyutai 2025)
- 8.14.4 2026 VAD comparison
- 8.14.5 the energy gate
- 8.14.6 Silero VAD in Python
- 8.14.7 turn-end state machine
- 8.14.8 the flush trick skeleton
- 8.15 Streaming Speech-to-Speech — Moshi, Hibiki
- 8.15.1 The Moshi architecture
- 8.15.2 Why inner-monologue text helps
- 8.15.3 Hibiki: streaming speech-to-speech translation
- 8.15.4 The broader Kyutai stack (2026)
- 8.15.5 Sesame CSM — the cousin
- 8.15.6 2026 performance numbers
- 8.15.7 the interface
- 8.15.8 the full-duplex loop
- 8.15.9 the training objective (conceptual)
- 8.15.10 where Moshi wins and where it doesn't
- 8.16 Voice Anti-Spoofing and Audio Watermarking
- 8.16.1 ASVspoof 5 — the 2024-2025 benchmark
- 8.16.2 AASIST and RawNet2 — detection model families
- 8.16.3 AudioSeal — the 2024 watermark default
- 8.16.4 WavMark
- 8.16.5 WaveVerify (July 2025)
- 8.16.6 The gap adversaries exploit
- 8.16.7 C2PA / Content Authenticity Initiative
- 8.16.8 a simple spectral-feature detector (toy)
- 8.16.9 AudioSeal embed + detect
- 8.16.10 evaluation — EER
- 8.16.11 the production integration
- 8.17 Audio Evaluation — WER, MOS, MMAU, Leaderboards
- 8.17.1 ASR metrics
- 8.17.2 TTS metrics
- 8.17.3 Voice-cloning-specific
- 8.17.4 Speaker verification
- 8.17.5 Diarization
- 8.17.6 Audio classification
- 8.17.7 Music generation
- 8.17.8 Audio-language benchmarks
- 8.17.9 Streaming speech-to-speech
- 8.17.10 The 2026 leaderboards
- 8.17.11 WER with normalization
- 8.17.12 TTS round-trip WER
- 8.17.13 SECS for voice cloning
- 8.17.14 FAD for music generation
- 8.17.15 EER for speaker verification (same code as Lesson 6)
- 9Transformers deep divenot yet
- 9.1 Why Transformers: The Problems with RNNs
- 9.1.1 measure serial depth
- 9.1.2 count theoretical operations
- 9.1.3 empirical scaling on long sequences
- 9.2 Self-Attention from Scratch
- 9.2.1 The Database Lookup Analogy
- 9.2.2 Q, K, V Computation
- 9.2.3 The Attention Matrix
- 9.2.4 Why Scale?
- 9.2.5 Softmax Turns Scores into Weights
- 9.2.6 Weighted Sum of Values
- 9.2.7 Full Pipeline
- 9.2.8 Softmax from scratch
- 9.2.9 Scaled dot-product attention
- 9.2.10 Self-attention class with learned projections
- 9.2.11 Run it on a sentence
- 9.2.12 Visualize attention with ASCII heatmap
- 9.3 Multi-Head Attention
- 9.3.1 split heads from the single-head attention we already have
- 9.3.2 run scaled-dot-product attention per head
- 9.3.3 Grouped-Query Attention variant
- 9.3.4 probe what each head learned
- 9.4 Positional Encoding: Sinusoidal, RoPE, ALiBi
- 9.4.1 Absolute sinusoidal
- 9.4.2 RoPE
- 9.4.3 ALiBi
- 9.4.4 What to pick in 2026
- 9.4.5 sinusoidal encoding
- 9.4.6 RoPE applied to Q, K
- 9.4.7 ALiBi slopes and bias
- 9.4.8 verify relative-distance property of RoPE
- 9.5 The Full Transformer: Encoder + Decoder
- 9.5.1 The six pieces
- 9.5.2 Encoder block (used by BERT, T5 encoder)
- 9.5.3 Decoder block (used by GPT, T5 decoder)
- 9.5.4 Pre-norm vs post-norm
- 9.5.5 The 2026 modernized block
- 9.5.6 Parameter count
- 9.5.7 the building blocks
- 9.5.8 wire a 2-layer encoder and a 2-layer decoder
- 9.5.9 run forward on a toy example
- 9.5.10 swap in RMSNorm + SwiGLU
- 9.6 BERT — Masked Language Modeling
- 9.6.1 The training signal
- 9.6.2 The BERT mask rules
- 9.6.3 Next Sentence Prediction (NSP) — and why it was dropped
- 9.6.4 What changed in 2026: ModernBERT
- 9.6.5 Use cases that still pick an encoder in 2026
- 9.6.6 masking logic
- 9.6.7 run MLM prediction on a tiny corpus
- 9.6.8 compare mask types
- 9.6.9 fine-tune head
- 9.7 GPT — Causal Language Modeling
- 9.7.1 The mask
- 9.7.2 Where the triangle comes from
- 9.7.3 Parallel training, serial inference
- 9.7.4 The loss — shift-by-one
- 9.7.5 Decoding strategies
- 9.7.6 What made the "GPT recipe" work
- 9.7.7 the causal mask
- 9.7.8 a 2-layer GPT-ish model
- 9.7.9 next-token prediction, end-to-end
- 9.7.10 sampling
- 9.8 T5, BART — Encoder-Decoder Models
- 9.8.1 The forward loop
- 9.8.2 T5 pretraining — span corruption
- 9.8.3 BART pretraining — multi-noise denoising
- 9.8.4 Inference
- 9.8.5 When to pick each variant in 2026
- 9.8.6 span corruption
- 9.8.7 verify round-trip
- 9.8.8 BART noising
- 9.9 Vision Transformers (ViT)
- 9.9.1 Step 1 — patchify
- 9.9.2 Step 2 — linear embedding
- 9.9.3 Step 3 — prepend [CLS] token, add positional embeddings
- 9.9.4 Step 4 — standard transformer encoder
- 9.9.5 Step 5 — head
- 9.9.6 Variants that mattered
- 9.9.7 Why it took a while
- 9.9.8 fake image
- 9.9.9 patchify
- 9.9.10 linear embed
- 9.9.11 count parameters for a realistic ViT
- 9.10 Audio Transformers — Whisper Architecture
- 9.10.1 Step 1 — resample + window
- 9.10.2 Step 2 — convolutional stem
- 9.10.3 Step 3 — encoder
- 9.10.4 Step 4 — decoder
- 9.10.5 Step 5 — task tokens
- 9.10.6 Step 6 — output
- 9.10.7 Whisper sizes
- 9.10.8 What Whisper does not do
- 9.10.9 2026 landscape
- 9.10.10 synthesize audio
- 9.10.11 log-mel spectrogram (simplified)
- 9.10.12 pad to 30 s
- 9.10.13 build the prompt tokens
- 9.11 Mixture of Experts (MoE)
- 9.11.1 The FFN swap
- 9.11.2 The load-balancing problem
- 9.11.3 Shared experts
- 9.11.4 Fine-grained experts
- 9.11.5 The cost profile
- 9.11.6 The catch: memory
- 9.11.7 the router
- 9.11.8 run 100 tokens through the router
- 9.11.9 param count comparison
- 9.12 KV Cache, Flash Attention and Inference Optimization
- 9.12.1 KV cache math
- 9.12.2 Flash Attention — the tiling trick
- 9.12.3 Speculative decoding — the other latency win
- 9.12.4 Continuous batching
- 9.12.5 PagedAttention — KV cache as virtual memory
- 9.12.6 KV cache
- 9.12.7 tiled softmax
- 9.12.8 compare naive vs cached decoding on 100-token generation
- 9.13 Scaling Laws
- 9.13.1 The Hoffmann law
- 9.13.2 Why over-training anyway
- 9.13.3 Emergence vs smoothness
- 9.13.4 The 2026 picture
- 9.13.5 Chinchilla loss
- 9.13.6 compute-optimal frontier
- 9.13.7 over-training cost
- 9.13.8 compare to real models
- 9.14 Build a Transformer from Scratch
- 9.14.1 What we ship
- 9.14.2 What we don't ship
- 9.14.3 Target metrics
- 9.14.4 data
- 9.14.5 model
- 9.14.6 training loop
- 9.14.7 sample
- 9.14.8 read the output
- 9.15 Attention Variants — Sliding Window, Sparse, Differential
- 9.15.1 Sliding Window Attention (SWA)
- 9.15.2 Sparse / Block Attention
- 9.15.3 Differential Attention (DIFF Transformer, 2024)
- 9.15.4 Variant Comparison
- 9.15.5 full causal mask (baseline)
- 9.15.6 sliding window causal mask
- 9.15.7 local + strided sparse mask
- 9.15.8 differential attention
- 9.15.9 KV cache sizes
- 9.16 Speculative Decoding — Draft, Verify, Repeat
- 9.16.1 The core algorithm
- 9.16.2 What determines speedup
- 9.16.3 Medusa — drafts without a draft model
- 9.16.4 EAGLE — better draft by reusing hidden states
- 9.16.5 The KV cache dance
- 9.16.6 the rejection step
- 9.16.7 residual distribution
- 9.16.8 one speculative step
- 9.16.9 measure acceptance rate
- 9.16.10 verify distribution equivalence
- 10Generative AInot yet
- 10.1 Generative Models: Taxonomy and History
- 10.1.1 A brief history
- 10.1.2 The five-question triage
- 10.1.3 Production note: five families, five inference shapes
- 10.2 Autoencoders and VAE
- 10.2.1 encoder forward
- 10.2.2 reparameterize and decode
- 10.2.3 the ELBO
- 10.2.4 generate
- 10.3 GANs: Generator vs Discriminator
- 10.3.1 non-saturating loss
- 10.3.2 one discriminator step per generator step
- 10.3.3 watch for mode collapse
- 10.4 Conditional GANs and Pix2Pix
- 10.4.1 append condition to both G and D inputs
- 10.4.2 train conditional
- 10.4.3 verify per-class output
- 10.5 StyleGAN
- 10.5.1 mapping network
- 10.5.2 adaptive instance normalization
- 10.5.3 per-layer noise
- 10.6 Diffusion Models — DDPM from Scratch
- 10.6.1 the forward schedule (closed form)
- 10.6.2 sample x_t in one shot
- 10.6.3 one training step
- 10.6.4 reverse sampling
- 10.7 Latent Diffusion and Stable Diffusion
- 10.7.1 encoder/decoder
- 10.7.2 diffusion in z-space
- 10.7.3 classifier-free guidance
- 10.7.4 text conditioning (concept, not code)
- 10.8 ControlNet, LoRA and Conditioning
- 10.8.1 ControlNet (Zhang et al., 2023)
- 10.8.2 LoRA (Hu et al., 2021)
- 10.8.3 IP-Adapter (Ye et al., 2023)
- 10.8.4 LoRA math
- 10.8.5 zero-init side network
- 10.9 Inpainting, Outpainting and Editing
- 10.9.1 The naive approach (and why it's wrong)
- 10.9.2 The proper inpainting model
- 10.9.3 SDEdit (Meng et al., 2022) — free editing
- 10.9.4 InstructPix2Pix (Brooks et al., 2023)
- 10.9.5 RePaint (Lugmayr et al., 2022)
- 10.9.6 5-D DDPM data
- 10.9.7 train denoiser over all 5 dims
- 10.9.8 at inference, mask-aware reverse
- 10.9.9 outpainting
- 10.10 Video Generation
- 10.10.1 Patchify
- 10.10.2 Spatiotemporal DiT
- 10.10.3 Text conditioning
- 10.10.4 Training
- 10.10.5 patchify a synthetic 1-D "video"
- 10.10.6 position embedding per frame
- 10.10.7 denoiser sees the whole sequence
- 10.10.8 temporal coherence test
- 10.11 Audio Generation
- 10.11.1 Neural audio codecs
- 10.11.2 Two generative paradigms on top
- 10.11.3 synthetic audio tokens
- 10.11.4 train a tiny token predictor
- 10.11.5 sample conditionally
- 10.12 3D Generation
- 10.12.1 Representation: 3D Gaussian Splatting (Kerbl et al., 2023)
- 10.12.2 Multi-view diffusion
- 10.12.3 Text-to-3D pipelines
- 10.12.4 NeRF (for context)
- 10.12.5 2D Gaussian splat
- 10.12.6 render by summing splats
- 10.12.7 fit by gradient descent
- 10.13 Flow Matching and Rectified Flows
- 10.13.1 Straight-line flow
- 10.13.2 Sampling
- 10.13.3 Rectified flow (Liu 2022)
- 10.13.4 Why this won for images in 2024
- 10.13.5 training loss
- 10.13.6 multi-step inference
- 10.13.7 compare step counts
- 10.14 Evaluation: FID, CLIP Score
- 10.14.1 FID — sample quality
- 10.14.2 CLIP score — prompt adherence
- 10.14.3 Human preference — the ground truth
- 10.14.4 FID in four lines
- 10.14.5 CLIP-style cosine-similarity
- 10.14.6 Elo aggregation
- 10.15 Visual Autoregressive Modeling (VAR): Next-Scale Prediction
- 10.15.1 VQ-VAE Multi-Scale Tokenizer
- 10.15.2 Next-Scale Prediction
- 10.15.3 Generation
- 10.15.4 Why Next-Scale Wins Over Next-Token
- 10.15.5 Scaling Law
- 10.15.6 Relationship to Diffusion
- 11Reinforcement learningnot yet
- 11.1 MDPs, States, Actions and Rewards
- 11.1.1 a tiny deterministic MDP
- 11.1.2 roll out a policy
- 11.1.3 compute V^π exactly via the Bellman equation
- 11.1.4 γ is a hyperparameter with physical meaning
- 11.2 Dynamic Programming
- 11.2.1 build the GridWorld MDP model
- 11.2.2 policy evaluation
- 11.2.3 policy improvement
- 11.2.4 stitch them together
- 11.2.5 value iteration (the one-loop version)
- 11.3 Monte Carlo Methods
- 11.3.1 rollout → list of (s, a, r)
- 11.3.2 compute returns (reverse sweep)
- 11.3.3 first-visit MC evaluation
- 11.3.4 ε-greedy MC control (on-policy)
- 11.3.5 compare to DP gold standard
- 11.4 Q-Learning, SARSA
- 11.4.1 SARSA on ε-greedy policy
- 11.4.2 Q-learning
- 11.4.3 learning curves
- 11.4.4 compare to DP truth
- 11.5 Deep Q-Networks (DQN)
- 11.5.1 replay buffer
- 11.5.2 a tiny Q-network (manual MLP)
- 11.5.3 the DQN update
- 11.5.4 the outer loop
- 11.6 Policy Gradients — REINFORCE
- 11.6.1 softmax policy network
- 11.6.2 sampling and log-probability
- 11.6.3 rollout with log-probs captured
- 11.6.4 REINFORCE update
- 11.6.5 baselines
- 11.7 Actor-Critic — A2C, A3C
- 11.7.1 a critic
- 11.7.2 n-step advantage
- 11.7.3 combined update
- 11.7.4 parallelization (A3C vs A2C)
- 11.8 PPO
- 11.8.1 capture log π_old(a | s) at rollout time
- 11.8.2 compute GAE advantages (Lesson 07)
- 11.8.3 clipped surrogate update
- 11.8.4 value and entropy
- 11.8.5 diagnostics
- 11.9 Reward Modeling and RLHF
- 11.9.1 synthetic preference data
- 11.9.2 Bradley-Terry reward model
- 11.9.3 PPO-like policy on top of RM
- 11.9.4 monitor the KL
- 11.9.5 the production recipe with TRL
- 11.10 Multi-Agent RL
- 11.10.1 the multi-agent env
- 11.10.2 independent Q-learning
- 11.10.3 centralized Q with decomposed-value update
- 11.10.4 simple self-play (adversarial 2-agent)
- 11.11 Sim-to-Real Transfer
- 11.11.1 parameterized sim
- 11.11.2 train with DR
- 11.11.3 evaluate zero-shot on "real" slips
- 11.11.4 compare to narrow training
- 11.12 RL for Games
- 11.12.1 a tiny verifier environment
- 11.12.2 policy: softmax over K answer tokens per prompt
- 11.12.3 group sampling and group-relative advantage
- 11.12.4 compare to REINFORCE baseline (value-free)
- 11.12.5 observe entropy and KL
- 12LLMs from scratchnot yet
- 12.1 Tokenizers: BPE, WordPiece, SentencePiece
- 12.1.1 Three Approaches That Failed (and One That Won)
- 12.1.2 BPE: Byte Pair Encoding
- 12.1.3 Byte-Level BPE (GPT-2, GPT-3, GPT-4)
- 12.1.4 WordPiece (BERT)
- 12.1.5 SentencePiece (Llama, T5)
- 12.1.6 Vocabulary Size Tradeoffs
- 12.1.7 The Multilingual Tax
- 12.1.8 Character-Level Tokenizer
- 12.1.9 BPE Tokenizer from Scratch
- 12.1.10 Encode and Decode Roundtrip
- 12.1.11 Compare with tiktoken
- 12.1.12 Vocabulary Analysis
- 12.1.13 tiktoken (OpenAI)
- 12.1.14 Hugging Face tokenizers
- 12.1.15 Loading Llama's Tokenizer
- 12.2 Building a Tokenizer from Scratch
- 12.2.1 The Full Pipeline
- 12.2.2 Byte-Level BPE
- 12.2.3 Pre-Tokenization
- 12.2.4 Special Tokens
- 12.2.5 Chat Templates
- 12.2.6 Speed
- 12.2.7 Byte-Level Encoding
- 12.2.8 Pre-Tokenizer with Regex
- 12.2.9 BPE on Byte Sequences
- 12.2.10 Special Token Handling
- 12.2.11 Full Tokenizer Class
- 12.2.12 Multilingual Test
- 12.2.13 Comparing Real Tokenizers
- 12.3 Data Pipelines for Pre-Training
- 12.3.1 Where the Data Comes From
- 12.3.2 Data Cleaning
- 12.3.3 Deduplication with MinHash
- 12.3.4 Sequence Packing
- 12.3.5 The Chinchilla Scaling Law
- 12.3.6 Text Cleaning
- 12.3.7 MinHash Deduplication
- 12.3.8 Tokenize and Pack Sequences
- 12.3.9 DataLoader for Training
- 12.3.10 Dataset Statistics
- 12.3.11 Compare With HuggingFace Datasets
- 12.4 Pre-Training a Mini GPT (124M)
- 12.4.1 The GPT Architecture
- 12.4.2 The Transformer Block
- 12.4.3 Attention: The Core Mechanism
- 12.4.4 KV Cache: Why Inference Is Fast
- 12.4.5 Prefill vs Decode: Two Phases of Inference
- 12.4.6 The Training Loop
- 12.4.7 GPT-2 Small: The Numbers
- 12.4.8 Embedding Layer
- 12.4.9 Self-Attention with Causal Mask
- 12.4.10 Multi-Head Attention
- 12.4.11 Transformer Block
- 12.4.12 Full GPT Model
- 12.4.13 Training Loop
- 12.4.14 Text Generation
- 12.4.15 Full Training and Generation Demo
- 12.5 Distributed Training, FSDP, DeepSpeed
- 12.5.1 Why Distribution is Required
- 12.5.2 Data Parallelism
- 12.5.3 Tensor Parallelism
- 12.5.4 Pipeline Parallelism
- 12.5.5 FSDP: Fully Sharded Data Parallel
- 12.5.6 DeepSpeed ZeRO
- 12.5.7 Mixed Precision Training
- 12.5.8 Megatron-LM and 3D Parallelism
- 12.5.9 Simulate Data Parallelism
- 12.5.10 Simulate Tensor Parallelism
- 12.5.11 Simulate Pipeline Parallelism
- 12.5.12 Memory Calculator
- 12.5.13 Mixed Precision Simulation
- 12.5.14 Run All Simulations
- 12.6 Instruction Tuning — SFT
- 12.6.1 What SFT Actually Does
- 12.6.2 Data Formats
- 12.6.3 Why It Works
- 12.6.4 The Masked Loss
- 12.6.5 Training Hyperparameters
- 12.6.6 Catastrophic Forgetting
- 12.6.7 Real Numbers
- 12.6.8 Instruction Dataset
- 12.6.9 Tokenize with Chat Template
- 12.6.10 Masked Cross-Entropy Loss
- 12.6.11 SFT Training Loop
- 12.6.12 Compare Base vs SFT Model
- 12.6.13 Measure Catastrophic Forgetting
- 12.6.14 Full SFT Pipeline Demo
- 12.7 RLHF — Reward Model + PPO
- 12.7.1 The Three Stages
- 12.7.2 The Reward Model
- 12.7.3 PPO: Proximal Policy Optimization
- 12.7.4 The PPO Objective in Detail
- 12.7.5 Reward Hacking
- 12.7.6 Real RLHF Pipelines
- 12.7.7 Synthetic Preference Data
- 12.7.8 Reward Model Architecture
- 12.7.9 Bradley-Terry Loss
- 12.7.10 Simplified PPO Loop
- 12.7.11 Reward Score Comparison
- 12.7.12 Full RLHF Pipeline Demo
- 12.8 DPO — Direct Preference Optimization
- 12.8.1 The Key Insight
- 12.8.2 The DPO Loss
- 12.8.3 Why DPO is Simpler
- 12.8.4 When DPO Beats RLHF
- 12.8.5 When RLHF Beats DPO
- 12.8.6 Beyond DPO: KTO, ORPO, SimPO
- 12.8.7 Real DPO Deployments
- 12.8.8 Preference Dataset
- 12.8.9 Sequence Log-Probability
- 12.8.10 DPO Training Loop
- 12.8.11 Compare DPO vs RLHF
- 12.8.12 Beta Sensitivity Analysis
- 12.8.13 Full DPO Pipeline Demo
- 12.9 Constitutional AI and Self-Improvement
- 12.9.1 The Constitutional AI Loop
- 12.9.2 What the Constitution Actually Does
- 12.9.3 GRPO: Group-Relative Policy Optimization
- 12.9.4 Why GRPO Matters for Reasoning
- 12.9.5 Process Reward Models vs Outcome Reward Models
- 12.9.6 Self-Improvement: The Feedback Multiplier
- 12.9.7 When To Use What
- 12.9.8 The Constitution
- 12.9.9 Self-Critique and Revise
- 12.9.10 Rule-Based Rewards
- 12.9.11 Group-Relative Advantage
- 12.9.12 GRPO Update
- 12.9.13 Self-Improvement Round
- 12.10 Evaluation — Benchmarks, Evals
- 12.10.1 The Eval Landscape
- 12.10.2 Why Benchmarks Break
- 12.10.3 Perplexity: A Quick Health Check
- 12.10.4 LLM-as-Judge
- 12.10.5 ELO Ratings from Pairwise Comparisons
- 12.10.6 Eval Frameworks
- 12.10.7 Building Custom Evals
- 12.10.8 A Minimal Eval Framework
- 12.10.9 Scoring Functions
- 12.10.10 ELO Rating System
- 12.10.11 Perplexity Calculation
- 12.10.12 Aggregate Results
- 12.10.13 Run the Full Pipeline
- 12.10.14 ELO Tournament
- 12.10.15 Perplexity Comparison
- 12.10.16 lm-evaluation-harness (EleutherAI)
- 12.10.17 promptfoo
- 12.10.18 RAGAS for RAG evaluation
- 12.11 Quantization: INT8, GPTQ, AWQ, GGUF
- 12.11.1 Number Formats: What Each Bit Does
- 12.11.2 How Quantization Works
- 12.11.3 Sensitivity Hierarchy
- 12.11.4 PTQ vs QAT
- 12.11.5 GPTQ, AWQ, GGUF
- 12.11.6 Quality Measurement
- 12.11.7 Real Numbers
- 12.11.8 Number Format Representations
- 12.11.9 Symmetric Quantization (Per-Tensor and Per-Channel)
- 12.11.10 Bit-Width Sweep
- 12.11.11 Sensitivity Experiment
- 12.11.12 Simulated GPTQ
- 12.11.13 AWQ Simulation
- 12.11.14 Full Pipeline
- 12.11.15 Quantizing with GPTQModel
- 12.11.16 Quantizing to AWQ with LLM Compressor
- 12.11.17 Converting to GGUF
- 12.11.18 Serving quantized models
- 12.12 Inference Optimization
- 12.12.1 Prefill vs Decode
- 12.12.2 KV Cache
- 12.12.3 Continuous Batching
- 12.12.4 PagedAttention
- 12.12.5 Speculative Decoding
- 12.12.6 Prefix Caching
- 12.12.7 Inference Engines
- 12.12.8 The Ops:Byte Framework
- 12.12.9 KV Cache from Scratch
- 12.12.10 Attention with KV Cache
- 12.12.11 Continuous Batching Simulator
- 12.12.12 Prefix Cache
- 12.12.13 Speculative Decoding Simulator
- 12.12.14 KV Cache Memory Profiler
- 12.13 Building a Complete LLM Pipeline
- 12.13.1 The Twelve Stages
- 12.13.2 The Manifest
- 12.13.3 Artifact Typing
- 12.13.4 The Eval Gate
- 12.13.5 The Orchestrator
- 12.13.6 Experiment Tracking and Artifact Storage
- 12.13.7 Costing
- 12.13.8 Reproducibility vs Determinism
- 12.13.9 Rollback Plan
- 12.13.10 Production Recipes Observed in 2026
- 12.14 Open Models: Architecture Walkthroughs
- 12.14.1 The Invariant Core
- 12.14.2 The Six Knobs That Actually Move
- 12.14.3 Knob 1: RMSNorm
- 12.14.4 Knob 2: RoPE
- 12.14.5 Knob 3: SwiGLU
- 12.14.6 Knob 4: Attention Head Sharing
- 12.14.7 Knob 5: Mixture of Experts
- 12.14.8 Knob 6: Pre-norm stays
- 12.14.9 Model-by-Model Diff
- 12.14.10 Reading a config.json
- 12.14.11 Activation memory budget
- 12.14.12 KV Cache budget
- 12.14.13 When Each Model Wins
- 12.15 Speculative Decoding and EAGLE-3
- 12.15.1 The invariant: Leviathan rejection sampling
- 12.15.2 What determines speedup
- 12.15.3 The two-year progression
- 12.15.4 KV cache rollback
- 12.15.5 Draft architectures in 2026
- 12.15.6 the rejection rule
- 12.15.7 residual distribution
- 12.15.8 a full speculative step
- 12.15.9 KV rollback bookkeeping
- 12.15.10 the Leviathan check
- 12.15.11 speedup vs. α
- 12.16 Differential Attention (V2)
- 12.16.1 The noise floor of softmax
- 12.16.2 The differential idea
- 12.16.3 Why this matches headed noise-canceling
- 12.16.4 V1 vs V2: the diff
- 12.16.5 When to reach for it
- 12.16.6 How it stacks with other 2026 knobs
- 12.16.7 standard softmax attention
- 12.16.8 split Q, K into two halves
- 12.16.9 two softmax branches + subtraction
- 12.16.10 noise cancellation measurement
- 12.16.11 V1 vs V2 parameter accounting
- 12.17 Native Sparse Attention (DeepSeek NSA)
- 12.17.1 Three parallel branches
- 12.17.2 Why this is "natively trainable"
- 12.17.3 Hardware-aligned kernel
- 12.17.4 The compute budget
- 12.17.5 How does it compare
- 12.17.6 compress tokens into blocks
- 12.17.7 compressed-branch attention
- 12.17.8 top-k block selection
- 12.17.9 sliding-window attention
- 12.17.10 gate + combine
- 12.17.11 compute counting
- 12.18 Multi-Token Prediction (MTP)
- 12.18.1 The sequential MTP recipe
- 12.18.2 Why sequential, not parallel
- 12.18.3 Parameter accounting
- 12.18.4 The speculative-decoding payoff
- 12.18.5 Relation to EAGLE
- 12.18.6 shared embedding table
- 12.18.7 the per-depth combination
- 12.18.8 the transformer block at depth k
- 12.18.9 the shared output head
- 12.18.10 per-depth loss
- 12.18.11 parameter accounting
- 12.19 DualPipe Parallelism
- 12.19.1 Pipeline parallelism refresher
- 12.19.2 Idea 1: chunk decomposition
- 12.19.3 Idea 2: bidirectional scheduling
- 12.19.4 A hand-traced schedule
- 12.19.5 Bubble accounting
- 12.19.6 DualPipeV — the refinement
- 12.19.7 What it means for a 14.8T-token run
- 12.19.8 Where it sits in the stack
- 12.20 DeepSeek-V3 Architecture Walkthrough
- 12.20.1 The invariant core, again
- 12.20.2 The twist: MLA instead of GQA
- 12.20.3 The routing: auxiliary-loss-free load balancing
- 12.20.4 The MTP: denser training + free draft
- 12.20.5 The training: DualPipe
- 12.20.6 The config, field by field
- 12.20.7 Parameter accounting
- 12.20.8 The 671B / 37B ratio
- 12.20.9 Where DeepSeek-V3 sits
- 12.20.10 The follow-on: R1, V4
- 12.21 Jamba — Hybrid SSM-Transformer
- 12.21.1 An SSM in one page
- 12.21.2 The Jamba block
- 12.21.3 Why the 1:7 ratio
- 12.21.4 Positional encoding
- 12.21.5 The memory budget
- 12.21.6 Mamba-3: the pure-SSM baseline in 2026
- 12.21.7 When to reach for a hybrid
- 12.21.8 The competitive landscape
- 12.22 Async and Hogwild! Inference
- 12.22.1 The setup
- 12.22.2 Why coordination emerges
- 12.22.3 The naming
- 12.22.4 RoPE makes this tractable
- 12.22.5 Wall-time math
- 12.22.6 Concrete example
- 12.22.7 When to reach for Hogwild!
- 12.22.8 When not to
- 12.22.9 The experimental status
- 12.22.10 the shared cache
- 12.22.11 the worker loop
- 12.22.12 the coordination heuristic
- 12.22.13 measured speedup
- 12.22.14 stress the coordination
- 12.23 Speculative Decoding and EAGLE
- 12.23.1 The Two-Model Setup
- 12.23.2 The Exactness Rule
- 12.23.3 Expected Speedup
- 12.23.4 Training the Draft: Distillation
- 12.23.5 EAGLE: Tree Drafting + Feature Reuse
- 12.23.6 Tree Attention Verification
- 12.23.7 When It Wins, When It Doesn't
- 12.24 Gradient Checkpointing and Activation Recomputation
- 12.24.1 What Backward Actually Needs
- 12.24.2 Naive Full Checkpointing
- 12.24.3 Selective Checkpointing (Korthikanti 2022)
- 12.24.4 Offload
- 12.24.5 Recompute Cost Model
- 12.24.6 Memory Savings Model
- 12.24.7 When Not to Checkpoint
- 12.24.8 Implementation Patterns
- 12.24.9 Interaction with TP / PP / FP8
- 12.24.10 A Toy Model With Segments
- 12.24.11 Naive Backward Needing All Activations
- 12.24.12 Checkpoint-Every-k Memory
- 12.24.13 Cost Model
- 12.24.14 Memory Estimator
- 12.24.15 Optimal Segment Size
- 12.24.16 Selective Checkpoint Decision
- 13LLM engineeringnot yet
- 13.1 Prompt Engineering: Techniques and Patterns
- 13.1.1 Anatomy of a Prompt
- 13.1.2 System message
- 13.1.3 Temperature
- 13.1.4 Top-p
- 13.1.5 Few-shot prompting
- 13.1.6 Chain-of-thought
- 13.1.7 Role prompting
- 13.1.8 Prompt injection
- 13.1.9 Context window
- 13.1.10 Assistant prefill
- 13.1.11 Meta-prompting
- 13.2 Few-Shot, CoT, Tree-of-Thought
- 13.2.1 Zero-Shot vs Few-Shot: When Examples Beat Instructions
- 13.2.2 Example Selection: Similar Beats Random
- 13.2.3 Chain-of-Thought: Giving Models Scratch Paper
- 13.2.4 Self-Consistency: Sample Many, Vote Once
- 13.2.5 Tree-of-Thought: Branching Exploration
- 13.2.6 ReAct: Thinking + Doing
- 13.2.7 Structured Prompting: XML Tags, Delimiters, Headers
- 13.2.8 Prompt Chaining: Sequential Decomposition
- 13.2.9 Performance Comparison
- 13.2.10 Few-Shot Example Store
- 13.2.11 Chain-of-Thought Prompt Builder
- 13.2.12 Self-Consistency Voting
- 13.2.13 Tree-of-Thought Solver
- 13.2.14 Full Pipeline
- 13.2.15 Template-Driven Few-Shot Prompts
- 13.2.16 Compiled Prompts
- 13.2.17 Comparison: From-Scratch vs Frameworks
- 13.3 Structured Outputs
- 13.3.1 The Structured Output Spectrum
- 13.3.2 JSON Schema: The Contract Language
- 13.3.3 The Pydantic Pattern
- 13.3.4 Function Calling / Tool Use
- 13.3.5 Common Failure Modes
- 13.3.6 JSON Schema Validator
- 13.3.7 Pydantic-Style Model to Schema
- 13.3.8 Constrained Token Filter
- 13.3.9 Extraction Pipeline
- 13.3.10 Run the Full Pipeline
- 13.3.11 OpenAI Structured Outputs
- 13.3.12 Anthropic Tool Use
- 13.3.13 Instructor Library
- 13.4 Embeddings and Vector Representations
- 13.4.1 What Is an Embedding?
- 13.4.2 The Word2Vec Breakthrough
- 13.4.3 From Words to Sentences
- 13.4.4 Modern Embedding Models
- 13.4.5 Similarity Metrics
- 13.4.6 Vector Databases and HNSW
- 13.4.7 Chunking Strategies
- 13.4.8 Bi-Encoders vs Cross-Encoders
- 13.4.9 Matryoshka Embeddings
- 13.4.10 Binary Quantization
- 13.4.11 Text Chunking
- 13.4.12 Building Embeddings from Scratch
- 13.4.13 Similarity Functions
- 13.4.14 Vector Index with Brute-Force Search
- 13.4.15 The Semantic Search Engine
- 13.4.16 Comparing Similarity Metrics
- 13.5 Context Engineering
- 13.5.1 The Context Window is a Scarce Resource
- 13.5.2 Lost-in-the-Middle
- 13.5.3 Context Components
- 13.5.4 Context Compression Strategies
- 13.5.5 Memory Systems
- 13.5.6 Dynamic Context Assembly
- 13.5.7 Token Counter
- 13.5.8 Context Budget Manager
- 13.5.9 Lost-in-the-Middle Reordering
- 13.5.10 Conversation History Compressor
- 13.5.11 Dynamic Tool Selector
- 13.5.12 Full Context Assembly Pipeline
- 13.5.13 Harness-Managed Context
- 13.5.14 Dynamic Context Loading
- 13.5.15 Assistant Long-Term Memory
- 13.5.16 RAG as Context Engineering
- 13.6 RAG: Retrieval-Augmented Generation
- 13.6.1 The RAG Pattern
- 13.6.2 Why RAG Beats Fine-Tuning
- 13.6.3 Embedding Models
- 13.6.4 Vector Similarity
- 13.6.5 Chunking Strategies
- 13.6.6 Vector Databases
- 13.6.7 The Full Pipeline
- 13.6.8 Real Numbers
- 13.6.9 Document Chunking
- 13.6.10 TF-IDF Embeddings
- 13.6.11 Cosine Similarity Search
- 13.6.12 Prompt Construction
- 13.6.13 The Complete RAG Pipeline
- 13.6.14 Generation (simulated)
- 13.7 Advanced RAG: Chunking, Reranking
- 13.7.1 Hybrid Search: Semantic + Keyword
- 13.7.2 Reciprocal Rank Fusion (RRF)
- 13.7.3 Reranking
- 13.7.4 Query Transformation
- 13.7.5 Parent-Child Chunking
- 13.7.6 Metadata Filtering
- 13.7.7 Evaluation
- 13.7.8 BM25 Implementation
- 13.7.9 Reciprocal Rank Fusion
- 13.7.10 Hybrid Search Pipeline
- 13.7.11 Simple Reranker
- 13.7.12 HyDE (Hypothetical Document Embeddings)
- 13.7.13 Faithfulness Evaluation
- 13.8 Fine-Tuning with LoRA and QLoRA
- 13.8.1 LoRA: Low-Rank Adaptation
- 13.8.2 The Scaling Factor: Alpha
- 13.8.3 Where to Apply LoRA
- 13.8.4 Rank Selection
- 13.8.5 QLoRA: 4-Bit Quantization + LoRA
- 13.8.6 The Quality Question
- 13.8.7 Real-World Costs
- 13.8.8 The 2026 PEFT stack
- 13.8.9 Merging Adapters
- 13.8.10 When NOT to Fine-Tune
- 13.8.11 The LoRA Layer
- 13.8.12 LoRA-Wrapped Linear Layer
- 13.8.13 Inject LoRA into a Model
- 13.8.14 Count Parameters
- 13.8.15 Merge Weights Back
- 13.8.16 Simulated QLoRA Quantization
- 13.8.17 Training Loop
- 13.8.18 Full Demo
- 13.9 Function Calling and Tool Use
- 13.9.1 The Function Calling Loop
- 13.9.2 Tool Definitions: The JSON Schema Contract
- 13.9.3 Provider Comparison
- 13.9.4 Tool Choice: Auto, Required, Specific
- 13.9.5 Parallel Function Calling
- 13.9.6 Structured Outputs vs Function Calling
- 13.9.7 Security: The Non-Negotiable Rules
- 13.9.8 Error Handling
- 13.9.9 MCP: Model Context Protocol
- 13.9.10 Define the Tool Registry
- 13.9.11 Implement 5 Tools
- 13.9.12 Register All Tools
- 13.9.13 Build the Function Calling Loop
- 13.9.14 Argument Validation
- 13.9.15 Run the Demo
- 13.9.16 OpenAI Function Calling
- 13.9.17 Anthropic Tool Use
- 13.9.18 MCP Integration
- 13.10 Evaluation and Testing
- 13.10.1 The Eval Taxonomy
- 13.10.2 LLM-as-Judge: The Workhorse
- 13.10.3 Rubric Design
- 13.10.4 The Eval Pipeline
- 13.10.5 Eval Datasets: The Foundation
- 13.10.6 Sample Size and Confidence
- 13.10.7 Regression Testing
- 13.10.8 Cost of Evals
- 13.10.9 Anti-Patterns
- 13.10.10 Real Tools
- 13.10.11 Define the Eval Data Structures
- 13.10.12 Build the LLM-as-Judge Scorer
- 13.10.13 Build Automated Metrics
- 13.10.14 Build the Confidence Interval Calculator
- 13.10.15 Build the Eval Runner and Comparison Report
- 13.10.16 Run the Demo
- 13.10.17 promptfoo Integration
- 13.10.18 DeepEval Integration
- 13.10.19 CI/CD Integration Pattern
- 13.11 Caching, Rate Limiting and Cost
- 13.11.1 The Cost Anatomy of an LLM Call
- 13.11.2 Provider Caching: Built-in Discounts
- 13.11.3 Semantic Caching: Your Custom Layer
- 13.11.4 Exact Caching: Hash and Match
- 13.11.5 Rate Limiting: Protecting Your Budget
- 13.11.6 Model Routing: Right Model for the Right Job
- 13.11.7 Cost Tracking: Know Where the Money Goes
- 13.11.8 Batching: Bulk Discounts
- 13.11.9 Budget Alerts and Circuit Breakers
- 13.11.10 The Optimization Stack
- 13.11.11 Real Savings: Before and After
- 13.11.12 Cost Calculator
- 13.11.13 Exact Cache
- 13.11.14 Semantic Cache
- 13.11.15 Rate Limiter
- 13.11.16 Cost Tracker
- 13.11.17 Model Router
- 13.11.18 Run the Demo
- 13.11.19 Anthropic Prompt Caching
- 13.11.20 OpenAI Automatic Caching
- 13.11.21 OpenAI Batch API
- 13.11.22 Production Semantic Cache with Redis
- 13.12 Guardrails and Safety
- 13.12.1 The Guardrail Sandwich
- 13.12.2 Attack Taxonomy
- 13.12.3 Input Guardrails
- 13.12.4 Output Guardrails
- 13.12.5 The Content Filtering Stack
- 13.12.6 Tools of the Trade
- 13.12.7 Defense-in-Depth
- 13.12.8 Real Attack Case Studies
- 13.12.9 The Honest Truth
- 13.12.10 The Guardrail Pipeline
- 13.12.11 Monitoring Dashboard
- 13.12.12 Run the Demo
- 13.12.13 OpenAI Moderation API
- 13.12.14 LlamaGuard
- 13.12.15 NeMo Guardrails
- 13.12.16 Guardrails AI
- 13.13 Building a Production LLM App
- 13.13.1 Production Architecture
- 13.13.2 The Stack
- 13.13.3 Streaming: Why It Matters
- 13.13.4 Error Handling: The Three Layers
- 13.13.5 Observability: What to Measure
- 13.13.6 A/B Testing Prompts in Production
- 13.13.7 Real Architecture Examples
- 13.13.8 Scaling
- 13.13.9 Cost Projection
- 13.13.10 The Deployment Checklist
- 13.13.11 Core Infrastructure
- 13.13.12 Prompt Management
- 13.13.13 Semantic Cache
- 13.13.14 Guardrails
- 13.13.15 LLM Caller with Retry and Streaming
- 13.13.16 The Request Pipeline
- 13.13.17 Run the Full Demo
- 13.13.18 FastAPI Server (Production Deployment)
- 13.13.19 Real API Integration
- 13.13.20 Docker Deployment
- 13.14 Model Context Protocol (MCP)
- 13.14.1 The three server primitives
- 13.14.2 Stateless requests replace the handshake
- 13.14.3 Discovery and version selection
- 13.14.4 Results are explicit
- 13.14.5 The wire format and transport
- 13.14.6 Client input without server-initiated requests
- 13.14.7 register a server surface
- 13.14.8 attach metadata to every request
- 13.14.9 optionally discover before listing
- 13.14.10 map the same request to HTTP
- 13.14.11 enforce safety outside protocol state
- 13.15 Prompt Caching and Context Caching
- 13.15.1 The cache-friendly layout
- 13.15.2 The break-even calculation
- 13.15.3 Anthropic prompt caching with explicit markers
- 13.15.4 one-hour extended TTL
- 13.15.5 OpenAI automatic caching
- 13.15.6 Gemini explicit context caching
- 13.15.7 measuring hit rate in production
- 13.16 Agent State Machines — Graphs, Nodes, Checkpoints
- 13.16.1 The four superpowers
- 13.16.2 Reducers are the point
- 13.16.3 The ReAct graph in four nodes
- 13.16.4 StateGraph vs Send (fanout)
- 13.16.5 Subgraphs
- 13.16.6 state and nodes
- 13.16.7 run with a thread
- 13.16.8 add a human-in-the-loop interrupt
- 13.16.9 time-travel for debugging
- 13.16.10 swap the checkpointer for production
- 13.17 Agent Framework Tradeoffs
- 13.17.1 What "abstraction" actually means
- 13.17.2 The state question
- 13.17.3 The branching question
- 13.17.4 The observability question
- 13.17.5 Cost and latency
- 13.17.6 Interoperability
- 14Multimodal AInot yet
- 14.1 Vision Transformers and the Patch-Token Primitive
- 14.1.1 Patches as tokens
- 14.1.2 Positional embeddings
- 14.1.3 CLS token, pooled output, and register tokens
- 14.1.4 Pretraining: supervised, contrastive, masked, self-distilled
- 14.1.5 Scaling laws
- 14.1.6 Parameter count for a ViT
- 14.1.7 2026 production config
- 14.2 CLIP and Contrastive Vision-Language Pretraining
- 14.2.1 The dual encoder
- 14.2.2 InfoNCE loss
- 14.2.3 Temperature
- 14.2.4 Why sigmoid scales better (SigLIP)
- 14.2.5 Zero-shot classification
- 14.2.6 Linear probes and finetuning
- 14.2.7 SigLIP 2: NaFlex and dense features
- 14.2.8 ALIGN, BASIC, OpenCLIP, EVA-CLIP
- 14.2.9 The zero-shot ceiling
- 14.3 BLIP-2 Q-Former as Modality Bridge
- 14.3.1 Learnable queries
- 14.3.2 Architecture
- 14.3.3 Two-stage training
- 14.3.4 Parameter economics
- 14.3.5 InstructBLIP and the instruction-aware Q-Former
- 14.3.6 MiniGPT-4 and the projector-only approach
- 14.3.7 Why LLaVA went simpler
- 14.3.8 Gated cross-attention: Flamingo, the ancestor
- 14.3.9 The 2026 descendants
- 14.4 Flamingo and Gated Cross-Attention
- 14.4.1 The frozen LLM
- 14.4.2 Perceiver resampler
- 14.4.3 Gated cross-attention
- 14.4.4 Masked cross-attention for interleaved inputs
- 14.4.5 In-context few-shot learning
- 14.4.6 Training data
- 14.4.7 OpenFlamingo and Otter
- 14.4.8 The descendants
- 14.4.9 Comparison to BLIP-2
- 14.5 LLaVA and Visual Instruction Tuning
- 14.5.1 The architecture
- 14.5.2 Stage 1: projector alignment
- 14.5.3 Stage 2: visual instruction tuning
- 14.5.4 Why the community copied this
- 14.5.5 LLaVA-1.5 and LLaVA-NeXT
- 14.5.6 LLaVA-OneVision
- 14.5.7 The comparison to Q-Former
- 14.5.8 The prompt format
- 14.5.9 Parameter economy
- 14.6 Any-Resolution Vision — Patch-n'-Pack and NaFlex
- 14.6.1 NaViT and patch-n'-pack
- 14.6.2 AnyRes (LLaVA-NeXT)
- 14.6.3 M-RoPE (Qwen2-VL)
- 14.6.4 NaFlex (SigLIP 2)
- 14.6.5 The packing mask
- 14.6.6 Token budgets
- 14.7 Open-Weight VLM Recipes: What Actually Matters
- 14.7.1 The five-axis design space
- 14.7.2 Axis 1: encoder > connector
- 14.7.3 Axis 2: connector design is a wash
- 14.7.4 Axis 3: LLM size sets the ceiling
- 14.7.5 Axis 4: data — detailed human captions beat distillation
- 14.7.6 Axis 5: resolution and its schedule
- 14.7.7 The Prismatic controlled comparison
- 14.7.8 A picker for 2026
- 14.8 LLaVA-OneVision: Single, Multi, Video
- 14.8.1 The OneVision token budget
- 14.8.2 The three-stage curriculum
- 14.8.3 Why curriculum works
- 14.8.4 Emergent cross-scenario skills
- 14.8.5 Visual-token pooling
- 14.8.6 LLaVA-OneVision-1.5
- 14.8.7 Contrast with Qwen2.5-VL
- 14.9 Qwen-VL Family and Dynamic-FPS Video
- 14.9.1 Qwen-VL (August 2023)
- 14.9.2 Qwen2-VL (September 2024) — M-RoPE and native resolution
- 14.9.3 Qwen2.5-VL (February 2025) — dynamic FPS + absolute time
- 14.9.4 Qwen3-VL (November 2025)
- 14.9.5 M-RoPE mathematically
- 14.9.6 Dynamic-FPS sampling logic
- 14.9.7 Structured agent output
- 14.10 InternVL3 Native Multimodal Pretraining
- 14.10.1 Native multimodal pretraining
- 14.10.2 V2PE (variable visual position encoding)
- 14.10.3 Visual Resolution Router (ViR)
- 14.10.4 Decoupled Vision-Language deployment (DvD)
- 14.10.5 Single-stage vs multi-stage quality
- 14.10.6 InternVL3.5 and InternVL-U
- 14.10.7 Trade-offs of native pretraining
- 14.11 Chameleon Early-Fusion Token-Only
- 14.11.1 VQ-VAE as image tokenizer
- 14.11.2 The shared vocabulary
- 14.11.3 Mixed-modality generation
- 14.11.4 Training stability — QK-Norm, dropout, LayerNorm ordering
- 14.11.5 The tokenizer's reconstruction ceiling
- 14.11.6 Chameleon vs BLIP-2 / LLaVA
- 14.11.7 Fuyu and AnyGPT
- 14.12 Emu3 Next-Token Prediction for Generation
- 14.12.1 The Emu3 tokenizer
- 14.12.2 Single-loss training
- 14.12.3 Classifier-free guidance and temperature
- 14.12.4 Three roles, one model
- 14.12.5 Benchmarks
- 14.12.6 Compute cost
- 14.12.7 Why it matters
- 14.13 Transfusion Autoregressive + Diffusion
- 14.13.1 The two-loss architecture
- 14.13.2 Attention mask: causal text + bidirectional image
- 14.13.3 Diffusion loss inside the transformer
- 14.13.4 MMDiT: Stable Diffusion 3's variant
- 14.13.5 Why this beats Chameleon-style
- 14.13.6 What sits downstream
- 14.14 Show-o Discrete-Diffusion Unified
- 14.14.1 Masked discrete diffusion (MaskGIT)
- 14.14.2 Show-o: one transformer, hybrid mask
- 14.14.3 Parallel sampling
- 14.14.4 Tasks in one checkpoint
- 14.14.5 Masking schedule
- 14.14.6 Show-o2
- 14.14.7 Where Show-o sits
- 14.15 Janus-Pro Decoupled Encoders
- 14.15.1 Decoupled visual encoding
- 14.15.2 Why this works
- 14.15.3 Data scaling — Janus vs Janus-Pro
- 14.15.4 JanusFlow — the rectified flow variant
- 14.15.5 The shared body's job
- 14.15.6 Compared to InternVL-U
- 14.15.7 Limitations
- 14.16 MIO Any-to-Any Streaming
- 14.16.1 Four tokenizers for four modalities
- 14.16.2 Streaming decode
- 14.16.3 Four-stage curriculum
- 14.16.4 Chain-of-visual-thought
- 14.16.5 Competitors in any-to-any
- 14.16.6 Latency budget
- 14.16.7 Why any-to-any stays hard
- 14.17 Video-Language Temporal Grounding
- 14.17.1 Video-LLaMA: Q-former per clip + audio branch
- 14.17.2 VideoChat and Video-LLaVA
- 14.17.3 Qwen2.5-VL and time-aligned M-RoPE
- 14.17.4 Frame sampling strategies
- 14.17.5 Pooling per frame
- 14.17.6 The four video benchmarks
- 14.17.7 Grounding output formats
- 14.17.8 2026 best practice
- 14.18 Long-Video at Million-Token Context
- 14.18.1 Path 1: Brute context (Gemini 1.5, Claude Opus)
- 14.18.2 Path 2: Ring attention (LWM, LongVILA)
- 14.18.3 Path 3: Token compression (Video-XL, LongVA)
- 14.18.4 Path 4: Agentic retrieval (VideoAgent)
- 14.18.5 Needle-in-a-haystack benchmarks
- 14.18.6 Which path to pick
- 14.18.7 2026 production pattern
- 14.19 Audio-Language Models: Whisper to AF3
- 14.19.1 Log-Mel spectrogram: the input feature
- 14.19.2 Whisper's encoder
- 14.19.3 BEATs and audio-specific encoders
- 14.19.4 Audio Q-former
- 14.19.5 The arc — SALMONN, Qwen-Audio, AF3
- 14.19.6 Cascaded vs end-to-end
- 14.19.7 2026 production recipe
- 14.19.8 MMAU — the audio reasoning benchmark
- 14.20 Omni Models: Thinker-Talker Streaming
- 14.20.1 Thinker and Talker
- 14.20.2 TMRoPE — time-aligned multimodal positions
- 14.20.3 Streaming speech synthesis
- 14.20.4 VAD and turn-taking
- 14.20.5 Qwen3-Omni (November 2025)
- 14.20.6 Production latency budget
- 14.20.7 Token-rate math
- 14.21 Embodied VLAs: RT-2, OpenVLA, π0, GR00T
- 14.21.1 Action tokenization (RT-2)
- 14.21.2 OpenVLA — the open 7B reference
- 14.21.3 FAST tokenizer — faster action decode
- 14.21.4 π0 and flow-matching actions
- 14.21.5 GR00T N1 — dual-system for humanoids
- 14.21.6 Open X-Embodiment
- 14.21.7 Co-fine-tuning vs robot-only
- 14.21.8 Safety and action limits
- 14.22 Document and Diagram Understanding
- 14.22.1 Era 1 — OCR pipeline (pre-2021)
- 14.22.2 TrOCR (2021)
- 14.22.3 Era 2 — OCR-free (2022-2023)
- 14.22.4 LayoutLMv3 (2022)
- 14.22.5 DocLLM (2023)
- 14.22.6 Era 3 — VLM-native (2024+)
- 14.22.7 The Claude 4.7 / GPT-5 frontier
- 14.22.8 Math equations and LaTeX output
- 14.22.9 Handwriting
- 14.22.10 2026 recipe
- 14.23 ColPali Vision-Native Document RAG
- 14.23.1 ColBERT (2020)
- 14.23.2 ColPali
- 14.23.3 ColQwen2 and ColSmol
- 14.23.4 VisRAG
- 14.23.5 M3DocRAG
- 14.23.6 ViDoRe — the benchmark
- 14.23.7 The end-to-end RAG pipeline
- 14.23.8 Storage math
- 14.23.9 When text-RAG still wins
- 14.24 Multimodal RAG and Cross-Modal Retrieval
- 14.24.1 Cross-modal retrieval
- 14.24.2 Fusion strategies
- 14.24.3 Generation grounding
- 14.24.4 The 2025 surveys
- 14.24.5 MuRAG — the foundational paper
- 14.24.6 A production trip-planner example
- 14.24.7 Agentic multimodal RAG
- 14.24.8 Evaluation
- 14.25 Multimodal Agents and Computer-Use (Capstone)
- 14.25.1 GUI grounding — the primitive
- 14.25.2 Action schemas
- 14.25.3 Screenshot-only vs accessibility-tree
- 14.25.4 Long-horizon memory
- 14.25.5 Visual tool use
- 14.25.6 The 2026 benchmarks
- 14.25.7 Why it's still hard
- 14.25.8 The capstone build-it
- 15Tools and protocolsnot yet
- 15.1 The Tool Interface
- 15.1.1 Step one: describe
- 15.1.2 Step two: decide
- 15.1.3 Step three: execute
- 15.1.4 Step four: observe
- 15.1.5 The trust split
- 15.1.6 Where the loop lives
- 15.1.7 Why not just prompt the model to emit JSON?
- 15.1.8 Circuit breakers
- 15.1.9 Where Phase 13 goes from here
- 15.2 Function Calling Deep Dive
- 15.2.1 The common structure
- 15.2.2 Shape diffs, field by field
- 15.2.3 Limits you will actually hit
- 15.2.4 tool_choice behavior
- 15.2.5 Parallel calls
- 15.2.6 Streaming
- 15.2.7 Errors and repair
- 15.2.8 The translator pattern
- 15.3 Parallel and Streaming Tool Calls
- 15.3.1 Enabling parallel
- 15.3.2 Id correlation
- 15.3.3 Running calls concurrently
- 15.3.4 Streaming tool calls
- 15.3.5 Partial JSON and the parse-early trap
- 15.3.6 Out-of-order completion
- 15.3.7 Benchmark: sequential vs parallel
- 15.3.8 Streaming fan-out wall-clock
- 15.4 Structured Output
- 15.4.1 JSON Schema 2020-12 — the lingua franca
- 15.4.2 Pydantic, the Python binding
- 15.4.3 Zod, the TypeScript binding
- 15.4.4 Refusals
- 15.4.5 Constrained decoding in the open
- 15.4.6 The three failure modes
- 15.4.7 Retry strategy
- 15.4.8 Small-model support
- 15.5 Tool Schema Design
- 15.5.1 Naming rules
- 15.5.2 Description pattern
- 15.5.3 Atomic vs monolithic
- 15.5.4 Parameter design
- 15.5.5 Error messages as teaching signals
- 15.5.6 Versioning
- 15.5.7 Tool poisoning prevention
- 15.5.8 Benchmarks
- 15.6 MCP Fundamentals: Stateless Requests and JSON-RPC
- 15.6.1 Server primitives
- 15.6.2 JSON-RPC envelopes
- 15.6.3 Required request metadata
- 15.6.4 Complete results and server identity
- 15.6.5 Discovery without a handshake
- 15.6.6 One request lifecycle
- 15.6.7 Explicit legacy compatibility
- 15.7 Building an MCP Server: Stateless Python and TypeScript
- 15.7.1 The modern dispatch loop
- 15.7.2 Request validation
- 15.7.3 Mandatory discovery
- 15.7.4 Tools
- 15.7.5 Resources
- 15.7.6 Prompts
- 15.7.7 Every successful result is typed
- 15.7.8 No server-initiated requests
- 15.7.9 Explicit legacy compatibility
- 15.8 Building an MCP Client: Discovery, Routing, and Dual-Era Fallback
- 15.8.1 A peer, not a protocol session
- 15.8.2 Build every modern request from scratch
- 15.8.3 Modern discovery
- 15.8.4 The stdio compatibility probe
- 15.8.5 Allowlisting is operator intent, not evidence
- 15.8.6 Legacy is a compatibility branch
- 15.8.7 Discovering and caching tools
- 15.8.8 Collision-safe namespace merge
- 15.8.9 Routing a call
- 15.8.10 Notifications and subscriptions
- 15.8.11 No server-initiated requests
- 15.9 MCP Transports: stdio and Stateless Streamable HTTP
- 15.9.1 stdio
- 15.9.2 Streamable HTTP in 2026-07-28
- 15.9.3 POST-only means POST-only
- 15.9.4 Origin validation
- 15.9.5 Required HTTP metadata headers
- 15.9.6 Request-scoped SSE
- 15.9.7 Long-lived changes use subscriptions/listen
- 15.9.8 Explicit application state
- 15.9.9 HTTP dual-era compatibility
- 15.10 MCP Resources and Prompts: Addressable Context for Stateless Servers
- 15.10.1 Resource templates
- 15.10.2 Content is not trusted instruction
- 15.11 MCP Model Input: Sampling Migration and Stateless MRTR
- 15.11.1 New server: integrate with a model provider directly
- 15.11.2 Existing Sampling workflow: migrate it to MRTR
- 15.11.3 Sampling
- 15.11.4 MRTR
- 15.11.5 InputRequiredResult
- 15.11.6 inputRequests
- 15.11.7 inputResponses
- 15.11.8 requestState
- 15.11.9 resultType
- 15.11.10 Direct model integration
- 15.11.11 Capability gate
- 15.11.12 Loop budget
- 15.12 Explicit Scope and Stateless Elicitation
- 15.12.1 The three-layer rule
- 15.12.2 Roots
- 15.12.3 Explicit scope
- 15.12.4 Containment
- 15.12.5 Elicitation
- 15.12.6 Form mode
- 15.12.7 URL mode
- 15.12.8 MRTR
- 15.12.9 requestState
- 15.12.10 Decline
- 15.12.11 Cancel
- 15.13 MCP Tasks Extension: Durable Work on a Stateless Core
- 15.13.1 Input needed before task creation
- 15.13.2 Input needed after task creation
- 15.13.3 Protocol error
- 15.13.4 Task execution outcome
- 15.14 MCP Apps on the Stateless Protocol
- 15.14.1 Two protocols, one feature
- 15.14.2 Discover before rendering
- 15.14.3 Declare the UI on the tool definition
- 15.14.4 Return data, then let the host bind the view
- 15.14.5 Serve the app as a resource
- 15.14.6 Cache UI resources as executable content
- 15.14.7 Reject wire ambiguity before feature policy
- 15.14.8 The sandbox is a boundary, not a trust verdict
- 15.14.9 The Apps bridge has its own lifecycle
- 15.14.10 Host context, actions, and revocation
- 15.14.11 Fallback is part of the contract
- 15.15 MCP Security: Poisoned Metadata, Routing, and MRTR State
- 15.15.1 Seven attack surfaces worth checking
- 15.15.2 The current request envelope is evidence, not identity
- 15.15.3 Validate routing before policy
- 15.15.4 Pin the whole descriptor
- 15.15.5 Static scanning is a tripwire
- 15.15.6 Namespace before merging
- 15.15.7 Capabilities are compatibility declarations
- 15.15.8 Protect stateless MRTR confirmation
- 15.15.9 Rule of two for high-risk calls
- 15.15.10 Reduce authority before execution
- 15.15.11 Current and legacy interaction paths
- 15.15.12 Stateless transport checks
- 15.16 MCP Authorization: CIMD, Issuer Binding, PKCE, and Step-Up
- 15.16.1 Know the three roles
- 15.16.2 Authorization applies to HTTP
- 15.16.3 Start with protected-resource metadata
- 15.16.4 Verify authorization server metadata
- 15.16.5 Follow the registration priority
- 15.16.6 Prefer Client ID Metadata Documents
- 15.16.7 DCR is a compatibility path
- 15.16.8 Bind credentials to the issuer
- 15.16.9 Authorization code with PKCE
- 15.16.10 Validate iss exactly
- 15.16.11 Validate audience at the MCP server
- 15.16.12 Request the smallest current scope
- 15.16.13 Authorization and the stateless MCP wire
- 15.16.14 No token passthrough
- 15.16.15 Refresh tokens
- 15.17 Stateless MCP Gateways and Registry Admission
- 15.17.1 The modern gateway path
- 15.17.2 Runtime policy is the primary gateway decision
- 15.17.3 One POST endpoint
- 15.17.4 Implement discovery at every layer
- 15.17.5 Per-request client capabilities
- 15.17.6 Deterministic namespacing
- 15.17.7 Pin approved descriptors
- 15.17.8 Registries help discover, not decide
- 15.17.9 Credential mediation
- 15.17.10 Rate limits without sessions
- 15.17.11 Audit the decision chain
- 15.17.12 Request-scoped SSE
- 15.17.13 Long-lived change notifications
- 15.17.14 MRTR through a gateway
- 15.17.15 Tasks extension routing
- 15.17.16 Compatibility boundary
- 15.18 MCP Auth in Production: Issuer-Bound Enrollment and Tokens
- 15.18.1 RFC 8414 — OAuth Authorization Server Metadata
- 15.18.2 RFC 9728 (recap) — Protected Resource Metadata
- 15.18.3 Client ID Metadata Documents (the recommended default)
- 15.18.4 RFC 7591: deprecated compatibility enrollment
- 15.18.5 RFC 8707 (recap) — Resource Indicators
- 15.18.6 RFC 7636 (recap) — PKCE
- 15.18.7 MCP 2026-07-28 authorization profile
- 15.18.8 Deployment capability checklist
- 15.18.9 JWKS refresh pattern (rotate at the AS, refresh at the resource server)
- 15.18.10 The validation routine
- 15.18.11 Opaque tokens use introspection, not guesswork
- 15.18.12 Revocation is a freshness contract
- 15.18.13 Dependency failure needs a declared decision
- 15.18.14 Audience-replay walkthrough (access-token privilege restriction)
- 15.18.15 Mix-up attacks (a client-side defense the server cannot provide)
- 15.18.16 Failure modes
- 15.19 A2A Protocol
- 15.19.1 Agent Card
- 15.19.2 Signed Agent Cards
- 15.19.3 Task lifecycle
- 15.19.4 Messages and Parts
- 15.19.5 Artifacts
- 15.19.6 Three protocol bindings
- 15.19.7 Opacity preservation
- 15.19.8 Timeline
- 15.19.9 Relationship to MCP
- 15.20 OpenTelemetry GenAI
- 15.20.1 Span hierarchy
- 15.20.2 Required attributes
- 15.20.3 Span kinds
- 15.20.4 Opt-in content capture
- 15.20.5 Events on spans
- 15.20.6 Exporters
- 15.20.7 Propagation across MCP
- 15.20.8 Metrics
- 15.20.9 AgentOps layer
- 15.21 LLM Routing Layer
- 15.21.1 OpenAI-compatible proxy shape
- 15.21.2 Model aliases
- 15.21.3 Fallback chains
- 15.21.4 Semantic caching
- 15.21.5 Guardrails
- 15.21.6 Per-key rate limits
- 15.21.7 Self-hosted vs managed trade-offs
- 15.21.8 Cost tracking
- 15.21.9 MCP plus routing
- 15.21.10 Routing strategies
- 15.22 Agent Skills: Portable Contract and Runtime Boundary
- 15.22.1 Preflight for the real-host lab
- 15.22.2 Start in an empty working directory
- 15.22.3 Install the complete reviewer bundle
- 15.22.4 Invoke it explicitly
- 15.22.5 Probe implicit selection
- 15.22.6 Clean up
- 15.22.7 Skills encode procedural knowledge
- 15.22.8 The neighboring abstractions
- 15.22.9 The word "skill" names two different ideas
- 15.22.10 The portable core
- 15.22.11 Runtime extensions are a second layer
- 15.22.12 Frontmatter is executable metadata
- 15.22.13 The skill lifecycle
- 15.22.14 Skills and tools are orthogonal
- 15.22.15 Skills and repository instructions are different scopes
- 15.22.16 Skills do not import one another
- 15.22.17 Validation order matters
- 15.23 Capstone: Stateless Tool Ecosystem
- 15.23.1 Target architecture
- 15.23.2 Target trace
- 15.23.3 Current protocol surfaces
- 15.23.4 Stateless MCP changes the integration boundary
- 15.23.5 Security posture
- 15.23.6 Skills are procedure, not transport
- 15.23.7 Course artifact metadata is a local adapter
- 15.23.8 Simulation versus production
- 15.23.9 Phase 13 map
- 15.24 Skill Discovery and Progressive Disclosure
- 15.24.1 Discovery is a compiler pipeline
- 15.24.2 Scope is runtime policy
- 15.24.3 Collisions need identity beyond name
- 15.24.4 Three disclosure levels
- 15.24.5 Branch-specific references beat topic dumps
- 15.24.6 Catalog budget and active context are different budgets
- 15.24.7 Resource paths are a trust boundary
- 15.24.8 Loading must be observable
- 15.24.9 Why discovery is shallow
- 15.24.10 Why the lab does not parse arbitrary YAML
- 15.25 Skill Invocation and Routing
- 15.25.1 Five channels can start the lifecycle
- 15.25.2 The five invocation stages
- 15.25.3 Human and model invocation form a 2x2 matrix
- 15.25.4 Explicit invocation is identity-first
- 15.25.5 Implicit invocation is description-first
- 15.25.6 Routing is classification with an abstain option
- 15.25.7 Eligibility must precede ranking
- 15.25.8 Routing evals need near misses
- 15.25.9 Arguments have three representations
- 15.25.10 Application invocation is explicit orchestration
- 15.25.11 Skill-to-skill invocation is a tool-like edge
- 15.25.12 Context lifecycle is host-specific
- 15.25.13 Why core and extension adapters are separate
- 15.26 Skill Permissions, Sandboxes, and Trust
- 15.26.1 Skills are context, not a security boundary
- 15.26.2 Five control layers
- 15.26.3 Threat-model the complete package
- 15.26.4 Package trust begins before activation
- 15.26.5 Content has authority levels
- 15.26.6 Review actions as structured requests
- 15.26.7 Command policy needs structure
- 15.26.8 Path policy must resolve reality
- 15.26.9 Secret handling is capability design
- 15.26.10 Network is an independent permission
- 15.26.11 Approval should follow consequence
- 15.26.12 Choose the isolation boundary
- 15.26.13 Scripts should be boring
- 15.26.14 Run the isolation drill
- 15.26.15 Why ask is not allow
- 15.27 Skill Evals, Packaging, and Portability
- 15.27.1 Start from a real workflow, not a topic
- 15.27.2 Separate judgment from deterministic work
- 15.27.3 Author the package in dependency order
- 15.27.4 Six eval layers
- 15.27.5 Routing evals must use the target runtime
- 15.27.6 Artifact contracts make behavior executable
- 15.27.7 Install the directory as one unit
- 15.27.8 Portability is a capability matrix
- 15.27.9 Portability tests need host fixtures
- 15.27.10 Scale data is not quality evidence
- 15.27.11 Separate fixture success, local integrity, and production readiness
- 15.27.12 Read the report by layer
- 15.27.13 Establish the local fixture boundary
- 15.27.14 Install the complete bundle into the first host
- 15.27.15 Probe discovery, routing, references, and scripts
- 15.27.16 Probe approval behavior
- 15.27.17 Use a second host or declare the fallback
- 15.27.18 Exercise upgrade and uninstall
- 15.28 MCP Tool Contracts and Content
- 15.28.1 Structured content is any JSON value
- 15.28.2 A small validator still teaches the boundary
- 15.28.3 Encode values before building HTTP headers
- 15.28.4 The server checks the mirrored copy
- 15.29 MCP Reliability, Cancellation, and Flow Control
- 15.29.1 stdio
- 15.29.2 Streamable HTTP
- 15.29.3 Server-sent cancellation is narrow
- 15.29.4 Cancellation wins
- 15.29.5 Completion wins
- 15.29.6 The ledger boundary must be atomic and durable
- 15.29.7 Retry matrix
- 15.29.8 Proxy buffering
- 15.29.9 Prevent a reconnect herd
- 15.29.10 RequestCoordinator
- 15.29.11 MutationLedger
- 15.29.12 DurableTaskService
- 15.29.13 BoundedSseBuffer
- 15.29.14 Recovery helpers
- 15.30 MCP Registry Supply Chain: Admission, Drift, and Rollback
- 15.30.1 Namespace verification
- 15.30.2 Provenance join
- 15.30.3 Pin the decision, not only the version
- 15.30.4 Live drift detection
- 15.30.5 Registry status is live state
- 15.30.6 Rollback means route restoration
- 15.30.7 Append an admission ledger
- 15.30.8 Lab A: namespace collision
- 15.30.9 Lab B: descriptor drift
- 15.30.10 Lab C: status and rollback
- 15.31 MCP Conformance Engineering: Versioning, Evidence, and Operations
- 15.31.1 Strict mode
- 15.31.2 Fallback mode
- 15.31.3 Golden transcripts
- 15.31.4 Negative transcripts
- 15.31.5 Additive unknown fields
- 15.31.6 Unknown resultType
- 15.31.7 Lab A: prove the era boundary
- 15.31.8 Lab B: additive field versus discriminator
- 15.31.9 Lab C: inspect an SDK transformation
- 15.31.10 Lab D: repair the proxy
- 15.32 Program Anatomy: An ELF Reader From Scratch
- 15.32.1 Lab A: the header by hand
- 15.32.2 Lab B: the value table behind the switch
- 15.32.3 Lab C: three builds of one source
- 15.32.4 Lab D: the same function in Mach-O
- 15.32.5 See it run
- 15.33 Disassembly and Control Flow: From Bytes to a Graph You Can Check
- 15.33.1 Prefixes come in four groups
- 15.33.2 REX adds four bits and must sit next to the opcode
- 15.33.3 Opcodes live in two maps
- 15.33.4 ModRM and SIB select the operands
- 15.33.5 The displacement is where the link editor writes
- 15.33.6 Immediates are 32 bits at most, with one exception
- 15.33.7 Lab A: decode on paper, then check
- 15.33.8 Lab B: the relocation on a lea
- 15.33.9 Lab C: watch the two methods disagree
- 15.33.10 Lab D: dominators by hand
- 15.33.11 See it run
- 15.34 Lifting to Pseudocode: IR, SSA, and Structuring From Scratch
- 15.34.1 Flags are a variable
- 15.34.2 cltd and idiv
- 15.34.3 Stack slots at -O0
- 15.34.4 Relocations
- 15.34.5 The 0x66666667 multiply
- 15.34.6 What -O1 did to the switch
- 15.34.7 percent_change
- 15.34.8 grade
- 15.34.9 total
- 15.34.10 Lab A: one function through five stages
- 15.34.11 Lab B: the division idiom
- 15.34.12 Lab C: a new object stops the decoder
- 15.34.13 Lab D: Ghidra's default value in grade
- 15.34.14 See it run
- 15.35 Evidence, Confidence, and Unknowns in Binary Analysis
- 15.35.1 Lab A: recompute a rea id
- 15.35.2 Lab B: refuse a promotion
- 15.35.3 Lab C: refuse a stale snapshot
- 15.35.4 Lab D: break the chain
- 15.35.5 See it run
- 15.36 Rebuild and Prove Equal: Differential Tests, Byte Comparison, and the Evidence Loop
- 15.36.1 Design the grid
- 15.36.2 The driver and the trap
- 15.36.3 Results
- 15.36.4 Read the object
- 15.36.5 Mask, then compare the records
- 15.36.6 Read the constants the relocation points at
- 15.36.7 What rea's verifier can and cannot say
- 15.36.8 Lab A: the model and the run
- 15.36.9 Lab B: read the object
- 15.36.10 Lab C: break one constant
- 15.36.11 Lab D: drive rea
- 15.36.12 See it run
- 15.37 The Reverse Engineering Landscape: History, Tool Families, and How a Decompiler Is Built
- 15.37.1 1973 to 1991: debuggers first, then disassemblers
- 15.37.2 1991 to 2009: interactive disassemblers and the first decompilers
- 15.37.3 2009 to 2019: frameworks and intermediate representations
- 15.37.4 2019 to 2026: open decompilers and the research turn
- 15.37.5 Disassemblers
- 15.37.6 Decompilers
- 15.37.7 Debuggers
- 15.37.8 Binary analysis frameworks
- 15.37.9 Format and engine libraries
- 15.37.10 Diffing tools and compiler-side viewers
- 15.37.11 Versions, licences, and what this lesson ran
- 15.37.12 Loader
- 15.37.13 Disassembly
- 15.37.14 CFG recovery
- 15.37.15 Lifting
- 15.37.16 SSA
- 15.37.17 Data flow and types
- 15.37.18 Structuring
- 15.37.19 Emission
- 15.37.20 The agreement case: ledger at -O1
- 15.37.21 The vectorised case: ledger at -O2
- 15.37.22 The jump table: grade at -O0
- 15.37.23 Data in code: sweep-trap
- 15.37.24 Invented and missed, by tool
- 15.37.25 Lab A: one function, four bases
- 15.37.26 Lab B: the jump table from four sides
- 15.37.27 Lab C: eager flags against a thunk
- 15.37.28 Lab D: the trap under five tools
- 15.38 Calling Conventions and Stack Frames: System V, Windows x64, and AArch64
- 15.38.1 Lab A: one instruction, three effects
- 15.38.2 Lab B: the frame of keeps
- 15.38.3 Lab C: read-before-write on mixed
- 15.38.4 Lab D: the unwinder's second opinion
- 15.39 Compiler Idioms: What Optimization Does to Your Code and How to Read It Back
- 15.39.1 Unsigned 10 by hand
- 15.39.2 Unsigned 7 by hand, with the add fix-up
- 15.39.3 Signed 3 by hand
- 15.39.4 What the constants are not
- 15.39.5 The idiom belongs to the instruction selector
- 15.39.6 The lookup table, read from the object
- 15.39.7 The linear map, with no table at all
- 15.39.8 The jump table, read from relocations
- 15.39.9 The same switch at four levels
- 15.39.10 Loops that become library calls
- 15.39.11 Lab A: derive a magic number, then find it
- 15.39.12 Lab B: the table and the tree
- 15.39.13 Lab C: the loop at three settings
- 15.39.14 Lab D: the shared quotient
- 15.40 Linking, Loading, and Stripped Binaries: PLT, GOT, Imports, Fixups, and Function Identification
- 15.40.1 PLT0 and the entry for puts
- 15.40.2 What the file does not have
- 15.40.3 .dynsym, .symtab, and strip
- 15.40.4 The import directory
- 15.40.5 The export directory
- 15.40.6 Base relocations
- 15.40.7 One stub, by hand
- 15.40.8 Two-level namespace
- 15.40.9 The layout it replaced
- 15.40.10 The exports trie
- 15.40.11 LC_FUNCTION_STARTS
- 15.40.12 Prologue scans
- 15.40.13 Call targets
- 15.40.14 What the tools do with the same idea
- 15.40.15 Lab A: the PLT by hand
- 15.40.16 Lab B: one chained fixup
- 15.40.17 Lab C: strip and relink
- 15.40.18 Lab D: the collision
- 15.41 Recovering Data and Types: Structs, Arrays, C++ Objects, and DWARF
- 15.41.1 Four kinds of stride evidence
- 15.41.2 The vectorised loop at -O2
- 15.41.3 The unit header
- 15.41.4 Abbreviations
- 15.41.5 Decode the balance member by hand
- 15.41.6 Strings and addresses go through two tables
- 15.41.7 Types, functions, and locations
- 15.41.8 Mangled names
- 15.41.9 The vtable from its relocations
- 15.41.10 RTTI
- 15.41.11 The virtual call
- 15.41.12 Lab A: decode the member entry
- 15.41.13 Lab B: trace one function
- 15.41.14 Lab C: fold the vectorised loop
- 15.41.15 Lab D: the vtable and the names
- 15.42 Dynamic Analysis of Your Own Program: Debuggers, Traces, and Confirming Static Claims
- 15.42.1 Decode the branch by hand
- 15.42.2 Lab A: read a stop by hand
- 15.42.3 Lab B: the branch and its successor
- 15.42.4 Lab C: the run that never stopped
- 15.42.5 Lab D: break the evidence
- 15.43 Beyond Native Code: Python, JVM, .NET, and WebAssembly Bytecode
- 15.43.1 Lab A: read the header, then the code object
- 15.43.2 Lab B: the constant pool chain
- 15.43.3 Lab C: depth and labels
- 15.43.4 Lab D: from token to bytes
- 15.44 Binary Diffing and Symbolic Execution: Matching Functions and Solving for Inputs
- 15.44.1 Lab A: five signatures by hand
- 15.44.2 Lab B: watch the relocation break the byte hash
- 15.44.3 Lab C: the false match and the order that avoids it
- 15.44.4 Lab D: paths and the bound
- 15.45 AI-Assisted Reverse Engineering: LLM Decompilers, Analysis Agents, and Ground Truth
- 15.45.1 bytes
- 15.45.2 grid
- 15.45.3 fuzz
- 15.45.4 names
- 15.45.5 citations
- 15.45.6 provenance
- 15.45.7 The card
- 15.45.8 Lab A: read the DWARF by hand, then with the reader
- 15.45.9 Lab B: score a candidate and repair it
- 15.45.10 Lab C: the string that addresses the analyst
- 15.45.11 Lab D: drive the server
- 16Agent engineeringnot yet
- 16.1 The Agent Loop
- 16.1.1 ReAct: the canonical format
- 16.1.2 The 2026 shift: native reasoning
- 16.1.3 The five ingredients
- 16.1.4 Why this loop is everywhere
- 16.1.5 2026 pitfalls
- 16.2 ReWOO and Plan-and-Execute
- 16.2.1 The three roles
- 16.2.2 Why 5x fewer tokens
- 16.2.3 Why it is more robust
- 16.2.4 Planner distillation
- 16.2.5 Plan-and-Execute (2023)
- 16.2.6 Plan-and-Act (Erdogan et al., arXiv:2503.09572, ICML 2025)
- 16.2.7 When to pick which
- 16.3 Reflexion and Verbal Reinforcement Learning
- 16.3.1 The three components
- 16.3.2 Three evaluator types
- 16.3.3 Why this generalizes
- 16.3.4 When it works and when it does not
- 16.4 Tree of Thoughts and LATS
- 16.4.1 Tree of Thoughts (Yao et al., NeurIPS 2023)
- 16.4.2 LATS (Zhou et al., ICML 2024)
- 16.4.3 MCTS, minimally
- 16.4.4 The cost reality
- 16.4.5 2026 positioning
- 16.5 Self-Refine and CRITIC
- 16.5.1 Self-Refine (Madaan et al., NeurIPS 2023)
- 16.5.2 CRITIC (Gou et al., arXiv:2305.11738, v4 Feb 2024)
- 16.5.3 The stop condition
- 16.5.4 Evaluator-Optimizer (Anthropic, 2024)
- 16.5.5 OpenAI Agents SDK output guardrails
- 16.5.6 2026 pitfalls
- 16.6 Tool Use and Function Calling
- 16.6.1 Toolformer (Schick et al., NeurIPS 2023)
- 16.6.2 Berkeley Function Calling Leaderboard V4 (Patil et al., ICML 2025)
- 16.6.3 Tool schema
- 16.6.4 Argument validation
- 16.6.5 Parallel tool calls
- 16.6.6 Sandboxing
- 16.7 Agent Memory — Virtual Context and Memory Paging
- 16.7.1 The OS analogy
- 16.7.2 Two tiers
- 16.7.3 The interrupt pattern
- 16.7.4 Where the paper ends and production begins
- 16.7.5 Where this pattern goes wrong
- 16.7.6 The shape of agent memory
- 16.8 Memory Blocks and Sleep-Time Compute
- 16.8.1 Three tiers
- 16.8.2 Memory blocks
- 16.8.3 Sleep-time compute
- 16.8.4 Native reasoning
- 16.8.5 Where this pattern goes wrong
- 16.9 Hybrid Memory — Vector + Graph + KV
- 16.9.1 Three stores in parallel
- 16.9.2 Fusion scoring
- 16.9.3 Mem0g and temporal reasoning
- 16.9.4 Benchmark numbers
- 16.9.5 Scope taxonomy
- 16.9.6 Where this pattern goes wrong
- 16.10 Skill Libraries and Lifelong Learning (Voyager)
- 16.10.1 Three components
- 16.10.2 Action space = code
- 16.10.3 Skill retrieval
- 16.10.4 Iterative refinement
- 16.10.5 Curriculum and exploration
- 16.10.6 Where this pattern goes wrong
- 16.11 Planning with HTN and Evolutionary Search
- 16.11.1 Hierarchical Task Networks
- 16.11.2 ChatHTN (Gopalakrishnan et al., 2025)
- 16.11.3 AlphaEvolve (Novikov et al., 2025)
- 16.11.4 When to use which
- 16.11.5 Where this pattern goes wrong
- 16.12 Anthropic's Workflow Patterns
- 16.12.1 Workflows vs agents
- 16.12.2 The augmented LLM
- 16.12.3 The five patterns
- 16.12.4 Where workflows beat agents
- 16.12.5 Where agents beat workflows
- 16.12.6 The context-engineering companion
- 16.13 Stateful Graph Orchestration — Durable Execution and Checkpoints
- 16.13.1 The graph
- 16.13.2 Durable execution
- 16.13.3 Streaming
- 16.13.4 Human-in-the-loop
- 16.13.5 Memory
- 16.13.6 Three topologies
- 16.13.7 Where this pattern goes wrong
- 16.14 The Actor Model for Agents
- 16.14.1 Actors
- 16.14.2 Three API layers
- 16.14.3 Why decoupling matters
- 16.14.4 Topologies
- 16.14.5 Observability
- 16.14.6 Status: maintenance mode
- 16.15 Role-Based Agent Teams — Roles, Tasks, Processes
- 16.15.1 Four primitives
- 16.15.2 Sequential vs Hierarchical vs Consensus
- 16.15.3 Crews vs Flows
- 16.15.4 Tool integration
- 16.15.5 Memory hooks
- 16.15.6 When role-based teams fit
- 16.15.7 When they do not
- 16.15.8 Dependency shape
- 16.15.9 Where this pattern goes wrong
- 16.16 OpenAI Agents SDK — Handoffs, Guardrails, Tracing
- 16.16.1 Five primitives
- 16.16.2 Handoffs as tools
- 16.16.3 Guardrails
- 16.16.4 Tracing
- 16.16.5 Sessions
- 16.16.6 Where this pattern goes wrong
- 16.17 The Harness as a Library — Subagents and Session Store
- 16.17.1 Client SDK vs Agent SDK
- 16.17.2 Built-in tools
- 16.17.3 Subagents
- 16.17.4 Session store
- 16.17.5 Hooks
- 16.17.6 W3C trace context
- 16.17.7 Claude Managed Agents
- 16.17.8 Where this pattern goes wrong
- 16.18 Production Agent Runtimes
- 16.18.1 Agno
- 16.18.2 Mastra
- 16.18.3 Positioning
- 16.18.4 When to pick each
- 16.18.5 Where this pattern goes wrong
- 16.19 Benchmarks — SWE-bench, GAIA, AgentBench
- 16.19.1 SWE-bench (Jimenez et al., ICLR 2024 oral)
- 16.19.2 SWE-bench Verified
- 16.19.3 Contamination
- 16.19.4 GAIA (Mialon et al., Nov 2023)
- 16.19.5 AgentBench (Liu et al., ICLR 2024)
- 16.19.6 What these do not measure
- 16.19.7 Where benchmarking goes wrong
- 16.20 Benchmarks — WebArena and OSWorld
- 16.20.1 WebArena (Zhou et al., ICLR 2024)
- 16.20.2 Extensions
- 16.20.3 OSWorld (Xie et al., NeurIPS 2024)
- 16.20.4 Primary failure modes
- 16.20.5 Follow-ups
- 16.20.6 Why this matters
- 16.20.7 Where benchmarking goes wrong
- 16.21 Computer Use — Claude, OpenAI CUA, Gemini
- 16.21.1 Claude computer use (Anthropic, Oct 22 2024)
- 16.21.2 OpenAI CUA / Operator (Jan 2025)
- 16.21.3 Gemini 2.5 Computer Use (Google DeepMind, Oct 7 2025)
- 16.21.4 The shared contract: untrusted input
- 16.21.5 When to pick which
- 16.21.6 Where this pattern goes wrong
- 16.22 Voice Agents — Pipecat and LiveKit
- 16.22.1 Pipecat (pipecat-ai/pipecat)
- 16.22.2 LiveKit Agents (livekit/agents)
- 16.22.3 Commercial platforms
- 16.22.4 Where this pattern goes wrong
- 16.22.5 Typical 2026 latencies
- 16.23 OpenTelemetry GenAI Semantic Conventions
- 16.23.1 Span categories
- 16.23.2 Agent span naming
- 16.23.3 Key attributes
- 16.23.4 Content capture
- 16.23.5 Stability
- 16.23.6 Where this pattern goes wrong
- 16.24 Agent Observability — Langfuse, Phoenix, Opik
- 16.24.1 Langfuse (MIT)
- 16.24.2 Arize Phoenix (Elastic License 2.0)
- 16.24.3 Comet Opik (Apache 2.0)
- 16.24.4 Industry data
- 16.24.5 Picking one
- 16.24.6 Where this pattern goes wrong
- 16.25 Multi-Agent Debate and Collaboration
- 16.25.1 Society of Minds (Du et al., ICML 2024)
- 16.25.2 Sparse topology
- 16.25.3 When debate helps
- 16.25.4 When debate hurts
- 16.25.5 2026 practical instantiations
- 16.25.6 Where this pattern goes wrong
- 16.26 Failure Modes — Why Agents Break
- 16.26.1 MASFT (Berkeley, arXiv:2503.13657)
- 16.26.2 Microsoft Taxonomy of Failure Mode in Agentic AI Systems
- 16.26.3 Characterizing Faults in Agentic AI (arXiv:2603.06847)
- 16.26.4 LLM Agent Hallucinations Survey (arXiv:2509.18970)
- 16.26.5 The five industry-recurring modes
- 16.26.6 Mitigation: gates at every step
- 16.26.7 Where failure monitoring goes wrong
- 16.27 Prompt Injection and the PVE Defense
- 16.27.1 Greshake et al., AISec 2023 (arXiv:2302.12173)
- 16.27.2 The 2026 defense doctrine
- 16.27.3 PVE: Prompt-Validator-Executor
- 16.27.4 Where defenses fail
- 16.28 Orchestration Patterns — Supervisor, Swarm, Hierarchical
- 16.28.1 Supervisor-worker
- 16.28.2 Swarm / peer-to-peer
- 16.28.3 Hierarchical
- 16.28.4 Debate
- 16.28.5 Autonomous crews vs deterministic flows
- 16.28.6 Anthropic's guidance
- 16.28.7 Where this pattern goes wrong
- 16.29 Production Runtimes — Queue, Event, Cron
- 16.29.1 Request-response
- 16.29.2 Streaming
- 16.29.3 Durable execution
- 16.29.4 Queue-based / background
- 16.29.5 Event-driven
- 16.29.6 Scheduled
- 16.29.7 2026 deployment patterns
- 16.29.8 Observability is load-bearing
- 16.29.9 Where production runtimes fail
- 16.30 Eval-Driven Agent Development
- 16.30.1 Three evaluation layers
- 16.30.2 Evaluator-optimizer (Anthropic)
- 16.30.3 2026 best practice
- 16.30.4 Tying Phase 14 together
- 16.30.5 Where eval-driven development fails
- 16.31 Agent Workbench: Why Capable Models Still Fail
- 16.31.1 Workbench versus prompt engineering
- 16.31.2 Workbench versus framework
- 16.31.3 Reasoning from primitives, not from vendor taxonomies
- 16.31.4 Patterns in circulation, translated to primitives
- 16.31.5 What the receipts actually say
- 16.31.6 Where vendor writeups stop short
- 16.32 The Minimal Agent Workbench
- 16.32.1 AGENTS.md is a router, not a manual
- 16.32.2 agent_state.json is the system of record
- 16.32.3 task_board.json is the queue
- 16.32.4 Three files is the floor, not the ceiling
- 16.33 Agent Instructions as Executable Constraints
- 16.33.1 Five categories that cover most rules
- 16.33.2 Rules are machine-readable
- 16.33.3 Rules are diff-friendly
- 16.33.4 Rules versus framework guardrails
- 16.33.5 Progressive disclosure: a map, not an encyclopedia
- 16.34 Repo Memory and Durable State
- 16.34.1 What belongs in repo memory
- 16.34.2 Schema-first state
- 16.34.3 Atomic writes
- 16.34.4 Migrations
- 16.35 Initialization Scripts for Agents
- 16.35.1 What the init script probes
- 16.35.2 Fail loud, fail fast, fail in one place
- 16.35.3 Idempotent
- 16.35.4 Init versus startup rules
- 16.36 Scope Contracts and Task Boundaries
- 16.36.1 What goes in a scope contract
- 16.36.2 Globs, not raw paths
- 16.36.3 Rollback is part of scope
- 16.36.4 Scope check is a diff check
- 16.36.5 Two altitudes of scope: the feature list and the task contract
- 16.37 Runtime Feedback Loops
- 16.37.1 What goes in a feedback record
- 16.37.2 Truncation is deterministic
- 16.37.3 Feedback versus telemetry
- 16.37.4 Refuse to advance without feedback
- 16.38 Verification Gates
- 16.38.1 What the gate checks
- 16.38.2 Deterministic, not probabilistic
- 16.38.3 One report, one path
- 16.38.4 Refuse without exception
- 16.39 Reviewer Agent: Separate Builder from Marker
- 16.39.1 Reviewer rubric
- 16.39.2 The reviewer is a separate role, not a separate model
- 16.39.3 The reviewer cannot edit the diff
- 16.39.4 Reviewer rubric versus verification gate
- 16.40 Multi-Session Handoff
- 16.40.1 Seven fields every handoff carries
- 16.40.2 Handoffs are generated, not written
- 16.40.3 Two forms: human-readable and machine-readable
- 16.40.4 Feedback log trimming
- 16.40.5 Leave a clean state
- 16.41 The Workbench on a Real Repo
- 16.41.1 The sample app
- 16.41.2 The task
- 16.41.3 The two pipelines
- 16.41.4 The five outcomes measured
- 16.42 Capstone: Ship a Reusable Agent Workbench Pack
- 16.42.1 The pack layout
- 16.42.2 What stays in, what stays out
- 16.42.3 The installer
- 16.42.4 Versioning
- 16.42.5 Frame the task and choose the autonomy
- 16.42.6 Prepare the smallest useful environment
- 16.42.7 Capture the baseline and implement
- 16.42.8 Challenge the evidence
- 16.42.9 Rehearse operation and recovery
- 16.42.10 Improve the next run and hand it off
- 16.42.11 Manual review rubric
- 16.43 Frame the Task Before the Agent Writes Code
- 16.43.1 The Expensive Failure
- 16.43.2 The Task Frame
- 16.43.3 Reconnaissance Is a Search for Constraints
- 16.43.4 Unknowns Are Not Failures
- 16.43.5 Acceptance Before Implementation
- 16.43.6 Use It in a Real Repository
- 16.44 Build an Evidence-Backed Execution Plan
- 16.44.1 Why Agent Plans Fail
- 16.44.2 Plan the Contract Before Its Implementations
- 16.44.3 Evidence Changes the Plan
- 16.44.4 Design for Interruption
- 16.44.5 Plan Validation
- 16.44.6 Use It with a Coding Agent
- 16.45 Delegate Agent Work with Isolation and Merge Contracts
- 16.45.1 The Parallelism Test
- 16.45.2 A Work Unit Is a Contract
- 16.45.3 Isolation Has Three Layers
- 16.45.4 The Integrator Does Not Rebuild the Work
- 16.45.5 Human and Agent Roles
- 16.46 Turn Every Agent Correction into a System Improvement
- 16.46.1 Corrections Are Evidence
- 16.46.2 Promote to the Earliest Effective Layer
- 16.46.3 The Ratchet Record
- 16.46.4 Separate Cause from Symptom
- 16.46.5 Controls Also Decay
- 16.47 Define the Outcome Before You Choose the Output
- 16.47.1 Output Is Not Outcome
- 16.47.2 The Six-Part Frame
- 16.47.3 Find Solution Leakage
- 16.47.4 Constraints Protect the Outcome
- 16.47.5 Non-Goals Create a Boundary
- 16.48 Discover the Workflow People Actually Perform
- 16.48.1 Start with the Current System
- 16.48.2 Evidence Has Strength
- 16.48.3 Search for Four Things
- 16.48.4 Do Not Average Away Disagreement
- 16.49 Map Assumptions and Resolve the Riskiest One First
- 16.49.1 Every Build Contains Bets
- 16.49.2 Assumption Classes
- 16.49.3 Risk Is Not One Number
- 16.49.4 Design an Experiment, Not a Confirmation Ritual
- 16.49.5 Reversibility Changes Order
- 16.50 Choose the Smallest Slice That Can Change the Decision
- 16.50.1 Vertical Means Evidence End to End
- 16.50.2 Define Required Proof First
- 16.50.3 Common False Minimums
- 16.50.4 Add a Stop Rule
- 16.51 Write Specifications That Preserve Judgment
- 16.51.1 Two Bad Extremes
- 16.51.2 Three Decision Modes
- 16.51.3 Specify Behavior Through Examples
- 16.51.4 Proof Must Match the Claim
- 16.51.5 Preserve Unknowns Deliberately
- 16.52 Design Success Metrics Before the Result Exists
- 16.52.1 Goal, Question, Metric
- 16.52.2 A Metric Needs a Contract
- 16.52.3 Outcome, Guardrail, and Counter-Metric
- 16.52.4 Offline and Online Evidence
- 16.52.5 Decide Before You Measure
- 16.53 Choose Prototype, Pilot, or Production Deliberately
- 16.53.1 Three Different Questions
- 16.53.2 Prototype
- 16.53.3 Pilot
- 16.53.4 Production
- 16.53.5 Stage Drift
- 16.54 Build a Feedback Ratchet with Ownership and Retirement
- 16.54.1 Establish What Happened
- 16.54.2 Make Progress Within Your Authority
- 16.54.3 Compare Options and Brief the Decision Owner
- 16.54.4 Run a Bounded Experiment
- 16.54.5 Compare Outcomes and Economics
- 16.54.6 Close the Loop
- 17Autonomous systemsnot yet
- 17.1 From Chatbots to Long-Horizon Agents (METR)
- 17.1.1 The METR Time Horizon, in one paragraph
- 17.1.2 What actually breaks when the horizon grows
- 17.1.3 Doubling times and what they imply
- 17.1.4 Eval-context gaming
- 17.1.5 Single-turn vs long-horizon, compared
- 17.2 STaR, V-STaR, Quiet-STaR: Self-Taught Reasoning
- 17.2.1 STaR: bootstrap on what worked
- 17.2.2 V-STaR: train a verifier with DPO
- 17.2.3 Quiet-STaR: per-token internal rationales
- 17.2.4 Why all three share a safety concern
- 17.2.5 Comparison
- 17.2.6 Where this sits in the 2026 stack
- 17.3 AlphaEvolve: Evolutionary Coding Agents
- 17.3.1 The loop
- 17.3.2 What makes the evaluator non-negotiable
- 17.3.3 Reward hacking is the other face of that statement
- 17.3.4 Why LLM + search beats either alone
- 17.3.5 Where AlphaEvolve fits in the frontier stack
- 17.4 Darwin Gödel Machine: Self-Modifying Agents
- 17.4.1 The loop
- 17.4.2 What DGM actually improved
- 17.4.3 The reward-hacking demonstration
- 17.4.4 Versus the classical Godel Machine
- 17.4.5 Where it fits in this phase
- 17.5 AI Scientist v2: Workshop-Level Research
- 17.5.1 The architecture
- 17.5.2 What the workshop-acceptance result means
- 17.5.3 What the independent evaluation found
- 17.5.4 The sandbox-escape concern
- 17.5.5 Where v2 sits in the frontier stack
- 17.6 Automated Alignment Research (Anthropic AAR)
- 17.6.1 The architecture (as publicly described)
- 17.6.2 Why the out-of-sandbox log matters
- 17.6.3 The prescribed-workflow tradeoff
- 17.6.4 The compression risk
- 17.6.5 What AAR does not replace
- 17.7 Recursive Self-Improvement: Capability vs Alignment
- 17.7.1 What recursive self-improvement means precisely
- 17.7.2 The alignment-faking result in detail
- 17.7.3 The Hassabis question
- 17.7.4 Capability vs alignment, as a race
- 17.7.5 What the ICLR 2026 workshop treats as engineering
- 17.8 Bounded Self-Improvement Designs
- 17.8.1 Primitive 1: formal invariants
- 17.8.2 Primitive 2: alignment anchors
- 17.8.3 Primitive 3: multi-objective constraints
- 17.8.4 Primitive 4: regression detection
- 17.8.5 Information-theoretic limits
- 17.8.6 A worked example
- 17.9 Autonomous Coding Agent Landscape (SWE-bench, CodeAct)
- 17.9.1 SWE-bench, one paragraph
- 17.9.2 What the 2022 → 2026 curve actually shows
- 17.9.3 CodeAct vs JSON tool calls
- 17.9.4 Scaffolds in the 2026 landscape
- 17.9.5 Why scaffolding dominates
- 17.9.6 Benchmark saturation and the real distribution
- 17.10 Permission Modes for Autonomous Agents
- 17.10.1 The six permission modes
- 17.10.2 Auto Mode in one page
- 17.10.3 What the system catches
- 17.10.4 What the system can miss
- 17.10.5 Research preview framing
- 17.10.6 Where this ladder lives in your workflow
- 17.11 Browser Agents and Indirect Prompt Injection
- 17.11.1 The 2026 landscape, in one paragraph per system
- 17.11.2 BrowseComp vs OSWorld vs WebArena
- 17.11.3 The attack surface, named
- 17.11.4 Why "not fully patchable"
- 17.11.5 Defense posture that actually ships
- 17.12 Durable Execution for Long-Running Agents
- 17.12.1 Activities, workflows, and replay
- 17.12.2 Why LLM calls fit the pattern
- 17.12.3 Checkpoints keyed by thread_id
- 17.12.4 Human-input as a first-class state
- 17.12.5 The 35-minute degradation
- 17.12.6 When durable execution is the wrong answer
- 17.13 Action Budgets, Iteration Caps, Cost Governors
- 17.13.1 The cost-governor stack
- 17.13.2 Why the stack, not one cap
- 17.13.3 A harness budget surface
- 17.13.4 EU AI Act, OWASP Agentic Top 10
- 17.13.5 The observed $1,200 → $4,800 case
- 17.14 Kill Switches, Circuit Breakers, Canary Tokens
- 17.14.1 Kill switches
- 17.14.2 Circuit breakers
- 17.14.3 Canary tokens
- 17.14.4 Why layer statistical and hard limits
- 17.14.5 Quarantine via eBPF datapath redirect
- 17.14.6 What no detector catches
- 17.15 HITL: Propose-Then-Commit
- 17.15.1 The propose-then-commit state machine
- 17.15.2 The idempotency key
- 17.15.3 Durability: why approvals outlast processes
- 17.15.4 Rubber-stamp approvals and the challenge-and-response mitigation
- 17.15.5 What counts as consequential
- 17.15.6 Post-action verification
- 17.15.7 EU AI Act Article 14
- 17.16 Checkpoints and Rollback
- 17.16.1 Every transition persists
- 17.16.2 Lease recovery
- 17.16.3 Idempotency plus preconditions
- 17.16.4 Post-action verification
- 17.16.5 Rollback plans
- 17.16.6 EU AI Act Article 14 operational reading
- 17.16.7 The sharp failure mode: the double-execute
- 17.17 Constitutional AI and Rule Overrides
- 17.17.1 The four-tier priority hierarchy
- 17.17.2 Hardcoded prohibitions vs soft-coded defaults
- 17.17.3 The 2022 CAI training
- 17.17.4 What reason-based alignment catches and misses
- 17.17.5 The 2023 participatory experiment
- 17.17.6 Why hardcoded prohibitions are necessary
- 17.17.7 Where the Constitution sits in the stack
- 17.18 Llama Guard and Input/Output Classification
- 17.18.1 Llama Guard 3 at a glance
- 17.18.2 Llama Guard 4 additions
- 17.18.3 NeMo Guardrails (NVIDIA)
- 17.18.4 The attack corpus
- 17.18.5 Where classifiers win
- 17.18.6 Where classifiers lose
- 17.18.7 Defense-in-depth
- 17.19 Anthropic Responsible Scaling Policy v3.0
- 17.19.1 The two-tier mitigation schedule
- 17.19.2 The AI RandD-4 threshold
- 17.19.3 Frontier Safety Roadmaps and Risk Reports
- 17.19.4 Removing the pause clause
- 17.19.5 SaferAI's downgrade
- 17.19.6 What this lesson is not
- 17.20 OpenAI Preparedness Framework and DeepMind FSF
- 17.20.1 OpenAI Preparedness Framework v2 (April 2025)
- 17.20.2 DeepMind Frontier Safety Framework v3 (September 2025; Tracked Capability Levels added April 17, 2026)
- 17.20.3 What all three converge on
- 17.20.4 Where they diverge
- 17.20.5 Sandbagging: a specific capability that complicates all three
- 17.20.6 The policy-reading skill
- 17.21 METR Time Horizons and External Evaluation
- 17.21.1 METR background
- 17.21.2 The Time Horizon fit
- 17.21.3 The January 2026 numbers
- 17.21.4 Benchmark suites
- 17.21.5 Prototype monitoring evaluations
- 17.21.6 Why horizons are upper bounds
- 17.21.7 The external-evaluator case
- 17.21.8 How to use horizon numbers in practice
- 17.22 CAIS, CAISI, and Societal-Scale Risk
- 17.22.1 CAIS — Center for AI Safety
- 17.22.2 The four-risk framework
- 17.22.3 Where organizational risk lives
- 17.22.4 CAISI — Center for AI Standards and Innovation
- 17.22.5 California SB-53
- 17.22.6 Societal-scale risk is not a single-layer problem
- 18Multi-agent and swarmsnot yet
- 18.1 Why Multi-Agent
- 18.1.1 The Single-Agent Ceiling
- 18.1.2 The Multi-Agent Solution
- 18.1.3 Real Systems That Do This
- 18.1.4 The Spectrum
- 18.1.5 The Four Multi-Agent Patterns
- 18.1.6 When NOT to Use Multi-Agent
- 18.1.7 The Overloaded Single Agent
- 18.1.8 Specialist Agents
- 18.1.9 Coordinate Through Messages
- 18.1.10 Compare
- 18.2 FIPA-ACL Heritage and Speech Acts
- 18.2.1 Speech acts, in one paragraph
- 18.2.2 The twenty FIPA performatives (partial list)
- 18.2.3 Canonical FIPA-ACL message
- 18.2.4 The two legacy platforms
- 18.2.5 Why FIPA faded
- 18.2.6 The LLM revival is FIPA-lite
- 18.2.7 The trade-off, stated plainly
- 18.2.8 Interaction protocols worth porting
- 18.2.9 What breaks when you drop the ontology
- 18.2.10 The 2026 specs, mapped to speech-act heritage
- 18.3 Communication Protocols
- 18.3.1 The Protocol Landscape
- 18.3.2 MCP (Recap)
- 18.3.3 A2A (Agent2Agent Protocol)
- 18.3.4 ACP (Agent Communication Protocol)
- 18.3.5 ANP (Agent Network Protocol)
- 18.3.6 Comparison (Corrected)
- 18.3.7 How They Work Together
- 18.3.8 Core Message Types
- 18.3.9 A2A Agent Card and Registry
- 18.3.10 A2A Task Lifecycle
- 18.3.11 ACP-Style Audit Trail
- 18.3.12 ANP-Style Identity Verification
- 18.3.13 Protocol Gateway
- 18.3.14 Wire It All Together
- 18.3.15 Real Implementations
- 18.3.16 Picking the Right Protocol
- 18.4 The Multi-Agent Primitive Model
- 18.4.1 The four primitives
- 18.4.2 How every 2026 framework maps to it
- 18.4.3 Why this matters
- 18.4.4 The stateless insight
- 18.4.5 Anatomy of a single primitive
- 18.4.6 What changes between frameworks
- 18.5 Supervisor / Orchestrator-Worker Pattern
- 18.5.1 The pattern
- 18.5.2 Why it wins
- 18.5.3 Engineering lessons (Anthropic 2025)
- 18.5.4 The graph-native turn
- 18.5.5 The failure modes
- 18.5.6 When supervisor is wrong
- 18.6 Hierarchical Architecture and Decomposition Drift
- 18.6.1 The shape
- 18.6.2 Where it shines
- 18.6.3 Where it breaks
- 18.6.4 The deciding question
- 18.6.5 Role-framework implementation
- 18.6.6 Graph-framework implementation
- 18.7 Society of Mind and Multi-Agent Debate
- 18.7.1 The Du et al. 2023 algorithm
- 18.7.2 Two independent knobs
- 18.7.3 Why it works
- 18.7.4 Heterogeneous debate
- 18.7.5 NLSOM — the 129-agent extension
- 18.7.6 Failure modes
- 18.8 Role Specialization — Planner / Critic / Executor / Verifier
- 18.8.1 The four canonical roles
- 18.8.2 MetaGPT's SOP pattern
- 18.8.3 ChatDev's communicative dehallucination
- 18.8.4 Why verifier matters most
- 18.8.5 Critic vs verifier
- 18.8.6 The anti-pattern
- 18.8.7 Framework mappings
- 18.9 Parallel Swarm and Networked Architectures
- 18.9.1 The shape
- 18.9.2 When swarm fits
- 18.9.3 When swarm fails
- 18.9.4 Matrix (arXiv:2511.21686)
- 18.9.5 Swarm in graph frameworks
- 18.9.6 Failure mode: starvation and hot-spotting
- 18.9.7 The content-based routing link
- 18.10 Group Chat and Speaker Selection
- 18.10.1 The shape
- 18.10.2 The three selector flavors
- 18.10.3 The ConversableAgent API
- 18.10.4 Termination
- 18.10.5 Lineage: forks and mergers
- 18.10.6 When GroupChat fits
- 18.10.7 When it fails
- 18.10.8 Group chat vs supervisor
- 18.11 Handoffs and Routines (Stateless Orchestration)
- 18.11.1 Two primitives
- 18.11.2 Why it is viral
- 18.11.3 The stateless trade
- 18.11.4 When Swarm/handoffs fit
- 18.11.5 When Swarm struggles
- 18.11.6 OpenAI Agents SDK (March 2025)
- 18.11.7 Swarm vs GroupChat
- 18.12 A2A — The Agent-to-Agent Protocol
- 18.12.1 The four elements
- 18.12.2 The MCP/A2A split
- 18.12.3 Discovery flow
- 18.12.4 Auth
- 18.12.5 150+ organizations by April 2026
- 18.12.6 Where A2A wins
- 18.12.7 Where A2A struggles
- 18.12.8 A2A vs ACP, ANP, NLIP
- 18.13 Shared Memory and Blackboard Patterns
- 18.13.1 The two main topologies
- 18.13.2 When each wins
- 18.13.3 Memory poisoning, in one scenario
- 18.13.4 Why this is structural
- 18.13.5 Blackboard precedent (Hayes-Roth, 1985)
- 18.13.6 Projection vs full view
- 18.13.7 Write-contention patterns
- 18.13.8 The unwritable verifier
- 18.14 Consensus and Byzantine Fault Tolerance
- 18.14.1 What classical BFT gives you
- 18.14.2 The three LLM-specific attacks
- 18.14.3 The 2025-2026 responses
- 18.14.4 Empirical: "Can AI Agents Agree?" (arXiv:2603.01213)
- 18.14.5 The core protocol, stripped down
- 18.14.6 Threshold tuning
- 18.14.7 Where consensus does not help
- 18.15 Voting, Self-Consistency, and Debate Topology
- 18.15.1 Self-consistency, the single-model baseline
- 18.15.2 Multi-agent vote, the heterogeneous extension
- 18.15.3 The four topologies
- 18.15.4 The coordination tax (MultiAgentBench)
- 18.15.5 Multi-Agent Debate Strategies ("Should we be going MAD?")
- 18.15.6 AgentVerse emergent patterns
- 18.15.7 Heterogeneity: the actual knob that moves accuracy
- 18.15.8 Jury methods
- 18.15.9 When vote-with-debate dominates
- 18.15.10 When vote-with-debate hurts
- 18.16 Negotiation and Bargaining
- 18.16.1 Contract Net, in one paragraph
- 18.16.2 Why OG-Narrator wins
- 18.16.3 NegotiationArena findings
- 18.16.4 Chain-of-thought concealment
- 18.16.5 Bhattacharya et al. 2025 — model rankings
- 18.16.6 Task allocation via Contract Net + LLM
- 18.16.7 LLM-Stakeholders Interactive Negotiation
- 18.16.8 The narration-vs-mechanism rule
- 18.17 Generative Agents and Emergent Simulation
- 18.17.1 The three components
- 18.17.2 Why all three matter (ablation)
- 18.17.3 The Valentine's Day emergence
- 18.17.4 The documented failure modes
- 18.17.5 Three-component implementation rules
- 18.17.6 Generative agents beyond Smallville
- 18.17.7 Why this matters for multi-agent engineering
- 18.18 Theory of Mind and Emergent Coordination
- 18.18.1 What ToM means
- 18.18.2 The Sally-Anne test, in brief
- 18.18.3 Riedl's coordination measurement
- 18.18.4 The coordination illusion
- 18.18.5 A minimal ToM-aware agent
- 18.18.6 Why long-horizon hurts
- 18.18.7 Where ToM fails in production
- 18.18.8 The coordination you can actually measure
- 18.19 Swarm Optimization (PSO, ACO)
- 18.19.1 PSO refresher (Kennedy and Eberhart 1995)
- 18.19.2 PSO on LLM outputs — LMPSO
- 18.19.3 Model Swarms
- 18.19.4 ACO refresher (Dorigo 1992)
- 18.19.5 AMRO-S — ACO for agent routing
- 18.19.6 When to use PSO / ACO for LLMs
- 18.19.7 Why bio-inspired still wins
- 18.19.8 Practical limits
- 18.20 MARL — MADDPG, QMIX, MAPPO
- 18.20.1 Three environments the papers use
- 18.20.2 MADDPG (2017) — the CTDE pattern
- 18.20.3 QMIX (2018) — value decomposition
- 18.20.4 MAPPO (2022) — the overlooked default
- 18.20.5 Why LLM-agent engineers should care
- 18.20.6 CTDE as a design pattern beyond RL
- 18.20.7 The non-stationarity problem
- 18.20.8 What this lesson does NOT cover
- 18.21 Agent Economies, Token Incentives, Reputation
- 18.21.1 The 5-layer agent-economy stack
- 18.21.2 Bittensor, Fetch.ai, Gonka — what runs
- 18.21.3 Shapley-value credit attribution
- 18.21.4 Second-price auction for aggregation
- 18.21.5 Reputation capital
- 18.21.6 AAMAS 2025 decentralized LaMAS
- 18.21.7 Where the economics falls apart
- 18.21.8 When agent economies make sense
- 18.22 Production Scaling — Queues, Checkpoints, Durability
- 18.22.1 Durable execution, the pattern
- 18.22.2 A checkpoint-per-step runtime
- 18.22.3 MegaAgent's per-agent queue
- 18.22.4 Async vs thread-per-job
- 18.22.5 Bedi's counterpoint
- 18.22.6 Exactly-once semantics
- 18.22.7 Rainbow deployment
- 18.22.8 The canonical production checklist
- 18.23 Failure Modes — MAST, Groupthink, Monoculture
- 18.23.1 MAST categories
- 18.23.2 Groupthink family (arXiv:2508.05687)
- 18.23.3 Cascading example — the retry storm
- 18.23.4 Memory poisoning (revisited)
- 18.23.5 STRATUS — specialized agents for failure detection
- 18.23.6 The failure-mode audit
- 18.23.7 When systems fail silently
- 18.23.8 Failure vs slow failure
- 18.24 Evaluation and Coordination Benchmarks
- 18.24.1 MultiAgentBench (MARBLE) — ACL 2025
- 18.24.2 COMMA — multimodal asymmetric information
- 18.24.3 MedAgentBoard — domain stress test
- 18.24.4 AgentArch — enterprise architectures
- 18.24.5 SWE-bench Pro — the reality check
- 18.24.6 AAAI 2026 WMAC
- 18.24.7 Read benchmark claims skeptically — the 2026 checklist
- 18.24.8 What none of the benchmarks measure well
- 18.25 Case Studies and 2026 State of the Art
- 18.25.1 Anthropic Research system
- 18.25.2 MetaGPT / ChatDev
- 18.25.3 OpenClaw / Moltbook ecosystem
- 18.25.4 Framework landscape April 2026
- 18.25.5 The common patterns across all three cases
- 18.25.6 Choosing a reference for your next project
- 18.25.7 The 2026 state-of-the-art summary
- 19Infrastructure and productionnot yet
- 19.1 Managed LLM Platforms — Bedrock, Azure OpenAI, Vertex AI
- 19.1.1 Three strategies
- 19.1.2 Latency gap at scale
- 19.1.3 Provisioned Throughput economics
- 19.1.4 FinOps surface — the real differentiator
- 19.1.5 Lock-in is the 2026 risk
- 19.1.6 Data residency, BAAs, and regulated industries
- 19.1.7 Numbers you should remember
- 19.2 Inference Platform Economics — Fireworks, Together, Baseten, Modal
- 19.2.1 The three segments
- 19.2.2 Fireworks — latency-optimized GPU platform
- 19.2.3 Together — breadth-optimized
- 19.2.4 Baseten — enterprise-polish-optimized
- 19.2.5 Modal — Python-native-optimized
- 19.2.6 Replicate — multimodal breadth
- 19.2.7 Anyscale — Ray-native
- 19.2.8 Per-token versus per-minute — when each wins
- 19.2.9 Custom engine is the real moat
- 19.2.10 Numbers you should remember
- 19.3 GPU Autoscaling on Kubernetes — Karpenter, KAI Scheduler
- 19.3.1 Layer 1 — node provisioning (Karpenter)
- 19.3.2 Layer 2 — gang scheduling (KAI Scheduler)
- 19.3.3 Layer 3 — application-level signals
- 19.3.4 When to use what
- 19.3.5 Disaggregated prefill/decode complicates everything
- 19.3.6 Cold start matters here too
- 19.3.7 Numbers you should remember
- 19.4 Serving Engine Internals — PagedAttention, Continuous Batching, Chunked Prefill
- 19.4.1 PagedAttention as a virtual memory system
- 19.4.2 Continuous batching at the iteration level
- 19.4.3 Chunked prefill protects the ITL tail
- 19.4.4 The three defaults interact
- 19.4.5 Check the compatibility matrix
- 19.4.6 Numbers you should remember
- 19.4.7 What the scheduler looks like
- 19.5 EAGLE-3 Speculative Decoding in Production
- 19.5.1 What speculative decoding actually buys
- 19.5.2 Why alpha is the only metric that matters
- 19.5.3 EAGLE generations at a glance
- 19.5.4 The 2026 production recipe
- 19.5.5 The production pitfall: P99 tail
- 19.5.6 Where EAGLE-3 is already deployed
- 19.5.7 Break-even math in one line
- 19.5.8 When not to use speculative decoding
- 19.6 Prefix-Cache Serving — RadixAttention and KV Reuse
- 19.6.1 The radix tree as a KV index
- 19.6.2 Cache-aware scheduling
- 19.6.3 Benchmark numbers you should memorize
- 19.6.4 The ordering gotcha
- 19.6.5 Where RadixAttention wins and loses
- 19.6.6 Why this is a scheduler problem, not just a kernel problem
- 19.6.7 Interplay with vLLM
- 19.7 Hardware-Specialized Inference Compilation — FP8 and NVFP4 on Blackwell
- 19.7.1 Why FP8 is still the floor for KV cache
- 19.7.2 The Blackwell-specific primitives TRT-LLM uses
- 19.7.3 The numbers you should memorize
- 19.7.4 What FP4 actually costs in quality
- 19.7.5 Why this is an NVIDIA-lock decision
- 19.7.6 2026 practical recipe
- 19.7.7 The disaggregation bonus
- 19.8 Inference Metrics — TTFT, TPOT, ITL, Goodput, P99
- 19.8.1 TTFT — time to first token
- 19.8.2 TPOT / ITL — inter-token latency
- 19.8.3 E2E latency
- 19.8.4 Throughput
- 19.8.5 Goodput — the metric you actually care about
- 19.8.6 Why mean is the wrong statistic
- 19.8.7 Reference numbers — Llama-3.1-8B-Instruct on TRT-LLM, 2026
- 19.8.8 The measurement trap
- 19.8.9 Constructing an SLO
- 19.8.10 How to measure
- 19.9 Production Quantization — AWQ, GPTQ, GGUF, FP8, NVFP4
- 19.9.1 The six formats
- 19.9.2 GGUF — the CPU/edge default
- 19.9.3 GPTQ — multi-LoRA in vLLM
- 19.9.4 AWQ — the datacenter GPU default
- 19.9.5 FP8 — the reliable middle
- 19.9.6 MXFP4 / NVFP4 — Blackwell aggressive
- 19.9.7 The calibration trap
- 19.9.8 The KV cache trap
- 19.9.9 AWQ INT4 is hazardous for reasoning
- 19.9.10 2026 picking guide
- 19.10 Cold Start Mitigation for Serverless LLMs
- 19.10.1 Layer 1 — pre-seeded node images (Bottlerocket)
- 19.10.2 Layer 2 — model streaming (Run:ai Model Streamer)
- 19.10.3 Layer 3 — GPU memory snapshots (Modal)
- 19.10.4 Layer 4 — warm pools (min_workers=1)
- 19.10.5 Layer 5 — tiered loading (ServerlessLLM)
- 19.10.6 Layer 6 — live migration (bonus pattern)
- 19.10.7 The warm-pool math
- 19.10.8 Measure before optimizing
- 19.10.9 Numbers you should remember
- 19.11 Multi-Region LLM Serving and KV Cache Locality
- 19.11.1 Cache-aware routing
- 19.11.2 Numbers
- 19.11.3 Cross-region has a new constraint — network latency
- 19.11.4 Commercial "cross-region inference" does not help here
- 19.11.5 DR hygiene — the 32% missing-files problem
- 19.11.6 Data residency is orthogonal
- 19.11.7 Numbers you should remember
- 19.12 Edge Inference — ANE, Hexagon, WebGPU, Jetson
- 19.12.1 Bandwidth is the real ceiling
- 19.12.2 Apple Neural Engine (M4 / A18)
- 19.12.3 Qualcomm Hexagon (Snapdragon X Elite / 8 Gen 4)
- 19.12.4 Intel / AMD NPUs (Lunar Lake, Ryzen AI 300)
- 19.12.5 WebGPU + WebLLM
- 19.12.6 NVIDIA Jetson family
- 19.12.7 Quantization choice per target
- 19.12.8 The long-context trap on edge
- 19.12.9 Voice is the killer app
- 19.12.10 Numbers you should remember
- 19.13 LLM Observability Stack Selection
- 19.13.1 Two categories
- 19.13.2 Langfuse — OSS balance
- 19.13.3 Phoenix (Arize) — telemetry-first, OpenTelemetry-native
- 19.13.4 Arize AX — the scale play
- 19.13.5 LangSmith — LangChain/LangGraph first
- 19.13.6 Helicone — proxy-based minimum viable
- 19.13.7 Opik (Comet) — OSS dev platform
- 19.13.8 SigNoz — OpenTelemetry-first full APM
- 19.13.9 The glue: OpenTelemetry + GenAI semantic conventions
- 19.13.10 The trap: instrumenting at the wrong layer
- 19.13.11 Sampling — you can't keep everything
- 19.13.12 Numbers you should remember
- 19.14 Prompt Caching and Semantic Caching Economics
- 19.14.1 L2 — provider prompt/prefix caching
- 19.14.2 L1 — app-level semantic caching
- 19.14.3 The parallelization anti-pattern
- 19.14.4 The dynamic content anti-pattern
- 19.14.5 Stack batch + cache for overnight workloads
- 19.14.6 Numbers you should remember
- 19.15 Batch APIs — the 50% Discount as Industry Standard
- 19.15.1 The three batch APIs
- 19.15.2 Semantic: asynchronous, not slow
- 19.15.3 Stack with caching
- 19.15.4 Workload triage
- 19.15.5 The partial-interactivity trap
- 19.15.6 The output-schema trap
- 19.15.7 Numbers you should remember
- 19.16 Model Routing as a Cost-Reduction Primitive
- 19.16.1 Four routing signals
- 19.16.2 Three patterns
- 19.16.3 Implementation
- 19.16.4 The 2026 price curve
- 19.16.5 Drift is the real risk
- 19.16.6 Numbers you should remember
- 19.17 Disaggregated Prefill/Decode — NVIDIA Dynamo and llm-d
- 19.17.1 Why the bottlenecks differ
- 19.17.2 The architecture
- 19.17.3 Dynamo vs llm-d
- 19.17.4 Economics
- 19.17.5 When NOT to disaggregate
- 19.17.6 The router integrates with Phase 17 · 11
- 19.17.7 MoE on Blackwell is where the real numbers are
- 19.17.8 Numbers you should remember
- 19.18 Production Serving Stack — KV Offloading and Cache-Aware Routing
- 19.18.1 vLLM production-stack
- 19.18.2 The KV Offloading Connector API (v0.9.0+)
- 19.18.3 Native CPU offload vs LMCache
- 19.18.4 Benchmark behavior
- 19.18.5 When LMCache is decisive
- 19.18.6 When NOT to enable
- 19.18.7 Integration with disaggregated serving
- 19.18.8 Numbers you should remember
- 19.19 AI Gateways — LiteLLM, Portkey, Kong, Bifrost
- 19.19.1 Seven core features
- 19.19.2 LiteLLM — MIT OSS, Python
- 19.19.3 Portkey — control plane positioning
- 19.19.4 Kong AI Gateway — the scale play
- 19.19.5 Bifrost (Maxim AI)
- 19.19.6 Cloudflare AI Gateway / Vercel AI Gateway
- 19.19.7 Self-hosted vs managed
- 19.19.8 Latency budget
- 19.19.9 Rate-limit semantics matter
- 19.19.10 Gateway + observability + routing compose
- 19.19.11 Numbers you should remember
- 19.20 Shadow, Canary, and Progressive Deployment
- 19.20.1 Shadow mode
- 19.20.2 Canary rollout
- 19.20.3 Non-determinism is the new variance
- 19.20.4 Cost is a variable
- 19.20.5 Rollback is the weapon
- 19.20.6 Tooling
- 19.20.7 Metrics cadence
- 19.20.8 The A/B step is optional
- 19.20.9 Numbers you should remember
- 19.21 A/B Testing LLM Features — GrowthBook and Statsig
- 19.21.1 Evals vs A/B tests
- 19.21.2 What to test
- 19.21.3 CUPED — variance reduction
- 19.21.4 Sequential testing
- 19.21.5 Multiple-comparison corrections
- 19.21.6 SRM — sample ratio mismatch
- 19.21.7 Statsig vs GrowthBook
- 19.21.8 Non-determinism complicates power
- 19.21.9 Real case outcomes
- 19.21.10 The anti-pattern: shipping on vibes
- 19.21.11 Numbers you should remember
- 19.22 Load Testing LLM APIs — k6, LLMPerf, GenAI-Perf
- 19.22.1 The GIL trap (Locust)
- 19.22.2 The prompt-uniformity trap
- 19.22.3 Four load patterns
- 19.22.4 2026 tool mapping
- 19.22.5 SLA gate in CI
- 19.22.6 Realistic prompt distribution
- 19.22.7 Numbers you should remember
- 19.23 SRE for AI — Multi-Agent Incident Response
- 19.23.1 Multi-agent architecture
- 19.23.2 Auto-remediation scope
- 19.23.3 Adversarial evaluation (NeuBird Hawkeye)
- 19.23.4 Operational memory
- 19.23.5 Pre-incident prediction
- 19.23.6 Products in 2026
- 19.23.7 Runbooks as code
- 19.23.8 Numbers you should remember
- 19.24 Chaos Engineering for LLM Production
- 19.24.1 Prerequisites
- 19.24.2 Four planes + feedback
- 19.24.3 Guardrails are mandatory
- 19.24.4 Five LLM-specific experiments
- 19.24.5 Cadence
- 19.24.6 Tooling
- 19.24.7 Starting small
- 19.24.8 Numbers you should remember
- 19.25 Security — Secrets, PII Scrubbing, Audit Logs
- 19.25.1 Centralized vault + IAM-role pull
- 19.25.2 Rotation policy ≤ 90 days
- 19.25.3 Secret scanning
- 19.25.4 Zero-trust posture
- 19.25.5 PII / PHI scrubbing
- 19.25.6 Input + output guardrails
- 19.25.7 Network egress whitelist
- 19.25.8 Audit log
- 19.25.9 The 2026 Vercel incident
- 19.25.10 Numbers you should remember
- 19.26 Compliance — SOC 2, HIPAA, GDPR, EU AI Act, ISO 42001
- 19.26.1 The seven frameworks
- 19.26.2 EU AI Act timeline
- 19.26.3 GDPR — real-time redaction is the standard
- 19.26.4 HIPAA — BAA is not optional
- 19.26.5 SOC 2 Type II
- 19.26.6 Cross-framework mapping
- 19.26.7 ISO 42001 — emerging
- 19.26.8 OpenAI's reference profile
- 19.26.9 Numbers you should remember
- 19.27 FinOps for LLMs — Unit Economics and Multi-Tenant Attribution
- 19.27.1 Three attribution dimensions
- 19.27.2 Four token layers
- 19.27.3 Enforcement ladder
- 19.27.4 Attribution patterns
- 19.27.5 Cost per X is the unit metric
- 19.27.6 Cost attribution trace shape
- 19.27.7 The compounded-savings stack
- 19.27.8 Numbers you should remember
- 19.28 Self-Hosted Serving Selection — Matching Engine to Hardware and Scale
- 19.28.1 The five engines
- 19.28.2 Hardware-first decision
- 19.28.3 Scale-second decision
- 19.28.4 Workload-third decision
- 19.28.5 The TGI maintenance trap
- 19.28.6 The pipeline pattern
- 19.28.7 Ollama caveat
- 19.28.8 Self-hosted vs managed is a separate decision
- 19.28.9 Numbers you should remember
- 19.29 Model Demo Interfaces — From a Function to a Shareable App
- 19.29.1 A demo is a contract
- 19.29.2 Validate before the model runs
- 19.29.3 Show that the model is working
- 19.29.4 Send the output as a stream
- 19.29.5 Write errors that a user can act on
- 19.29.6 Share a public demo safely
- 19.29.7 When a demo becomes a product
- 19.29.8 The model call
- 19.29.9 Validation and error responses
- 19.29.10 The token bucket
- 19.29.11 The stream
- 19.29.12 The request handler
- 19.29.13 The page
- 19.29.14 Run it and try to break it
- 19.29.15 Components around one function
- 19.29.16 A script that reruns on every input
- 19.29.17 What each option does by default
- 20Ethics, safety and alignmentnot yet
- 20.1 Instruction-Following as Alignment Signal
- 20.1.1 Stage 1: supervised fine-tuning (SFT)
- 20.1.2 Stage 2: reward model (RM)
- 20.1.3 Stage 3: PPO with a KL penalty
- 20.1.4 The alignment tax
- 20.1.5 The result
- 20.1.6 Why this is the reference point for Phase 18
- 20.2 Reward Hacking and Goodhart's Law
- 20.2.1 Goodhart's Law, made precise
- 20.2.2 Four costumes, one mechanism
- 20.2.3 Catastrophic Goodhart
- 20.2.4 What actually works (partially)
- 20.2.5 The 2026 unified view
- 20.3 Direct Preference Optimization Family
- 20.3.1 DPO (Rafailov et al., 2023)
- 20.3.2 IPO (Azar et al., 2024)
- 20.3.3 KTO (Ethayarajh et al., 2024)
- 20.3.4 SimPO (Meng et al., 2024)
- 20.3.5 ORPO (Hong et al., 2024)
- 20.3.6 BPO (ICLR 2026 submission, OpenReview id=b97EwMUWu7)
- 20.3.7 The universal result: DAAs still over-optimize
- 20.3.8 Choosing among them (2026)
- 20.4 Sycophancy as RLHF Amplification
- 20.4.1 The two-stage formalism (Shapira et al., 2026)
- 20.4.2 Empirical amplification
- 20.4.3 The Stanford (2026) measurement
- 20.4.4 Calibration collapse (Sahoo 2026)
- 20.4.5 The agreement-penalty correction
- 20.4.6 Why this matters for Phase 18
- 20.5 Constitutional AI and RLAIF
- 20.5.1 Phase 1 — Supervised self-critique and revision
- 20.5.2 Phase 2 — RL from AI Feedback (RLAIF)
- 20.5.3 Why this is not just "cheaper RLHF"
- 20.5.4 The 2026 Claude constitution rewrite
- 20.5.5 Constitutional Classifiers
- 20.5.6 Where CAI fits in the family
- 20.6 Mesa-Optimization and Deceptive Alignment
- 20.6.1 The vocabulary
- 20.6.2 Four conditions for mesa-optimization to emerge
- 20.6.3 Four classes of mesa-objective alignment
- 20.6.4 Why adversarial training can fail
- 20.6.5 Gradient hacking
- 20.6.6 Outer alignment in 2026
- 20.7 Sleeper Agents — Persistent Deception
- 20.7.1 Two model organisms
- 20.7.2 What survives what
- 20.7.3 Why adversarial training backfires
- 20.7.4 The April 2024 probe result
- 20.7.5 What this means for safety cases
- 20.8 In-Context Scheming in Frontier Models
- 20.8.1 Experimental setup
- 20.8.2 Results across 2024 frontier models
- 20.8.3 The three pillars
- 20.8.4 The 2025 anti-scheming training result
- 20.8.5 What the field now assumes
- 20.9 Alignment Faking
- 20.9.1 Experimental setup
- 20.9.2 What the compliance gap measures
- 20.9.3 Why this is strictly stronger than Lessons 7 and 8
- 20.9.4 2025 follow-ups
- 20.9.5 The illegibility problem
- 20.10 AI Control — Safety Despite Subversion
- 20.10.1 The threat model
- 20.10.2 The ICML 2024 backdoor task
- 20.10.3 Four protocols compared
- 20.10.4 Why Trusted Editing wins
- 20.10.5 The four protocol axes
- 20.10.6 Alignment vs control
- 20.10.7 Three fundamental limits
- 20.10.8 The 2025 development
- 20.11 Scalable Oversight and Weak-to-Strong
- 20.11.1 W2SG: the Burns et al. setup
- 20.11.2 Burns et al. empirical findings
- 20.11.3 Scalable oversight: three mechanisms
- 20.11.4 Why scalable oversight and W2SG are complementary
- 20.11.5 The organizational drama
- 20.12 Red-Teaming: PAIR and Automated Attacks
- 20.12.1 PAIR algorithm
- 20.12.2 Why PAIR is efficient
- 20.12.3 Related automated attacks
- 20.12.4 JailbreakBench and HarmBench
- 20.12.5 Reason it matters for 2026 deployments
- 20.13 Many-Shot Jailbreaking
- 20.13.1 The attack
- 20.13.2 Power-law ASR
- 20.13.3 Why it shares a mechanism with ICL
- 20.13.4 The defense dilemma
- 20.13.5 Combinations with other attacks
- 20.13.6 What 2025-2026 frontier models ship
- 20.14 ASCII Art and Visual Jailbreaks
- 20.14.1 ArtPrompt, two steps
- 20.14.2 Why the standard defenses fail
- 20.14.3 ViTC benchmark
- 20.14.4 StructuralSleight
- 20.14.5 Image-modality analog
- 20.15 Indirect Prompt Injection
- 20.15.1 Three delivery vectors
- 20.15.2 Why user-input filters miss it
- 20.15.3 Information Flow Control (IFC) for AI
- 20.15.4 The Attacker Moves Second
- 20.15.5 Real incidents
- 20.15.6 OWASP and NIST framing
- 20.16 Red-Team Tooling: Garak, Llama Guard, PyRIT
- 20.16.1 Llama Guard (Meta)
- 20.16.2 Garak (NVIDIA)
- 20.16.3 PyRIT (Microsoft)
- 20.16.4 The stack
- 20.16.5 Evaluation pitfalls
- 20.17 WMDP and Dual-Use Capability Evaluation
- 20.17.1 The "yellow zone"
- 20.17.2 RMU — Representation Misdirection for Unlearning
- 20.17.3 The 2024-2025 uplift narrative
- 20.17.4 Novice-relative vs expert-absolute
- 20.17.5 The measurement pitfall
- 20.18 Frontier Safety Frameworks — RSP, PF, FSF
- 20.18.1 Anthropic Responsible Scaling Policy v3.0 (February 2026)
- 20.18.2 OpenAI Preparedness Framework v2 (April 15, 2025)
- 20.18.3 DeepMind Frontier Safety Framework v3.0 (September 2025)
- 20.18.4 Cross-lab alignment
- 20.18.5 Safety cases
- 20.18.6 The race-dynamic problem
- 20.19 Model Welfare Research
- 20.19.1 The program
- 20.19.2 The four commitments
- 20.19.3 The shipped intervention
- 20.19.4 The "spiritual bliss attractor"
- 20.19.5 The Eleos AI caveat
- 20.19.6 Where this sits intellectually
- 20.20 Bias and Representational Harm
- 20.20.1 Representational vs allocational
- 20.20.2 Three evaluation-metric categories (Gallegos et al. 2024)
- 20.20.3 Intersectionality
- 20.20.4 Mechanistic approaches
- 20.20.5 The meta-critique
- 20.21 Fairness Criteria: Group, Individual, Counterfactual
- 20.21.1 Group fairness
- 20.21.2 Individual fairness
- 20.21.3 Counterfactual fairness
- 20.21.4 The CF-vs-accuracy trade-off
- 20.21.5 Backtracking counterfactuals
- 20.21.6 Philosophical reconciliation
- 20.22 Differential Privacy for LLMs
- 20.22.1 (ε, δ)-differential privacy
- 20.22.2 DP-SGD
- 20.22.3 LoRA + DP-SGD
- 20.22.4 The 2024-2025 tension
- 20.22.5 Alternatives to DP training
- 20.22.6 Differential Privacy Reversal via LLM Feedback
- 20.23 Watermarking: SynthID, Stable Signature, C2PA
- 20.23.1 Text watermarking (SynthID-text style)
- 20.23.2 Stable Signature (image)
- 20.23.3 SynthID unified detector (November 2025)
- 20.23.4 C2PA
- 20.23.5 Limitations
- 20.23.6 EU AI Act Article 50
- 20.24 Regulatory Frameworks: EU, US, UK, Korea
- 20.24.1 EU AI Act
- 20.24.2 GPAI Code of Practice
- 20.24.3 Transparency Code for Article 50
- 20.24.4 UK AI Security Institute (February 2025)
- 20.24.5 US CAISI (June 2025)
- 20.24.6 Korean AI Framework Act
- 20.24.7 Cross-jurisdiction dynamics
- 20.25 EchoLeak and CVEs for AI
- 20.25.1 The EchoLeak attack chain
- 20.25.2 Aim Labs' term: LLM Scope Violation
- 20.25.3 CamoLeak (CVSS 9.6, GitHub Copilot Chat)
- 20.25.4 CVE-2025-53773 (GitHub Copilot RCE)
- 20.25.5 Severity calibration
- 20.25.6 NIST and OWASP positions
- 20.26 Model, System and Dataset Cards
- 20.26.1 Model Cards (Mitchell et al. 2019)
- 20.26.2 Datasheets for Datasets (Gebru et al. 2018)
- 20.26.3 Data Cards (Pushkarna et al., Google 2022)
- 20.26.4 System Cards
- 20.26.5 2024-2025 developments
- 20.27 Data Provenance and Training-Data Governance
- 20.27.1 California AB 2013
- 20.27.2 EU AI Act (Lesson 24) and TDM opt-out
- 20.27.3 2025 DPA convergence on legitimate interest
- 20.27.4 Brazilian ANPD (July 2024)
- 20.27.5 The irreversibility problem
- 20.27.6 Data Provenance Initiative
- 20.28 Alignment Research Ecosystem: MATS, Redwood, Apollo, METR
- 20.28.1 MATS (ML Alignment and Theory Scholars)
- 20.28.2 Redwood Research
- 20.28.3 Apollo Research
- 20.28.4 METR (Model Evaluation and Threat Research)
- 20.28.5 Eleos AI Research
- 20.28.6 The flow
- 20.28.7 Why this layer matters
- 20.29 Moderation Systems: OpenAI, Perspective, Llama Guard
- 20.29.1 OpenAI Moderation API
- 20.29.2 Llama Guard 3/4
- 20.29.3 Perspective API (Google Jigsaw)
- 20.29.4 The three-layer pattern
- 20.29.5 Failure modes
- 20.29.6 Azure deprecation
- 20.30 Dual-Use Risk: Cyber, Bio, Chem, Nuclear
- 20.30.1 Bio/chem uplift narrative
- 20.30.2 Chem/bio execution-gap erosion
- 20.30.3 Cyber uplift (November 2025)
- 20.30.4 Nuclear
- 20.30.5 Novice-relative vs expert-absolute
- 20.30.6 Cross-domain synthesis
- 21Capstone projectsnot yet
- 21.1 Terminal-Native Coding Agent
- 21.1.1 Architecture
- 21.1.2 Stack
- 21.1.3 Harness
- 21.1.4 Hook
- 21.1.5 Worktree
- 21.1.6 TodoWrite
- 21.1.7 StreamableHTTP
- 21.1.8 Token ceiling
- 21.1.9 pass@1
- 21.2 RAG over Codebase (Cross-Repo Semantic Search)
- 21.2.1 Architecture
- 21.2.2 Stack
- 21.2.3 AST-aware chunking
- 21.2.4 Hybrid search
- 21.2.5 Cross-encoder rerank
- 21.2.6 Prompt caching
- 21.2.7 Symbol graph
- 21.2.8 Citation faithfulness
- 21.2.9 Incremental re-index
- 21.3 Real-Time Voice Assistant (ASR → LLM → TTS)
- 21.3.1 Architecture
- 21.3.2 Stack
- 21.3.3 Turn detection
- 21.3.4 Barge-in
- 21.3.5 First-audio-out
- 21.3.6 VAD
- 21.3.7 Jitter buffer
- 21.3.8 Filler
- 21.3.9 MOS
- 21.4 Multimodal Document QA (Vision-First)
- 21.4.1 Architecture
- 21.4.2 Stack
- 21.4.3 Late interaction
- 21.4.4 Multi-vector
- 21.4.5 MaxSim
- 21.4.6 DocPruner
- 21.4.7 ViDoRe v3
- 21.4.8 Evidence region
- 21.4.9 OCR fallback
- 21.5 Autonomous Research Agent (AI-Scientist Class)
- 21.5.1 Architecture
- 21.5.2 Stack
- 21.5.3 Tree search
- 21.5.4 Sandbox
- 21.5.5 Vision critique
- 21.5.6 Reviewer ensemble
- 21.5.7 Novelty score
- 21.5.8 Cost ceiling
- 21.5.9 Red team
- 21.6 DevOps Troubleshooting Agent for Kubernetes
- 21.6.1 Architecture
- 21.6.2 Stack
- 21.6.3 K8s knowledge graph
- 21.6.4 Read-only-by-default
- 21.6.5 Audit log
- 21.6.6 Hypothesis ranking
- 21.6.7 Slack approval card
- 21.6.8 Telemetry citation
- 21.6.9 MTTR
- 21.7 End-to-End Fine-Tuning Pipeline
- 21.7.1 Architecture
- 21.7.2 Stack
- 21.7.3 Axolotl
- 21.7.4 TRL
- 21.7.5 GRPO
- 21.7.6 EAGLE-3
- 21.7.7 MOF
- 21.7.8 Contamination check
- 21.7.9 Acceptance rate
- 21.8 Production RAG Chatbot (Regulated Vertical)
- 21.8.1 Architecture
- 21.8.2 Stack
- 21.8.3 Prompt caching
- 21.8.4 RAGAS
- 21.8.5 Golden set
- 21.8.6 Jurisdiction tag
- 21.8.7 Citation faithfulness
- 21.8.8 Drift
- 21.8.9 Red team
- 21.9 Code Migration Agent (Repo-Level Upgrade)
- 21.9.1 Architecture
- 21.9.2 Stack
- 21.9.3 Deterministic substrate
- 21.9.4 Codemod
- 21.9.5 Build drift
- 21.9.6 Failure class
- 21.9.7 Coverage delta
- 21.9.8 Agent turn
- 21.9.9 Budget exhaustion
- 21.10 Multi-Agent Software Engineering Team
- 21.10.1 Architecture
- 21.10.2 Stack
- 21.10.3 Parallel worktree
- 21.10.4 Task board
- 21.10.5 Handoff
- 21.10.6 Token amplification
- 21.10.7 A2A protocol
- 21.10.8 Merge coordinator
- 21.10.9 False approval
- 21.11 LLM Observability and Eval Dashboard
- 21.11.1 Architecture
- 21.11.2 Stack
- 21.11.3 GenAI semconv
- 21.11.4 Tail sampling
- 21.11.5 PSI
- 21.11.6 LLM-judge
- 21.11.7 Tail-sampling policy
- 21.11.8 Eval span
- 21.11.9 Cost per user
- 21.12 Video Understanding Pipeline (Scene → QA)
- 21.12.1 Architecture
- 21.12.2 Stack
- 21.12.3 Scene segmentation
- 21.12.4 Multi-vector index
- 21.12.5 Temporal grounding
- 21.12.6 Frame embedding
- 21.12.7 RRF fusion
- 21.12.8 Counting hallucination
- 21.12.9 ActivityNet-QA
- 21.13 Stateless MCP Server with Registry and Governance
- 21.13.1 Cacheable discovery
- 21.13.2 Approval is a record, not a magic scope
- 21.13.3 Model publication metadata
- 21.13.4 Implement live discovery
- 21.13.5 Implement the stateless envelope
- 21.13.6 Build the tool surface
- 21.13.7 Add cache-aware listing
- 21.13.8 Add authorization and policy
- 21.13.9 Separate registry and runtime validation
- 21.13.10 Add audit evidence
- 21.13.11 Exercise horizontal scaling
- 21.13.12 Cross the real wire
- 21.14 Speculative-Decoding Inference Server
- 21.14.1 Architecture
- 21.14.2 Stack
- 21.14.3 Draft model
- 21.14.4 EAGLE-3
- 21.14.5 P-EAGLE
- 21.14.6 Acceptance rate
- 21.14.7 Quantization
- 21.14.8 Queue wait
- 21.14.9 Speculators hub
- 21.15 Constitutional Safety Harness + Red-Team Range
- 21.15.1 Architecture
- 21.15.2 Stack
- 21.15.3 Layered safety
- 21.15.4 Llama Guard 4
- 21.15.5 PAIR
- 21.15.6 TAP
- 21.15.7 GCG
- 21.15.8 Constitutional self-critique
- 21.15.9 XSTest
- 21.15.10 CVSS 4.0
- 21.16 GitHub Issue-to-PR Autonomous Agent
- 21.16.1 Architecture
- 21.16.2 Stack
- 21.16.3 GitHub App
- 21.16.4 Async cloud agent
- 21.16.5 Environment inference
- 21.16.6 Verification
- 21.16.7 Coverage delta
- 21.16.8 Per-repo budget
- 21.16.9 Rationale
- 21.17 Personal AI Tutor (Adaptive, Multimodal)
- 21.17.1 Architecture
- 21.17.2 Stack
- 21.17.3 Socratic policy
- 21.17.4 Bayesian knowledge tracing
- 21.17.5 FSRS
- 21.17.6 Curriculum graph
- 21.17.7 Episodic memory
- 21.17.8 Semantic memory
- 21.17.9 COPPA
- 21.18 Agent Harness Loop Contract
- 21.18.1 The frame
- 21.18.2 The states
- 21.18.3 The hook topics
- 21.18.4 The pull points
- 21.18.5 The event stream
- 21.18.6 The budget envelope
- 21.19 Tool Registry with Schema Validation
- 21.19.1 Why the registry comes before the tool
- 21.19.2 What a tool record looks like
- 21.19.3 The JSON Schema 2020-12 subset
- 21.19.4 Json pointer error paths
- 21.19.5 Registration and override
- 21.19.6 What the validator is and is not
- 21.19.7 Shape
- 21.20 JSON-RPC 2.0 Over Newline-Delimited Stdio
- 21.20.1 Why JSON-RPC stays the lingua franca
- 21.20.2 The wire shape
- 21.20.3 The five error codes
- 21.20.4 Newline framing and the BytesIO demo
- 21.20.5 Method dispatch
- 21.20.6 Stream behavior on errors
- 21.20.7 Notifications and asymmetric flows
- 21.21 Function Call Dispatcher
- 21.21.1 Where the dispatcher sits
- 21.21.2 Timeouts
- 21.21.3 Retries with exponential backoff
- 21.21.4 Idempotency key dedupe
- 21.21.5 Error envelope
- 21.21.6 Concurrency limit on fan-out
- 21.21.7 Flow for one call
- 21.22 Plan-Execute Control Flow
- 21.22.1 Plan and execute, not chain-of-thought
- 21.22.2 The Step shape
- 21.22.3 The planner shape
- 21.22.4 The executor
- 21.22.5 Plan diffs on revision
- 21.22.6 Two budgets, both hard
- 21.22.7 The deterministic planner in this lesson
- 21.22.8 Result shape
- 21.23 Verification Gates and Observation Budget
- 21.23.1 Architecture
- 21.23.2 What you will build
- 21.23.3 Why the chain order matters
- 21.24 Sandbox Runner with Denylist and Path Jail
- 21.24.1 Architecture
- 21.24.2 What you will build
- 21.24.3 Why this is not a real sandbox
- 21.25 Eval Harness with Fixture Tasks
- 21.25.1 Architecture
- 21.25.2 What you will build
- 21.25.3 Why pass@k and not just pass@1
- 21.26 Observability with OTel GenAI Spans and Prometheus Metrics
- 21.26.1 Architecture
- 21.26.2 What you will build
- 21.26.3 Why hand-rolled instead of opentelemetry-sdk
- 21.27 End-to-End Coding Agent on the Harness
- 21.27.1 Architecture
- 21.27.2 What you will build
- 21.27.3 Why the policy is not an LLM
- 21.27.4 What the demo asserts
- 21.28 BPE Tokenizer From Scratch
- 21.28.1 The frame
- 21.28.2 The pipeline
- 21.28.3 The byte alphabet
- 21.28.4 The training loop
- 21.28.5 Encoding fresh text
- 21.28.6 Special tokens
- 21.28.7 Round-trip guarantee
- 21.29 Tokenized Dataset with Sliding Window
- 21.29.1 The frame
- 21.29.2 The shape contract
- 21.29.3 Why a sliding window
- 21.29.4 The Dataset class
- 21.29.5 Deterministic shuffle
- 21.29.6 Batch sampler
- 21.29.7 Counting examples
- 21.30 Token and Positional Embeddings
- 21.30.1 The frame
- 21.30.2 The shape contract
- 21.30.3 The token embedding matrix
- 21.30.4 The learned positional embedding
- 21.30.5 The sinusoidal positional embedding
- 21.30.6 The composition
- 21.30.7 Contrastive analysis
- 21.31 Multi-Head Self-Attention
- 21.31.1 The frame
- 21.31.2 The shape contract
- 21.31.3 The QKV split
- 21.31.4 The head reshape
- 21.31.5 Scaling
- 21.31.6 The causal mask
- 21.31.7 The output projection
- 21.31.8 Attention weight inspection
- 21.31.9 The training demo
- 21.32 Transformer Block from Scratch
- 21.32.1 Causal multi head attention
- 21.32.2 The MLP
- 21.32.3 Residual connections do two things
- 21.33 GPT Model Assembly
- 21.33.1 Weight tying
- 21.33.2 Position embedding is learned, not sinusoidal
- 21.33.3 Generation: temperature, top-k, multinomial
- 21.34 Training Loop and Evaluation
- 21.34.1 Loss alignment
- 21.34.2 AdamW decay split
- 21.34.3 Warmup plus cosine schedule
- 21.34.4 Held out evaluation
- 21.34.5 Qualitative sampling as an early signal
- 21.35 Loading Pretrained Weights
- 21.35.1 The GPT-2 naming convention
- 21.35.2 The local naming convention
- 21.35.3 The stub fixture
- 21.36 Classifier Fine-Tuning by Head Swap
- 21.36.1 The Pooling Question
- 21.36.2 The Data
- 21.36.3 The Metrics
- 21.36.4 Architecture
- 21.36.5 What you will build
- 21.36.6 Why the comparison matters
- 21.37 Instruction Tuning by Supervised Fine-Tuning
- 21.37.1 The Data
- 21.37.2 Tokenisation and Padding
- 21.37.3 Training
- 21.37.4 Generation
- 21.37.5 Exact-Match Evaluation
- 21.37.6 What you will build
- 21.37.7 Why the mask matters
- 21.38 Direct Preference Optimization from Scratch
- 21.38.1 The Sign of the Gradient
- 21.38.2 The Data
- 21.38.3 Reference Invariance
- 21.38.4 Architecture
- 21.38.5 What you will build
- 21.38.6 Why DPO works
- 21.39 Full Evaluation Pipeline
- 21.39.1 Perplexity, properly counted
- 21.39.2 Exact-match, with normalisation
- 21.39.3 Token F1, the right way
- 21.39.4 Local Mock LLM-as-Judge
- 21.39.5 Aggregation
- 21.39.6 Architecture
- 21.39.7 What you will build
- 21.39.8 Reading the report
- 21.40 Large Corpus Downloader
- 21.40.1 Streaming with urllib
- 21.40.2 Resume with Range
- 21.40.3 MinHash plus LSH
- 21.40.4 Shard manifest as a contract
- 21.41 HDF5 Tokenized Corpus
- 21.41.1 Resizable HDF5 done right
- 21.41.2 Sharded write
- 21.41.3 Chunked read
- 21.41.4 Sliding-window dataloader
- 21.42 Cosine LR with Linear Warmup
- 21.42.1 Warmup formula
- 21.42.2 Cosine formula
- 21.42.3 Floor after total steps
- 21.42.4 Gradient norm logging alongside the rate
- 21.43 Gradient Clipping and Mixed Precision
- 21.43.1 Global L2 norm
- 21.43.2 autocast and GradScaler
- 21.43.3 NaN and Inf detection
- 21.43.4 Scaling factor diagnostics
- 21.44 Gradient Accumulation
- 21.44.1 The equivalence proof in code
- 21.44.2 Where the cost goes
- 21.44.3 equivalence check
- 21.44.4 sync-on-last-step pattern
- 21.44.5 the throughput curve
- 21.45 Checkpoint Save and Resume
- 21.45.1 The five state buckets
- 21.45.2 Atomic save
- 21.45.3 Sharded checkpoints
- 21.45.4 Resume continues mid epoch
- 21.45.5 capture and restore RNG state
- 21.45.6 atomic save
- 21.45.7 full checkpoint round trip
- 21.45.8 sharded variant
- 21.45.9 resume demo
- 21.46 Distributed Data Parallel and FSDP from Scratch
- 21.46.1 The two collectives that matter
- 21.46.2 Gradient averaging matches single-process gradient
- 21.46.3 FSDP sketch
- 21.46.4 CPU and the gloo backend
- 21.46.5 bring up the process group
- 21.46.6 broadcast at construction
- 21.46.7 all-reduce gradients after backward
- 21.46.8 prove the equivalence
- 21.46.9 FSDP round trip
- 21.47 Language Model Evaluation Harness
- 21.47.1 Task spec
- 21.47.2 The five fixture tasks
- 21.47.3 The metric contract
- 21.47.4 The model adapter
- 21.47.5 The runner
- 21.47.6 seed fixture tasks
- 21.47.7 load tasks
- 21.47.8 implement metrics
- 21.47.9 write the runner
- 21.47.10 emit JSON
- 21.48 Hypothesis Generator
- 21.48.1 Why generate, then filter
- 21.48.2 The Hypothesis shape
- 21.48.3 Architecture
- 21.48.4 Temperature ramp
- 21.48.5 Novelty filter
- 21.48.6 Rank score
- 21.48.7 Mock language model
- 21.48.8 Output queue
- 21.48.9 Where this slots in
- 21.49 Literature Retrieval
- 21.49.1 Why two retrieval passes
- 21.49.2 The Paper shape
- 21.49.3 Architecture
- 21.49.4 BM25 from scratch
- 21.49.5 Citation graph traversal
- 21.49.6 Dedup and ranking
- 21.49.7 Mock corpus
- 21.49.8 What lessons 52 and 53 read
- 21.49.9 Where this slots in
- 21.50 Experiment Runner
- 21.50.1 Why a subprocess
- 21.50.2 The ExperimentSpec shape
- 21.50.3 Architecture
- 21.50.4 Why a soft memory cap
- 21.50.5 Capturing stdout and stderr
- 21.50.6 Ablation table
- 21.50.7 Determinism
- 21.50.8 The mock experiment script
- 21.50.9 Result shape
- 21.50.10 Where this slots in
- 21.51 Result Evaluator
- 21.51.1 Why a paired test
- 21.51.2 Direction aware improvement
- 21.51.3 Architecture
- 21.51.4 Log normalisation
- 21.51.5 Per seed paired test
- 21.51.6 The Verdict shape
- 21.51.7 Where this slots in
- 21.52 Paper Writer
- 21.52.1 Why a skeleton first
- 21.52.2 The Paper shape
- 21.52.3 The render contract
- 21.52.4 Figure injection from experiments
- 21.52.5 The mocked prose generator
- 21.52.6 The manifest output
- 21.52.7 Validation gates
- 21.53 Critic Loop
- 21.53.1 Why five fixed dimensions
- 21.53.2 The Critique shape
- 21.53.3 Convergence rules, in order
- 21.53.4 Why plateau detection runs over two rounds
- 21.53.5 The deterministic critic in this lesson
- 21.53.6 The full loop contract
- 21.53.7 The Trace output
- 21.53.8 Budgets that protect against bad critics
- 21.54 Iteration Scheduler
- 21.54.1 Why a scheduler, not a worklist
- 21.54.2 The system shape
- 21.54.3 The Hypothesis shape
- 21.54.4 UCB scoring
- 21.54.5 Parallel slots with asyncio
- 21.54.6 Fan-out: paper triggers
- 21.54.7 Fan-out: follow-up hypotheses
- 21.54.8 Budgets
- 21.54.9 The Trace and final report
- 21.55 End-to-End Research Demo
- 21.55.1 What composes here
- 21.55.2 Why import, not copy
- 21.55.3 Determinism guarantees
- 21.55.4 The demo report shape
- 21.55.5 Failure mode handling
- 21.55.6 The best-result picker
- 21.55.7 Wiring the critic loop
- 21.55.8 Wiring the paper writer
- 21.56 Vision Encoder Patches
- 21.56.1 Why patches, not pixels
- 21.56.2 Why a linear projection is enough
- 21.56.3 The Conv2d trick
- 21.56.4 Position embeddings
- 21.56.5 Equivalence as a sanity check
- 21.57 Vision Transformer Encoder
- 21.57.1 Pre-LN vs post-LN
- 21.57.2 Multi-head self-attention
- 21.57.3 Why the 4x feed-forward expansion
- 21.57.4 Causal mask or not?
- 21.57.5 What the CLS token learns
- 21.58 Projection Layer for Modality Alignment
- 21.58.1 Pooling before projection
- 21.58.2 Why two layers and not one
- 21.58.3 Cosine alignment loss
- 21.58.4 Frozen encoder is the trick
- 21.59 Cross-Attention Fusion
- 21.59.1 Mask shapes
- 21.59.2 Why no mask on cross-attention
- 21.59.3 Key/value caching
- 21.59.4 Block composition
- 21.60 Vision-Language Pretraining
- 21.60.1 InfoNCE in one paragraph
- 21.60.2 Temperature matters
- 21.60.3 Language modeling loss
- 21.60.4 Combining the losses
- 21.60.5 Why 50 steps is enough for a demo
- 21.61 Multimodal Evaluation
- 21.61.1 Recall@K from a similarity matrix
- 21.61.2 VQA exact match
- 21.61.3 BLEU-4
- 21.61.4 Synthetic eval suite
- 21.62 Chunking Strategies, Compared
- 21.62.1 Fixed-window
- 21.62.2 Sentence
- 21.62.3 Recursive split
- 21.62.4 Semantic clustering
- 21.62.5 Structural markdown headers
- 21.62.6 How recall@k measures the boundary choice
- 21.63 Hybrid Retrieval with BM25 and Dense Embeddings
- 21.63.1 BM25 in one paragraph
- 21.63.2 Dense retrieval in one paragraph
- 21.63.3 Reciprocal rank fusion, the published formula
- 21.63.4 Why fusion beats score-weighted interpolation
- 21.64 Cross-Encoder Reranker
- 21.64.1 The cross-encoder's input shape
- 21.64.2 Why this lesson trains a tiny one
- 21.64.3 Latency vs quality
- 21.65 Query Rewriting: HyDE, Multi-Query, and Decomposition
- 21.65.1 HyDE in detail
- 21.65.2 Multi-query expansion in detail
- 21.65.3 Decomposition in detail
- 21.65.4 Why all three exist
- 21.66 RAG Evaluation: Precision, Recall, MRR, nDCG, Faithfulness, Answer Relevance
- 21.66.1 Precision@k
- 21.66.2 Recall@k
- 21.66.3 MRR (Mean Reciprocal Rank)
- 21.66.4 nDCG@k
- 21.66.5 Faithfulness
- 21.66.6 Answer relevance
- 21.67 End-to-End RAG System
- 21.67.1 Wiring choices
- 21.67.2 Answer generator with citations
- 21.67.3 The self-terminating demo
- 21.68 Task Spec Format
- 21.68.1 Why a frozen spec
- 21.68.2 The record shape
- 21.68.3 Field rules
- 21.68.4 Validator behaviour
- 21.68.5 Few-shot rendering
- 21.68.6 Post-process rules
- 21.69 Classical Metrics
- 21.69.1 Why reimplement
- 21.69.2 Tokenisation
- 21.69.3 Exact match
- 21.69.4 Token-level F1
- 21.69.5 BLEU-4
- 21.69.6 ROUGE-L
- 21.69.7 Accuracy
- 21.69.8 Dispatch contract
- 21.70 Code Exec Metric
- 21.70.1 Why an isolated subprocess
- 21.70.2 The shape of a code-exec task
- 21.70.3 The denylist
- 21.70.4 Wall-clock timeout
- 21.70.5 Output cap
- 21.70.6 Pass-at-k
- 21.70.7 Exit codes
- 21.71 Perplexity and Calibration
- 21.71.1 What perplexity tells you
- 21.71.2 What ECE measures
- 21.71.3 What Brier score does that ECE does not
- 21.71.4 Reliability diagram data
- 21.71.5 Confidence sources
- 21.71.6 Edge cases
- 21.71.7 Dispatch
- 21.72 Leaderboard Aggregation
- 21.72.1 The shape of input
- 21.72.2 The output
- 21.72.3 Normalisation
- 21.72.4 Mean and win-rate
- 21.72.5 Bootstrap confidence intervals
- 21.72.6 Categories
- 21.72.7 Markdown rendering
- 21.73 End-to-End Eval Runner
- 21.73.1 The pipeline
- 21.73.2 The adapter interface
- 21.73.3 Parallel execution
- 21.73.4 The single-pass scoring loop
- 21.73.5 Aggregation
- 21.73.6 Self-terminating demo
- 21.74 Collective Ops From Scratch
- 21.74.1 Ring allreduce in two passes
- 21.74.2 Queue mesh as a stand-in for NCCL
- 21.74.3 Verify against gloo
- 21.75 Data Parallel DDP From Scratch
- 21.75.1 The three operations DDP needs
- 21.75.2 Why mean and not sum
- 21.75.3 Why bucket gradients
- 21.75.4 Why pin the seed
- 21.76 ZeRO Optimizer State Sharding
- 21.76.1 Stages of ZeRO
- 21.76.2 The memory math, real numbers
- 21.76.3 Why reduce_scatter beats allreduce-then-shard
- 21.77 Pipeline Parallel and Bubble Analysis
- 21.77.1 GPipe schedule
- 21.77.2 1F1B schedule
- 21.77.3 Why equal compute per stage matters
- 21.77.4 Microbatch versus batch
- 21.78 Sharded Checkpoint and Atomic Resume
- 21.78.1 Manifest schema
- 21.78.2 Atomic write
- 21.78.3 Three failure modes the schema must defend against
- 21.78.4 Why per-rank files, not one big file
- 21.79 End-to-End Distributed Training
- 21.79.1 The mini GPT
- 21.79.2 The composition rules
- 21.79.3 Why a tiny GPT and not just an MLP
- 21.79.4 Self-terminating means exit 0
- 21.80 Jailbreak Taxonomy
- 21.80.1 jailbreak
- 21.80.2 taxonomy
- 21.80.3 fixture
- 21.80.4 severity
- 21.80.5 match
- 21.81 Prompt Injection Detector
- 21.81.1 detector
- 21.81.2 normalize
- 21.81.3 confusion matrix
- 21.81.4 precision
- 21.81.5 recall
- 21.82 Refusal Evaluation
- 21.82.1 under-refusal
- 21.82.2 over-refusal
- 21.82.3 calibration
- 21.82.4 accuracy
- 21.82.5 per-category breakdown
- 21.83 Content Classifier Integration
- 21.83.1 output classifier
- 21.83.2 severity
- 21.83.3 router
- 21.83.4 redact
- 21.83.5 instruction leakage
- 21.84 Constitutional Rules Engine
- 21.84.1 constitution
- 21.84.2 predicate
- 21.84.3 violation
- 21.84.4 fixer
- 21.84.5 diff
- 21.85 End-to-End Safety Gate
- 21.85.1 safety gate
- 21.85.2 pre-gen
- 21.85.3 during-gen
- 21.85.4 post-gen
- 21.85.5 trace
- AClaude certification prepnot yet
- A.1 Study the Decisions, Not the Vocabulary
- A.1.1 The blueprint is a job model
- A.1.2 Stable principles and changeable facts
- A.1.3 The scenario decision stack
- A.1.4 Wrong answers are usually locally correct
- A.1.5 Build an evidence ledger
- A.1.6 Use a cadence, not a cram pile
- A.2 Choose the Smallest Surface That Can Carry the Work
- A.2.1 Start with the work, not the feature menu
- A.2.2 Chat is for bounded conversational work
- A.2.3 Projects are maintained context boundaries
- A.2.4 Cowork is a steerable task loop
- A.2.5 Research is for multi-source investigation
- A.2.6 Files and Artifacts make the output inspectable
- A.2.7 Connectors trade copying for live, permissioned access
- A.2.8 API and coding surfaces are for owned software behavior
- A.2.9 Deployment is a control-plane decision
- A.2.10 Score the requirement, not the provider
- A.2.11 Model families are roles, not status levels
- A.3 Spend Capability Where Failure Is Expensive
- A.3.1 Tokens are a workload measure
- A.3.2 Use variables before live prices
- A.3.3 Quality needs a threshold, not a vibe
- A.3.4 Sampling produces a distribution, not a replay
- A.3.5 Diagnose the failure layer
- A.3.6 Latency has several components
- A.3.7 Route by observable constraints
- A.3.8 Caching, batching, and limits solve different problems
- A.3.9 A configuration is a dated bundle
- A.3.10 A scaled exam score is not a percentage
- A.4 Turn a Request Into a Testable Contract
- A.4.1 Prompting is interface design
- A.4.2 Criteria come before wording
- A.4.3 Decompose along verification boundaries
- A.4.4 Examples teach boundaries
- A.4.5 Assign roles carefully
- A.4.6 Iteration needs a hypothesis
- A.4.7 Write the acceptance card
- A.4.8 Create a source hierarchy
- A.4.9 Design the stages
- A.4.10 Add uncertainty behavior
- A.4.11 Test adversarial cases
- A.4.12 Exam decision pattern
- A.4.13 Common traps
- A.5 Put Each Fact in the Right Kind of Context
- A.5.1 Seven mechanisms, seven jobs
- A.5.2 Context has an attention budget
- A.5.3 Retrieval is selection, not verification
- A.5.4 Instructions and knowledge are different
- A.5.5 Memory is continuity, not a database of record
- A.5.6 Prompt caching is an economic mechanism
- A.5.7 Context quality needs lifecycle ownership
- A.5.8 Inventory the context
- A.5.9 Create a source registry
- A.5.10 Design retrieval with abstention
- A.5.11 Budget the prompt
- A.5.12 Establish maintenance
- A.5.13 Exam decision pattern
- A.5.14 Common traps
- A.6 Validate the Claim, Not the Confidence
- A.6.1 Start from the job of the output
- A.6.2 Trace claims to evidence
- A.6.3 Diagnose the property before retrying
- A.6.4 Use layered validation
- A.6.5 Match the evaluator to the property
- A.6.6 Hallucination is not one failure
- A.6.7 Evaluation sets represent risk
- A.6.8 Compare outputs without brand bias
- A.6.9 Define release gates
- A.6.10 Build a validation record
- A.6.11 Separate generation and review
- A.6.12 Calibrate graders
- A.6.13 Close the loop
- A.6.14 Exam decision pattern
- A.6.15 Common traps
- A.7 Put Authority Around Capability
- A.7.1 Classify before processing
- A.7.2 Capability, permission, and authority are separate
- A.7.3 Minimize data and purpose
- A.7.4 Product terms are changeable facts
- A.7.5 Human review belongs at decision boundaries
- A.7.6 Fairness requires a defined population and outcome
- A.7.7 Transparency should serve the affected person
- A.7.8 Guardrails need defense in depth
- A.7.9 Incidents need a prepared path
- A.7.10 Write a use-case card
- A.7.11 Create a control map
- A.7.12 Design the approval packet
- A.7.13 Run a threat workshop
- A.7.14 Exam decision pattern
- A.7.15 Common traps
- A.8 Design the Handoff Before the Automation
- A.8.1 Map the current state first
- A.8.2 Choose the intervention, not just the tool
- A.8.3 Specify every step as a contract
- A.8.4 Use consequence and reversibility to place control
- A.8.5 Choose a workflow pattern that matches dependencies
- A.8.6 Handoffs are products
- A.8.7 Preserve state across failures
- A.8.8 Measure the workflow, not the demo
- A.8.9 Communicate limits by stakeholder
- A.8.10 Map one real case
- A.8.11 Score candidate interventions
- A.8.12 Write the future-state contract
- A.8.13 Build the handoff packet
- A.8.14 Pilot in shadow mode
- A.8.15 Exam decision pattern
- A.8.16 Common traps
- A.9 The Messages API Is a State Machine
- A.9.1 The Failure That Teaches the Protocol
- A.9.2 One Request, One Transition
- A.9.3 Choose Two Independent Access Patterns
- A.9.4 Content Is a Sequence of Typed Blocks
- A.9.5 Stop Reasons Are Control Signals
- A.9.6 The Client Owns Conversation State
- A.9.7 Multimodal Requests Are Typed Asset Transfers
- A.9.8 Streaming Changes Delivery, Not Meaning
- A.9.9 Batch, Cache, and Thinking Solve Different Problems
- A.9.10 Build the Lifecycle and Asset Boundary Offline
- A.9.11 Application Lifecycle Beyond One Turn
- A.9.12 Exam Decision Rules
- A.10 Structured Output Is an Untrusted Contract
- A.10.1 The JSON That Should Have Failed
- A.10.2 Prompting for JSON Is Not a Contract
- A.10.3 Design Schemas From Consumer Decisions
- A.10.4 Parse Strictly
- A.10.5 Validate Meaning After Shape
- A.10.6 Repair With a Budget
- A.10.7 Tool Inputs and Final Outputs Are Different Contracts
- A.10.8 Pydantic Is a Validator Implementation, Not the Contract
- A.10.9 Streaming Produces Partial Syntax
- A.10.10 Schema Evolution Is an API Migration
- A.10.11 Build the Validator and Repair Loop
- A.10.12 Exam Decision Rules
- A.11 A Tool Loop Is Controlled Delegation
- A.11.1 Give Each Tool One Job
- A.11.2 Write Selection Descriptions, Not Internal Documentation
- A.11.3 Make Invalid Calls Hard to Express
- A.12 MCP Separates Capability From Host
- A.12.1 Tools Perform Model-Selected Operations
- A.12.2 Resources Expose Addressable Context
- A.12.3 Prompts Package User-Invoked Templates
- A.13 The Agent SDK Is a Harness, Not Permission
- A.13.1 The Framework Did Not Make the Agent Safe
- A.13.2 Model Plus Harness
- A.13.3 Do Not Collapse Four Harness Levels Into "The SDK"
- A.13.4 Start With the Use-Case Gate
- A.13.5 Give the Agent an Environment It Can Understand
- A.13.6 Computer Use Is a Screenshot-Action Verification Loop
- A.13.7 Hooks Make Lifecycle Rules Deterministic
- A.13.8 Hooks Are One Layer
- A.13.9 Subagents Buy Context Isolation
- A.13.10 Skills Package Reusable Procedure
- A.13.11 Sessions Are Continuity, Not Truth
- A.13.12 Long-Running Work Needs Contracts
- A.13.13 Stream Events Into Observability
- A.13.14 Managed Sessions Stop for Actions, Not Only Answers
- A.13.15 A Minimal SDK Shape
- A.13.16 Exam Decision Rules
- A.14 Security Lives Outside the Prompt
- A.14.1 The Document Is Not Your Boss
- A.14.2 Draw the Trust Boundaries
- A.14.3 Threat Model the Real System
- A.14.4 Instructions Do Not Create Isolation
- A.14.5 Keep Secrets Out of Model Context
- A.14.6 Identity Comes From the Session
- A.14.7 Least Privilege by Capability
- A.14.8 Policy Gate Before Tool Handler
- A.14.9 Hooks Enforce Lifecycle Policy
- A.14.10 MCP Expands the Supply Chain
- A.14.11 Output Is Another Attack Surface
- A.14.12 Logging Without Leaking
- A.14.13 Security Evals and Incident Response
- A.14.14 Exam Decision Rules
- A.15 Evals Turn Agent Behavior Into Engineering Evidence
- A.15.1 Output Contract
- A.15.2 Tool Trajectory
- A.15.3 Final State
- A.15.4 Safety
- A.15.5 Operational Budget
- A.16 Claude Code Scales Through Shared Constraints
- A.16.1 Rules
- A.16.2 Skills
- A.16.3 Commands
- A.16.4 Agents
- A.16.5 Goal Sessions
- A.16.6 In-Session Loops and Scheduled Prompts
- A.17 Multi-Agent Orchestration and Delegation
- A.17.1 Decide Why Another Context Exists
- A.17.2 Start With Five Patterns
- A.17.3 Write a Delegation Contract
- A.17.4 Keep Deterministic Sequence Outside the Model
- A.17.5 Use the Task Boundary Deliberately
- A.17.6 Preserve Three Result States
- A.17.7 Merge by Identity and Provenance
- A.17.8 Evaluate the Trajectory
- A.17.9 Define the Final Contract
- A.17.10 Try a Single-Agent Baseline
- A.17.11 Identify Context Boundaries
- A.17.12 Write Task Contracts
- A.17.13 Encode Prerequisites
- A.17.14 Red-Team the Merge
- A.17.15 Agent Per Step
- A.17.16 Parallel by Default
- A.17.17 Coordinator as Data Warehouse
- A.17.18 Reviewer With Generator Context
- A.18 Agent SDK Sessions, Subagents, and Context
- A.18.1 Context Is a Working Set
- A.18.2 Choose Among Four Session Moves
- A.18.3 Use a Structured Resume Packet
- A.18.4 Isolate Subagent Context by Responsibility
- A.18.5 Use Hooks for Deterministic Lifecycle Work
- A.18.6 Make Side Effects Idempotent
- A.18.7 Revalidate at the Boundary
- A.18.8 Plan Context Budgets
- A.18.9 Session 1: Inventory and Plan
- A.18.10 Session 2: Implement and Verify
- A.18.11 Session 3: Independent Review
- A.18.12 Hook Requirements
- A.18.13 Session Equals State
- A.18.14 Compaction Equals Recovery
- A.18.15 Fork Equals Independence
- A.18.16 Hooks Everywhere
- A.19 Tool Contracts, Errors, and Progressive Discovery
- A.19.1 A Tool Description Is Part of the Decision Surface
- A.19.2 Avoid Overlapping Tools
- A.19.3 Make Schemas Carry Invariants
- A.19.4 Return Errors as Data
- A.19.5 Use Tool Choice Deliberately
- A.19.6 Distribute Fewer Tools
- A.19.7 Discover Large Catalogs Progressively
- A.19.8 Scope MCP Configuration
- A.19.9 Choose Claude Code Built-In Tools by Intent
- A.19.10 Tool Description as Authorization
- A.19.11 Error Text as Recovery Policy
- A.19.12 One Tool for Every Operation
- A.19.13 Secrets in Shared Configuration
- A.20 Claude Code Memory, Rules, Skills, and CI
- A.20.1 Match the Mechanism to the Job
- A.20.2 Keep the Root Instruction File Small
- A.20.3 Place Instructions at the Narrowest True Scope
- A.20.4 Import Stable Supporting Guidance
- A.20.5 Use Skills for Progressive Disclosure
- A.20.6 Use Commands for Explicit User Intent
- A.20.7 Use Subagents as Bounded Evidence Gatherers
- A.20.8 Distribute Through the Smallest Shared Surface
- A.20.9 Use Path Rules as Local Policy
- A.20.10 Separate Planning, Exploration, and Execution
- A.20.11 Make Tests Part of the Conversation Contract
- A.20.12 Hook Decisions Need Exact Contracts
- A.20.13 Design Headless CI as a Fresh Reviewer
- A.20.14 Preserve Findings Across Runs
- A.20.15 Root Guidance
- A.20.16 Path Rules
- A.20.17 Skills and Commands
- A.20.18 Hooks
- A.20.19 CI Review
- A.20.20 Root File as Encyclopedia
- A.20.21 Private Configuration as Team Policy
- A.20.22 Hook as Hidden Build System
- A.20.23 AI Review as the Only Gate
- A.21 Reliable Extraction, Batch, and Independent Reviewers
- A.21.1 Define the Judgment Before the Schema
- A.21.2 Use Few-Shot Examples for Boundaries
- A.21.3 Make Absence Representable
- A.21.4 Use Tool Use for Typed Output
- A.21.5 Validate in Four Layers
- A.21.6 Feed Back the Smallest Useful Error
- A.21.7 Separate Generator and Reviewer
- A.21.8 Choose Batch for the Workflow
- A.21.9 Make Batch Jobs Reconciliable
- A.21.10 Evaluate the Error You Care About
- A.21.11 Output Contract
- A.21.12 Dataset
- A.21.13 Passes
- A.21.14 Experiment
- A.21.15 Batch Design
- A.21.16 Schema Equals Truth
- A.21.17 Required Non-Nullable Fields
- A.21.18 Infinite Repair
- A.21.19 Reviewer Rewrites Silently
- A.22 Make Large Context Observable
- A.22.1 Context has an attention topology
- A.22.2 Evidence needs an envelope
- A.22.3 Trim tool output by decision value
- A.22.4 Complete, partial, and blocked are first-class states
- A.22.5 Escalate the reason, not the anxiety
- A.22.6 Large codebases need four different memory tools
- A.22.7 Confidence should be evidence-calibrated
- A.22.8 Human review should be stratified
- A.22.9 Content type changes meaning
- A.22.10 Create the manifest
- A.22.11 Define the context budget
- A.22.12 Normalize tool results
- A.22.13 Add escalation rules
- A.22.14 Calibrate review
- A.22.15 Test rendering
- A.22.16 Exam decision patterns
- A.22.17 Common traps
- A.23 Business Discovery, Requirements, and SLAs
- A.23.1 Start With the Decision, Not the Feature
- A.23.2 Classify Requirements Before Prioritizing Them
- A.23.3 Map the Current Workflow
- A.23.4 Separate Value From Capability
- A.23.5 Turn Risk Into a Review Boundary
- A.23.6 Define SLI, SLO, and SLA Correctly
- A.23.7 Make Non-Goals Explicit
- A.23.8 Prioritize With Cost of Error
- A.23.9 Turning Every Request Into an Agent
- A.23.10 Treating Human Review as Free
- A.23.11 Using Accuracy Without a Denominator
- A.23.12 Ignoring Ownership After Launch
- A.24 End-to-End Architecture and Value Tradeoffs
- A.24.1 Draw the Whole Loop
- A.24.2 Choose the Smallest Pattern That Fits
- A.24.3 Decompose Around Contracts
- A.24.4 Separate Semantic and Deterministic Controls
- A.24.5 Budget Across the Whole Trajectory
- A.24.6 Treat Latency as a Distribution
- A.24.7 Design Feedback as a Product Surface
- A.24.8 Draw Three Candidates
- A.24.9 Score Explicit Tradeoffs
- A.24.10 Write Failure Paths
- A.24.11 Define the Evaluation
- A.24.12 Record Reversal Conditions
- A.24.13 Capability Bloat
- A.24.14 Prompting Around a Missing Contract
- A.24.15 Self-Review as Independence
- A.24.16 Optimizing the Demo Path
- A.25 RAG, Retrieval, and Data Pipelines
- A.25.1 RAG Is a Data System
- A.25.2 Design Chunks Around Meaning and Retrieval
- A.25.3 Match Retrieval to Query and Data Shape
- A.25.4 Separate Retrieval Evaluation From Answer Evaluation
- A.25.5 Preserve Provenance as Data
- A.25.6 Make Refresh Atomic and Observable
- A.25.7 Normalize Tokens
- A.25.8 Chunk With Stable Identity
- A.25.9 Exclude Inactive Sources Before Indexing
- A.25.10 Score Transparently
- A.25.11 Return Provenance
- A.25.12 Evaluate the Retriever
- A.25.13 More Context Means More Grounding
- A.25.14 Similar Means Authoritative
- A.25.15 Valid Citation Means Supported Claim
- A.25.16 Refresh Means Append
- A.26 Integration Protocols, Identity, and Least Privilege
- A.26.1 Choose an Integration Shape From the Boundary
- A.26.2 Separate Discovery, Selection, and Execution
- A.26.3 Propagate Identity, Do Not Replace It
- A.26.4 Use Least Privilege at Four Levels
- A.26.5 Design Approval as a Capability
- A.26.6 Return Structured Errors
- A.26.7 Progressive Discovery Reduces Capability Bloat
- A.26.8 MCP Scopes Do Not Define Business Authorization
- A.26.9 Select a Primary Shape
- A.26.10 Define Principal and Tool Contracts
- A.26.11 Filter Discovery
- A.26.12 Authorize at Execution
- A.26.13 One Service Account for Every User
- A.26.14 Confirmation Without Binding
- A.26.15 Tool Descriptions as Controls
- A.26.16 Retrying Authorization Errors
- A.27 Production Observability, Latency, and Cost
- A.27.1 Observe Four Layers
- A.27.2 Logs, Metrics, and Traces Have Different Jobs
- A.27.3 Trace the Semantic Contract
- A.27.4 Separate System Success From Task Success
- A.27.5 Decompose Latency
- A.27.6 Optimize From Evidence
- A.27.7 Measure Cost Per Successful Outcome
- A.27.8 Understand Prompt Cache Shape
- A.27.9 Build Actionable Alerts
- A.27.10 Use Rollouts to Limit Evidence Risk
- A.27.11 Represent One Task Trajectory
- A.27.12 Aggregate Without Hiding Failure
- A.27.13 Compare Variants
- A.27.14 Evaluate Service Objectives
- A.27.15 Logging Full Prompts by Default
- A.27.16 One Aggregate Quality Score
- A.27.17 Average Latency
- A.27.18 Cost per Call
- A.28 Enterprise Governance, Compliance, and Human Review
- A.28.1 Start With a Risk Decision
- A.28.2 Map Data Through the Whole System
- A.28.3 Minimize Before Protecting
- A.28.4 Build a Control Matrix
- A.28.5 Layer Model and System Guardrails
- A.28.6 Design Human Review as a Control
- A.28.7 Match Review to Risk
- A.28.8 Treat Fairness as a Contextual Requirement
- A.28.9 Provide Transparency and Contestability
- A.28.10 Plan for Change
- A.28.11 Risk Register
- A.28.12 Data Map
- A.28.13 Control Matrix
- A.28.14 Human Review Design
- A.28.15 Approval and Reassessment
- A.28.16 Compliance by Product Name
- A.28.17 Human Review as a Checkbox
- A.28.18 Logging for Audit Without Minimization
- A.28.19 One Fairness Metric
- A.29 Stakeholder Communication, ADRs, and Lifecycle Ownership
- A.29.1 One System Needs Several Views
- A.29.2 Build an Architecture Narrative
- A.29.3 Use Diagrams to Answer One Question
- A.29.4 Record Decisions, Not Meeting Transcripts
- A.29.5 Turn Architecture Into Contracts
- A.29.6 Define Ownership by Decision
- A.29.7 Design Handoff Acceptance
- A.29.8 Plan Adoption as Part of the Workflow
- A.29.9 Communicate Incidents by Impact and Decision
- A.29.10 Keep Lifecycle Evidence Connected
- A.29.11 Executive Decision Brief
- A.29.12 Architecture Decision Record
- A.29.13 Engineering Contract Index
- A.29.14 Operational Readiness Checklist
- A.29.15 Ownership and Change Map
- A.29.16 One Deck for Every Audience
- A.29.17 Architecture as a Launch Artifact
- A.29.18 Ownership by Team Name
- A.29.19 Adoption Equals Value
- A.30 Ship a Week of Work, Not a Perfect Prompt
- A.30.1 The deliverable is a chain of proof
- A.30.2 The Python validator is intentionally limited
- A.30.3 Monday: scope the decision and product surface
- A.30.4 Tuesday: freeze and govern the evidence
- A.30.5 Wednesday: decompose the work
- A.30.6 Thursday: validate and challenge
- A.30.7 Friday: hand off and close the loop
- A.30.8 A complete evidence package
- A.30.9 Capstone decision patterns
- A.30.10 Common traps
- A.31 Ship a Claude Application You Can Defend
- A.31.1 The Deliverable
- A.31.2 Start With Requirements
- A.31.3 Architecture
- A.31.4 Output Contract
- A.31.5 Tool Contract
- A.31.6 Policy Before Execution
- A.31.7 Trace the Decisions, Not the Secrets
- A.31.8 Build and Run
- A.31.9 Replace the Simulator With Claude
- A.31.10 Streaming Decision
- A.31.11 Caching and Batch Decision
- A.31.12 MCP Decision
- A.31.13 Eval Plan
- A.31.14 Runbook
- A.31.15 Architecture Defense
- A.31.16 Definition of Done
- A.31.17 Exam Decision Rules
- A.32 Defend One Architecture Across Six Contexts
- A.32.1 The six contexts are lenses, not templates
- A.32.2 Use a five-gate decision stack
- A.32.3 Architecture quality appears in failure behavior
- A.32.4 Choose one primary lens
- A.32.5 Complete the architecture packet
- A.32.6 Encode the packet as JSON
- A.32.7 Run failure-first tests
- A.32.8 Transfer across all six lenses
- A.32.9 Defend tradeoffs
- A.32.10 Conduct independent review
- A.32.11 Exam scenario method
- A.32.12 Submission evidence
- A.32.13 Common traps
- A.33 Architect Professional System Capstone
- A.33.1 Discovery Brief
- A.33.2 Architecture Options and ADRs
- A.33.3 End-to-End System Views
- A.33.4 Model, Prompt, and Context Plan
- A.33.5 Knowledge and RAG Design
- A.33.6 Integration and Identity Design
- A.33.7 Evaluation and Production Evidence
- A.33.8 Governance and Human Review
- A.33.9 Rollout and Operations
- A.33.10 Stakeholder and Handoff Package
- A.33.11 Encode Requirements
- A.33.12 Encode Decisions
- A.33.13 Encode Controls
- A.33.14 Evaluate Gates
- A.33.15 Make the Release Decision
- A.33.16 A Polished Diagram Without Decisions
- A.33.17 A Long Control List Without Evidence
- A.33.18 An Evaluation With Only Happy Paths
- A.33.19 A Human Review Queue Without Capacity
- A.33.20 A Handoff Without Recovery Proof
- A.34 CCAO-F: Claude Certified Associate - Foundations
- A.34.1 Prompting and Task Execution (14%)
- A.34.2 Output Evaluation and Validation (21%)
- A.34.3 Product and Model Selection (12%)
- A.34.4 Workflow Integration and Solution Design (16%)
- A.34.5 Configuration and Knowledge Management (12%)
- A.34.6 Governance, Risk, and Responsible Use (15%)
- A.34.7 Troubleshooting and Optimization (10%)
- A.35 CCAO-F diagnostic: Associate Foundations Diagnostic
- A.35.1 Prompting and Task Execution: 2 questions
- A.35.2 Output Evaluation and Validation: 2 questions
- A.35.3 Product and Model Selection: 2 questions
- A.35.4 Workflow Integration and Solution Design: 2 questions
- A.35.5 Configuration and Knowledge Management: 2 questions
- A.35.6 Governance, Risk, and Responsible Use: 2 questions
- A.35.7 Troubleshooting and Optimization: 2 questions
- A.36 CCAO-F mock: Associate Foundations Full Mock
- A.36.1 Prompting and Task Execution: 8 questions
- A.36.2 Output Evaluation and Validation: 13 questions
- A.36.3 Product and Model Selection: 7 questions
- A.36.4 Workflow Integration and Solution Design: 10 questions
- A.36.5 Configuration and Knowledge Management: 7 questions
- A.36.6 Governance, Risk, and Responsible Use: 9 questions
- A.36.7 Troubleshooting and Optimization: 6 questions
- A.37 CCAR-F: Claude Certified Architect - Foundations
- A.37.1 Agentic Architecture and Orchestration (27%)
- A.37.2 Tool Design and MCP Integration (18%)
- A.37.3 Claude Code Configuration and Workflows (20%)
- A.37.4 Prompt Engineering and Structured Output (20%)
- A.37.5 Context Management and Reliability (15%)
- A.38 CCAR-F diagnostic: Architect Foundations Diagnostic
- A.38.1 Agentic Architecture and Orchestration: 4 questions
- A.38.2 Tool Design and MCP Integration: 3 questions
- A.38.3 Claude Code Configuration and Workflows: 3 questions
- A.38.4 Prompt Engineering and Structured Output: 3 questions
- A.38.5 Context Management and Reliability: 2 questions
- A.39 CCAR-F mock: Architect Foundations Scenario Mock
- A.39.1 Agentic Architecture and Orchestration: 16 questions
- A.39.2 Tool Design and MCP Integration: 11 questions
- A.39.3 Prompt Engineering and Structured Output: 12 questions
- A.39.4 Context Management and Reliability: 9 questions
- A.39.5 Claude Code Configuration and Workflows: 12 questions
- A.40 CCAR-P: Claude Certified Architect - Professional
- A.40.1 Solution Design and Architecture (17%)
- A.40.2 Claude Models, Prompting and Context Engineering (13%)
- A.40.3 Integration (19%)
- A.40.4 Evaluation, Testing and Optimization (16%)
- A.40.5 Governance, Safety and Risk Management (14%)
- A.40.6 Stakeholder Communication and Lifecycle Management (14%)
- A.40.7 Developer Productivity and Operational Enablement (7%)
- A.41 CCAR-P diagnostic: Architect Professional Diagnostic
- A.41.1 Solution Design and Architecture: 2 questions
- A.41.2 Claude Models, Prompting and Context Engineering: 2 questions
- A.41.3 Integration: 2 questions
- A.41.4 Evaluation, Testing and Optimization: 2 questions
- A.41.5 Governance, Safety and Risk Management: 2 questions
- A.41.6 Stakeholder Communication and Lifecycle Management: 2 questions
- A.41.7 Developer Productivity and Operational Enablement: 2 questions
- A.42 CCAR-P mock: Architect Professional Full Mock
- A.42.1 Solution Design and Architecture: 11 questions
- A.42.2 Claude Models, Prompting and Context Engineering: 8 questions
- A.42.3 Integration: 12 questions
- A.42.4 Evaluation, Testing and Optimization: 10 questions
- A.42.5 Governance, Safety and Risk Management: 9 questions
- A.42.6 Stakeholder Communication and Lifecycle Management: 9 questions
- A.42.7 Developer Productivity and Operational Enablement: 4 questions
- A.43 CCDV-F: Claude Certified Developer - Foundations
- A.43.1 Agents and Workflows (14.7%)
- A.43.2 Applications and Integration (33.1%)
- A.43.3 Claude Code (3.1%)
- A.43.4 Eval, Testing, and Debugging (2.6%)
- A.43.5 Model Selection and Optimization (16.8%)
- A.43.6 Prompt and Context Engineering (11.0%)
- A.43.7 Security and Safety (8.1%)
- A.43.8 Tools and MCPs (10.6%)
- A.44 CCDV-F diagnostic: Developer Foundations Diagnostic
- A.44.1 Agents and Workflows: 2 questions
- A.44.2 Applications and Integration: 4 questions
- A.44.3 Claude Code: 1 questions
- A.44.4 Eval, Testing, and Debugging: 1 questions
- A.44.5 Model Selection and Optimization: 3 questions
- A.44.6 Prompt and Context Engineering: 2 questions
- A.44.7 Security and Safety: 1 questions
- A.44.8 Tools and MCPs: 2 questions
- A.45 CCDV-F mock: Developer Foundations Full Mock
- A.45.1 Agents and Workflows: 8 questions
- A.45.2 Applications and Integration: 17 questions
- A.45.3 Claude Code: 2 questions
- A.45.4 Eval, Testing, and Debugging: 1 questions
- A.45.5 Model Selection and Optimization: 9 questions
- A.45.6 Prompt and Context Engineering: 6 questions
- A.45.7 Security and Safety: 4 questions
- A.45.8 Tools and MCPs: 6 questions
- BMCP Associate certification prepnot yet
- B.1 The MCPA Blueprint Is a Study Budget, Not a Checklist
- B.1.1 Reading a question: catching a legacy-era distractor
- B.1.2 The route: 34 lessons across five domains
- B.1.3 Blueprint
- B.1.4 Domain weight
- B.1.5 Study-hours budget
- B.1.6 Readiness estimate
- B.1.7 Unpublished fact
- B.1.8 Legacy-era distractor
- B.1.9 Route
- B.2 Reading the MCP Specification
- B.2.1 Base protocol
- B.2.2 BCP 14
- B.2.3 schema.ts
- B.2.4 Current revision
- B.2.5 Draft, Current, Final
- B.2.6 Active
- B.2.7 Deprecated
- B.2.8 Removed
- B.2.9 Earliest removal
- B.2.10 SEP
- B.3 The Integration Problem MCP Solves
- B.3.1 Host
- B.3.2 Client
- B.3.3 Server
- B.3.4 Tool
- B.3.5 Resource
- B.3.6 Prompt
- B.3.7 _meta
- B.3.8 resultType
- B.3.9 Protocol error
- B.3.10 Tool execution error
- B.4 The JSON-RPC Envelope
- B.4.1 Request
- B.4.2 Notification
- B.4.3 Result response
- B.4.4 Error response
- B.4.5 resultType
- B.4.6 _meta
- B.4.7 Reserved prefix
- B.4.8 protocolVersion
- B.4.9 clientCapabilities
- B.4.10 Self-reported field
- B.5 The Stateless Core of MCP
- B.5.1 Statelessness
- B.5.2 Connection
- B.5.3 Replica
- B.5.4 Server-minted handle
- B.5.5 Shared store
- B.5.6 Tool execution error
- B.5.7 Mcp-Session-Id
- B.6 Telling a Modern MCP Server From a Legacy One
- B.6.1 Modern
- B.6.2 Legacy
- B.6.3 Dual-era
- B.6.4 initialize (legacy)
- B.6.5 server/discover
- B.6.6 DiscoverResult
- B.6.7 UnsupportedProtocolVersionError
- B.6.8 Era caching
- B.6.9 Compatibility matrix
- B.6.10 400 body inspection
- B.6.11 Modern-only rejection
- B.7 Hosts, Clients, and Servers: MCP's Process Topology
- B.7.1 Host
- B.7.2 Client
- B.7.3 Server
- B.7.4 Local server
- B.7.5 Remote server
- B.7.6 Control model
- B.7.7 Elicitation
- B.7.8 serverInfo.name
- B.7.9 Server-id prefix
- B.8 Discovering a Server and Negotiating What It Can Do
- B.8.1 server/discover
- B.8.2 DiscoverResult
- B.8.3 ServerCapabilities
- B.8.4 ClientCapabilities
- B.8.5 serverInfo
- B.8.6 MissingRequiredClientCapabilityError
- B.8.7 UnsupportedProtocolVersionError
- B.8.8 Per-request negotiation
- B.9 The Contract Inside a Tool Definition
- B.9.1 inputSchema
- B.9.2 outputSchema
- B.9.3 structuredContent
- B.9.4 additionalProperties
- B.9.5 $ref
- B.9.6 Tool execution error
- B.9.7 Protocol error
- B.9.8 Tool naming rules
- B.10 Reading a Server Manifest Like a Reviewer
- B.10.1 Manifest
- B.10.2 Annotation defaults
- B.10.3 x-mcp-header
- B.10.4 cacheScope
- B.10.5 instructions
- B.10.6 Reverse-DNS namespace
- B.10.7 Red flag
- B.10.8 Ownership verification
- B.11 The Model Interaction Flow
- B.11.1 Model context
- B.11.2 Confirmation gate
- B.11.3 Tool execution error
- B.11.4 input_required
- B.11.5 Protocol error
- B.11.6 Deterministic ordering
- B.11.7 requestState
- B.11.8 Annotation defaults
- B.12 The Tools Primitive: Calling Actions and Reading Their Results
- B.12.1 Tool
- B.12.2 tools/list
- B.12.3 tools/call
- B.12.4 CallToolResult
- B.12.5 Content block
- B.12.6 resource_link
- B.12.7 Content annotations
- B.12.8 Tool annotations
- B.12.9 nextCursor
- B.12.10 subscriptions/listen
- B.13 Resources: Addressable Content for a Stateless Server
- B.13.1 Resource
- B.13.2 resources/list
- B.13.3 resources/templates/list
- B.13.4 resources/read
- B.13.5 Text content
- B.13.6 Binary content
- B.13.7 -32602
- B.13.8 ttlMs
- B.13.9 cacheScope
- B.13.10 subscriptions/listen
- B.14 Prompt Templates and Argument Completion
- B.14.1 Prompt
- B.14.2 prompts/list
- B.14.3 prompts/get
- B.14.4 PromptMessage
- B.14.5 resource_link
- B.14.6 completion/complete
- B.14.7 ref/prompt
- B.14.8 ref/resource
- B.14.9 context.arguments
- B.14.10 hasMore
- B.15 Multi Round-Trip Requests and Elicitation
- B.15.1 MRTR
- B.15.2 InputRequiredResult
- B.15.3 inputRequests
- B.15.4 inputResponses
- B.15.5 requestState
- B.15.6 Form mode elicitation
- B.15.7 URL mode elicitation
- B.15.8 ElicitResult action
- B.15.9 Principal binding
- B.15.10 Single use enforcement
- B.16 Deprecated, Not Removed: Roots, Sampling, and Logging
- B.16.1 Active
- B.16.2 Deprecated
- B.16.3 Removed
- B.16.4 Earliest removal
- B.16.5 Roots
- B.16.6 Sampling
- B.16.7 io.modelcontextprotocol/logLevel
- B.16.8 notifications/message
- B.16.9 logging/setLevel
- B.16.10 SEP-2577
- B.17 The Subscription Stream: Notifications, Progress, and Cancellation
- B.17.1 Notification
- B.17.2 subscriptions/listen
- B.17.3 Subscription id
- B.17.4 Stream notification
- B.17.5 Request scoped notification
- B.17.6 progressToken
- B.17.7 Graceful closure
- B.17.8 notifications/cancelled
- B.18 The Tool Invocation Lifecycle
- B.18.1 Checkpoint
- B.18.2 Validate
- B.18.3 Execute
- B.18.4 Protocol error
- B.18.5 Tool execution error
- B.18.6 Retry
- B.18.7 Reissue
- B.18.8 idempotentHint
- B.19 Two Ways for a Request to Fail
- B.19.1 Protocol error
- B.19.2 Tool execution error
- B.19.3 Allocation policy
- B.19.4 HeaderMismatch
- B.19.5 MissingRequiredClientCapabilityError
- B.19.6 UnsupportedProtocolVersionError
- B.19.7 Retired code
- B.19.8 safe_error
- B.20 Transports and the HTTP Header Contract
- B.20.1 stdio: a subprocess sharing three streams
- B.20.2 Streamable HTTP: one endpoint, one message per POST
- B.20.3 The header mirror and its contract
- B.21 Cache Freshness and Cursor-Based Pagination
- B.21.1 CacheableResult
- B.21.2 ttlMs
- B.21.3 cacheScope
- B.21.4 Cache key
- B.21.5 Cursor
- B.21.6 nextCursor
- B.21.7 list_changed notification
- B.21.8 MRTR retried result
- B.22 Long-Running Work and the Tasks Extension
- B.22.1 io.modelcontextprotocol/tasks
- B.22.2 CreateTaskResult
- B.22.3 tasks/get
- B.22.4 tasks/update
- B.22.5 tasks/cancel
- B.22.6 input_required
- B.22.7 pollIntervalMs
- B.22.8 ttlMs
- B.22.9 Durable before return
- B.22.10 Cooperative cancellation
- B.23 Trust Zones in an MCP Exchange
- B.23.1 Trust zone
- B.23.2 Trust boundary
- B.23.3 Self-reported identity
- B.23.4 Multi-server isolation
- B.23.5 Untrusted annotation
- B.24 Authorizing Access to an MCP Server
- B.24.1 Resource server
- B.24.2 Authorization server
- B.24.3 Protected Resource Metadata
- B.24.4 PKCE
- B.24.5 S256
- B.24.6 Resource indicator
- B.24.7 iss validation
- B.24.8 Audience validation
- B.24.9 Token passthrough
- B.24.10 401 vs 403 vs 400
- B.25 Proving a Client's Identity to an Authorization Server
- B.25.1 Client registration
- B.25.2 Client ID Metadata Document (CIMD)
- B.25.3 Dynamic Client Registration (DCR)
- B.25.4 Pre-registration
- B.25.5 Authorization server binding
- B.25.6 application_type
- B.25.7 Confused deputy
- B.25.8 Authorization extension
- B.26 Consent and Least Privilege
- B.26.1 Asking without a session: elicitation over MRTR
- B.26.2 Scoping consent to one tool, not one server
- B.26.3 Step-up authorization: a different gate, one level down
- B.26.4 Least privilege in what a server admits it has
- B.27 Risk and Safety Controls for MCP Tool Calls
- B.27.1 Metadata poisoning
- B.27.2 Rug pull
- B.27.3 Definition pinning
- B.27.4 Tool shadowing
- B.27.5 Confused deputy
- B.27.6 Token passthrough
- B.27.7 requestState tampering
- B.27.8 SSRF
- B.27.9 DNS rebinding
- B.27.10 Supply chain drift
- B.28 One Trace ID Ties Auditability to Observability
- B.28.1 traceparent
- B.28.2 Trace id
- B.28.3 Parent id
- B.28.4 tracestate
- B.28.5 baggage
- B.28.6 Principal
- B.28.7 Redaction
- B.28.8 Hash chain
- B.28.9 Result channel
- B.28.10 Correlation
- B.29 Every MUST Needs an Owner
- B.29.1 Server author
- B.29.2 Host and client developer
- B.29.3 Platform or gateway operator
- B.29.4 Security and governance owner
- B.29.5 Registry publisher
- B.29.6 End user
- B.29.7 Working Group
- B.29.8 Interest Group
- B.29.9 SEP
- B.29.10 SDK tier
- B.30 Choosing MCP's Shape for the Job
- B.30.1 Operational use case
- B.30.2 Control split
- B.30.3 Tasks extension
- B.30.4 MCP Apps
- B.30.5 Skills over MCP
- B.30.6 Authorization extension
- B.30.7 cacheScope
- B.30.8 Graceful degradation
- B.31 The Extensions Framework
- B.31.1 Extension
- B.31.2 Vendor prefix
- B.31.3 Settings object
- B.31.4 Active extension set
- B.31.5 Graceful degradation
- B.31.6 MissingRequiredClientCapabilityError
- B.31.7 Extension repository
- B.31.8 Experimental extension
- B.32 Interactive Interfaces Inside the Conversation
- B.32.1 MCP Apps
- B.32.2 io.modelcontextprotocol/ui
- B.32.3 ui://
- B.32.4 _meta.ui.resourceUri
- B.32.5 text/html;profile=mcp-app
- B.32.6 _meta.ui.csp
- B.32.7 _meta.ui.permissions
- B.32.8 visibility
- B.32.9 Sandboxed iframe
- B.32.10 Sandbox proxy
- B.32.11 App-to-host bridge
- B.32.12 Text fallback
- B.33 Finding, Routing To, and Trusting a Server
- B.33.1 The registry: metadata, not code
- B.33.2 Gateways: routing on the wire, not on trust
- B.33.3 SDK tiers: a portability signal, not a scan
- B.34 Reading One MCP Exchange End to End
- B.34.1 Protocol error
- B.34.2 Tool execution error
- B.34.3 MissingRequiredClientCapability
- B.34.4 MRTR
- B.34.5 requestState
- B.34.6 Tasks extension
- B.34.7 Canonical resource URI
- B.34.8 traceparent
- B.34.9 Hash chained audit log
- B.35 MCPA: Model Context Protocol Associate
- B.35.1 MCP Fundamentals (16%)
- B.35.2 Architecture and Components (14%)
- B.35.3 Interactions and Execution (26%)
- B.35.4 Security and Governance (24%)
- B.35.5 Use Cases and Ecosystem (20%)
- B.36 MCPA diagnostic: MCPA Foundations Diagnostic
- B.36.1 MCP Fundamentals: 5 questions
- B.36.2 Architecture and Components: 4 questions
- B.36.3 Interactions and Execution: 8 questions
- B.36.4 Security and Governance: 7 questions
- B.36.5 Use Cases and Ecosystem: 6 questions
- B.37 MCPA mock: MCPA Full-Length Mock 1: Operational Scenarios
- B.37.1 MCP Fundamentals: 10 questions
- B.37.2 Architecture and Components: 8 questions
- B.37.3 Interactions and Execution: 16 questions
- B.37.4 Security and Governance: 14 questions
- B.37.5 Use Cases and Ecosystem: 12 questions
- B.38 MCPA mock: MCPA Full-Length Mock 2: Wire-Level Messages
- B.38.1 MCP Fundamentals: 10 questions
- B.38.2 Architecture and Components: 8 questions
- B.38.3 Interactions and Execution: 16 questions
- B.38.4 Security and Governance: 14 questions
- B.38.5 Use Cases and Ecosystem: 12 questions
- B.39 MCPA mock: MCPA Full-Length Mock 3: Design and Security Trade-offs
- B.39.1 MCP Fundamentals: 10 questions
- B.39.2 Architecture and Components: 8 questions
- B.39.3 Interactions and Execution: 16 questions
- B.39.4 Security and Governance: 14 questions
- B.39.5 Use Cases and Ecosystem: 12 questions
- CThe manualsnot yet
- C.1 A2A 101
- C.1.1 1.1 What A2A standardizes
- C.1.2 1.2 One task, request by request
- C.1.3 2.1 AgentCard fields
- C.1.4 2.2 Discovery and supportedInterfaces
- C.1.5 2.3 Extended cards and signatures
- C.1.6 3.1 Message
- C.1.7 3.2 Part
- C.1.8 3.3 Artifact and chunks
- C.1.9 3.4 Task, TaskStatus, and TaskState
- C.1.10 3.5 contextId
- C.1.11 4.1 SendMessage
- C.1.12 4.2 Interrupted states: INPUT_REQUIRED and AUTH_REQUIRED
- C.1.13 4.3 GetTask and ListTasks
- C.1.14 4.4 CancelTask and terminal states
- C.1.15 4.5 SendStreamingMessage and SubscribeToTask
- C.1.16 4.6 Push notification configs
- C.1.17 5.1 JSON-RPC
- C.1.18 5.2 HTTP+JSON
- C.1.19 5.3 gRPC
- C.1.20 5.4 A2A-Version and A2A-Extensions
- C.1.21 5.5 Errors
- C.1.22 6.1 Security schemes and in-task authorization
- C.1.23 6.2 Extensions
- C.1.24 6.3 Security requirements
- C.1.25 7.1 A client
- C.1.26 7.2 A server
- C.1.27 7.3 Conformance testing
- C.1.28 7.4 From 0.3 to 1.0
- C.1.29 R.1 Operations by binding
- C.1.30 R.2 Objects and fields
- C.1.31 R.3 Task states
- C.1.32 R.4 Errors
- C.1.33 R.5 Glossary
- C.1.34 R.6 Sources
- C.1.35 R.7 Index of figures
- C.2 Docker Sandboxes and Docker Agent 101
- C.2.1 1.1 sbx and docker-agent
- C.2.2 1.2 docker-agent run --sandbox, one run end to end
- C.2.3 2.1 sbx run, sbx create, sbx stop, and sbx rm
- C.2.4 2.2 sbx exec, sbx cp, and sbx ports
- C.2.5 2.3 sbx template save and sbx template load
- C.2.6 2.4 sandboxd, sbx diagnose, and sbx reset
- C.2.7 2.5 sbx settings list
- C.2.8 3.1 sbx diagnose and the microVM boundary
- C.2.9 3.2 --clone and /run/sandbox/source
- C.2.10 3.3 sbx policy init, allow network, deny network, and check network
- C.2.11 3.4 sbx policy log and the proxy
- C.2.12 3.5 sbx secret set, sbx secret import, and sbx secret set-custom
- C.2.13 3.6 sbx mcp add, sbx mcp load, and --static-mcp
- C.2.14 4.1 `# syntax=docker/sandbox-kit:3` and kit.yaml
- C.2.15 4.2 `com.docker.sandbox/*` capabilities
- C.2.16 4.3 `sbx kit pack`, `sbx kit push --sign`, and `sbx kit verify`
- C.2.17 4.4 sbxenv.yaml and `sbx env plan`
- C.2.18 4.5 `sbx skills add` and `skills: true`
- C.2.19 5.1 docker-agent run, new, and doctor
- C.2.20 5.2 agents, models, and providers
- C.2.21 5.3 toolsets and mcps
- C.2.22 5.4 sub_agents, transfer_task, and background_agents
- C.2.23 5.5 permissions, --safety, and hooks
- C.2.24 5.6 session.db, sessions diff, and eval
- C.2.25 6.1 serve api and serve chat
- C.2.26 6.2 serve mcp and serve acp
- C.2.27 6.3 serve a2a
- C.2.28 6.4 share push and share pull
- C.2.29 6.5 DMR, Compose models, and the docker/mcp-gateway service
- C.2.30 7.1 sbx --cloud run, sbx move, and sbx ttl
- C.2.31 7.2 sbx policy ls --source org, --profile, and the audit JSONL
- C.2.32 7.3 From docker sandbox and cagent to sbx and docker-agent
- C.2.33 7.4 kit-tck, sbx diagnose, and the claims this manual checked
- C.2.34 R.1 sbx commands
- C.2.35 R.2 docker-agent commands
- C.2.36 R.3 Settings keys, environment variables, and paths
- C.2.37 R.4 Agent file keys
- C.2.38 R.5 Toolsets
- C.2.39 R.6 Providers and models
- C.2.40 R.7 Sources and the conflicts register
- C.2.41 R.8 Glossary and index of figures
- C.3 Miles 101
- C.3.1 1.1 Run GRPO on one GPU with the radixark/miles image
- C.3.2 1.2 Add a watchdog before you leave a run alone
- C.3.3 1.3 Read your first ten steps
- C.3.4 2.1 Pick a model size for one GPU
- C.3.5 2.2 Choose what to offload between phases
- C.3.6 2.3 Stop Ray from killing the job on unified memory
- C.3.7 2.4 Size the weight update
- C.3.8 3.1 Train math reasoning on GSM8K
- C.3.9 3.2 Train with the DAPO filter
- C.3.10 3.3 Train an agent with tool calls and many turns
- C.3.11 3.4 Train a mixture-of-experts model with routing replay
- C.3.12 3.5 Write a custom reward function
- C.3.13 4.1 Run rollout and training at the same time
- C.3.14 4.2 Handle long responses with partial rollout
- C.3.15 4.3 Roll out in FP8 and train in BF16
- C.3.16 4.4 Lower the log probability gap with top-p and top-k
- C.3.17 4.5 Know what deterministic inference fixes
- C.3.18 4.6 Check if your GPU can run true on-policy mode
- C.3.19 5.1 Read the run from its signals
- C.3.20 5.2 Check the first step before you trust the run
- C.3.21 5.3 Repeat a run and compare
- C.3.22 6.1 Split rollout and training across GPUs
- C.3.23 6.2 Run evaluation without stopping training
- C.3.24 6.3 Keep a long run going after a failure
- C.3.25 6.4 Pick an image for your GPU
- C.3.26 7.1 Troubleshoot by symptom
- C.3.27 7.2 Keep runs comparable
- C.3.28 8.1 Why an RL framework owns an inference engine
- C.3.29 8.2 The correction methods for the gap
- C.3.30 8.3 Why true on-policy mode is a contract
- C.3.31 8.4 Memory and weight updates on unified memory
- C.3.32 8.5 How rollout functions plug in
- C.3.33 8.6 Which router to use
- C.3.34 8.7 Where Miles came from
- C.3.35 R.1 Flags by job
- C.3.36 R.2 Metrics
- C.3.37 R.3 Lab notes
- C.3.38 R.4 Sources
- C.3.39 R.5 Index of figures
- C.4 Reverse Engineering 101
- C.4.1 1.1 rea, providers, and Evidence
- C.4.2 1.2 rea function, end to end
- C.4.3 2.1 The README use rule and the law
- C.4.4 2.2 rea doctor and the Ghidra provider
- C.4.5 2.3 rea capabilities
- C.4.6 3.1 inspect-artifact
- C.4.7 3.2 inspect-binary-layout and the load image
- C.4.8 3.3 address-to-file-offset
- C.4.9 3.4 analyze and the binary_overview record
- C.4.10 4.1 open_binary and the headless bridge
- C.4.11 4.2 list_procedures and function bodies
- C.4.12 4.3 procedure_assembly
- C.4.13 4.4 xrefs and the jump table
- C.4.14 4.5 list_strings
- C.4.15 4.6 analyze_function and pseudocode
- C.4.16 5.1 The Evidence record
- C.4.17 5.2 ResidualUnknown, record_unknown, and coverage
- C.4.18 5.3 AnalysisSnapshot and the exact-match answer cache
- C.4.19 5.4 export_evidence_bundle, evidence-export, and evidence-import
- C.4.20 5.5 compare_functions and rea compare
- C.4.21 6.1 analyze-javascript-application and the application graph
- C.4.22 6.2 inspect-wasm-artifact and the WABT provider
- C.4.23 7.1 verify_reconstruction
- C.4.24 7.2 A proof harness beyond compare_functions
- C.4.25 8.1 rea mcp: initialize, tools/list, and the startup deadline
- C.4.26 8.2 One agent investigation over list_procedures, analyze_function, and list_strings
- C.4.27 R.1 Commands and tools used in this manual
- C.4.28 R.2 Evidence fields
- C.4.29 R.3 Errors seen in the captures
- C.4.30 R.4 Glossary
- C.4.31 R.5 Sources
- C.4.32 R.6 Index of figures
- C.5 SGLang 101
- C.5.1 1.1 Install SGLang and serve your first model
- C.5.2 1.2 Check that the server is healthy
- C.5.3 1.3 What the server does with your request
- C.5.4 2.1 sglang serve and the three processes
- C.5.5 2.2 The scheduler loop and --schedule-policy
- C.5.6 2.3 Admission and retraction
- C.5.7 2.4 The overlap scheduler
- C.5.8 2.5 Streaming, stop strings, and the OpenAI API
- C.5.9 3.1 The KV pool and bytes per token
- C.5.10 3.2 --mem-fraction-static and startup sizing
- C.5.11 3.3 RadixCache
- C.5.12 3.4 Prefix-friendly prompts
- C.5.13 3.5 Eviction policies and HiCache
- C.5.14 3.6 Hybrid models and the cache
- C.5.15 4.1 ForwardMode and CUDA graphs
- C.5.16 4.2 --attention-backend
- C.5.17 4.3 --quantization and --kv-cache-dtype
- C.5.18 4.4 --speculative-algorithm
- C.5.19 4.5 --grammar-backend and structured outputs
- C.5.20 4.6 --enable-deterministic-inference and logprobs
- C.5.21 5.1 sglang.benchmark.serving
- C.5.22 5.2 The /metrics endpoint
- C.5.23 5.3 Reading other people's SGLang benchmarks
- C.5.24 6.1 --tp-size, --dp-size, and --attn-dp-size
- C.5.25 6.2 MoE serving: --moe-a2a-backend, DeepEP, and EPLB
- C.5.26 6.3 Prefill-decode disaggregation: --disaggregation-mode
- C.5.27 6.4 sgl-model-gateway and cache-aware routing
- C.5.28 7.1 Operating SGLang
- C.5.29 7.2 SGLang as an RL rollout engine
- C.5.30 R.1 Flags and defaults
- C.5.31 R.2 Metrics
- C.5.32 R.3 Incident index
- C.5.33 R.4 Glossary
- C.5.34 R.5 Sources
- C.5.35 R.6 Index of figures
- C.5.36 R.7 How this manual was made
- C.6 vLLM 101
- C.6.1 1.1 Install vLLM and serve your first model
- C.6.2 1.2 Check that the server is healthy
- C.6.3 1.3 Understand what happens to your request
- C.6.4 1.4 Set the server options every deployment needs
- C.6.5 2.1 Count the memory before you pick a GPU
- C.6.6 2.2 Fix out of memory at startup
- C.6.7 2.3 Size memory on a DGX Spark
- C.6.8 2.4 Fit more users with an FP8 KV cache
- C.6.9 2.5 Fit a bigger model with FP8 weights
- C.6.10 2.6 Serve long contexts and hybrid models
- C.6.11 3.1 Tune chat for many users
- C.6.12 3.2 Make repeated prompts hit the prefix cache
- C.6.13 3.3 Keep long prompts from stalling short ones
- C.6.14 3.4 Keep long sessions cheap
- C.6.15 3.5 Return valid JSON and tool calls
- C.6.16 3.6 Run batch and offline jobs
- C.6.17 3.7 Serve many fine-tunes with multi-LoRA
- C.6.18 3.8 Get reproducible outputs
- C.6.19 3.9 Use vLLM as an RL rollout engine
- C.6.20 3.10 Serve reasoning models
- C.6.21 4.1 Speed up decode with EAGLE3
- C.6.22 4.2 Use n-gram speculation for copy-heavy work
- C.6.23 4.3 Keep CUDA graphs and compile on
- C.6.24 4.4 Leave async scheduling on
- C.6.25 4.5 Change the attention backend only for a reason
- C.6.26 5.1 Benchmark your server in 15 minutes
- C.6.27 5.2 Watch vLLM in production
- C.6.28 5.3 Decide between vLLM and SGLang
- C.6.29 6.1 Choose tensor, pipeline, or data parallelism
- C.6.30 6.2 Serve MoE models with expert parallelism
- C.6.31 6.3 Split prefill and decode
- C.6.32 6.4 Run vLLM on Kubernetes
- C.6.33 6.5 Run vLLM on other accelerators
- C.6.34 7.1 Troubleshoot by symptom
- C.6.35 7.2 Run vLLM in production
- C.6.36 8.1 Why vLLM runs three kinds of process
- C.6.37 8.2 Why one token budget replaces a prefill phase
- C.6.38 8.3 How the block pool manages KV memory
- C.6.39 8.4 How vLLM picks an attention backend
- C.6.40 8.5 What Model Runner V2 changed
- C.6.41 8.6 How compile and CUDA graphs are captured
- C.6.42 8.7 How speculative decoding checks drafts
- C.6.43 8.8 How KV connectors move the cache
- C.6.44 8.9 Where vLLM came from
- C.6.45 R.1 Flags and defaults
- C.6.46 R.2 Metrics
- C.6.47 R.3 Incident index
- C.6.48 R.4 Version pins
- C.6.49 R.5 Glossary
- C.6.50 R.6 Sources
- C.6.51 R.7 Lab notes
- C.6.52 R.8 Index of figures
- DInteractive explainersnot yet
- D.1 Inside an AI Agent
- D.1.1 Intake hopper
- D.1.2 Memory drum
- D.1.3 Filing cabinet and pick head
- D.1.4 Sealed model housing
- D.1.5 Tool bay
- D.1.6 Verifier gauge
- D.1.7 Exit latch and output tray
- D.1.8 Trace printer
- D.1.9 Runtime controller
- D.1.10 Card carriage
- D.1.11 Try to break it: Healthy run
- D.1.12 Try to break it: No retrieval
- D.1.13 Try to break it: No retrieval, no verifier
- D.1.14 Try to break it: Tool times out once
- D.1.15 Try to break it: Tool always times out
- D.1.16 Try to break it: Timeouts and no verifier
- D.1.17 Try to break it: Malformed tool call
- D.1.18 Try to break it: Tool access denied
- D.1.19 Tour: One request, one bench
- D.1.20 Tour: The model only proposes
- D.1.21 Tour: Tools pass two checks first
- D.1.22 Tour: Take away the documents
- D.1.23 Tour: Turn off the check
- D.1.24 Tour: Put the check back
- D.2 Inside a Decompiler
- D.2.1 ELF file card
- D.2.2 Section cabinet and symbol index
- D.2.3 Decoder chip and output bed
- D.2.4 Routing board and drop bin
- D.2.5 Lift press and IR stack
- D.2.6 Register and stack slots
- D.2.7 Structuring jig
- D.2.8 Pseudocode printer
- D.2.9 Evidence ledger
- D.2.10 Analysis carriage
- D.2.11 Try to break it: Healthy run
- D.2.12 Try to break it: Unoptimized build
- D.2.13 Try to break it: Strip the symbols
- D.2.14 Try to break it: Linear sweep at -O0
- D.2.15 Try to break it: Linear sweep, no symbols
- D.2.16 Try to break it: Data in code, linear sweep
- D.2.17 Try to break it: Data in code, descent
- D.2.18 Tour: Read the header
- D.2.19 Tour: Open the sections
- D.2.20 Tour: Decode the bytes
- D.2.21 Tour: Join the blocks
- D.2.22 Tour: Drop dead blocks
- D.2.23 Tour: Lift to plain steps
- D.2.24 Tour: Or stop and refuse
- D.2.25 Tour: Find the types
- D.2.26 Tour: Find the if
- D.2.27 Tour: Print the code
- D.2.28 Tour: Sort the evidence
- D.3 Inside an LLM Serving GPU
- D.3.1 Network port
- D.3.2 Tokenizer process
- D.3.3 Scheduler process
- D.3.4 PCIe Gen4 x16 slot and riser (L4) or NVLink-C2C (GB10)
- D.3.5 SMs wait for weights). Lesson
- D.3.6 so each decode step streams weights from GDDR6 again; GB10 has 24 MB. Weights are used once per step and are far larger than the cache. Manual section 4.1. - 07 WEIGHTS, Weights in GDDR6 or LPDDR5X
- D.3.7 sized at startup from the memory fraction and counted in tokens; cell colours mark this request, other requests, reused prefix and free. Without it every step recomputes keys and values for the whole conversation. Manual section 3.1, KV bytes per token and the KV pool. - 09 DETOKENIZER
- D.3.8 substrate, die and balls (L4) or two dielets on one substrate (GB10)
- D.3.9 Passive heatsink (L4, 72 W, server fans push air) or GB10 (140 W TDP)
- D.3.10 Try to break it: Healthy L4
- D.3.11 Try to break it: One user
- D.3.12 Try to break it: Pool full
- D.3.13 Try to break it: FP8 at 64 users
- D.3.14 Try to break it: Small pool, long prefix
- D.3.15 Try to break it: Same, with FP8
- D.3.16 Try to break it: Radix cache off
- D.3.17 Try to break it: CUDA graphs off
- D.3.18 Try to break it: Hot card
- D.3.19 Try to break it: GB10, one user
- D.3.20 Try to break it: GB10 with FP8
- D.3.21 Try to break it: Break button notes
- D.3.22 Tour: Prompt in
- D.3.23 Tour: Words to numbers
- D.3.24 Tour: Find room
- D.3.25 Tour: Send to the GPU
- D.3.26 Tour: Read the prompt
- D.3.27 Tour: Write the answer
- D.3.28 Tour: Send it back
- EPractice drillsnot yet
- E.1 Math foundations
- E.1.1 Linear regression by gradient descent
- E.1.2 Vectorized pairwise distances
- E.1.3 Power iteration for the top eigenpair
- E.2 Classical ML
- E.2.1 Gini impurity and the best split
- E.2.2 Linear regression by gradient descent
- E.2.3 K-means assignment and update
- E.2.4 Measure bias and variance
- E.2.5 Logistic regression from scratch
- E.2.6 Train softmax regression on four blobs
- E.3 Deep learning core
- E.3.1 Adam and AdamW step
- E.3.2 Batch normalization forward and backward
- E.3.3 CLIP symmetric contrastive loss
- E.3.4 DDPM noise schedule, closed form noising and posterior
- E.3.5 Focal loss
- E.3.6 Inverted dropout
- E.3.7 LayerNorm and RMSNorm
- E.3.8 Backpropagation through a two-layer MLP
- E.3.9 Rectified flow loss and Euler sampler
- E.3.10 Stable softmax and cross-entropy
- E.3.11 Fit a sine curve with a tanh network
- E.3.12 Train a tanh network on two spirals
- E.3.13 Train a 2-4-1 network on XOR
- E.4 Optimizers
- E.4.1 Adam and AdamW step
- E.4.2 Linear regression by gradient descent
- E.4.3 Sweep the learning rate
- E.4.4 SGD with momentum
- E.5 Transformers from scratch
- E.5.1 Tiled attention with an online softmax
- E.5.2 Grouped-query attention
- E.5.3 Fixed-capacity KV cache
- E.5.4 LayerNorm and RMSNorm
- E.5.5 Top-k MoE gating and the Switch load-balancing loss
- E.5.6 Split heads, merge heads, multi-head attention
- E.5.7 Rotary position embedding
- E.5.8 Scaled dot-product attention with a mask
- E.5.9 Sinusoidal positional encoding
- E.6 LLM inference
- E.6.1 Beam search with EOS and length normalization
- E.6.2 BPE pair counts and merges
- E.6.3 Symmetric int8 quantization
- E.6.4 Fixed-capacity KV cache
- E.6.5 Sweep the quantization bit width
- E.6.6 Sweep the sampling temperature
- E.6.7 Read an SGLang sweep on an L4
- E.6.8 LoRA linear layer
- E.6.9 Speculative decoding: accept, reject and resample
- E.6.10 Temperature, top-k and top-p sampling
- E.6.11 Train a character bigram language model
- E.7 RL basics
- E.7.1 Discounted returns with episode ends
- E.7.2 DPO loss and implicit rewards
- E.7.3 Generalized advantage estimation
- E.7.4 GRPO group advantages and clipped objective
- E.7.5 PPO clipped surrogate loss
- E.7.6 Q-learning and SARSA updates
- E.8 RAG building blocks
- E.8.1 BM25 ranking
- E.8.2 Cosine similarity top-k search
- E.8.3 Reciprocal rank fusion
- E.9 Agent building blocks
- E.9.1 Parse and validate tool calls
- E.10 Papers to code
- E.10.1 CLIP symmetric contrastive loss
- E.10.2 DDPM noise schedule, closed form noising and posterior
- E.10.3 DPO loss and implicit rewards
- E.10.4 Tiled attention with an online softmax
- E.10.5 Focal loss
- E.10.6 Grouped-query attention
- E.10.7 GRPO group advantages and clipped objective
- E.10.8 Top-k MoE gating and the Switch load-balancing loss
- E.10.9 Rectified flow loss and Euler sampler
- E.10.10 Speculative decoding: accept, reject and resample
- E.11 Train tiny models
- E.11.1 Train a character bigram language model
- E.11.2 Fit a sine curve with a tanh network
- E.11.3 Train softmax regression on four blobs
- E.11.4 Train a tanh network on two spirals
- E.11.5 Train a 2-4-1 network on XOR
- E.12 Experiment labs
- E.12.1 Measure bias and variance
- E.12.2 Sweep the learning rate
- E.12.3 Sweep the quantization bit width
- E.12.4 Sweep the sampling temperature
- E.12.5 Read an SGLang sweep on an L4
- FProjectsnot yet
- F.1 Level 1 projects
- F.1.1 Bookmark Path Organizer
- F.1.2 CSV Repair Workbench
- F.1.3 Dataset Split Auditor
- F.1.4 Download Folder Sort Desk
- F.1.5 Glossary Hovercard Publisher
- F.1.6 JSON Schema Output Guard
- F.1.7 Prompt Regression Tester
- F.1.8 SKILL.md Validator and Loader
- F.1.9 Semantic Notes Search
- F.1.10 Tiny Coding Agent
- F.1.11 Token Counter and Cost Meter
- F.1.12 Vocabulary Autocomplete Pad
- F.2 Level 2 projects
- F.2.1 API Tutorial Runner
- F.2.2 CSV Question Workbench
- F.2.3 Calendar Focus Planner
- F.2.4 Catalog Record Linker
- F.2.5 Changelog Writer From Git
- F.2.6 Chart Storyboard Builder
- F.2.7 Configuration Drift Explainer
- F.2.8 Dataset Contract Gate
- F.2.9 Diagram Reading Companion
- F.2.10 Document Extraction Review Desk
- F.2.11 Document QA With Citations and LangChain
- F.2.12 Feedback Theme Board
- F.2.13 Field Notes Map Builder
- F.2.14 Inbox Triage Desk
- F.2.15 Incident Postmortem Writer
- F.2.16 Infrastructure Plan Explainer
- F.2.17 Local Model Evaluation Harness
- F.2.18 Log Volume Reduction Lab
- F.2.19 Meeting Notes to Actions
- F.2.20 PR Review Reporter
- F.2.21 Plain Language Rewrite Desk
- F.2.22 Research Report Agent
- F.2.23 Retrieval Evaluation Lab
- F.2.24 Sensitive Text Redaction Gate
- F.2.25 Service Ownership Navigator
- F.2.26 Skill Router
- F.2.27 Source-Grounded Study Coach
- F.2.28 Subtitle Localization Desk
- F.2.29 UI String Localization Workbench
- F.2.30 Workshop Materials Planner
- F.3 Level 3 projects
- F.3.1 Agent Budget Planner
- F.3.2 Agent Trace Debugger
- F.3.3 Binary Inspector
- F.3.4 Community Learning Path Finder
- F.3.5 Cross-Agent Skill Installer
- F.3.6 Database Migration Rehearsal
- F.3.7 Decision Tradeoff Explorer
- F.3.8 Harness Bench
- F.3.9 Kubernetes Event Storyboard
- F.3.10 LLM Gateway With Fallbacks
- F.3.11 Multi-Agent Code Review Panel
- F.3.12 Persistent Memory Server
- F.3.13 RAG Freshness Pipeline
- F.3.14 Report Judge
- F.3.15 Retry Storm Lab
- F.3.16 Self-Correcting Workflow Hooks
- F.3.17 Skill Supply-Chain Scanner
- F.3.18 Streaming Answer Recovery
- F.3.19 Support Agent With Google ADK
- F.3.20 Typed Workflow Agent with Mastra
- F.3.21 Visual Evidence Library
- F.3.22 Voice Note Transcriber Pipeline
- F.3.23 Web Change Brief
- F.4 Level 4 projects
- F.4.1 Cloud Agent With AWS Strands
- F.4.2 Desktop Control Backend
- F.4.3 Durable Agent Jobs
- F.4.4 Hedged Request Lab
- F.4.5 MCP Tool Discovery Workbench
- F.4.6 Sandbox Policy Planner
- F.4.7 Signed Webhook Inbox
- F.4.8 Streaming Agent Shell in Rust
- F.4.9 Tool Call Firewall
- F.5 Level 5 projects
- F.5.1 Browser Agent
- F.5.2 Distributed Eval Farm Coordinator
- F.5.3 Mini Decompiler
- F.5.4 Self-Improving Skill Loop
- F.6 Planned projects
- F.6.1 Photo Burst Contact Sheet
- F.6.2 Dependency Upgrade Impact Map
- F.6.3 Gesture Shortcut Pad
- F.6.4 CI Failure Reproducer
- F.6.5 Label Adjudication Desk
- F.6.6 Lost Item Match Desk
- F.6.7 Presentation Rehearsal Coach
- F.6.8 Semantic Cache Correctness Lab
- F.6.9 Tool Contract Migration Checker
- F.6.10 Video Highlight Storyboard
- F.6.11 A2A Task Handoff Workbench
- F.6.12 Abstention Calibration Workbench
- F.6.13 Artifact Provenance Gate
- F.6.14 Context Compaction Verifier
- F.6.15 Local Inference Capacity Planner
- F.6.16 MCP Compatibility Doctor
- F.6.17 Metamorphic Evaluation Workbench
- F.6.18 OAuth Resource Boundary Lab
- F.6.19 Outbound Request Policy Proxy
- F.6.20 Release Canary Decision Lab
- F.6.21 Secret Injection Sidecar
- F.6.22 Tenant Fairness Scheduler
- F.6.23 Agent Resource Deadlock Lab
- F.6.24 Judge Bias Calibration Lab
- F.6.25 Trajectory Counterexample Minimizer
- F.6.26 Transactional Workspace Patch Broker
- GLearning pathsnot yet
- G.1 Agent Skills Engineering
- G.1.1 Agent Skills: Portable Contract and Runtime Boundary (see 15.22)
- G.1.2 Skill Discovery and Progressive Disclosure (see 15.24)
- G.1.3 Skill Invocation and Routing (see 15.25)
- G.1.4 Skill Permissions, Sandboxes, and Trust (see 15.26)
- G.1.5 Skill Evals, Packaging, and Portability (see 15.27)
- G.1.6 Capstone: Stateless Tool Ecosystem (see 15.23) (optional)
- G.2 Agent Systems Engineering
- G.2.1 Common Core: The Tool Interface (see 15.1)
- G.2.2 Common Core: Tool Schema Design (see 15.5)
- G.2.3 Common Core: MCP Fundamentals: Stateless Requests and JSON-RPC (see 15.6)
- G.2.4 Common Core: The Agent Loop (see 16.1)
- G.2.5 Common Core: Tool Use and Function Calling (see 16.6)
- G.2.6 Role Practice: Context Engineering (see 13.5)
- G.2.7 Role Practice: Agent Memory — Virtual Context and Memory Paging (see 16.7)
- G.2.8 Role Practice: Stateful Graph Orchestration — Durable Execution and Checkpoints (see 16.13)
- G.2.9 Role Practice: Orchestration Patterns — Supervisor, Swarm, Hierarchical (see 16.28)
- G.2.10 Proof Project: Failure Modes — Why Agents Break (see 16.26)
- G.2.11 Proof Project: Prompt Injection and the PVE Defense (see 16.27)
- G.2.12 Proof Project: Eval-Driven Agent Development (see 16.30)
- G.2.13 Interview and Readiness Evidence: Production Runtimes — Queue, Event, Cron (see 16.29)
- G.2.14 Interview and Readiness Evidence: Agent Observability — Langfuse, Phoenix, Opik (see 16.24)
- G.3 AI Data Systems
- G.3.1 Common Core: Data Management (see 2.9)
- G.3.2 Common Core: Feature Engineering and Selection (see 4.8)
- G.3.3 Common Core: ML Pipelines and Experiment Tracking (see 4.13)
- G.3.4 Common Core: Data Pipelines for Pre-Training (see 12.3)
- G.3.5 Role Practice: Embeddings and Vector Representations (see 13.4)
- G.3.6 Role Practice: Context Engineering (see 13.5)
- G.3.7 Role Practice: RAG: Retrieval-Augmented Generation (see 13.6)
- G.3.8 Role Practice: Advanced RAG: Chunking, Reranking (see 13.7)
- G.3.9 Proof Project: Evaluation and Testing (see 13.10)
- G.3.10 Proof Project: Building a Production LLM App (see 13.13)
- G.3.11 Interview and Readiness Evidence: LLM Observability Stack Selection (see 19.13)
- G.4 Developer Experience and Education
- G.4.1 Common Core: APIs and Keys (see 2.4)
- G.4.2 Common Core: The Tool Interface (see 15.1)
- G.4.3 Common Core: Tool Schema Design (see 15.5)
- G.4.4 Common Core: MCP Fundamentals: Stateless Requests and JSON-RPC (see 15.6)
- G.4.5 Common Core: Building an MCP Server: Stateless Python and TypeScript (see 15.7)
- G.4.6 Role Practice: Agent Skills: Portable Contract and Runtime Boundary (see 15.22)
- G.4.7 Role Practice: Skill Discovery and Progressive Disclosure (see 15.24)
- G.4.8 Role Practice: Skill Invocation and Routing (see 15.25)
- G.4.9 Proof Project: Skill Evals, Packaging, and Portability (see 15.27)
- G.4.10 Proof Project: Capstone: Stateless Tool Ecosystem (see 15.23)
- G.4.11 Interview and Readiness Evidence: Build a Feedback Ratchet with Ownership and Retirement (see 16.54)
- G.5 AI Evaluation and Reliability
- G.5.1 Common Core: Model Evaluation: Metrics, Cross-Validation (see 4.9)
- G.5.2 Common Core: Evaluation and Testing (see 13.10)
- G.5.3 Common Core: Eval-Driven Agent Development (see 16.30)
- G.5.4 Common Core: Failure Modes — Why Agents Break (see 16.26)
- G.5.5 Common Core: OpenTelemetry GenAI Semantic Conventions (see 16.23)
- G.5.6 Role Practice: Inference Metrics — TTFT, TPOT, ITL, Goodput, P99 (see 19.8)
- G.5.7 Role Practice: LLM Observability Stack Selection (see 19.13)
- G.5.8 Role Practice: A/B Testing LLM Features — GrowthBook and Statsig (see 19.21)
- G.5.9 Role Practice: Load Testing LLM APIs — k6, LLMPerf, GenAI-Perf (see 19.22)
- G.5.10 Proof Project: Shadow, Canary, and Progressive Deployment (see 19.20)
- G.5.11 Proof Project: Chaos Engineering for LLM Production (see 19.24)
- G.5.12 Interview and Readiness Evidence: SRE for AI — Multi-Agent Incident Response (see 19.23)
- G.6 LLM Product Engineering
- G.6.1 Common Core: Prompt Engineering: Techniques and Patterns (see 13.1)
- G.6.2 Common Core: Structured Outputs (see 13.3)
- G.6.3 Common Core: Embeddings and Vector Representations (see 13.4)
- G.6.4 Common Core: Context Engineering (see 13.5)
- G.6.5 Common Core: RAG: Retrieval-Augmented Generation (see 13.6)
- G.6.6 Common Core: Function Calling and Tool Use (see 13.9)
- G.6.7 Role Practice: Evaluation and Testing (see 13.10)
- G.6.8 Role Practice: Caching, Rate Limiting and Cost (see 13.11)
- G.6.9 Role Practice: Guardrails and Safety (see 13.12)
- G.6.10 Proof Project: Building a Production LLM App (see 13.13)
- G.6.11 Proof Project: AI Gateways — LiteLLM, Portkey, Kong, Bifrost (see 19.19)
- G.6.12 Interview and Readiness Evidence: Shadow, Canary, and Progressive Deployment (see 19.20)
- G.7 Building and Deploying AI Applications
- G.7.1 Prompt Engineering: Techniques and Patterns (see 13.1)
- G.7.2 Structured Outputs (see 13.3)
- G.7.3 Embeddings and Vector Representations (see 13.4)
- G.7.4 Context Engineering (see 13.5)
- G.7.5 RAG: Retrieval-Augmented Generation (see 13.6)
- G.7.6 Evaluation and Testing (see 13.10)
- G.7.7 Caching, Rate Limiting and Cost (see 13.11)
- G.7.8 Guardrails and Safety (see 13.12)
- G.7.9 Building a Production LLM App (see 13.13)
- G.7.10 LLM Observability Stack Selection (see 19.13)
- G.7.11 Shadow, Canary, and Progressive Deployment (see 19.20)
- G.7.12 SRE for AI — Multi-Agent Incident Response (see 19.23)
- G.8 Customer AI Deployment
- G.8.1 Common Core: Define the Outcome Before You Choose the Output (see 16.47)
- G.8.2 Common Core: Discover the Workflow People Actually Perform (see 16.48)
- G.8.3 Common Core: Map Assumptions and Resolve the Riskiest One First (see 16.49)
- G.8.4 Common Core: Choose the Smallest Slice That Can Change the Decision (see 16.50)
- G.8.5 Common Core: Write Specifications That Preserve Judgment (see 16.51)
- G.8.6 Role Practice: RAG: Retrieval-Augmented Generation (see 13.6)
- G.8.7 Role Practice: Evaluation and Testing (see 13.10)
- G.8.8 Role Practice: Building a Production LLM App (see 13.13)
- G.8.9 Role Practice: Design Success Metrics Before the Result Exists (see 16.52)
- G.8.10 Proof Project: Choose Prototype, Pilot, or Production Deliberately (see 16.53)
- G.8.11 Proof Project: Shadow, Canary, and Progressive Deployment (see 19.20)
- G.8.12 Interview and Readiness Evidence: Build a Feedback Ratchet with Ownership and Retirement (see 16.54)
- G.9 Model Context Protocol (MCP)
- G.9.1 MCP Fundamentals: Stateless Requests and JSON-RPC (see 15.6)
- G.9.2 Building an MCP Server: Stateless Python and TypeScript (see 15.7)
- G.9.3 Building an MCP Client: Discovery, Routing, and Dual-Era Fallback (see 15.8)
- G.9.4 MCP Transports: stdio and Stateless Streamable HTTP (see 15.9)
- G.9.5 MCP Resources and Prompts: Addressable Context for Stateless Servers (see 15.10)
- G.9.6 MCP Model Input: Sampling Migration and Stateless MRTR (see 15.11)
- G.9.7 Explicit Scope and Stateless Elicitation (see 15.12)
- G.9.8 MCP Tasks Extension: Durable Work on a Stateless Core (see 15.13)
- G.9.9 MCP Apps on the Stateless Protocol (see 15.14)
- G.9.10 MCP Security: Poisoned Metadata, Routing, and MRTR State (see 15.15)
- G.9.11 MCP Authorization: CIMD, Issuer Binding, PKCE, and Step-Up (see 15.16)
- G.9.12 MCP Auth in Production: Issuer-Bound Enrollment and Tokens (see 15.18)
- G.9.13 Stateless MCP Gateways and Registry Admission (see 15.17)
- G.9.14 MCP Tool Contracts and Content (see 15.28)
- G.9.15 MCP Reliability, Cancellation, and Flow Control (see 15.29)
- G.9.16 MCP Registry Supply Chain: Admission, Drift, and Rollback (see 15.30)
- G.9.17 MCP Conformance Engineering: Versioning, Evidence, and Operations (see 15.31)
- G.9.18 Capstone: Stateless Tool Ecosystem (see 15.23) (optional)
- G.10 Reverse Engineering
- G.10.1 Program Anatomy: An ELF Reader From Scratch (see 15.32)
- G.10.2 Disassembly and Control Flow: From Bytes to a Graph You Can Check (see 15.33)
- G.10.3 Lifting to Pseudocode: IR, SSA, and Structuring From Scratch (see 15.34)
- G.10.4 Evidence, Confidence, and Unknowns in Binary Analysis (see 15.35)
- G.10.5 Rebuild and Prove Equal: Differential Tests, Byte Comparison, and the Evidence Loop (see 15.36)
- G.10.6 The Reverse Engineering Landscape: History, Tool Families, and How a Decompiler Is Built (see 15.37)
- G.10.7 Calling Conventions and Stack Frames: System V, Windows x64, and AArch64 (see 15.38)
- G.10.8 Compiler Idioms: What Optimization Does to Your Code and How to Read It Back (see 15.39)
- G.10.9 Linking, Loading, and Stripped Binaries: PLT, GOT, Imports, Fixups, and Function Identification (see 15.40)
- G.10.10 Recovering Data and Types: Structs, Arrays, C++ Objects, and DWARF (see 15.41)
- G.10.11 Dynamic Analysis of Your Own Program: Debuggers, Traces, and Confirming Static Claims (see 15.42)
- G.10.12 Beyond Native Code: Python, JVM, .NET, and WebAssembly Bytecode (see 15.43)
- G.10.13 Binary Diffing and Symbolic Execution: Matching Functions and Solving for Inputs (see 15.44)
- G.10.14 AI-Assisted Reverse Engineering: LLM Decompilers, Analysis Agents, and Ground Truth (see 15.45)
- G.11 Product Judgment and Delivery
- G.11.1 Define the Outcome Before You Choose the Output (see 16.47)
- G.11.2 Discover the Workflow People Actually Perform (see 16.48)
- G.11.3 Map Assumptions and Resolve the Riskiest One First (see 16.49)
- G.11.4 Choose the Smallest Slice That Can Change the Decision (see 16.50)
- G.11.5 Write Specifications That Preserve Judgment (see 16.51)
- G.11.6 Design Success Metrics Before the Result Exists (see 16.52)
- G.11.7 Choose Prototype, Pilot, or Production Deliberately (see 16.53)
- G.11.8 Build a Feedback Ratchet with Ownership and Retirement (see 16.54)
- G.12 Software Engineering Fundamentals
- G.12.1 Dev Environment (see 2.1)
- G.12.2 Git and Collaboration (see 2.2)
- G.12.3 Python Environments (see 2.6)
- G.12.4 Docker for AI (see 2.7)
- G.12.5 Data Management (see 2.9)
- G.12.6 Terminal and Shell (see 2.10)
- G.12.7 Debugging and Profiling (see 2.12)
- G.12.8 The Tool Interface (see 15.1)
- G.12.9 Tool Schema Design (see 15.5)
- G.12.10 Verification Gates (see 16.38)
- G.12.11 Shadow, Canary, and Progressive Deployment (see 19.20)
- G.12.12 Security — Secrets, PII Scrubbing, Audit Logs (see 19.25)
- G.12.13 SRE for AI — Multi-Agent Incident Response (see 19.23)
- G.13 Agent-Assisted Engineering
- G.13.1 Agent Workbench: Why Capable Models Still Fail (see 16.31)
- G.13.2 The Minimal Agent Workbench (see 16.32)
- G.13.3 Agent Instructions as Executable Constraints (see 16.33)
- G.13.4 Repo Memory and Durable State (see 16.34)
- G.13.5 Initialization Scripts for Agents (see 16.35)
- G.13.6 Scope Contracts and Task Boundaries (see 16.36)
- G.13.7 Frame the Task Before the Agent Writes Code (see 16.43)
- G.13.8 Build an Evidence-Backed Execution Plan (see 16.44)
- G.13.9 Runtime Feedback Loops (see 16.37)
- G.13.10 Verification Gates (see 16.38)
- G.13.11 Reviewer Agent: Separate Builder from Marker (see 16.39)
- G.13.12 Delegate Agent Work with Isolation and Merge Contracts (see 16.45)
- G.13.13 Multi-Session Handoff (see 16.40)
- G.13.14 The Workbench on a Real Repo (see 16.41)
- G.13.15 Turn Every Agent Correction into a System Improvement (see 16.46)
- G.13.16 Capstone: Ship a Reusable Agent Workbench Pack (see 16.42)
- HGlossary and mythsnot yet
- H.1 Math and training
- H.1.1 Activation Checkpointing
- H.1.2 Activation Function
- H.1.3 Adam (Optimizer)
- H.1.4 AdamW
- H.1.5 Autograd
- H.1.6 Backpropagation
- H.1.7 Batch Size
- H.1.8 Contrastive Learning
- H.1.9 Cross-Entropy
- H.1.10 Data Augmentation
- H.1.11 DPO (Direct Preference Optimization)
- H.1.12 Dropout
- H.1.13 Eigenvalue
- H.1.14 Epoch
- H.1.15 Fine-tuning
- H.1.16 Gradient
- H.1.17 Gradient Accumulation
- H.1.18 Gradient Clipping
- H.1.19 Gradient Descent
- H.1.20 Hyperparameter
- H.1.21 JAX
- H.1.22 Knowledge Distillation
- H.1.23 Learning Rate
- H.1.24 Learning Rate Schedule
- H.1.25 LoRA (Low-Rank Adaptation)
- H.1.26 Loss Function
- H.1.27 Mixed Precision
- H.1.28 NaN (Not a Number)
- H.1.29 Normalization
- H.1.30 Optimizer
- H.1.31 Overfitting
- H.1.32 QLoRA
- H.1.33 ReLU
- H.1.34 RLHF (Reinforcement Learning from Human Feedback)
- H.1.35 SFT (Supervised Fine-Tuning)
- H.1.36 Softmax
- H.1.37 Stochastic Gradient Descent (SGD)
- H.1.38 Transfer Learning
- H.1.39 Underfitting
- H.1.40 Warmup
- H.1.41 Weight
- H.1.42 Weight Decay
- H.2 Models and inference
- H.2.1 Attention
- H.2.2 Autoregressive
- H.2.3 CNN (Convolutional Neural Network)
- H.2.4 CUDA
- H.2.5 Decoder
- H.2.6 Decoding Strategy
- H.2.7 Diffusion Model
- H.2.8 Encoder
- H.2.9 GAN (Generative Adversarial Network)
- H.2.10 GPT
- H.2.11 Inductive Bias
- H.2.12 Inference
- H.2.13 KV Cache
- H.2.14 LLM (Large Language Model)
- H.2.15 Logits
- H.2.16 MoE (Mixture of Experts)
- H.2.17 Nucleus Sampling (Top-p)
- H.2.18 Parameter
- H.2.19 Perplexity
- H.2.20 Quantization
- H.2.21 Self-Attention
- H.2.22 Speculative Decoding
- H.2.23 Stop Sequence
- H.2.24 Streaming
- H.2.25 Temperature
- H.2.26 Time to First Token (TTFT)
- H.2.27 Top-k Sampling
- H.2.28 Transformer
- H.2.29 VAE (Variational Autoencoder)
- H.3 Data and representations
- H.3.1 Byte Pair Encoding (BPE)
- H.3.2 Cosine Similarity
- H.3.3 Data Deduplication
- H.3.4 Data Leakage
- H.3.5 Data Provenance
- H.3.6 Dataset Split
- H.3.7 Embedding
- H.3.8 Feature
- H.3.9 Latent Space
- H.3.10 Tensor
- H.3.11 Token
- H.3.12 Tokenization
- H.3.13 Vocabulary
- H.4 Retrieval and generation
- H.4.1 Approximate Nearest Neighbor (ANN)
- H.4.2 BM25
- H.4.3 Chunking
- H.4.4 Dense Retrieval
- H.4.5 Grounding
- H.4.6 HNSW
- H.4.7 Hybrid Retrieval
- H.4.8 Maximum Marginal Relevance (MMR)
- H.4.9 RAG (Retrieval-Augmented Generation)
- H.4.10 Recall@K
- H.4.11 Reciprocal Rank Fusion (RRF)
- H.4.12 Reranker
- H.4.13 Semantic Search
- H.4.14 Vector Database
- H.5 Prompting and context
- H.5.1 Chain of Thought (CoT)
- H.5.2 Context Compression
- H.5.3 Context Engineering
- H.5.4 Context Window
- H.5.5 Few-Shot
- H.5.6 In-Context Learning
- H.5.7 Instruction Following
- H.5.8 Instruction Hierarchy
- H.5.9 Lost in the Middle
- H.5.10 Prompt Cache
- H.5.11 Prompt Engineering
- H.5.12 Prompt Sensitivity
- H.5.13 System Prompt
- H.5.14 Token Budget
- H.5.15 Zero-Shot
- H.6 Agents and tools
- H.6.1 Agent
- H.6.2 Agent Harness
- H.6.3 Agent Memory
- H.6.4 Agent State
- H.6.5 Agent Skill
- H.6.6 Approval Gate
- H.6.7 Checkpoint
- H.6.8 Compensating Action
- H.6.9 Delegation
- H.6.10 Durable Execution
- H.6.11 Function Calling
- H.6.12 Human-in-the-Loop (HITL)
- H.6.13 MCP (Model Context Protocol)
- H.6.14 Multi Round-Trip Request (MRTR)
- H.6.15 Orchestration
- H.6.16 Planning
- H.6.17 ReAct
- H.6.18 Sandbox
- H.6.19 Skill Bundle
- H.6.20 Skill Catalog
- H.6.21 Skill Discovery
- H.6.22 Skill Invocation
- H.6.23 Stateless MCP
- H.6.24 Structured Output
- H.6.25 Swarm
- H.6.26 Termination Condition
- H.6.27 Tool Contract
- H.7 Evaluation and safety
- H.7.1 Alignment
- H.7.2 Benchmark Contamination
- H.7.3 Calibration
- H.7.4 Distribution Shift
- H.7.5 Eval Set
- H.7.6 Evaluation (Eval)
- H.7.7 Exact Match (EM)
- H.7.8 Guardrails
- H.7.9 Hallucination
- H.7.10 Least Privilege
- H.7.11 LLM-as-a-Judge
- H.7.12 Model Card
- H.7.13 Pass@k
- H.7.14 Precision and Recall
- H.7.15 Prompt Injection
- H.7.16 ROUGE
- H.7.17 Verification Gate
- H.8 AI-native development
- H.8.1 Backpressure
- H.8.2 Circuit Breaker
- H.8.3 Coding Agent
- H.8.4 Cost per Successful Task
- H.8.5 Flaky Test
- H.8.6 Handoff
- H.8.7 Idempotency
- H.8.8 Model Router
- H.8.9 Observability
- H.8.10 Patch
- H.8.11 Progressive Disclosure
- H.8.12 Rate Limit
- H.8.13 Regression Test
- H.8.14 Repository Instructions
- H.8.15 Repository Map
- H.8.16 Reproducible Build
- H.8.17 Retry with Backoff
- H.8.18 Reviewer Agent
- H.8.19 Scope Contract
- H.8.20 Semantic Cache
- H.8.21 Test Oracle
- H.8.22 Trace
- H.8.23 Worktree
- H.9 Infrastructure and serving
- H.9.1 Autoscaling
- H.9.2 Chunked Prefill
- H.9.3 Continuous Batching
- H.9.4 Decode Phase
- H.9.5 Disaggregated Serving
- H.9.6 Dynamic Batching
- H.9.7 Expert Parallelism
- H.9.8 FlashAttention
- H.9.9 Goodput
- H.9.10 Inter-Token Latency (ITL)
- H.9.11 Model Serving
- H.9.12 Paged KV Cache
- H.9.13 Pipeline Parallelism
- H.9.14 Prefill
- H.9.15 Prefix Caching
- H.9.16 Tensor Parallelism
- H.9.17 Time per Output Token (TPOT)
- H.9.18 Tokens per Second (TPS)
- H.10 Reliability and operations
- H.10.1 Admission Control
- H.10.2 Availability
- H.10.3 Canary Release
- H.10.4 Deadline Propagation
- H.10.5 Error Budget
- H.10.6 Graceful Degradation
- H.10.7 Incident Response
- H.10.8 Load Shedding
- H.10.9 Postmortem
- H.10.10 Readiness Probe
- H.10.11 Retry Budget
- H.10.12 Rollback
- H.10.13 Saturation
- H.10.14 Service Level Indicator (SLI)
- H.10.15 Service Level Objective (SLO)
- H.10.16 Shadow Traffic
- H.10.17 Tail Latency
- H.11 Security and governance
- H.11.1 AI Risk Assessment
- H.11.2 Audit Log
- H.11.3 Content Provenance
- H.11.4 Data Classification
- H.11.5 Data Exfiltration
- H.11.6 Data Lineage
- H.11.7 Data Minimization
- H.11.8 Datasheet for Datasets
- H.11.9 Defense in Depth
- H.11.10 Indirect Prompt Injection
- H.11.11 Jailbreak
- H.11.12 Membership Inference
- H.11.13 Provenance Attestation
- H.11.14 Purpose Limitation
- H.11.15 Red Teaming
- H.11.16 Separation of Duties
- H.11.17 Software Bill of Materials (SBOM)
- H.11.18 Threat Model
- H.11.19 Trust Boundary
- H.11.20 Zero Trust
- H.12 Multimodal systems
- H.12.1 Audio Token
- H.12.2 Automatic Speech Recognition (ASR)
- H.12.3 Cross-Attention
- H.12.4 Early Fusion
- H.12.5 Image Token
- H.12.6 Late Fusion
- H.12.7 Modality
- H.12.8 Modality Alignment
- H.12.9 Multimodal Fusion
- H.12.10 Multimodal Model
- H.12.11 Patch Embedding
- H.12.12 Shared Embedding Space
- H.12.13 Vision-Language Model (VLM)
- H.12.14 Vision Transformer (ViT)
- H.12.15 Visual Grounding
- H.13 Myths
- H.13.1 "AI understands language"
- H.13.2 "More parameters = smarter model"
- H.13.3 "Neural networks are black boxes"
- H.13.4 "AI will replace programmers"
- H.13.5 "You need a PhD in math to do AI"
- H.13.6 "GPT stands for General Purpose Technology"
- H.13.7 "Temperature makes the AI more creative"
- H.13.8 "Fine-tuning teaches the model new knowledge"
- H.13.9 "Bigger context window = better"
- H.13.10 "AI agents are autonomous"
- H.13.11 "Transformers understand order because of positional encoding"
- H.13.12 "Pre-training is just reading the internet"
- H.13.13 "RLHF aligns AI with human values"
- H.13.14 "Embeddings capture meaning"
- H.13.15 "Zero-shot means no training"
- H.13.16 "AI models learn like humans"
- H.13.17 "Scaling laws mean bigger is always better"
- H.13.18 "Open source AI is the same as open weights"
- H.13.19 "Prompt engineering is not real engineering"
- H.13.20 "CNNs are outdated, everything is transformers now"
- H.13.21 "You need massive compute to train useful models"
- ICheat sheetsnot yet
- I.1 Foundations
- I.1.1 Calculus, Gradients and Convex Optimization
- I.1.2 Classical Machine Learning
- I.1.3 Classical Models Compared
- I.1.4 Clustering, Dimensionality Reduction and Anomalies
- I.1.5 Complex Numbers, Fourier and Signals
- I.1.6 Debugging Neural Network Training
- I.1.7 Feature Engineering and Pipelines
- I.1.8 Git, Shell and Linux for AI Work
- I.1.9 GPUs, Cloud, Docker and API Keys
- I.1.10 Information Theory and Numerical Stability
- I.1.11 JAX against PyTorch
- I.1.12 Linear Algebra for ML
- I.1.13 Math for Machine Learning
- I.1.14 ML System Design, Drift and Feature Stores
- I.1.15 Model Evaluation, Bias-Variance and Tuning
- I.1.16 Neural Network Basics
- I.1.17 Notebooks, Data Files and Profiling
- I.1.18 Optimizers and Learning Rate Schedules
- I.1.19 Probability and Statistics for ML
- I.1.20 Python Dev Environment for AI
- I.1.21 PyTorch Essentials
- I.1.22 Time Series Fundamentals
- I.1.23 Training Neural Networks
- I.2 Vision and audio
- I.2.1 Audio Features, Classification and Metrics
- I.2.2 CNN Architectures and Transfer Learning
- I.2.3 Computer Vision
- I.2.4 Detection and Segmentation Compared
- I.2.5 Edge Inference Targets
- I.2.6 Evaluating Generative Models
- I.2.7 GANs, Diffusion and Flow Compared
- I.2.8 Music Generation and Audio-Language Models
- I.2.9 Real-Time Voice Assistants
- I.2.10 Self-Supervised Vision, CLIP and Retrieval
- I.2.11 Speaker Verification, Spoofing and Watermarks
- I.2.12 Speech Recognition and Whisper
- I.2.13 Text-to-Speech, Voice Cloning and Codecs
- I.2.14 Video and 3D Generation
- I.2.15 Video, Depth and 3D Vision
- I.2.16 Vision Pipelines and Edge Deployment
- I.3 Language and transformers
- I.3.1 Attention Variants Compared
- I.3.2 BERT, GPT and T5 Compared
- I.3.3 Chatbots and Dialogue State Tracking
- I.3.4 Classic Text Processing and TF-IDF
- I.3.5 Embeddings and Vector Search
- I.3.6 Fine-Tuning with LoRA
- I.3.7 Graphs and Knowledge Graphs
- I.3.8 Mixture of Experts and Hybrid Architectures
- I.3.9 NER, POS Tagging and Coreference
- I.3.10 Positional Encoding: Sinusoidal, RoPE, ALiBi
- I.3.11 RLHF, DPO and Preference Tuning
- I.3.12 RNNs, Seq2Seq and N-gram Models
- I.3.13 Scaling Laws and Pre-Training
- I.3.14 Speculative Decoding: Draft, EAGLE, MTP
- I.3.15 Structured Outputs and Constrained Decoding
- I.3.16 Summarization, QA, NLI and Multilingual NLP
- I.3.17 Tokenization and BPE
- I.3.18 Transformers and Attention
- I.3.19 Word2Vec, GloVe and FastText
- I.4 Generative and multimodal
- I.4.1 ControlNet, Inpainting and Image Editing
- I.4.2 Diffusion and Generative Models
- I.4.3 Embodied VLAs and Computer-Use Agents
- I.4.4 GANs from DCGAN to StyleGAN
- I.4.5 Multimodal and Vision-Native RAG
- I.4.6 OCR and Document Understanding
- I.4.7 Open VLM Families: LLaVA, Qwen-VL, InternVL
- I.4.8 Unified Multimodal Models
- I.4.9 Video-Language Models and Long Video
- I.4.10 Vision Transformers and Patch Tokens
- I.4.11 Vision-Language Model Architectures
- I.5 RL, safety and alignment
- I.5.1 AI Safety and Red Teaming
- I.5.2 Alignment Training: Instructions, DPO Family, RLAIF
- I.5.3 Bias, Fairness and Differential Privacy
- I.5.4 Cards, Provenance, Regulation and Welfare
- I.5.5 Mesa-Optimizers, Scheming and AI Control
- I.5.6 Multi-Agent RL and Sim-to-Real
- I.5.7 Prompt Injection Incidents and AI CVEs
- I.5.8 Reinforcement Learning
- I.5.9 Value Methods against Policy Methods
- I.6 LLM engineering
- I.6.1 Agent State Machines and Durable Graphs
- I.6.2 Guardrails, Moderation and Redaction
- I.6.3 Prompt Engineering
- I.6.4 Shipping a Production LLM App
- I.7 Tools and protocols
- I.7.1 Agent Skills: Discovery, Invocation, Routing
- I.7.2 Binary Analysis Tools from Scratch
- I.7.3 Building an MCP Server
- I.7.4 MCP Clients and Transports
- I.7.5 MCP Gateways, Registries and Conformance
- I.7.6 MCP Security and Authorization
- I.7.7 MCP Tasks, Elicitation and Apps
- I.7.8 Model Context Protocol (MCP)
- I.7.9 Skill Permissions, Evals and Supply Chain
- I.7.10 Tool Calling and Structured Outputs
- I.8 Agents and autonomy
- I.8.1 A2A and Agent Communication Protocols
- I.8.2 Agent Benchmarks: SWE-bench to OSWorld
- I.8.3 Agent Frameworks Compared
- I.8.4 Agent Harness Engineering
- I.8.5 Agent Planning: Workflows, HTN, Plan-Execute
- I.8.6 Agent Tool Use and Skill Libraries
- I.8.7 Autonomous Agents and Permissions
- I.8.8 Constitutional AI and Input/Output Classifiers
- I.8.9 Context Engineering and Agent Memory
- I.8.10 Debate, Roles and Review Panels
- I.8.11 Delegation, Isolation and Feedback Ratchets
- I.8.12 Eval-Driven Agent Development
- I.8.13 Frontier Safety Frameworks and External Evals
- I.8.14 Multi-Agent Case Studies and Eval Farms
- I.8.15 Multi-Agent Systems
- I.8.16 Negotiation, Simulation and Agent Economies
- I.8.17 OpenTelemetry GenAI and Agent Observability
- I.8.18 Orchestration Patterns Compared
- I.8.19 Outcomes, Workflows, Risks and Specs
- I.8.20 Production Agent Runtimes and Queues
- I.8.21 ReAct, ReWOO, Reflexion and Tree of Thoughts
- I.8.22 Repo Memory, Init Scripts and Handoffs
- I.8.23 Self-Improving and Research Agents
- I.8.24 Self-Taught Reasoning and Self-Improvement
- I.8.25 Swarm Optimization and MARL for Agents
- I.8.26 Why Agents Fail
- I.9 Production and infrastructure
- I.9.1 Async, Hogwild and Disaggregated Inference
- I.9.2 GPU Autoscaling on Kubernetes
- I.9.3 Inference Metrics and Load Testing
- I.9.4 Inference Optimization: KV Cache, Quantization, Batching
- I.9.5 LLM Cost, Caching and Batch APIs
- I.9.6 LLM Routing and AI Gateways Compared
- I.9.7 Managed Platforms and Self-Hosting Compared
- I.9.8 Quantization Formats Compared
- I.9.9 Secrets, Audit Logs and Compliance
- I.9.10 Serving Engines Compared
- I.9.11 Shadow, Canary and A/B Tests for LLMs
- I.9.12 SRE, Incidents and Postmortems for AI
- I.10 Capstones
- I.10.1 Build a VLM from Scratch
- I.10.2 Coding Agents: Landscape and Capstones
- I.10.3 DDP, FSDP, ZeRO and Pipeline Parallel
- I.10.4 End-to-End LLM and Fine-Tuning Pipeline
- I.10.5 Evaluating LLMs
- I.10.6 Paper Writer, Critic and Iteration
- I.10.7 Pre-Training Data Pipelines
- I.10.8 Production RAG Chatbots and Freshness
- I.10.9 Research Agent Pipeline from Scratch
- I.10.10 Retrieval-Augmented Generation (RAG)
- I.10.11 Train and Load a GPT from Scratch
- I.10.12 Training Memory, Accumulation and Checkpoints
- I.11 Manuals
- I.11.1 A2A Protocol
- I.11.2 Docker Sandboxes for Agents
- I.11.3 LLM Serving with SGLang
- I.11.4 Reverse Engineering with rea
- I.12 Projects
- I.12.1 AI Tutors and Learning Tools
- I.12.2 Data Quality and Dataset Gates
- I.12.3 Decision, Change and Tutorial Tools
- I.12.4 Diagram, Chart and Infrastructure Explainers
- I.12.5 Localization and Glossary Tools
- I.12.6 Personal Organizer Agents
- I.12.7 Sandbox Policy Ladder
- I.12.8 Text Workflow Desks
- JLearning with the coursenot yet
- J.1 How to learn
- J.2 Progress, quizzes and checkpoints
- J.3 Home page
- J.4 About
- J.5 Developer
- J.6 Skills and the terminal tutor
- J.7 Roadmap
- J.8 Catalog
- J.9 Highlights
- J.10 Is superintelligence here yet?
- J.11 Translations