AI Engineering from Scratch
by Rohit Ghumare and contributors
A free, MIT-licensed AI engineering curriculum that goes from math and PyTorch to MCP, agent harnesses and production LLM infrastructure, with runnable code in every lesson.
Overview
AI Engineering from Scratch is an MIT-licensed GitHub curriculum maintained by Rohit Ghumare and contributors, with a companion site at aiengineeringfromscratch.com labeled curriculum v1.0, 2026. It holds 542 lessons in 20 phases. Each lesson has a docs/en.md write-up and runnable code in Python, TypeScript, Rust or Julia, and is tagged as either a Learn or a Build lesson. Phases 0 to 9 cover setup and tooling, math foundations, classical ML, deep learning in PyTorch and JAX, computer vision, NLP, speech, a transformer deep dive (attention, positional encoding, MoE, KV cache), generative models and reinforcement learning through PPO and RLHF. Phase 10 builds LLMs from scratch: tokenizers, pretraining, SFT, DPO, quantization and DeepSeek-style architectures. The later phases are the bulk of the AI engineering material. Phase 11 covers LLM engineering (structured outputs, RAG, LoRA, evals, guardrails). Phase 13 has 45 lessons on tools and protocols, including MCP in depth, A2A and agent skills. Phase 14 has 54 lessons on agent engineering, Phase 15 covers long-horizon and autonomous agents, Phase 16 covers multi-agent systems, and Phase 17 covers production serving (PagedAttention, continuous batching, model routing, canary deploys, compliance). Phase 18 covers safety and alignment. Phase 19 has 85 capstone lessons: 17 end-to-end products and 9 deep-build tracks covering agent harnesses, advanced RAG, eval frameworks and distributed training. The repo had 72.2k stars and 12.7k forks when checked on 2026-10-22. Its May 2026 Hacker News thread was critical of the AI-assisted writing and the site layout, so treat it as a broad map that you verify as you go.
At a Glance
- Topic
- Agentic
- Level
- All Levels
- Format
- Course
- Cost
- Free
- Duration
- Self-paced, 542 lessons in 20 phases; months end to end (each capstone project is listed at 20-40 hours)
- Provider
- Rohit Ghumare and contributors
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Build tokenizers, pretraining loops, SFT and DPO stages for a small LLM from scratch
- ✓Implement self-attention, positional encoding, mixture-of-experts layers and a KV cache in code
- ✓Design RAG pipelines with structured outputs, evaluation and guardrails in the LLM engineering phase
- ✓Implement function calling, MCP servers and clients, A2A messaging and agent skills hands-on
- ✓Engineer agent loops with planning, memory, multi-agent coordination, benchmarks and observability
- ✓Serve models in production using PagedAttention, continuous batching, model routing and canary deploys
- ✓Apply safety techniques such as AI control, jailbreak defenses and prompt injection detection
- ✓Ship capstones like a terminal-native coding agent or a GitHub issue-to-PR autonomous agent
Highlights
- •Unusually wide scope in one free repo: 542 lessons from linear algebra to agent harnesses and EU AI Act compliance
- •Every lesson pairs a written explanation with runnable code, in Python, TypeScript, Rust or Julia
- •Heavy 2026 agent coverage: 45 lessons on tools and protocols (MCP, A2A, skills) and 54 on agent engineering
- •Capstone tracks for an agent harness, advanced RAG, an eval framework, distributed training and a safety harness
- •Very popular (72.2k GitHub stars, 12.7k forks as of 2026-10-22), and Hacker News commenters flagged the AI-assisted writing as verbose, so cross-check against primary sources
Who It’s For
Best For
- ✓Software engineers moving into AI engineering who want a single structured roadmap
- ✓Developers who learn by building and want runnable code for each concept
- ✓Engineers who already ship LLM apps and want to fill gaps in agents, MCP or production serving
- ✓Self-learners who want to choose a focused path (MCP or Agent Skills) instead of the full curriculum
Prerequisites
- •Able to write code in at least one language; Python helps most
- •Python 3 installed locally for running lessons; a GPU helps for the training phases
FAQ
What is AI Engineering from Scratch?
AI Engineering from Scratch is a free, open-source curriculum of 542 lessons in 20 phases for developers who want to understand how AI systems work rather than only call APIs. It runs from setup and math through transformers, LLM training, MCP, agent engineering and production infrastructure, ending in capstones such as a terminal coding agent.
Is AI Engineering from Scratch free?
AI Engineering from Scratch is free to access.
What level is AI Engineering from Scratch for?
AI Engineering from Scratch is aimed at a all levels audience. Recommended background: Able to write code in at least one language; Python helps most, Python 3 installed locally for running lessons; a GPU helps for the training phases.
How long does AI Engineering from Scratch take?
Expect roughly Self-paced, 542 lessons in 20 phases; months end to end (each capstone project is listed at 20-40 hours). Most learners work through it at their own pace.
What will I learn from AI Engineering from Scratch?
You'll learn: Build tokenizers, pretraining loops, SFT and DPO stages for a small LLM from scratch; Implement self-attention, positional encoding, mixture-of-experts layers and a KV cache in code; Design RAG pipelines with structured outputs, evaluation and guardrails in the LLM engineering phase; Implement function calling, MCP servers and clients, A2A messaging and agent skills hands-on; Engineer agent loops with planning, memory, multi-agent coordination, benchmarks and observability; Serve models in production using PagedAttention, continuous batching, model routing and canary deploys; Apply safety techniques such as AI control, jailbreak defenses and prompt injection detection; Ship capstones like a terminal-native coding agent or a GitHub issue-to-PR autonomous agent.
Topics
Sources
This page was written from 4 sources, 3 on domains other than github.com.