microgpt — 200 lines pure Python GPT, no deps
Original excerpt
This is a brief guide to my new art project microgpt, a single file of 200 lines of pure Python with no dependencies that trains and inferences a GPT. This file contains the full algorithmic content of what is needed: dataset of documents, tokenizer, autograd engine, a GPT-2-like neural network architecture, the Adam optimizer, training loop, and inference loop. Everything else is just efficiency. I cannot simplify this any further. This script is the culmination of multiple projects (micrograd, makemore, nanogpt, etc.) and a decade-long obsession to simplify LLMs to their bare essentials, and I think it is beautiful 🥹. It even breaks perfectly across 3 columns:
This GitHub gist has the…
Frequently asked questions
What is "microgpt — 200 lines pure Python GPT, no deps" about?
This article by Andrej Karpathy is part of the Andrej Karpathy reading list on Burn 451, covering ai agents.
Who wrote "microgpt — 200 lines pure Python GPT, no deps"?
This piece is part of the Andrej Karpathy vault on Burn 451, covering ai agents. The original author is attributed at the source link.
How can I read more content from Andrej Karpathy?
The complete Andrej Karpathy reading list is available at burn451.cloud/vault/karpathy. Each article includes an AI-generated summary so you can decide what to read in seconds. Connect the Burn 451 MCP server to Claude or Cursor to query all Andrej Karpathy articles as live AI context.
Can I use "microgpt — 200 lines pure Python GPT, no deps" with Claude or Cursor?
Yes. Install the burn-mcp-server npm package and connect it to Claude Desktop, Claude Code, or Cursor. Once connected, your AI can search and reference this article and the full Andrej Karpathy vault in real time — no manual copy-paste required.
37 more articles in this vault.
Import the full Andrej Karpathy vault to Burn 451 and build your own knowledge base.
Content attributed to the original author. Burn 451 curates publicly available writing as a reading index. For removal requests, contact @hawking520.