// zero dependencies. just math.

no-magic

Single-file, zero-dependency Python implementations of the algorithms that power modern AI. Every script runs with python script.py — no frameworks, no abstractions.

Algorithms
0
Dependencies
Tiers
Stars
Forks

Algorithm Catalog

Each script trains a model from scratch and performs inference. Read top-to-bottom like a tutorial.

Learning Paths

Structured tracks through the collection. Pick one based on your interest or time budget.

01
Weekend Sprint: Transformers
From raw text to self-attention. Tokenization, embeddings, RNNs, GPT, and BERT.
~4 hrs6 scripts
02
Weekend Sprint: Alignment
Steering model behavior post-training. LoRA, DPO, PPO, and RLHF.
~3 hrs5 scripts
03
Deep Dive: Modern Inference
Making models fast and small. Quantization, KV-cache, Flash Attention, parallelism.
~7 hrs10 scripts
04
Deep Dive: Generative Models
How models create new data. Diffusion, GANs, VAEs, and adversarial training.
~4 hrs4 scripts
05
Deep Dive: Retrieval & Search
Connecting models to external knowledge. BM25, vector search, RAG pipelines.
~3 hrs3 scripts
06
Agent Algorithms
Search and reasoning for autonomous agents. MCTS, minimax, bandits, ReAct.
~3 hrs5 scripts
07
Full Curriculum
All scripts in dependency order. The complete no-magic experience.
~22 hrs47 scripts

The constraint is the product

One file per algorithm

No local imports, no utils.py, no companion files. Everything in one place.

Zero dependencies

Python standard library only. If it needs pip install, it doesn't belong here.

Train + infer in one command

python script.py runs the full lifecycle. No setup, no config, no environment.

Comments are the curriculum

30-40% comment density. Math-to-code mappings. Why, not what. Read top-to-bottom like a tutorial.

Reproducible by default

random.seed(42) at the top of every script. Same input, same output, every time.

Under 10 minutes on CPU

Every script completes on a laptop CPU. No GPU required. No cloud. No excuses.

The Ecosystem

Tom Mathews
Created by
Tom Mathews
Building tools that make AI algorithms transparent and accessible.