microgpt

microgpt

安德烈·卡帕西 Andrej Karpathy · Eureka Labs · 2026-02-12 · Karpathy Blog ↗

打开互动全文版(逐段中英对照 + 图/公式 + 论文问答)→

摘要 · Abstract

这是关于我的新艺术项目 microgpt 的简要指南,一个 200 行纯 Python 的单文件,无依赖,可训练和推理 GPT。该文件包含了所需的所有算法内容:文档数据集、分词器、自动求导引擎、类似 GPT-2 的神经网络架构、Adam 优化器、训练循环和推理循环。其他一切都只是效率问题。我无法再简化它了。这个脚本是多个项目(micrograd、makemore、nanogpt 等)以及十年来将 LLM 简化至其最本质要素的执念的结晶,我认为它很美🥹。它甚至完美地分布在 3 列中:* 这个 GitHub gist 包含完整源代码:microgpt.py

Andrej Karpathy blog[](https://karpathy.github.io/2026/02/12/microgpt/#) 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 full source code: microgpt.py

核心贡献 · Key contributions

局限 · Limitations

论文章节 · Sections(共 21)

阅读逐段中英对照全文 →