ai-engineering-from-scratch

Introduction: Learn it. Build it. Ship it for others.
More: Author   ReportBugs   OfficialWebsite   
Tags:
AI Engineering from Scratch

From linear algebra to autonomous agent swarms. learn AI with AI, then ship the tools.


License: MIT PRs Welcome Lessons Phases Hours Stars

Python TypeScript Rust Julia PyTorch JAX Claude Code MCP


🧭 Quick Navigation

🚀 Get Started  ·  🤖 AI-Native  ·  🗺️ The Journey  ·  🧰 Toolkit  ·  📚 Glossary  ·  🛣️ Roadmap  ·  🤝 Contribute  ·  🌐 Website



💬 "84% of students already use AI tools. Only 18% feel prepared to use them professionally.

This course closes that gap."

260+ lessons. 20 phases. ~290 hours. From linear algebra to autonomous agent swarms. Python, TypeScript, Rust, Julia. Every lesson produces something reusable: prompts, skills, agents, and MCP servers.

You don't just learn AI. You learn AI with AI. Then you build real things. Then you ship tools others can use.


🆚 Why This Course?

📺 Traditional Courses 🧠 This Course
Scope
One slice (NLP or Vision or Agents)
Scope
🌍 Everything — math · ML · DL · NLP · vision · speech · transformers · LLMs · agents · swarms
Languages
Python only
Languages
🐍 Python · 🟦 TypeScript · 🦀 Rust · 🟣 Julia
Output
"I learned something"
Output
📦 A portfolio of tools, prompts, skills, and agents you can install
Depth
Surface-level or theory-heavy
Depth
🔬 Build from scratch first, then use frameworks
Format
Videos you watch
Format
💻 Runnable code + docs + web app + AI-powered quizzes
Style
Passive consumption
Style
🤖 AI-native — Claude Code skills test you as you go

🤖 AI-Native Learning

This isn't a course you watch. It's a course you use with your AI coding agent.

🎯 Learn with AI, not just about AI

# 🧪 Find where to start based on what you already know
/find-your-level

# ✅ Quiz yourself after completing a phase
/check-understanding 3

# 📦 Every lesson produces a reusable artifact
ls phases/03-deep-learning-core/05-loss-functions/outputs/
# ├── prompt-loss-function-selector.md
# └── prompt-loss-debugger.md

🛠️ Built-in Claude Code Skills

🎴 Skill ⚡ What it does
find-your-level 🧭 10-question quiz that maps your knowledge to a starting phase and builds a personalized path with hour estimates
check-understanding 📝 Per-phase quiz (8 questions) with feedback and specific lessons to review

🚢 Every Lesson Ships Something

Other courses end with "congratulations, you learned X." Our lessons end with a reusable tool:

📝
Prompts
Paste into any AI assistant for expert-level help

🎴
Skills
Install into Claude Code, Cursor, or any agent

🤖
Agents
Deploy as autonomous workers

🔌
MCP Servers
Plug into any MCP-compatible AI app

277-term searchable glossary. Full lesson catalog. ~290 hours of content with per-lesson time estimates.
🌐 Browse the website →


🗺️ The Journey

20 phases · 260+ lessons · click any phase to expand

Phase 0 Phase 1 Phase 2 Phase 3 Phase 4 Phase 5 Phase 6 Phase 7 Phase 8 Phase 9 Phase 10 Phase 11 Phase 12 Phase 13 Phase 14 Phase 15 Phase 16 Phase 17 Phase 18 Phase 19

Legend: Build hands-on implementation  ·  Learn concept + intuition


12 lessons

🛠️ Get your environment ready for everything that follows.

# Lesson Type Lang
01 Dev Environment Build 🐍 🟦 🦀
02 Git & Collaboration Learn
03 GPU Setup & Cloud Build 🐍
04 APIs & Keys Build 🐍 🟦
05 Jupyter Notebooks Build 🐍
06 Python Environments Build 🐍
07 Docker for AI Build 🐍
08 Editor Setup Build
09 Data Management Build 🐍
10 Terminal & Shell Learn
11 Linux for AI Learn
12 Debugging & Profiling Build 🐍
🟣 Phase 1 — Math Foundations  22 lessons  The intuition behind every AI algorithm, through code.
# Lesson Type Lang
01 Linear Algebra Intuition Learn 🐍 🟣
02 Vectors, Matrices & Operations Build 🐍 🟣
03 Matrix Transformations & Eigenvalues Build 🐍 🟣
04 Calculus for ML: Derivatives & Gradients Learn 🐍
05 Chain Rule & Automatic Differentiation Build 🐍
06 Probability & Distributions Learn 🐍
07 Bayes' Theorem & Statistical Thinking Build 🐍
08 Optimization: Gradient Descent Family Build 🐍
09 Information Theory: Entropy, KL Divergence Learn 🐍
10 Dimensionality Reduction: PCA, t-SNE, UMAP Build 🐍
11 Singular Value Decomposition Build 🐍 🟣
12 Tensor Operations Build 🐍
13 Numerical Stability Build 🐍
14 Norms & Distances Build 🐍
15 Statistics for ML Build 🐍
16 Sampling Methods Build 🐍
17 Linear Systems Build 🐍
18 Convex Optimization Build 🐍
19 Complex Numbers for AI Learn 🐍
20 The Fourier Transform Build 🐍
21 Graph Theory for ML Build 🐍
22 Stochastic Processes Learn 🐍
🔵 Phase 2 — ML Fundamentals  18 lessons  Classical ML — still the backbone of most production AI.
# Lesson Type Lang
01 What Is Machine Learning Learn 🐍
02 Linear Regression from Scratch Build 🐍
03 Logistic Regression & Classification Build 🐍
04 Decision Trees & Random Forests Build 🐍
05 Support Vector Machines Build 🐍
06 KNN & Distance Metrics Build 🐍
07 Unsupervised Learning: K-Means, DBSCAN Build 🐍
08 Feature Engineering & Selection Build 🐍
09 Model Evaluation: Metrics, Cross-Validation Build 🐍
10 Bias, Variance & the Learning Curve Learn 🐍
11 Ensemble Methods: Boosting, Bagging, Stacking Build 🐍
12 Hyperparameter Tuning Build 🐍
13 ML Pipelines & Experiment Tracking Build 🐍
14 Naive Bayes Build 🐍
15 Time Series Fundamentals Build 🐍
16 Anomaly Detection Build 🐍
17 Handling Imbalanced Data Build 🐍
18 Feature Selection Build 🐍
🟢 Phase 3 — Deep Learning Core  13 lessons  Neural networks from first principles. No frameworks until you build one.
# Lesson Type Lang
01 The Perceptron: Where It All Started Build 🐍
02 Multi-Layer Networks & Forward Pass Build 🐍
03 Backpropagation from Scratch Build 🐍
04 Activation Functions: ReLU, Sigmoid, GELU & Why Build 🐍
05 Loss Functions: MSE, Cross-Entropy, Contrastive Build 🐍
06 Optimizers: SGD, Momentum, Adam, AdamW Build 🐍
07 Regularization: Dropout, Weight Decay, BatchNorm Build 🐍
08 Weight Initialization & Training Stability Build 🐍
09 Learning Rate Schedules & Warmup Build 🐍
10 Build Your Own Mini Framework Build 🐍
11 Introduction to PyTorch Build 🐍
12 Introduction to JAX Build 🐍
13 Debugging Neural Networks Build 🐍
🟠 Phase 4 — Computer Vision  16 lessons  From pixels to understanding — image, video, and 3D.
# Lesson Type Lang
01 Image Fundamentals: Pixels, Channels, Color Spaces Learn 🐍
02 Convolutions from Scratch Build 🐍
03 CNNs: LeNet to ResNet Build 🐍
04 Image Classification Build 🐍
05 Transfer Learning & Fine-Tuning Build 🐍
06 Object Detection — YOLO from Scratch Build 🐍
07 Semantic Segmentation — U-Net Build 🐍
08 Instance Segmentation — Mask R-CNN Build 🐍
09 Image Generation — GANs Build 🐍
10 Image Generation — Diffusion Models Build 🐍
11 Stable Diffusion — Architecture & Fine-Tuning Build 🐍
12 Video Understanding — Temporal Modeling Build 🐍
13 3D Vision: Point Clouds, NeRFs Build 🐍
14 Vision Transformers (ViT) Build 🐍
15 Real-Time Vision: Edge Deployment Build 🐍 🦀
16 Build a Complete Vision Pipeline Build 🐍
🔴 Phase 5 — NLP: Foundations to Advanced  18 lessons  Language is the interface to intelligence.
# Lesson Type Lang
01 Text Processing: Tokenization, Stemming, Lemmatization Build 🐍
02 Bag of Words, TF-IDF & Text Representation Build 🐍
03 Word Embeddings: Word2Vec from Scratch Build 🐍
04 GloVe, FastText & Subword Embeddings Build 🐍
05 Sentiment Analysis Build 🐍
06 Named Entity Recognition (NER) Build 🐍
07 POS Tagging & Syntactic Parsing Build 🐍
08 Text Classification — CNNs & RNNs for Text Build 🐍
09 Sequence-to-Sequence Models Build 🐍
10 Attention Mechanism — The Breakthrough Build 🐍
11 Machine Translation Build 🐍
12 Text Summarization Build 🐍
13 Question Answering Systems Build 🐍
14 Information Retrieval & Search Build 🐍
15 Topic Modeling: LDA, BERTopic Build 🐍
16 Text Generation Build 🐍
17 Chatbots: Rule-Based to Neural Build 🐍
18 Multilingual NLP Build 🐍
🟡 Phase 6 — Speech & Audio  12 lessons  Hear, understand, speak.
# Lesson Type Lang
01 Audio Fundamentals: Waveforms, Sampling, FFT Learn 🐍
02 Spectrograms, Mel Scale & Audio Features Build 🐍
03 Audio Classification Build 🐍
04 Speech Recognition (ASR) Build 🐍
05 Whisper: Architecture & Fine-Tuning Build 🐍
06 Speaker Recognition & Verification Build 🐍
07 Text-to-Speech (TTS) Build 🐍
08 Voice Cloning & Voice Conversion Build 🐍
09 Music Generation Build 🐍
10 Audio-Language Models Build 🐍
11 Real-Time Audio Processing Build 🐍 🦀
12 Build a Voice Assistant Pipeline Build 🐍
🟢 Phase 7 — Transformers Deep Dive  14 lessons  The architecture that changed everything.
# Lesson Type Lang
01 Why Transformers: The Problems with RNNs Learn
02 Self-Attention from Scratch Build 🐍
03 Multi-Head Attention Build 🐍
04 Positional Encoding: Sinusoidal, RoPE, ALiBi Build 🐍
05 The Full Transformer: Encoder + Decoder Build 🐍
06 BERT — Masked Language Modeling Build 🐍
07 GPT — Causal Language Modeling Build 🐍
08 T5, BART — Encoder-Decoder Models Build 🐍
09 Vision Transformers (ViT) Build 🐍
10 Audio Transformers — Whisper Architecture Build 🐍
11 Mixture of Experts (MoE) Build 🐍
12 KV Cache, Flash Attention & Inference Optimization Build 🐍 🦀
13 Scaling Laws Learn 🐍
14 Build a Transformer from Scratch Build 🐍
💗 Phase 8 — Generative AI  14 lessons  Create images, video, audio, 3D, and more.
# Lesson Type Lang
01 Generative Models: Taxonomy & History Learn
02 Autoencoders & VAE Build 🐍
03 GANs: Generator vs Discriminator Build 🐍
04 Conditional GANs & Pix2Pix Build 🐍
05 StyleGAN Build 🐍
06 Diffusion Models — DDPM from Scratch Build 🐍
07 Latent Diffusion & Stable Diffusion Build 🐍
08 ControlNet, LoRA & Conditioning Build 🐍
09 Inpainting, Outpainting & Editing Build 🐍
10 Video Generation Build 🐍
11 Audio Generation Build 🐍
12 3D Generation Build 🐍
13 Flow Matching & Rectified Flows Build 🐍
14 Evaluation: FID, CLIP Score Build 🐍
🟣 Phase 9 — Reinforcement Learning  12 lessons  The foundation of RLHF and game-playing AI.
# Lesson Type Lang
01 MDPs, States, Actions & Rewards Learn 🐍
02 Dynamic Programming Build 🐍
03 Monte Carlo Methods Build 🐍
04 Q-Learning, SARSA Build 🐍
05 Deep Q-Networks (DQN) Build 🐍
06 Policy Gradients — REINFORCE Build 🐍
07 Actor-Critic — A2C, A3C Build 🐍
08 PPO Build 🐍
09 Reward Modeling & RLHF Build 🐍
10 Multi-Agent RL Build 🐍
11 Sim-to-Real Transfer Build 🐍
12 RL for Games Build 🐍
🟧 Phase 10 — LLMs from Scratch  14 lessons  Build, train, and understand large language models.
# Lesson Type Lang
01 Tokenizers: BPE, WordPiece, SentencePiece Build 🐍
02 Building a Tokenizer from Scratch Build 🐍
03 Data Pipelines for Pre-Training Build 🐍
04 Pre-Training a Mini GPT (124M) Build 🐍
05 Distributed Training, FSDP, DeepSpeed Build 🐍
06 Instruction Tuning — SFT Build 🐍
07 RLHF — Reward Model + PPO Build 🐍
08 DPO — Direct Preference Optimization Build 🐍
09 Constitutional AI Build 🐍
10 Evaluation — Benchmarks, Evals Build 🐍
11 Quantization: INT8, GPTQ, AWQ, GGUF Build 🐍 🦀
12 Inference Optimization Build 🐍
13 Building a Complete LLM Pipeline Build 🐍
14 Open Models: Architecture Walkthroughs Learn 🐍
🟥 Phase 11 — LLM Engineering  13 lessons  Put LLMs to work in production.
# Lesson Type Lang
01 Prompt Engineering: Techniques & Patterns Build 🐍
02 Few-Shot, CoT, Tree-of-Thought Build 🐍
03 Structured Outputs Build 🐍 🟦
04 Embeddings & Vector Representations Build 🐍
05 Context Engineering Build 🐍 🟦
06 RAG: Retrieval-Augmented Generation Build 🐍 🟦
07 Advanced RAG: Chunking, Reranking Build 🐍
08 Fine-Tuning with LoRA & QLoRA Build 🐍
09 Function Calling & Tool Use Build 🐍
10 Evaluation & Testing Build 🐍
11 Caching, Rate Limiting & Cost Build 🐍
12 Guardrails & Safety Build 🐍
13 Building a Production LLM App Build 🐍
🟩 Phase 12 — Multimodal AI  11 lessons  See, hear, read, and reason across modalities.
# Lesson Type Lang
01 Multimodal Representations Learn
02 CLIP: Vision + Language Build 🐍
03 Vision-Language Models Build 🐍
04 Audio-Language Models Build 🐍
05 Document Understanding Build 🐍
06 Video-Language Models Build 🐍
07 Multimodal RAG Build 🐍 🟦
08 Multimodal Agents Build 🐍 🟦
09 Text-to-Image Pipelines Build 🐍
10 Text-to-Video Pipelines Build 🐍
11 Any-to-Any Models Learn 🐍
🟦 Phase 13 — Tools & Protocols  10 lessons  The interfaces between AI and the real world.
# Lesson Type Lang
01 Function Calling Deep Dive Build 🐍 🟦
02 Tool Use Patterns Build 🟦
03 MCP: Model Context Protocol Learn
04 Building MCP Servers Build 🟦 🐍
05 Building MCP Clients Build 🟦 🐍
06 MCP Resources, Prompts & Sampling Build 🟦
07 Structured Output Schemas Build 🟦 🐍
08 API Design for AI Build 🟦
09 Browser Automation & Web Agents Build 🟦
10 Build a Complete Tool Ecosystem Build 🟦 🐍
🟧 Phase 14 — Agent Engineering  15 lessons  Build agents from first principles.
# Lesson Type Lang
01 The Agent Loop Build 🐍 🟦
02 Tool Dispatch & Registration Build 🟦
03 Planning: TodoWrite, DAGs Build 🟦
04 Memory: Short-Term, Long-Term, Episodic Build 🟦 🐍
05 Context Window Management Build 🟦
06 Context Compression & Summarization Build 🟦
07 Subagents: Delegation Build 🟦
08 Skills & Knowledge Loading Build 🟦
09 Permissions, Sandboxing & Safety Build 🟦 🦀
10 File-Based Task Systems Build 🟦
11 Background Task Execution Build 🟦
12 Error Recovery & Self-Healing Build 🟦
13 Hooks: PreToolUse, PostToolUse Build 🟦
14 Eval-Driven Agent Development Build 🐍 🟦
15 Build a Complete AI Agent Build 🟦
⬜ Phase 15 — Autonomous Systems  11 lessons  Agents that run without human intervention safely.
# Lesson Type Lang
01 What Makes a System Autonomous Learn
02 Autonomous Loops Build 🟦 🐍
03 Self-Healing Agents Build 🟦
04 AutoResearch: Autonomous Research Build 🟦 🐍
05 Eval-Driven Loops Build 🟦
06 Human-in-the-Loop Build 🟦
07 Continuous Agents Build 🟦
08 Cost-Aware Autonomous Systems Build 🟦
09 Monitoring & Observability Build 🟦 🦀
10 Safety Boundaries Build 🟦
11 Build an Autonomous Coding Agent Build 🟦
🟩 Phase 16 — Multi-Agent & Swarms  14 lessons  Coordination, emergence, and collective intelligence.
# Lesson Type Lang
01 Why Multi-Agent Learn
02 Agent Teams: Roles & Delegation Build 🟦
03 Communication Protocols Build 🟦
04 Shared State & Coordination Build 🟦 🦀
05 Message Passing & Mailboxes Build 🟦
06 Task Markets Build 🟦
07 Consensus Algorithms Build 🟦 🦀
08 Swarm Intelligence Build 🐍 🟦
09 Agent Economies Build 🟦
10 Worktree Isolation Build 🟦
11 Hierarchical Swarms Build 🟦
12 Self-Organizing Systems Build 🟦 🦀
13 DAG-Based Orchestration Build 🟦 🦀
14 Build an Autonomous Swarm Build 🟦 🦀
⬛ Phase 17 — Infrastructure & Production  11 lessons  Ship AI to the real world.
# Lesson Type Lang
01 Model Serving Build 🐍
02 Docker for AI Workloads Build 🐍 🦀
03 Kubernetes for AI Build 🐍
04 Edge Deployment: ONNX, WASM Build 🐍 🦀
05 Observability Build 🟦 🦀
06 Cost Optimization Build 🟦
07 CI/CD for ML Build 🐍
08 A/B Testing & Feature Flags Build 🐍 🟦
09 Data Pipelines Build 🐍 🦀
10 Security: Red Teaming, Defense Build 🐍 🟦
11 Build a Production AI Platform Build 🐍 🟦 🦀
🟪 Phase 18 — Ethics, Safety & Alignment  6 lessons  Build AI that helps humanity. Not optional.
# Lesson Type Lang
01 AI Ethics: Bias, Fairness Learn
02 Alignment: What & Why Learn
03 Red Teaming & Adversarial Testing Build 🐍
04 Responsible AI Frameworks Learn
05 Privacy: Differential Privacy, FL Build 🐍
06 Interpretability: SHAP, Attention Build 🐍
🏆 Phase 19 — Capstone Projects  5 projects  Prove everything you learned.
# Project Combines Lang
01 🤖 Build a Mini GPT & Chat Interface Phases 1, 3, 7, 10 🐍 🟦
02 🔍 Build a Multimodal RAG System Phases 5, 11, 12, 13 🐍 🟦
03 🧪 Build an Autonomous Research Agent Phases 14, 15, 6 🟦 🐍
04 👥 Build a Multi-Agent Dev Team Phases 14, 15, 16, 17 🟦 🦀
05 🚀 Build a Production AI Platform All phases 🐍 🟦 🦀

🧰 Course Output: The Toolkit

Other courses give you a certificate. This one gives you a toolkit.

Every lesson produces a reusable artifact — a prompt, skill, agent, or MCP server you can install and use immediately. By the end of the course you have:

outputs/
├── 📝 prompts/         Prompt templates for every AI task
├── 🎴 skills/          SKILL.md files for AI coding agents
├── 🤖 agents/          Agent definitions ready to deploy
└── 🔌 mcp-servers/     MCP servers you built during the course

💡 Install them with SkillKit. Plug them into Claude Code, Cursor, or any AI agent. These are real tools, not homework.


📐 How Each Lesson Works

phases/XX-phase-name/NN-lesson-name/
├── 💻 code/           Runnable implementations (Python, TS, Rust, Julia)
├── 📖 docs/
│   └── en.md          Lesson documentation
└── 📦 outputs/        Prompts, skills, agents produced by this lesson

🔄 Every lesson follows 6 steps

Step What happens
🎯 Motto One-line core idea that sticks
Problem A concrete scenario where not knowing this hurts
🧠 Concept Mermaid diagrams and intuition — no code yet
🔨 Build It Implement from scratch in pure Python. No frameworks.
⚙️ Use It Same thing with PyTorch, sklearn, or the real tool
🚢 Ship It The prompt, skill, or agent this lesson produces

