A field guide for engineers moving into ML

The ML Engineer's Math of AI

The ML Engineer needs ~50% of the math — and it's a specific 50%: not proofs and theorems, but working understanding. Every part of it maps to a concrete place in the model and the training loop. This guide is that map: what each part is, where it lives, what it explains, and how deep each one goes.

Where the line is

The 50% is defined by what it must let you do — not by chapters of a textbook.

Inside the 50%

Working fluency — math as a reading and debugging skill:

  • Read the equations in a paper and translate them into tensor code
  • Explain why a training run diverges, plateaus or NaNs — and what to change
  • Reason about shapes, distributions and dtypes as fluently as about types in software
  • Adapt an existing loss or schedule to your data

Beyond it — the research 100%

Producing new math stays on the other side of the line:

  • Proving an optimizer converges, deriving generalization bounds
  • Inventing new objectives (the WGAN move) rather than applying them
  • Measure theory, stochastic calculus, learning theory

That territory has its own guide.

The map: one training step, five kinds of math

Every part of the 50% is the machinery of one stage of the loop you'll run every day.

Anatomy of a training step

Data batch tokens · pixels · rows Forward pass matmuls, shapes, attention 1 · LINEAR ALGEBRA Loss how wrong were we? 3 · PROBABILITY   4 · LOSSES Backward pass chain rule → all gradients 2 · CALCULUS Optimizer step w ← w − η·∇L  (Adam, schedules) 2 · OPTIMIZATION repeat, millions of times Floating-point hardware dtypes · stability · memory — everything above runs on it 5 · NUMERICS & TENSOR CRAFT
This is the whole secret of the 50%: it isn't five subjects — it's five stations of one loop. Understanding any training run means understanding these stations.
Same math, different shapes — under the hood, a CNN, a GAN and a Transformer all run this exact loop on the same three pillars: linear algebra (90% of what the hardware computes), calculus (the chain rule driving learning), and probability (uncertainty and distributions). What changes wildly between families is the loss — which is why it gets its own part of the map.

The five parts — each with its own deep-dive page

Ordered as a roadmap of understanding: each part makes the next one readable.

1 · Linear Algebra

The language every model is written in. Vectors as meaning, matrices as transformations, matmul as 90% of all AI compute — and shapes as your daily debugging reality.

  • Dot product = similarity (attention, RAG)
  • Shape algebra of a transformer layer
  • Low-rank: why LoRA works
Enter the language →

2 · Calculus & Optimization

How models learn: gradients as sensitivity, backprop as the chain rule on a graph, and the optimizer as a hiker descending the loss landscape.

  • Backprop demystified
  • Adam, learning rates, schedules
  • Why residuals & norms exist at all
Enter the engine room →

3 · Probability & Statistics

Models are uncertainty machines: every output is a distribution, training is "make the data probable", and evaluation is statistics whether you notice or not.

  • Softmax, temperature, top-p — decoded
  • MLE: where cross-entropy comes from
  • Is that +0.5% eval win real?
Enter the casino →

4 · Losses & Information Theory

The loss is the product spec: whatever it rewards, the model becomes. One page connects cross-entropy, perplexity, KL and the exotic objectives behind each model family.

  • Why "confidently wrong" costs infinity
  • Perplexity — the LLM report card
  • Contrastive, minimax, diffusion, DPO
Enter the goal system →

5 · Numerics & Tensor Craft

Where math meets silicon: floating-point formats, stability tricks, and the memory arithmetic that decides what fits on a GPU — the part of the 50% you'll use in every debugging session.

  • FP32 / BF16 / FP16 / INT4 — what the bits buy
  • Why naive softmax overflows
  • Training ≈ 16 bytes/param, inference ≈ 2
Enter the machine floor →

Quick orientation: which part explains what

PartCore fluencyIt's the machinery of…It explains…
1 · Linear algebraShapes, matmul, dot products, low-rankEvery layer, attention, embeddingsShape errors, attention cost, why LoRA works
2 · Calculus & optimizationChain rule, gradient descent, Adam, schedulesBackward pass, optimizer stepDivergence, plateaus, why architectures look as they do
3 · Probability & statisticsDistributions, MLE, sampling, eval statisticsOutput layers, decoding, evaluationTemperature, hallucination-as-miscalibration, noisy evals
4 · Losses & informationCross-entropy, KL, perplexity, shaped objectivesThe goal of every training runWhy each model family behaves the way it does
5 · Numerics & tensorsDtypes, stability idioms, memory arithmeticThe silicon everything runs onNaNs, OOMs, quantization, mixed precision
How the map is meant to be walked: each page goes deeper in three levels — intuition (what to picture), working fluency (what you use daily), and the deep end (what to reach for when you need it). You can stop at any level and still have a complete, usable understanding.
← All field guidesArchitect · Engineer · Scientist