no-magic-ai/no-magic

Because `model.fit()` isn't an explanation

What it solves

no-magic addresses the gap in machine learning education between high-level library calls (like model.fit()) and dense academic papers. It provides a way to understand the internal mechanics of AI algorithms by implementing them as readable, transparent code without the abstraction layers of modern frameworks.

How it works

The project consists of a curated collection of single-file Python scripts. Each script is a complete, runnable program that implements a specific AI algorithm from scratch using only the Python standard library. Most scripts follow a lifecycle of training a model from scratch and then performing inference, though some focus on comparisons or non-learning mechanisms. These implementations are designed to run quickly on a standard laptop CPU without requiring a GPU or external dependencies.

Who it’s for

  • ML engineers wanting to understand the internals of the frameworks they use.
  • Students moving from theory to practice who want to see algorithms as working code.
  • Career switchers needing intuition for the underlying processes of ML APIs.
  • Researchers seeking minimal reference implementations for prototyping without framework overhead.

Highlights

  • Zero Dependencies: Uses only the Python standard library, requiring no pip install.
  • One File, One Algorithm: Every implementation is self-contained in a single script.
  • CPU-Optimized: Designed to run in minutes on a laptop CPU.
  • Broad Coverage: Includes implementations of GPT, BERT, Diffusion, LoRA, PPO, Flash Attention, and ReAct agents.
  • Educational Focus: Prioritizes readability and readability over line-count optimization.

Related

  • Project
  • Project
  • Project
  • Project