The maths behind AI.

Start with a single number. Finish by training a language model on your own device. 110 short lessons in 4 courses, and every idea in them is something you can drag, break and run again.

The whole of machine learning rests on this one line. Tap a symbol.

←\leftarrowθ\theta−-

∇L, the gradient of the loss. The direction in which the model gets more wrong, fastest. Subtracting it moves the ball downhill, which is all the animation is doing.

step 0loss 0.000
Tap the surface to drop the ball somewhere else.high losslow loss

4 courses. Start with the one that fits.

Each course stands on its own, and they link up: the maths explains what the Python computes, and the last course puts both to work.

Train a language model without leaving this page.

This is the model from the final module, running for real. A transformer with one attention layer learns to invent Indian names from 500 examples. Press Train and watch the loss fall. Then open Predict to see its bet on every next letter, or Ask to have it finish a name you start.

gradient.atomica.in/lab/tiny-gptNothing is uploaded. The model trains in this tab.
Loading the interactive…

You type. Then six things happen.

This is a trained model, the same kind you will build. Type two letters, press Play, and follow them through every stage: tokens, ids, vectors, attention, scores, and the pick of the next character.

A chatbot runs these same six stages once for every token it writes. The lesson that goes with this tool explains each one.

Read the lesson
Loading the interactive…

Every idea is something you can operate.

There are 61 interactive tools and animations in the course. This one is from the lesson on optimisers: three ways of walking downhill, racing from wherever you tap.

Loading the interactive…

7 labs to keep experimenting in.

Each lab is a full-size version of a tool from the lessons, with every setting unlocked and a plain explanation of what you are looking at.

How a lesson works.

  1. Step 1

    Read

    An everyday comparison first, then a short explanation with the real formulas, and a note on where AI uses the idea. Nothing is hand-waved and nothing is skipped.

  2. Step 2

    Play

    A working model of the idea. Move a slider, drag a point, press Step. You see what the formula does before you are asked to trust it.

  3. Step 3

    Check

    Three questions. Each one explains its answer as soon as you choose. Get two right and the lesson is marked done.

What you should know before starting

  • Free to learn

    Lesson 1 is open. A free account unlocks the rest and saves your progress.

  • Runs on your device

    Models train in the page. Nothing you type is uploaded.

  • Built for a phone first

    Every model works with a thumb as well as a mouse.

  • Nothing hidden

    Every formula is shown, and the training code is readable.

Questions people ask first.

Do I need to be good at maths?

You need school arithmetic and a little algebra: what a variable is and how to read a graph. Vectors, derivatives and probability are all built up from there, one idea at a time.

Is it free?

Yes. The first lesson of every course and the model on this page are open to everyone. A free account, which needs only a name, an email address and a password, unlocks the other lessons and the labs and keeps your progress on every device you use.

Do I need a powerful computer?

No. The models here are small enough to train on a phone. The largest one in the lab has about 60,000 parameters, and a first training run takes well under a minute.

Does anything I type get uploaded?

No. Training runs on your own device, inside the browser, and text you paste into a lab stays there. The only things kept on the server are your account details and which lessons you have finished.

Will this teach me to program AI?

Yes, if you want it to. Python for AI has you write real Python in the page, from your first line to a network that learns, with nothing to install. The maths course has no coding at all.

I am not a maths person. Is there something for me?

Yes. AI for everyone explains what AI is, how to use it well and where it goes wrong, with no formulas at all.

What will I be able to explain at the end?

What happens between typing a question and the first word of the answer appearing, step by step. Also how a network learns from its mistakes, how an image generator draws, why a chatbot sometimes invents facts, and what really differs between a model you train here and the largest ones.

How long do the courses take?

There are 110 lessons of 5 to 12 minutes each across 4 courses, about 15 hours in total. Most people do one or two a day.

Who makes Gradient?

Gradient is made by Atomica, the learning platform for physics, chemistry, mathematics, time and space.

Lesson 1 takes 5 minutes and needs no account.

It is called "Multiplication", and it shows why every AI model, however large, is one function.