How to learn AI from scratch in 2026 without getting stuck in math or wrapper tutorials
Most beginners trying to learn AI quit within four weeks for one of two opposite reasons. Either they spend months grinding university linear algebra and calculus textbooks before writing a single line of Python, or they copy-paste a 50-line agent framework tutorial on Day 1 and freeze the first time it hallucinates a tool call or hits a memory limit.
You do not need three college math courses before shipping useful AI software, and you do not need black-box wrappers that hide how prompts, tokens, and embeddings work. This 6-stage roadmap puts every chapter in build-first order, pairs each stage with a concrete exit milestone, and pulls in math at the exact hour your code touches it.
- Decide between shipping AI applications (AI Engineer, Stages 1 to 4) and training or serving models (ML Engineer, Stages 1 to 6) before opening a single course: roadmap.sh explicitly separates applying pre-trained models from training models from scratch.
- Skip the 6-month college math prerequisite wall upfront: fast.ai (9 lessons, about 13.5 hours) and Karpathy's Zero to Hero (8 lectures, 14 hours 32 minutes) prove you can start with Python and high-school math, then pull in vectors and derivatives right when code needs them.
- Skip heavy agent frameworks in month one: Anthropic's Building Effective Agents guide recommends starting with raw LLM API calls and deterministic workflows before autonomous wrappers, and keeping study detours in side threads avoids the 39% multi-turn accuracy drop measured by Laban et al. (arXiv:2505.06120).
Pick your AI track in 30 seconds
“Learn AI” mixes three different jobs under one label. On roadmap.sh's AI Engineer guide, an AI Engineer applies pre-trained models and existing AI tools to build user-facing products without training models from scratch, whereas an ML Engineer trains, fine-tunes, and serves model weights. Pick your stopping point below before buying courses or hoarding bookmarks.
| Target track | What you want to do | Stages needed | Math needed upfront | Hands-on study budget |
|---|---|---|---|---|
| AI-literate builder or student | Automate research, summarize docs, and build internal scripts without guesswork | Stages 1 to 3 | Arithmetic + dot product intuition | 30 to 40 hours (6 to 8 weeks at 5 hr/wk) |
| AI Engineer (shipping LLM apps) | Build, evaluate, and ship reliable RAG, tool-calling, and workflow features | Stages 1 to 4 | High-school algebra + basic probability | 50 to 60 hours (5 to 6 weeks at 10 hr/wk) |
| ML Engineer (training & serving) | Train classifiers, trace backprop, fine-tune with QLoRA, and size GPU serving | Stages 1 to 6 | Chain-rule derivatives + matrix shapes in Stage 5 | 130 to 150 hours (13 to 15 weeks at 10 hr/wk) |
Why most AI study plans fail by week four
University syllabi are ordered for proof-writing rather than self-study momentum. Stanford CS229 expects three college prerequisites before Lecture 1 even starts: Python and NumPy fluency (CS106A/B), probability theory (CS109 or MATH151), and multivariable calculus plus linear algebra (MATH51 or CS205L). Studying all three in isolation means months of abstract symbols before you ever see an embedding or a loss curve move.
Swinging to copy-paste agent tutorials fails just as fast. Anthropic's Building Effective Agents research notes that heavy frameworks add extra abstraction layers that obscure the underlying prompts and responses, making debugging harder when outputs break. Worse, a randomized developer study by Shen and Tamkin (arXiv:2601.20245) found that passively delegating code to AI impairs conceptual understanding, code reading, and debugging without delivering significant average speed gains.
Top practitioner courses flip the sequence. Jeremy Howard's fast.ai Practical Deep Learning for Coders covers 9 lessons (about 90 minutes each, roughly 13.5 hours of video) with only Python and high-school math, getting a working model deployed by Lesson 2. Andrej Karpathy's Neural Networks: Zero to Hero builds from empty Python files up to GPT and a Byte-Pair Encoding tokenizer in 8 lectures (14 hours 32 minutes total). Build first, inspect raw inputs and outputs, and pull in theory only when a line of code asks for it.
Stages 1 to 4: the AI Engineer core
If your goal is building AI features at work or shipping your own product, Stages 1 through 4 are your complete core curriculum. Do not advance to the next stage until you finish its exit milestone from an empty file without pasting unexamined boilerplate.
Stage 1: Python for data, HTTP APIs, and strict validation (10 to 15 hours)
Skip sprawling object-oriented design patterns at first. Focus on lists, dictionaries, file I/O, virtual environments, httpx or requests, asyncio basics, and schema validation with Pydantic or JSON Schema. Need a chapter syllabus first? Open the Python Horizon roadmap preview.
Exit milestone: Write a 60-line Python CLI that fetches JSON from a public HTTP endpoint, handles timeouts and HTTP 429 retries cleanly, validates fields, and writes a clean summary table.
Stage 2: Raw LLM APIs, tokens, schemas, and context hygiene (10 to 12 hours)
Call the Messages or Responses HTTP API directly in Python without LangChain or an agent SDK so you can inspect every prompt array, token count, stop reason, and tool-call payload. Learn why long multi-turn chats lose an average of 39% accuracy when wrong early drafts remain in history (93.0% single-turn vs 59.1% multi-turn on GPT-4o, recovering to 90.9% on a clean state reset).
Exit milestone: Build a structured extractor that streams tokens, enforces a strict JSON schema on messy support emails, logs exact input and output token counts, and resets state cleanly between runs.
Stage 3: Prompt caching vs Hybrid RAG with BM25 and RRF (12 to 15 hours)
Before standing up a vector database, learn when prompt-cached long context beats RAG and fine-tuning: under 25K static tokens, cached context costs $9.04 vs $10.20 per 1,000 queries on Sonnet 4.6, while on changing post-cutoff facts RAG jumps accuracy +34.9 percentage points (43.0% to 77.9%) where unsupervised fine-tuning drops 1.9 points. When your corpus grows past 50K tokens, avoid dense-only search: see why vector search misses exact error codes like E-4029 (0/6 top-1) and fuse BM25 lexical search with dense embeddings via Reciprocal Rank Fusion (k = 60).
Exit milestone: Index 50 markdown docs with chunk headers, combine BM25 + vector search using RRF, and measure Hit@3 on 20 real questions (10 semantic paraphrases and 10 exact error codes or SKUs).
Stage 4: Outcome eval gates, deterministic workflows, and safe retries (15 to 18 hours)
Follow Anthropic's rule: build deterministic workflows (prompt chaining, routing, parallel checks) before open-ended autonomous loops. Turn every bug into a regression test using outcome-graded CI release gates instead of grading whether the assistant politely said “Done.” Protect side-effecting tools with outer-loop idempotency keys on tool timeouts so network retries never double-charge users, and study System Design queues and rate limits alongside AI Engineering.
Exit milestone: Wire a 25-case pytest eval suite into GitHub Actions that grades final database state and blocks any pull request that regresses accuracy or triggers duplicate tool mutations.
Stages 5 to 6: ML and model depth
Stop after Stage 4 if your priority is shipping LLM-powered software. Continue to Stages 5 and 6 when you need to train tabular predictors, understand transformer internals line by line, fine-tune open-weight adapters, or self-host models on rented GPUs.
Stage 5: Classical ML baselines, micrograd backprop, and nanoGPT (45 to 50 hours)
Start with scikit-learn train/validation/test splits, data leakage checks, logistic regression, and gradient-boosted trees so you never deploy a slow LLM where a 2-millisecond classifier wins. Next, pair fast.ai Part 1 (~13.5 hours of video) with Karpathy's Zero to Hero (14 hours 32 minutes of video): write scalar backprop in micrograd (2h 25m), build a small GPT (1h 56m), and code a BPE tokenizer (2h 13m). Preview the full Machine Learning chapter map to keep each concept organized.
Exit milestone: Beat a heuristic baseline on a held-out tabular dataset without leakage, then implement scalar autograd and a tiny character-level transformer from scratch in PyTorch.
Stage 6: QLoRA VRAM math, KV-cache concurrency, and MoE vs dense serving (35 to 40 hours)
Production model work is mostly memory and bandwidth arithmetic. Learn why 4-bit QLoRA weights take 5 GiB yet still OOM a 24 GiB GPU at 51.2 GiB until gradient checkpointing and fused cross-entropy cut peak VRAM to 9.4 GiB. For inference, calculate why 32 concurrent 8K chats hit 28.2 GiB CUDA OOM and compare 30B Mixture-of-Experts vs 7B dense GPU memory and batch slowdown (522.9 tok/s at 1 chat dropping to 69.4 tok/s at 16 chats as 87% of experts wake up).
Exit milestone: Fine-tune an 8B open-weight model with QLoRA inside 24 GiB VRAM for strict schema compliance, benchmark it against your Stage 4 eval gate, and calculate max safe concurrent requests before serving.
Just-in-time math map
Instead of pausing your coding habit for a semester of proofs, pull in each math topic during the exact stage where you can print the numbers in Python and see what changes. When you want the full chapter-by-chapter sequence and skip list across linear algebra, cross-entropy, chain-rule gradients, and SVD/LoRA, follow our 4-stage Math for Machine Learning roadmap.
| When you hit this stage | Pull in this math concept | How you verify it in code | Horizon preview |
|---|---|---|---|
| Stage 3: Dense embeddings & similarity search | Vectors, norms, and dot product (cosine similarity) | Comparing two 1,536-float arrays to see why semantic search blurs exact SKU strings. | Linear Algebra |
| Stage 4: Sampling, logprobs, and eval pass rates | Conditional probability, softmax, and sample size | Turning logits into token probabilities and telling a real accuracy gain from a lucky 10-run coin flip. | AI Engineering |
| Stage 5: Autograd and backpropagation (micrograd) | Single-variable derivative and chain rule | Nudging weight w by 0.001 in Python and comparing the finite-difference slope against backward(). | Machine Learning |
| Stage 5 to 6: Attention blocks, LoRA, and KV cache | Matrix multiplication shapes and byte arithmetic | Matching (B, T, C) tensor dimensions in nanoGPT and sizing 24 GiB GPU memory before launch. | Linear Algebra |
Study workflow and preview roadmaps
How you study matters as much as chapter order. Pasting ten chapters of questions into one endless chat buries your syllabus and triggers multi-turn context rot, while static developer trees like roadmap.sh link out to 660 separate articles and cap free accounts at 20 lifetime AI chats (compare Claude Projects vs ChatGPT for studying and ChatGPT Study Mode vs NotebookLM vs roadmap.sh).
Each curated Topic Breakdown preview below gives you an immediate ordered chapter Table of Contents, a complete Chapter 1 guide, and clickable concept chips so you can ask prerequisite detours in side-by-side tabs without losing your place:
Dictionaries, file I/O, virtual environments, HTTP clients, and clean JSON validation.
Tokenization, context windows, prompt caching, hybrid RAG, tool calling, and eval gates.
Vectors, dot products, projections, and matrix shapes right when embeddings and attention need them.
Queues, rate limits, idempotent retries, caching layers, and tail-latency tradeoffs.
Train/validation splits, gradient descent, loss functions, neural networks, and overfitting.
Working memory limits, active retrieval practice, and spacing study sessions so concepts stick.
Scope note: Course durations and prerequisite lists come directly from Stanford CS229, fast.ai Part 1, Andrej Karpathy's Zero to Hero syllabus, roadmap.sh, and Anthropic Research checked on 2026-12-02. Study-hour budgets sum estimated hands-on practice across Stages 1 to 4 (50 to 60 hours) and Stages 5 to 6 (80 to 90 hours, including ~28 hours of fast.ai and Zero to Hero lectures plus coding exercises), divided by 5 or 10 weekly study hours.
Jump straight into AI Engineering or Python, explore the interactive /demo workspace, convert any public arXiv paper or documentation URL into chapters free on /read, or rescue an overgrown ChatGPT study thread into clean chapters on /rescue.
Sources
Checked 2026-12-02- roadmap.sh: AI Engineer Roadmaproadmap.sh
Defines an AI Engineer as using pre-trained models and existing AI tools to ship better user experiences without training models from scratch, distinguishing the role from ML Engineers and AI Researchers across 189 AI Engineer topics.
- Stanford CS229: Machine Learning Course Information and Prerequisites (Summer 2026)cs229.stanford.edu
Documents the traditional university prerequisite stack expected before Lecture 1: Python and NumPy fluency (CS106A/B), college probability theory (CS109/MATH151), and multivariable calculus plus linear algebra (MATH51/CS205L).
- fast.ai: Practical Deep Learning for Coders (Part 1)course.fast.ai
Verifies the 9-lesson (~90 minutes per lesson, ~13.5 hours total) top-down curriculum requiring coding experience and high-school math, where learners train and deploy a model by Lesson 2 and study math as needed.
Verifies the 8-lecture (14h 32m total) code-first sequence covering scalar autograd (micrograd, 2h 25m), character language models (makemore), building GPT from scratch (1h 56m), and the GPT BPE tokenizer (2h 13m).
- Anthropic Research: Building Effective Agentsanthropic.com
Advises starting with direct LLM API calls instead of heavy frameworks that hide prompts and responses, optimizing single calls with retrieval first, and favoring deterministic workflows (chaining, routing, parallelization) before autonomous agents.
Reports an average 39% accuracy drop across 200,000+ multi-turn conversations on 15 frontier LLMs (93.0% single-turn vs 59.1% multi-turn on GPT-4o) when early assumptions and detours accumulate in one thread.
Randomized developer study showing that passive AI delegation impairs conceptual understanding, code reading, and debugging without significant average speed gains, while active inquiry preserves learning.