How to Run Lesson Code Locally for Python, TypeScript, Rust, and Julia in AI Engineering From Scratch

Clone the repository, navigate to any lesson's code/ directory, and execute the entry file using the language-specific workflow—Python files run directly with Python 3.10+, TypeScript requires Node 20 and npm run start, Rust compiles with rustc, and Julia runs via the julia interpreter.

The AI Engineering From Scratch curriculum by rohitg00 organizes lessons into self-contained directories under phases/<phase-number>-<phase-name>/<lesson-number>-<lesson-slug>/code/. Each lesson ships with runnable implementations in one or more supported languages, following a minimal-dependency policy that keeps implementations free of heavy AI libraries unless explicitly marked with a # requires: comment.

Understanding the Repository Structure

Every lesson follows a uniform folder layout that makes it trivial to locate entry points. The repository structure places language-specific files inside the code/ directory at the lesson level, with subdirectories like ts/ for TypeScript when multiple implementations coexist. According to the source code organization, this standardization allows the scripts/lesson_run.pyhelper to batch-check Python files across the entire curriculum without requiring manual navigation.

Running Python Lessons

Python lessons require Python 3.10 or higher and run as pure-Python scripts unless external dependencies are specified. The typical entry file is named descriptively (e.g., vectors.py) and lives directly in the code/ folder.

Basic Execution

Navigate to the lesson directory and invoke the file directly:

git clone https://github.com/rohitg00/ai-engineering-from-scratch.git
cd ai-engineering-from-scratch
python3 phases/01-math-foundations/01-linear-algebra-intuition/code/vectors.py

Batch Syntax Checking

The repository provides a batch runner at scripts/lesson_run.py to validate the entire curriculum without executing heavy dependencies:


# Syntax-only check for all Python lessons

python3 scripts/lesson_run.py

# Execute each entry file (skips lessons with heavy dependencies unless forced)

python3 scripts/lesson_run.py --execute

The script uses py_compile to verify syntax and enforces a 10-second timeout when running files.

Running TypeScript Lessons

TypeScript lessons require Node.js 20 or higher and assume a self-contained project structure within code/ts/. The only recurring runtime dependency is zod for validation in select lessons, with tsx handling execution.

Setup and Execution

From the lesson directory, install dependencies and run the start script:

cd phases/19-capstone-projects/01-terminal-native-coding-agent/code/ts
npm install
npm run start

The package.json defines the start script as tsx src/index.ts, which compiles and runs the entry point. Most lessons also include a test script for validation:

npm run test

The entry point for TypeScript lessons is typically src/index.ts, as seen in phases/19-capstone-projects/01-terminal-native-coding-agent/code/ts/src/index.ts.

Running Rust Lessons

Rust lessons are implemented as single-file programs that do not require Cargo projects. You need Rust 1.70 or higher (rustc).

Compilation and Execution

Compile the source file with optimization and run the resulting binary:

cd phases/10-llms-from-scratch/01-tokenizers/code
rustc bpe.rs -O -o bpe
./bpe

The bpe.rs file in phases/10-llms-from-scratch/01-tokenizers/code/ demonstrates the BPE tokenizer implementation. Each Rust lesson includes compilation commands in its implicit documentation derived from the folder layout.

Running Julia Lessons

Julia lessons require Julia 1.9 or higher and execute as single-file scripts using only the standard library or approved packages like Random and Statistics.

Direct Execution

Launch the lesson file directly from the code/ directory:

cd phases/07-transformers-deep-dive/01-why-transformers/code
julia main.jl

The main.jl file in phases/07-transformers-deep-dive/01-why-transformers/code/ serves as the entry point for transformer architecture explorations.

Summary

  • Python: Run individual files with python3 or batch-check with scripts/lesson_run.py; requires Python 3.10+.
  • TypeScript: Use npm install and npm run start inside code/ts/ directories; requires Node 20.
  • Rust: Compile single files with rustc -O and execute the binary; requires Rust 1.70+.
  • Julia: Launch scripts directly with julia command; requires Julia 1.9+.
  • Dependencies: All lessons follow a "stdlib-first" policy; heavy dependencies are marked with # requires: comments and skipped by default in batch operations.

Frequently Asked Questions

Do I need to install machine learning libraries like PyTorch or TensorFlow to run the lessons?

No. The curriculum follows a "stdlib-first" policy where lessons are deliberately self-contained. Only lessons marked with a # requires: comment depend on external packages, and the scripts/lesson_run.py batch runner skips these unless you explicitly invoke the --execute flag.

Can I run the code without cloning the entire repository?

While you can copy individual files, the repository structure at rohitg00/ai-engineering-from-scratch is designed to work as a whole. Relative paths and the scripts/lesson_run.py utility expect the full directory tree under phases/ to be present. Cloning ensures you have the correct context for imports and helper scripts.

How do I know which dependencies are required for a specific lesson?

Check the file for a # requires: comment at the top. Python lessons without this comment are pure-Python. TypeScript lessons list dependencies in their local package.json. Rust and Julia lessons typically use only the standard library unless explicitly stated in comments or README files within the lesson directory.

Is there a way to verify all lessons compile without running them?

Yes. For Python, use python3 scripts/lesson_run.py without the --execute flag to perform syntax checking across the entire curriculum using py_compile. For Rust, you can compile with rustc without executing the output. TypeScript and Julia do not have official batch syntax checkers in this repository, but individual files can be checked with tsc --noEmit or julia --compile=min respectively.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →