How to Run Individual Lesson Code Locally for AI Engineering from Scratch
TLDR: Clone the rohitg00/ai-engineering-from-scratch repository, install the language-specific dependencies for your stack, navigate to the lesson's code/ folder, and execute the entry-point file with the appropriate interpreter or compiler.
The rohitg00/ai-engineering-from-scratch curriculum is organized into self-contained lessons that you can execute independently on your local machine. Each lesson includes a runnable entry point—such as main.py, main.ts, main.rs, or main.jl—and a dedicated test suite, so you can run individual lesson code locally for AI Engineering from Scratch without processing the entire curriculum. The repository follows a predictable directory structure under phases/<NN>-<phase-name>/<NN>-<lesson-name>/code/, making it easy to locate and launch any specific topic.
Clone the Repository
Start by cloning the entire curriculum to get a version-locked snapshot of every lesson:
git clone https://github.com/rohitg00/ai-engineering-from-scratch.git
cd ai-engineering-from-scratch
Because the repository is Git-tracked and each lesson is a separate commit, cloning gives you a clean, reproducible copy of all source files.
Install Language-Specific Dependencies
The curriculum deliberately limits dependencies to each language's standard library plus a small set of approved Python libraries. This keeps builds reproducible and educational, as documented in AGENTS.md. Install only what your target lesson requires:
- Python – Run
pip install -r requirements.txtfrom the repository root. The root-levelrequirements.txtfile is the single source of truth for all Python dependencies across lessons. - TypeScript – Run
npm install && npm install -g tsx(requires Node 20 or later). Apackage.jsonis generated by CI and provides the project context. - Rust – No external crates are needed. Every Rust lesson compiles against the standard library only, as noted in the repository rules.
- Julia – Standard library only. If a
Project.tomlexists, runjulia -e 'using Pkg; Pkg.instantiate()', but most lessons require no extra packages.
Locate the Lesson Code Directory
The repository tree follows a consistent pattern:
phases/
<phase-number>-<phase-name>/
<lesson-number>-<lesson-slug>/
code/
main.<ext>
docs/en.md
outputs/
quiz.json
For example, the Linear Algebra "Vectors" lesson lives at:
phases/01-math-foundations/01-linear-algebra-intuition/code/vectors.py
Navigating directly to that folder is the first step before you can execute the lesson.
Execute the Lesson Entry Point
Once inside the repository, run the lesson's entry-point file from your terminal using the command that matches its language.
Python Lessons
python phases/01-math-foundations/01-linear-algebra-intuition/code/vectors.py
The file contains an if __name__ == "__main__": block that prints a self-checking demo, typically found in the lower section of the script.
TypeScript Lessons
npx tsx phases/07-transformers-deep-dive/02-self-attention-from-scratch/code/main.ts
The TypeScript lessons ship a main.ts that executes with tsx, which bundles ESM support for immediate running.
Rust Lessons
rustc phases/10-llms-from-scratch/01-tokenizers/code/main.rs -O && ./main
All Rust lessons compile with a single rustc invocation because they depend solely on the standard library.
Julia Lessons
julia --project=phases/12-multimodal-ai/01-vision-transformer-patch-tokens/code/main.jl
Julia lessons use only the standard library, so no additional package installation is required before execution.
Verify with Lesson Tests (Optional)
Each lesson ships a tests/ directory. Running the native test runner confirms that the implementation matches the curriculum's expected behavior:
- Python –
python -m unittest discover -s phases/01-math-foundations/01-linear-algebra-intuition/code/tests -v - TypeScript –
npx jest(when ajest.config.jsis present) - Rust –
cargo test(for lessons that include aCargo.tomlplaceholder) - Julia –
julia --project=... -e "using Pkg; Pkg.test()"
Quick Reference Cheat Sheet
Keep these one-line patterns handy for any lesson:
- Clone:
git clone https://github.com/rohitg00/ai-engineering-from-scratch.git && cd ai-engineering-from-scratch - Install (Python):
pip install -r requirements.txt - Find lesson files:
ls phases/09-reinforcement-learning/08-ppo/code - Run (Python):
python phases/09-reinforcement-learning/08-ppo/code/main.py - Run (TypeScript):
npx tsx phases/07-transformers-deep-dive/02-self-attention-from-scratch/code/main.ts - Run (Rust):
rustc .../main.rs -O && ./main - Run (Julia):
julia --project=.../code/main.jl - Test (Python):
python -m unittest discover -s .../tests -v - Interactive picker:
python $(git ls-files "phases/*/*/code/*.py" | fzf)(replacepythonwithnpx tsx,rustc … && ./main, orjulia …for other languages)
Summary
- The
rohitg00/ai-engineering-from-scratchrepository arranges every lesson underphases/<phase>/<lesson>/code/with a runnable entry-point file. - You can run individual lesson code locally for AI Engineering from Scratch by cloning the repo, installing the minimal language-specific dependencies, and executing the target
main.<ext>file. - Python lessons rely on the root
requirements.txt, while TypeScript, Rust, and Julia lessons prioritize standard-library or near-standard-library tooling. - Optional test suites in each
tests/directory let you validate your local execution against the curriculum's expectations. - The optional helper script
scripts/install_skills.pyautomates the installation of reusable skill artifacts produced by lessons.
Frequently Asked Questions
Can I run a lesson without completing previous lessons?
Yes. Every lesson is self-contained. The repository structure isolates each topic in its own code/ directory, so you can jump directly to any phase or lesson and execute its entry point independently without running prior material.
Why does the curriculum avoid external dependencies?
According to the AGENTS.md policy, the curriculum enforces a standard-library-first dependency policy. This keeps setup minimal, reduces version conflicts, and ensures that you spend time learning AI engineering concepts instead of debugging dependency trees.
Do I need to install a separate environment for each lesson?
No. A single Python virtual environment with the root requirements.txt installed is sufficient for all Python lessons. Similarly, one global tsx installation handles all TypeScript lessons, while Rust and Julia lessons require no per-lesson package management at all.
Where are the skill artifacts that lessons produce?
Some lessons generate reusable skill artifacts that are used later in the curriculum. You can automate their installation with the optional helper script scripts/install_skills.py, which collects and sets up artifacts produced across the repository.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →