▶ Open the interactive course (lessons, derivations, quizzes)
ai-ml-course
Hoon’s 8-week, build-everything-from-scratch AI/ML engineering course. Every week you implement one layer of a single stack, and each layer is used by the next:
| Week | Topic | You build | Used later by |
|---|---|---|---|
| 1 | Math for ML | forge.autograd, forge.optim, forge.gradcheck — reverse-mode autodiff over numpy |
everything in W2–W3 |
| 2 | Machine Learning | forge.ml — linear/logistic regression, CART, gradient boosting, k-means, GMM/EM, PCA, metrics, CV |
W8 ranker, IVF index |
| 3 | Deep Learning I | forge.nn — Module system, Linear, BatchNorm, LayerNorm, Conv2d, MaxPool, Dropout; MNIST CNN |
W5 perf work |
| 4 | Deep Learning II | forge.gpt — BPE tokenizer, GPT with KV cache, AMP training loop (PyTorch, GPU) |
W5 CLI, W6 server |
| 5 | Python Engineering | pyeng.drills, forge.cli, packaging, mypy –strict, ruff, CI, profiling |
the rest of your career |
| 6 | MLOps | serve — dynamic batcher, FastAPI + SSE, Prometheus metrics, drift, MLflow, Docker, DVC, load test |
W7, W8 |
| 7 | System Design & HLD | sysdesign — consistent hashing, Bloom filter, LSM-tree KV store, rate limiters; an HLD doc |
W8 service |
| 8 | ML System Design | recsys — MovieLens two-tower retrieval, IVF ANN, GBM ranker, A/B stats, recsys service; an ML design doc |
— |
Lessons, derivations, quizzes, hints and the Claude tutor live in the course web app (link in your notes).
This repo holds stubs + an autograder. Nothing is implemented for you except plumbing
(scripts/get_data.py, benchmarks/bench_conv.py).
Setup (already done on this machine)
cd ~/Desktop/ai-ml-course
python -m venv .venv
.venv\Scripts\activate
pip install -e ".[dev,w4,w6]" # torch: pip install torch --index-url https://download.pytorch.org/whl/cu126
python scripts/get_data.py # MNIST, TinyShakespeare, California housing, MovieLens-1M -> data/
The .venv here already has numpy, pytest, hypothesis, scikit-learn, scipy, pandas, mypy, ruff, CUDA PyTorch,
FastAPI and MLflow, and data/ is downloaded. Activate it and go. (pip install -e . is a Week 5 task.)
Running the grader
pytest tests/w1 -q # one week, fast tests
pytest tests/w1 -q -k unbroadcast # one milestone
pytest tests/w3 -m slow -s # training/accuracy tests (MNIST, GPT, recommender)
pytest tests/w2 -m stretch # stretch goals
pytest -q # everything fast
Every test fails with NotImplementedError until you implement it. The tests are the spec: read a
test when a docstring is ambiguous.
Reference timings on this machine (RTX 3060, for a solid solution): W3 CNN 3 epochs ≈ 1 min (numpy, CPU), W4 Shakespeare GPT 2,500 steps ≈ 6 min (val loss ≈ 1.50), W8 pipeline ≈ 1 min.
Rules
- Write every line of project code yourself. Use AI to explain concepts, not to write your implementation.
- Derive before you code. If you can’t derive a backward pass on paper, you can’t debug it.
- Commit after each milestone:
git commit -am "w1: broadcasting". Your history is your portfolio. - Deliverable docs go in
docs/(templates indocs/templates/).
All files
- README.md
- benchmarks/bench_conv.py
- conftest.py
- course/content/w1.js
- course/content/w2.js
- course/content/w3.js
- course/content/w4.js
- course/content/w5.js
- course/content/w6.js
- course/content/w7.js
- course/content/w8.js
- course/index.html
- course/widgets.js
- docs/templates/hld.md
- docs/templates/ml_design.md
- docs/templates/perf.md
- forge/autograd.py
- forge/cli.py
- forge/gpt/model.py
- forge/gpt/sample.py
- forge/gpt/tokenizer.py
- forge/gpt/train.py
- forge/gradcheck.py
- forge/ml/cluster.py
- forge/ml/decomposition.py
- forge/ml/ensemble.py
- forge/ml/linear.py
- forge/ml/metrics.py
- forge/ml/mixture.py
- forge/ml/model_selection.py
- forge/ml/preprocessing.py
- forge/ml/tree.py
- forge/nn/conv.py
- forge/nn/data.py
- forge/nn/layers.py
- forge/nn/losses.py
- forge/nn/module.py
- forge/optim.py
- pyeng/drills.py
- pyproject.toml
- recsys/abtest.py
- recsys/ann.py
- recsys/baselines.py
- recsys/data.py
- recsys/metrics.py
- recsys/pipeline.py
- recsys/ranker.py
- recsys/service.py
- recsys/two_tower.py
- scripts/get_data.py
- serve/app.py
- serve/batcher.py
- serve/drift.py
- serve/engine.py
- serve/metrics.py
- sysdesign/bloom.py
- sysdesign/cache.py
- sysdesign/hashring.py
- sysdesign/lsm.py
- sysdesign/ratelimit.py
- tests/helpers.py
- tests/w1/test_autograd.py
- tests/w1/test_optim.py
- tests/w2/test_linear_metrics.py
- tests/w2/test_trees_boosting.py
- tests/w2/test_unsupervised.py
- tests/w3/test_layers.py
- tests/w3/test_mnist.py
- tests/w3/test_module.py
- tests/w4/test_model.py
- tests/w4/test_tokenizer.py
- tests/w4/test_train.py
- tests/w5/test_drills.py
- tests/w5/test_engineering.py
- tests/w5/test_properties.py
- tests/w6/test_app.py
- tests/w6/test_batcher.py
- tests/w6/test_metrics_drift.py
- tests/w6/test_mlops.py
- tests/w7/test_hashring_bloom.py
- tests/w7/test_lsm.py
- tests/w7/test_ratelimit.py
- tests/w8/test_pipeline.py
- tests/w8/test_recsys_core.py