GitHub · build-nanogpt: Video+code lecture on building nanoGPT from scratch
Open the sourceThis README describes Karpathy's from-scratch reproduction of nanoGPT, built step by step in clean git commits alongside a video lecture, starting from an empty file and ending with a GPT-2 (124M) reproduction. He explains that such base models only "dream" internet documents and are not chat models, notes that reproduction now costs about an hour and $10, and documents errata openly.
- The repo's git commits were deliberately kept clean and incremental so learners can walk through the history and see the model built slowly. - He starts from an empty file and works up to reproducing GPT-2 (124M), with the code also able to reproduce GPT-3 models given more time or money. - He notes that reproducing GPT-2 (124M) today takes roughly 1 hour and $10 on a cloud GPU. - He stresses that GPT-2 and GPT-3 are simple language models that only "dream" internet documents, and that chat finetuning (SFT) is a separate later step. - He shows sample outputs after 10B and 40B tokens of training to illustrate model behavior. - He publicly lists errata such as the leftover bias buffer, dtype conversion issues, and autocast device_type requirements.
Based on Andrej Karpathy's public content. Not affiliated with or endorsed by Andrej Karpathy.
Supports these rules
Quotes from this video
“the from-scratch reproduction of [nanoGPT](https://github.com/karpathy/nanoGPT/tree/master). The git commits were specifically kept step by step and clean so that one can easily walk through the git commit history to see it built slowly.”
“We basically start from an empty file and work our way to a reproduction of”
“SFT is just about swapping out the dataset and continuing the training)”
“a place for FAQ, and a place for fixes and errata, of which I am sure there will be a number”
“For more production-grade runs that are very similar to nanoGPT, I recommend looking at the following repos:”