🔑 The Build It / Use It split is the key. You understand what the framework does because you built it yourself first.


🚀 Getting Started

🅰️ Option A — Just start reading

Pick any completed lesson from the website or expand any phase above.

🅱️ Option B — Clone and run

git clone https://github.com/rohitg00/ai-engineering-from-scratch.git
cd ai-engineering-from-scratch

python phases/01-math-foundations/01-linear-algebra-intuition/code/vectors.py

If you already know some ML/DL, don't start from Phase 1. Use the built-in assessment:

# In Claude Code:
/find-your-level

This 10-question quiz maps your knowledge to a starting phase and builds a personalized path with hour estimates.

✅ Prerequisites

  • You can write code (Python or any language)
  • You want to understand how AI actually works, not just call APIs

👤 Who This Is For

🧑‍💻 You are... 🚪 Start at... ⏱️ Time to complete
🌱 New to programming + AI Phase 0 (Setup) ~290 hours
🐍 Know Python, new to ML Phase 1 (Math) ~270 hours
📊 Know ML, new to DL Phase 3 (Deep Learning) ~200 hours
🧠 Know DL, want LLMs/agents Phase 10 (LLMs from Scratch) ~100 hours
🚀 Senior eng, want agents only Phase 14 (Agent Engineering) ~60 hours

