Concept Wiki
Deep-dive reference pages for the algorithms and procedures behind the lessons. Every page comes with a runnable Colab notebook implementing the concept from scratch.
Agents
Agent Protocols: MCP & A2A
The two open protocols standardizing how agents connect to the world — MCP (Model Context Protocol) for agent-to-tool/data access and A2A (Agent2Agent) for agent-to-agent collaboration — their client/server architectures, message shapes, and how they compose.
Agentic Analysis: A Metrics Taxonomy
The four levels at which you measure an agentic system — single-agent correctness, per-agent profiling, multi-agent trajectory correctness, and whole-system health — plus the latency metrics that decide usability and the leading indicators that actually predict an effective agent.
LangGraph: Agents as State Graphs
Why LangGraph models an LLM agent as a stateful graph instead of a linear chain — the State/Node/Edge abstractions, conditional routing, cycles, and checkpointing — with a ReAct agent expressed as a compiled graph.
Observability for Agents
What changes when the traced system is an autonomous agent — trajectory traces with agent/tool/sub-agent spans, the agent-specific metrics that catch loops and budget burn, replay for debugging, and online evals over sampled trajectories.
Prompt Injection: Attack Taxonomy & Defenses
How direct and indirect prompt injection hijack LLM agents, why no filter fully closes the hole, and the defense-in-depth stack — privilege separation, provenance tagging, least privilege, and human-in-the-loop — that contains the blast radius instead.
Sub-Agent Types: Sequential, Parallel & Loop Agents
The three deterministic workflow-agent primitives — sequential pipelines, parallel fan-out/fan-in, and bounded loops — how they compose into hierarchies, their latency/cost/failure profiles, and when to use each instead of LLM-driven delegation.
The Agentic Project Loop
The spine every agent lesson hangs off — task definition → context & tools → orchestration → evaluation → guardrails → operations feedback. Learn to read any agent technique as a change to one slot, follow one docs-Q&A agent all the way around, and see exactly where the agentic loop parallels and departs from the ML loop.
Building With Llms
Langfuse & OpenTelemetry: Instrumenting LLM Apps
The concrete instrumentation stack behind LLM observability — OpenTelemetry's trace/span model and GenAI semantic conventions, Langfuse's trace → observation → score data model, and how a multi-step request becomes a queryable trace.
LLM-as-a-Judge: Automated LLM Evaluation
Using LLMs to evaluate LLM outputs — G-Eval, Prometheus, pairwise comparison, reference-free evaluation, and the biases and failure modes to avoid in production eval pipelines.
Calculus
Newton's Method for Optimization
Minimizing the quadratic Taylor model exactly in one step — deriving the H⁻¹ update and verifying it on a 2D quadratic that lands at the optimum in a single step.
The Directional Derivative
Deriving the directional derivative from its limit definition, connecting it to the gradient via the chain rule, and proving the dot-product formula that makes the gradient the direction of steepest ascent.
Causal Inference
Computer Vision
Neural Radiance Fields (NeRF)
AdvancedRepresenting a 3D scene as a neural network — volume rendering, positional encoding, and novel-view synthesis.
Non-Maximum Suppression (NMS)
6-step suppression procedure, IoU threshold trace on a 4-box example (confidences 0.92, 0.87, 0.61, 0.55), and the Soft-NMS Gaussian decay variant for crowded scenes.
Generative Models
Graphical Models
The Baum–Welch Algorithm
EM for Hidden Markov Models — forward-backward responsibilities and closed-form parameter re-estimation, derived step by step.
Variable Elimination
Exact inference in Bayesian Networks — set evidence, multiply factors, sum out hidden variables in a smart order.
Linear Algebra
Computing Eigenvalues & Eigenvectors
The characteristic equation det(A−λI)=0, solving the 2×2 quadratic, and finding eigenvectors from the null space — worked end-to-end for λ=5 and λ=2.
SVD and the Eckart-Young Theorem
Sum-of-rank-1-layers expansion of A=UΣVᵀ, the Eckart-Young best-approximation theorem, Frobenius-norm error bound, and numeric verification with a rank-10 example.
Ml Fundamentals
Ml In Practice
Continuous Batching
Iteration-level scheduling for LLM serving — the scheduler loop that rebuilds the batch every decode step, admission and token budgets, chunked prefill, preemption, and why it beats static batching 2–10× on chat traffic.
PagedAttention & KV-Cache Management
How vLLM manages the KV-cache like an operating system manages RAM — block tables, on-demand allocation, prefix sharing with copy-on-write, and preemption — recovering the 60–80% of GPU memory naive allocators waste.
Speculative Decoding
The draft-and-verify algorithm that speeds up LLM decoding 2–3× with zero quality loss — the acceptance rule, why the output distribution is provably unchanged, expected-speedup math, and the Medusa/EAGLE variants.
Ml Systems
Gradient Checkpointing
The memory/compute trade-off that makes training deep models feasible: instead of caching every layer's activations for backprop, cache only a handful of checkpoints and recompute the rest on demand, trading O(L) activation memory for O(√L) memory at the cost of one extra forward pass.
Population Stability Index (PSI): Measuring Distribution Drift
Step-by-step PSI computation with equal-frequency binning, a fully worked 10-bin example, the zero-bin edge case, why PSI equals the Jeffreys divergence, and an actionable response guide for each threshold band.
Model Evaluation
Concordance: the c-statistic, Somers' D, Gini and Kendall's tau
Concordant, discordant and tied pairs from first principles: the c-statistic as AUC without a curve, Somers' D and Gini as rescalings of it, Kendall's tau-a and Goodman–Kruskal gamma as different tie conventions, the O(n log n) rank-sum shortcut, and what binning a score does to each.
Decile Analysis: Gains, Lift, KS and Rank Ordering
The rank-ordering table a model validation pack opens with: equal-count deciles, cumulative gains and capture rate, lift and cumulative lift, the KS statistic as the widest gap between the two cumulative curves, monotonicity breaks, and the Hosmer–Lemeshow goodness-of-fit test computed on the same bins.
Is That Difference Real? DeLong, McNemar and Paired Resampling
Statistical tests for model comparison on a shared test set: DeLong's test for correlated AUCs derived from placement values, McNemar's test on the discordant cells, the paired bootstrap and the exact within-subject permutation test, confidence intervals over p-values, and correcting for a leaderboard's worth of comparisons.
Platt Scaling and Isotonic Regression
The two workhorse post-hoc calibration maps: Platt scaling fits a logistic sigmoid on classifier scores (with regularized targets), while isotonic regression fits a monotonic step function via the Pool-Adjacent-Violators algorithm. Derivations, a worked PAV trace, and when each wins.
ROC Curve and AUC: Derivation and Rank-Sum Interpretation
Step-by-step ROC curve construction from sorted scores, why AUC equals the probability that a random positive ranks above a random negative (Wilcoxon-Mann-Whitney equivalence), PR-AUC for class-imbalanced data, and practical threshold selection criteria.
Neural Networks
Activation Functions: From Sigmoid to GELU
Why networks need non-linearity, the saturation and dead-neuron failure modes, and a worked comparison of sigmoid, tanh, ReLU and its variants, ELU, GELU, Swish, and softmax — with derivatives and a practical chooser.
Automatic Differentiation: How Autograd Actually Works
What a framework does between your forward pass and your gradients — the tape it records, the topological order it replays, the += that makes fan-out correct, and why activations dominate training memory.
Batch Normalization: Forward Pass & Running Stats
Normalize-then-rescale procedure with learnable γ/β, 4-element worked example (x=[2,4,6,8], μ_B=5, σ²_B=5), and exponential moving average running statistics for deterministic inference.
Dropout: Inverted Dropout, Regularization Mechanism, and MC Dropout
The inverted dropout algorithm and why it requires no test-time rescaling, the ensemble interpretation as training exponentially many subnetworks, spatial dropout for CNNs, the problematic interaction with batch normalization, and Monte Carlo dropout as approximate Bayesian inference for uncertainty quantification.
Gradient Descent Optimizers: SGD, Momentum, Adagrad, RMSprop & Adam
The update rules behind every deep-learning optimizer — plain SGD, momentum and Nesterov, the adaptive family (Adagrad, RMSprop, Adadelta), Adam with bias correction, and AdamW — plus when each one fails and how to choose.
GroupNorm & InstanceNorm: Batch-Independent Normalization
The shared normalize-then-rescale formula behind GroupNorm and InstanceNorm, with explicit reduction axes, a worked trace on a toy (N,C,H,W) tensor, and a comparison table against BatchNorm and LayerNorm.
Inductive Bias & Equivariance
The second thread that runs through every architecture: CNNs, RNNs, transformers, and GNNs are one idea — match the model's symmetry to the data's symmetry — in four instantiations. Learn equivariance, why the right bias buys sample efficiency, what breaks when it's wrong, and why attention is the 'remove the bias, inject position' move.
Learning Rate Schedules: Warmup, Decay & Restarts
Why a fixed learning rate is rarely optimal, and the schedules that fix it — step and exponential decay, cosine annealing, linear warmup, one-cycle, reduce-on-plateau, and SGDR warm restarts — with formulas and a practical chooser.
Softmax + Cross-Entropy Gradient
Softmax formula, 3-class numeric worked example, cross-entropy loss derivation, and full chain-rule proof of ∂L/∂z_k = p̂_k − 1[k=y] with finite-difference verification.
The Perceptron Learning Algorithm
Update rule derivation, OR-dataset convergence trace (2 mistakes, boundary x₁+x₂=0), XOR impossibility proof by contradiction (4 inequalities), and the hidden-layer fix with full forward-pass trace.
Nlp
BM25: Lexical Ranking
The probabilistic bag-of-words ranking function behind classic search — TF-IDF's successor with term-frequency saturation and document-length normalization, a full worked score, and where it beats (and loses to) dense embeddings.
Byte-Pair Encoding (BPE)
The subword tokenization algorithm behind GPT — iterative pair merging, a full worked trace, and a from-scratch implementation.
Dependency Parsing
AdvancedRecovering the grammatical structure of a sentence — dependency trees, transition-based and graph-based parsers, and neural approaches.
GloVe Training Procedure
How GloVe learns word vectors from global co-occurrence statistics — matrix construction, weighting function, and the least-squares objective.
HNSW: Hierarchical Navigable Small World Graphs
How the default ANN index works from the inside — skip-list layers over a proximity graph, the greedy-descent + ef beam search, the insertion algorithm with M/efConstruction, a worked search trace, complexity, and the delete/memory gotchas.
Text Generation Metrics: BLEU, ROUGE & METEOR
The classic n-gram-overlap metrics for scoring machine translation and summarization against a reference: BLEU's modified precision + brevity penalty, ROUGE's recall-oriented n-gram/LCS overlap, and METEOR's precision/recall harmonic mean with stemming and a fragmentation penalty — worked by hand on one candidate sentence.
Vector Databases & ANN Indexes
How vector databases search millions of embeddings in milliseconds — exact kNN vs the approximate-nearest-neighbour index families (IVF, HNSW, product quantization), the recall/latency trade-off, and metadata filtering.
Probabilistic Models
Factor Analysis
A latent variable model that explains high-dimensional observations through a small number of hidden factors — and how EM fits it.
Independent Component Analysis (ICA)
Blind source separation — recovering independent signals from mixed observations using non-Gaussianity.
The EM Algorithm
Expectation-Maximization step by step — the ELBO derivation, monotonic likelihood proof, and a full worked iteration on a 1D Gaussian mixture.
Probability
Beta-Bernoulli Conjugate Posterior
Five-step derivation showing how Beta×Bernoulli produces another Beta — with exponent collection, posterior recognition, and a numeric update from Beta(2,2) with 7 heads in 10 flips.
Hypothesis Testing: Null, Alternative & p-values
What the null and alternative hypotheses actually claim, how a test statistic turns data into a p-value, what that p-value does and does not mean, and how significance level α trades off Type I against Type II error.
Information Theory for ML: Entropy, KL Divergence, and Cross-Entropy
Shannon entropy as a measure of surprise and compressibility, KL divergence as the cost of using the wrong model, cross-entropy loss as negative log-likelihood under a categorical distribution, mutual information for feature selection, and how these quantities unify probabilistic ML losses.
MCMC Sampling: Metropolis–Hastings & Gibbs
AdvancedWhy intractable posteriors need sampling, the Metropolis–Hastings acceptance ratio and detailed balance, Gibbs sampling from full conditionals, and the practical machinery — burn-in, thinning, acceptance-rate tuning, trace plots, R-hat and effective sample size.
MLE for the Gaussian
Eight-step derivation of the maximum-likelihood estimates for Gaussian mean and variance — differentiate, set to zero, solve, and interpret the bias.
Probability Distributions: A Field Guide & Where They're Used
A reference catalog of the distributions that show up in ML — Bernoulli, Binomial, Categorical, Poisson, Gaussian, Exponential, Gamma, Beta, Dirichlet, Laplace, Student-t and more — with parameters, mean/variance, the relationships between them, and the modeling job each one does.
Sampling Methods: Inverse Transform, Rejection & Importance Sampling
How to draw samples from a distribution you can only evaluate — inverse-transform sampling, rejection sampling and its acceptance rate, importance sampling for hard expectations, and variance-reduction tricks, with a bridge to MCMC.
The Bootstrap: Resampling for Standard Errors & Confidence Intervals
The plug-in principle, the core resample-with-replacement algorithm, percentile / basic / BCa confidence intervals, why ~63.2% of rows appear in each resample, when the bootstrap fails, and the block bootstrap for dependent data.
The Gaussian Integral (Normalization Constant)
Full 2-D polar-coordinate proof that ∫e^{−x²/2}dx = √(2π), followed by derivations of E[X]=μ and Var(X)=σ² for the Gaussian using substitution and integration by parts.
The Kolmogorov–Smirnov Test: Comparing Distributions
The empirical CDF, the supremum D statistic for one- and two-sample tests, how the KS distribution turns D into a p-value, a worked example, and when to reach for KS vs PSI vs Anderson–Darling for drift detection.
Probability Statistics
Recommender Systems
Reinforcement Learning
GRPO: Group Relative Policy Optimization
How DeepSeek trains reasoning models without a critic — sample a group of completions per prompt, normalize rewards within the group into an advantage, and optimize a clipped surrogate objective with a KL penalty against a reference policy.
Imitation Learning
Learning policies from expert demonstrations — behavioral cloning, DAgger, and GAIL.
Inverse Reinforcement Learning
AdvancedRecovering the reward function from expert behavior — the reward-ambiguity problem, max-margin and maximum-entropy IRL.
Multi-Agent Reinforcement Learning
AdvancedRL when multiple learning agents share an environment — game-theoretic equilibria, non-stationarity, and CTDE algorithms.
Partially Observable MDPs (POMDPs)
AdvancedDecision-making when the agent can't see the true state — belief states, the belief-MDP, and approximate solvers.
Sequence Models
Backpropagation Through Time (BPTT)
The chain rule unrolled over time — how RNN gradients accumulate across steps and how one step's Jacobian is derived.
Vanishing & Exploding Gradients: Spectral Analysis
Why the product of RNN Jacobians decays or grows exponentially — the spectral norm bound, three regimes table, and numeric decay/growth tables at multiple spectral radii.
Streaming
ADWIN: Adaptive Windowing for Drift Detection
A change detector that also maintains an optimally-sized window — the split test with its Hoeffding cut, why the window length itself estimates the current concept, the exponential-histogram implementation for O(log W) memory, and the false-alarm/detection guarantees. With a worked cut calculation.
DGIM: Counting Ones in a Sliding Window
How to count the 1-bits in the last N elements of a stream using O(log²N) bits instead of N — exponential buckets, the at-most-two-per-size rule, the merge step, and the ≤50% error bound. With a full worked bucket trace.
HyperLogLog
Counting distinct elements in kilobytes — from the Flajolet-Martin trailing-zero trick to stochastic averaging over registers, the harmonic-mean estimator, its 1.04/√m error, and the small/large-range corrections. With a worked trace.
The O(√T) Regret Bound for Online Gradient Descent
A full proof that online gradient descent has sublinear regret — the projection inequality, the convexity step, the telescoping sum, tuning the step size to D·G·√T, and the decaying-step and strongly-convex refinements. With a worked numeric example.
Supervised Learning
AdaBoost Algorithm
The original boosting algorithm — 6-step procedure, deriving the model weight α from exponential loss minimization, and a complete one-round worked trace with weight normalization.
Bias-Variance Decomposition
Full algebraic derivation of E[(y−f̂)²] = Bias² + Variance + σ², KNN at k=1 vs k=n, empirical estimation via repeated resampling, and a diagnosis table.
Decision Tree: Information Gain
Gini impurity, entropy, weighted child impurity — the complete split-scoring procedure with a full worked trace across all nine candidate thresholds.
Logistic Regression: Gradient Derivation
Five-link chain rule showing why the cross-entropy + sigmoid gradient collapses to ŷ − y — with a 2-point numeric worked step.
Minkowski Distance Family
Euclidean, Manhattan, and Minkowski distances defined and contrasted — with a full worked example computing all metrics for (1,2,3)→(4,6,3), and a table of the p-parameter's geometric effect.
OLS: The Normal Equation
A four-step algebraic derivation of w* = (XᵀX)⁻¹Xᵀy from first principles, with a complete 3-point hand-worked example.
Ridge & Lasso Regularization Paths
Step-by-step derivation of the Ridge closed-form solution, the Lasso's constant-gradient sparsity mechanism, and how coefficients evolve as λ sweeps from 0 to ∞.
VC Dimension
Capacity measured by shattering: the VC dimension of a hypothesis class, why a 2D linear classifier has VC dimension 3, the growth function and Sauer's lemma, and the generalization bound it yields.
Time Series
ACF & PACF: Reading the Correlogram
How to compute ACF and PACF from first principles, the significance bands, and a pattern-matching guide for identifying AR, MA, and ARMA orders from the plots.
ARIMA Order Selection: Box-Jenkins Methodology
The complete Box-Jenkins procedure — ADF test for d, ACF/PACF reading for p and q, model fitting, residual diagnostics — worked end-to-end on a 36-observation monthly dataset.
Hierarchical Forecasting & Reconciliation
Top-down, bottom-up, and optimal reconciliation methods for coherent forecasts across aggregation hierarchies — with the MinT reconciliation algorithm derived step by step.
The Augmented Dickey-Fuller Test
A deep dive into the ADF unit-root test — why stationarity is a statement about the roots of the AR characteristic polynomial, what regression the test actually runs, how to read the test statistic against the non-standard Dickey-Fuller distribution, and exactly what the p-value does and does not tell you.
Walk-Forward Validation
Time-series-aware model evaluation — why k-fold leaks the future, the expanding-window and sliding-window schemes, and a worked trace computing CV error on a 12-observation sequence.
Transformers
Attention Mechanisms: Self, Cross, Causal, MHA, MQA, and GQA
A unified reference for every attention variant used in modern transformers — self-attention, cross-attention, causal masking, multi-head attention, multi-query attention (MQA), grouped-query attention (GQA), and FlashAttention — with memory and complexity analysis.
Positional Encodings: Sinusoidal, RoPE, ALiBi, and Learned
How Transformers encode token position: the original sinusoidal formula and its frequency properties, learned absolute embeddings, relative position bias (T5), rotary position embeddings (RoPE), and attention with linear biases (ALiBi) — with length-extrapolation tradeoffs for each.
Scaled Dot-Product Attention
The Query-Key-Value mechanism with the √d_k variance derivation and a complete 3-token hand-worked example tracking scores, softmax weights, and output.
Unsupervised Learning
DBSCAN: Core, Border, Noise Classification
Formal point-type definitions with neighborhood conditions, 9-point worked example classifying every point at ε=2 and min_samples=3, and the k-distance elbow method for parameter selection.
Hierarchical Clustering Linkage Methods
Single, complete, average, and Ward linkage defined and contrasted — with a 4-point distance matrix and step-by-step merge trace for each linkage showing exactly where they agree and disagree.
K-Means: Full Algorithm
The 4-step assign/update procedure with convergence proof, and a complete 5-point 2-cluster worked iteration showing all distance calculations and centroid updates.
Case Studies
Ad Auction Mechanisms & Smart Bidding
Second-price auctions, Generalized Second Price (GSP), VCG, reserve prices, and how ML-powered smart bidding optimizes advertiser ROI across auction rounds.
Graph-Based Fraud Detection with GNNs
How Graph Neural Networks detect synthetic identity fraud by propagating risk through entity-sharing graphs — homophily, message passing for fraud, and incremental graph updates.
Text-to-SQL: LLM-Powered Database Querying
Schema-aware prompting, execution validation, and self-correction loops for translating natural language questions into SQL — with the patterns used by Salesforce, Uber, and Grab.
The Cold Start Problem in Recommender Systems
Strategies for new users, new items, and new contexts — content-based fallback, meta-learning, onboarding intent capture, and hybrid approaches used by Airbnb, Netflix, and Spotify.