build-nanogpt
Video+code lecture on building nanoGPT from scratch
A step-by-step coding tutorial that teaches you how to build and train your own GPT-2 language model from scratch, paired with a YouTube lecture and organized as incremental git commits.
What This Repo Does
This is a hands-on coding tutorial that teaches you how to build a large language model from the ground up. Specifically, it walks you through creating your own version of GPT-2, the famous text-prediction model that OpenAI released in 2019. The result is a working AI model that can generate surprisingly coherent text on its own, trained on real internet documents. The cool part: you can actually reproduce the full 124-million-parameter model yourself in about an hour using a rented cloud GPU for roughly $10.
The repository pairs with a YouTube video lecture where the creator walks through each step in detail. The code is organized as a series of clean git commits, each one adding a piece of the puzzle, so you can follow along in the video, understand why each part matters, and see the model gradually come to life. This approach makes it much easier to learn than reading a dense research paper or jumping into production code.
What you'll end up with is a model that dreams up plausible text based on whatever you give it as a prompt. It's not a chatbot like ChatGPT—it doesn't follow instructions or have personality. It just continues whatever text you start with, based on patterns it learned from billions of words. The README includes examples of the kind of rambling, semi-coherent stuff the model generates early in training versus after it's seen more data.
This is ideal for anyone curious about how modern AI language models actually work under the hood, especially if you want to understand the mechanics without getting lost in advanced research jargon or corporate-grade code. The creator explicitly notes this is the foundation-building phase; conversation abilities and fine-tuning come later. They also recommend checking out the Discord community if you get stuck or have questions while working through the material.
Where it fits
- Work through the tutorial step by step to build your own GPT-2 model and understand how language models actually work under the hood.
- Train the 124M parameter model on a rented cloud GPU in about an hour for roughly $10 to see a working AI text generator you built yourself.
- Use the incremental git commit structure to pause the video at any step, inspect the code changes, and resume with full context.
- Experiment with the trained model by giving it prompts and observing how text generation quality improves as training progresses.