karpathy/nanoGPT: The simplest, fastest repository for training/finetuning medium-sized GPTs.
The simplest, fastest repository for training/finetuning medium-sized GPTs. It is a rewrite of minGPT that prioritizes teeth over education. Still under active development, but currently the file train.py reproduces GPT-2 (124M) on OpenWebText, running on a single 8XA100 40GB node in about 4 days of training. The code itself is plain and readable: train.py is a ~300-line boilerplate training loop and model.py a ~300-line GPT model definition, which can optionally load the GPT-2 weights from OpenAI. That's it. Because the code is so simple, it is very easy to hack to your needs, train new models from scratch, or finetune pretrained checkpoints (e.g. biggest one currently available as a starting point would be the GPT-2 1.3B model from OpenAI). Dependencies: If you are not a deep learning professional and you just want to feel the magic and get your feet wet, the fastest way to get started is to train a character-level GPT on the works of Shakespeare. First, we download it as a single (1
nanoGPT Update Nov 2025 nanoGPT has a new and improved cousin called nanochat . It is very likely you meant to use/find nanochat instead. nanoGPT (this repo) is now very old and deprecated but I will leave it up for posterity. The simplest, fastest repository for training/finetuning medium-sized GPTs. It is a rewrite of minGPT that prioritizes teeth over education. Still under active development, but currently the file train.py reproduces GPT-2 (124M) on OpenWebText, running on a single 8XA100 40GB node in about 4 days of training. The code itself is plain and readable: train.py is a ~300-line
related reading
- GitHub - karpathy/nanochat: The best ChatGPT that $100 can buy.github.com
- GPT in 60 Lines of NumPy | Jay Modyjaykmody.com
- GitHub - karpathy/autoresearch: AI agents running research on single-GPU nanochat training automaticallygithub.com
- GitHub - rasbt/LLMs-from-scratch: Implement a ChatGPT-like LLM in PyTorch from scratch, step by stepgithub.com
- microgptkarpathy.github.io
- [2005.14165] Language Models are Few-Shot Learnersarxiv.org
- microgptgist.github.com
- GitHub - huggingface/nanotron: Minimalistic large language model 3D-parallelism training · GitHubgithub.com
- Tinkerthinkingmachines.ai
- What will GPT-2030 look like? — AI Alignment Forumalignmentforum.org
- Introducing nanocode: The best Claude Code that $200 can buy. · salmanmohammadi nanocode · Discussion #1github.com
- Hugging Face – The AI community building the future.huggingface.co