nanochat
by karpathy
nanochat is a small, easy-to-read code base for training your own chat language model from scratch, covering everything from tokenising text to chatting with the finished model. It is mainly meant for learning and research, and a GPT-2-level model can be trained for roughly $48 of rented GPU time.
- Stars
- 60k
- Licence
- MIT
- Runs on
- A gpu machine, with a GPU
- Setup
- Technical
- Language
- Python
- Age
- 385 days
What you can do with it
- Train a GPT-2-level chat model from scratch on a rented multi-GPU server using one script
- Chat with your trained model in a command-line interface
- Run small, cheap experiments on model size and training settings by changing a single depth setting
Ways a business could use it
- Learn how language model training works in-house before deciding whether to commission or fine-tune custom models
- Prototype a small, cheap custom model for research or experiments without paying for a managed training service
Can you use it commercially?
Free to use, change and sell, including in paid products. Keep the copyright notice.
Not legal advice. Read the project's licence file before building a product on it.
Getting it running
Install dependencies with uv (`uv sync --extra gpu`), then run `bash runs/speedrun.sh` on a rented 8xH100 GPU server and chat with `python -m scripts.chat_cli`.
Follow the official instructions in the project README.
Things to check
- The resulting model is weak, roughly like talking to a kindergartener, and often gives wrong answers
- Needs rented GPU time, around $15 to $48 per full run, and a lot more if you scale up
- Described as an experimental harness, with some hardware paths not fully tested
- Needs technical knowledge to tune settings if your GPUs have less than 80GB of memory
Who's talking about it
Checked 03 Nov 2026. Summary drafted by AI from the project's README.