nanoGPT: a clean, hackable 300-line GPT training loop that reproduces GPT-2 (124M)
AI-generated summary of reporting by GitHub Opensource Projects. Read the original for the full story.
Why it matters
Engineers get a complete, readable GPT-2 training implementation they can modify in an afternoon instead of fighting a large framework codebase.
nanoGPT is a free, open-source program written by Andrej Karpathy that trains an AI language model, software that learns to write text by reading examples. It fits in about 300 lines of Python, short enough to read in one sitting, and reproduces GPT-2, an older but famous OpenAI model. The article says it is mainly for learning how such models work, not for companies running them at scale. Training the full-size version takes about four days on a data-centre GPU, but a small practice version trains in under an hour.
This is an educational open-source release, not a production tool: nanoGPT is a 300-line Python script from Andrej Karpathy that reproduces the small 124M-parameter GPT-2. It does not replace commercial training infrastructure, so there is no procurement or adoption decision here. Its value is as a teaching resource or a clean starting point for internal experiments; the 124M model needs roughly four days on a 40GB A100 GPU, so hands-on exploration carries real compute cost.
nanoGPT implements the full GPT-2 training loop in ~300 lines of Python with dependencies limited to PyTorch, numpy, tiktoken, wandb and tqdm. The 124M-parameter configuration matches original GPT-2 and reproduces it on OpenWebText, with validation loss close to the original; configs scale up or down via a dict. Data prep scripts cover OpenWebText, Shakespeare and Tolstoy, and sample.py generates text. On one A100 40GB the 124M run takes about 4 days. No distributed training support is included.
Read the original
This summary exists to save you time, not to replace the source.
Key terms
Was this summary useful?
One click, anonymous. It tells us which summaries to re-run.
Related reading
datasette-charts 0.5a0
Datasette Charts 0.5a0 adds calendar heatmaps, box plots and active-over-time charts, enabling richer data visualisation directly in the browser without extra libraries.
OpenBitFun: an agent workspace with four harness modes and phone remote control
OpenBitFun lets agents run on any machine and be controlled from a phone, eliminating the need to choose between local power and remote access, saving developers time switching contexts.
Self-hosted YouTube client that falls back to SABR when side doors close
A self-hosted YouTube client lets users watch videos without Google accounts, ads, or tracking, keeping data local and enabling shared libraries across devices.
datasette-charts 0.4a0
Datasette now lets developers add custom chart types more easily, expanding visualisation options for data projects.
Speculative Decoding Makes Tool Calls Faster. Agents Need a Cache.
Speed improvements in speculative decoding mean agents can execute tool calls faster, reducing latency for real-time applications.