Start here

How to work through a lesson

Every lesson has the same parts in the same order. This page tells you what to do in each part, where to run the code, and what to do when an exercise stops you. Read it once before your first lesson, then come back when a step is not clear.

Set up once

The lessons run on your own computer. You read on the website or on GitHub, and you run the code from a copy of the repository. Clone it once:

git clone https://github.com/rohitg00/ai-engineering-from-scratch.git
cd ai-engineering-from-scratch
python3 phases/00-setup-and-tooling/01-dev-environment/code/verify.py --route beginner

The check tells you which tools you need now and which you need later. Each failure prints the reason and a command that fixes it. Run every lesson command from this folder, the repository root. It contains README.md and phases/.

Each lesson is a folder such as phases/01-math-foundations/01-linear-algebra-intuition/. It has docs/en.md (the text you read), code/ (the program you build and run), outputs/ (what the lesson ships), and quiz.json. If you are new, start with Phase 0, Dev Environment.

Read: motto, problem, concept

The first parts explain the idea. Read them with the code closed. When you finish, say the idea in two sentences in your own words: what problem it solves, and how. If you cannot, read the Concept part again before you write code.

Build It: write the small version yourself

Build It makes the idea from plain code, with no framework. The finished program is in the lesson's code/ folder, and the lesson page shows the command that runs it, for example:

python3 phases/01-math-foundations/01-linear-algebra-intuition/code/vectors.py
  1. Make your own file, for example my_vectors.py, in a folder of your own such as scratch/. Type the code from the lesson step by step. Do not copy and paste it.
  2. Run your file after each step. Compare its output with the output in the lesson.
  3. Run the finished file in code/ to see the correct result when yours is different.
  4. Change one value, predict the new output, then run the code again. If your prediction is wrong, find the line that causes the difference.

Use It: do the same thing with a real library

Use It does the same work with the library that people use in practice, such as NumPy, scikit-learn, or PyTorch. You see what the library does for you because you wrote the small version first. Install the libraries in a virtual environment in the repository root:

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

On Windows, run .venv\Scripts\activate in place of the source line. The requirements.txt file has every library in the course. For one lesson, install only the libraries that its Use It code imports, for example pip install numpy. Put the Use It code in your own file, run it, and check that its result is the same as the result of your Build It code.

Ship It: keep a tool you can use again

Ship It names the file that the lesson produces in its outputs/ folder. You do not deploy anything. The file is a tool for your daily work:

Open the output file and read it. Change one line so that it fits your work better. A tool that you use every week teaches you more than a tool that you only read.

Exercises: a routine for each one

The exercises do not show the answer. Use these steps:

  1. Say the task again. Write what goes in and what must come out.
  2. Predict. Calculate a small case by hand before you write code, for example two vectors with two numbers each.
  3. Start from the lesson code. Most exercises add one function or one change to the Build It code. Find the function that is nearest to the task.
  4. Write the smallest version that works for your small case.
  5. Check. Compare with your prediction. Then test one edge case, such as a zero vector or an empty list.

Many lessons have a Hints part after the exercises. Each hint gives you the first step and a way to check your answer. Open a hint only after you try the steps above.

Quiz and checkpoints

On the website, the panel at the top of each lesson has five checkpoints: read, build, run, prove, and continue. Mark each one when you finish it. The quiz at the end tests the main ideas. Your progress stays in your browser only. Go to the next lesson when you can explain the output of the code and make one small change without guessing.

Projects: pick by goal

Projects are larger programs that you build in stages, with tests for each stage. Start a project when you finish the phases that it needs.

When you are stuck

Write down the command, the folder you ran it from, and the full error. Most problems are a wrong folder, a missing library, or an old Python version. Run the setup check again. If the problem continues, search the issues or ask in discussions. Put the lesson path, the command, and the error in your question.