📰 Why This Matters Now

📈 The Industry Signal

"The hottest new programming language is English."
Andrej Karpathy (tweet)

"Software engineering is being remade in front of our eyes."
Boris Cherny, creator of Claude Code

"Models will keep getting better. The skill that compounds is knowing what to build."
— Industry consensus, 2026

📚 Foundational Papers Covered

  • 📄 Attention Is All You Need (Vaswani et al., 2017)Phase 7
  • 📄 GPT-3: Language Models are Few-Shot LearnersPhase 10
  • 📄 Denoising Diffusion Probabilistic ModelsPhase 8
  • 📄 InstructGPT / RLHFPhase 10
  • 📄 Direct Preference Optimization (DPO)Phase 10
  • 📄 Chain-of-Thought PromptingPhase 11
  • 📄 ReAct: Reasoning + Acting in LLMsPhase 14
  • 📄 MCP: Model Context Protocol (Anthropic)Phase 13

🤝 Contributing

We welcome contributions of all kinds — new lessons, translations, fixes, and outputs.

📋 Want to... 👉 Read
Contribute a lesson or fix CONTRIBUTING.md
Fork for your team or school FORKING.md
See the lesson template LESSON_TEMPLATE.md
Track progress ROADMAP.md
Code of conduct CODE_OF_CONDUCT.md

⭐ Star History

Star History Chart

🌟 If this helped you, please star the repo! It keeps the project alive.

💚 Built with care by Rohit Ghumare and the community.

Twitter Follow Website

📜 MIT License — Use it however you want. Fork it. Teach it. Sell it. Ship it.

From linear algebra to autonomous agent swarms — one lesson at a time.

Apps
About Me
GitHub: Trinea
Facebook: Dev Tools