Vectors, dot products, matrices, derivatives, gradient descent, probability, and a tiny neural network that learns — the intuition behind embeddings and training, learned by building a small toolkit instead of reading proofs.
Every AI explainer eventually says something like "the model turns words into vectors, multiplies them by matrices, and nudges the weights along the gradient of the loss." Most people nod and move on, because the words sound like a wall of university math. They are not. Each one is a small idea you can run in twenty lines of JavaScript, and once you have seen it run, the sentence stops being a wall.
This series teaches exactly the math that sentence uses, and nothing more. A vector is a list of numbers, and with it you can compare a student, a color, or a word. The dot product measures how much two vectors point the same way, which is the heart of search by meaning. A matrix is a table of numbers that transforms a vector, which is what one layer of a neural network does. A derivative is a slope, a gradient is a slope in many directions at once, and gradient descent is walking downhill until the error is small. Probability, logarithms, and cross-entropy explain why a language model's training loss looks the way it does. Finally you put all of it together in a small neural network that learns a problem a straight line cannot.
You build everything yourself. Across the series you grow mathai,
a zero-dependency Node.js toolkit with a vector module, a matrix module,
a numeric-derivative module, a gradient descent runner, a statistics
module, and a tiny neural network with hand-written backpropagation.
Every program prints real numbers you can check by hand, and nothing
needs an API key, a GPU, or a paid account.
Two honest notes. First, this is intuition with working code, not a math course: there are almost no proofs, and where something is simplified, the chapter says so. Real systems use libraries that run the same operations thousands of times faster on specialized hardware. The ideas are identical; the speed is not. Second, you do not need to memorize any of it. The goal is that when someone says "embedding", "loss", or "gradient", you know what is being computed, and you can say it to a class of students without hiding behind jargon.
You need basic JavaScript from JavaScript & TypeScript
Fundamentals and the
terminal from Command Line Basics.
School algebra is enough: you should be comfortable with y = 2x + 1.
Math for Programmers is a helpful
warm-up, especially its chapters on functions and
logarithms
and probability,
and How LLMs Work shows where each idea ends
up inside a language model. You need Node.js (the
LTS version) and a code editor such as Visual Studio
Code. Everything is free.