Learn AI Layer by Layer

Learn AI Layer by Layer

A hands-on guide to how modern AI actually works, built up from scratch one idea at a time. No math or coding background needed. Every chapter is full of widgets you can poke, drag, and break.

15 chapters80 interactive widgetsFree, no sign-up

Teaching a class? See the guide for educators

  1. Part 1

    The building blocks

    How a machine made of numbers can learn to do things nobody told it how to do.

    01100110111111111111111111111111011111100011110000011000cat99 97 116
    Chapter 1

    Computation

    Everything is numbers

    4 interactive widgets
    errorknob setting →
    Chapter 2

    Optimization

    The power of incremental improvement

    7 interactive widgets
    Chapter 3

    Neural Networks

    Building a brain

    9 interactive widgets
  2. Part 2

    Meaning as numbers

    How words become something a computer can reason about, and why predicting the next word requires understanding.

    size →fluffy →similarmousecatdogelephant
    Chapter 4

    Vectors

    Describing the world with numbers

    9 interactive widgets
    ANIMALSFRUITVEHICLEScatdoghorseapplebananacherrycarbusbike
    Chapter 5

    Embeddings

    From words to meanings

    8 interactive widgets
    Once upon atimetime74%hill9%dragon6%star4%
    Chapter 6

    Next-Word Prediction

    Understanding by predicting

    4 interactive widgets
  3. Part 3

    The transformer

    The architecture behind every modern chatbot, built from the pieces you already have.

    72%Thecatatebecauseitwashungry
    Chapter 7

    Attention

    Letting words look at each other

    6 interactive widgets
    #1the#2dog#3bit#4the#5man
    Chapter 8

    Positional Encoding

    Where am I?

    7 interactive widgets
    attentionneural netattentionneural netattentionneural netThecatsatonthemat
    Chapter 9

    Transformers

    One architecture to rule them all

    3 interactive widgets
  4. Part 4

    From model to assistant

    How a document-continuing machine becomes something that chats, reasons, and gets things done.

    What's the capital of France?BEFOREWhat's the capital of Spain? What's…AFTERThe capital of France is Paris.
    Chapter 10

    Post-Training

    Teaching a model to be useful

    3 interactive widgets
    User:Can you help me?AI:Sure! With what?User:Name a fruit.AI:Banana!
    Chapter 11

    Conversations

    One long document, pretending to be a chat

    3 interactive widgets
    17 × 24 =?408THINKING…17 × 20 = 34017 × 4 = 68340 + 68 = 408working it out before answering
    Chapter 12

    Reasoning

    Thinking by talking to yourself

    2 interactive widgets
    AIthinkuse a toolcheck resultfind flightscompare pricesbook a seat
    Chapter 13

    Agents

    Getting things done

    3 interactive widgets
  5. Part 5

    AI in the world

    What AI is doing to the society around it, and the realistic ways it could go badly wrong.

    homeworknewsworkadviceartcodeAI
    Chapter 14

    AI and Society

    Changing the shape of the world

    5 interactive widgets
    human → AIsend emailspend moneydeploy codefly dronesat stake
    Chapter 15

    Catastrophic Risk

    Could AI go badly wrong?

    7 interactive widgets
Want to write the code yourself?

Every chapter comes with real PyTorch code

Each chapter ends with an optional notebook you can run in Google Colab, with nothing to install. New to PyTorch? The PyTorch from Scratch appendix teaches you enough to follow along.

PyTorch from Scratch →

Coming soon

16 more chapters are planned, covering the ideas behind today's cutting-edge models.

Want to know when more chapters are written?

I announce each new chapter on my blog, Messy Progress. Subscribe and you'll get an email when the next one is out.

Subscribe to Messy Progress

Appendixes