LLMs-from-scratch
Code for building, pretraining and finetuning a GPT-like language model in PyTorch, step by step. It accompanies a book and teaches how large language models work.
Pick a small issue you can reproduce, then fix it with your AI coding agent.
Share on XCustom license (see repository)
Overview
This is the official code repository for the book Build a Large Language Model (From Scratch). It contains the code for developing, pretraining and finetuning a GPT-like model in PyTorch, going step by step with text, diagrams and examples. The approach is meant for education and mirrors how large foundation models are made, but at a small scale. The book also covers loading weights of larger pretrained models.
Key features
- Step by step code for building a GPT-like LLM in PyTorch
- Covers pretraining and finetuning
- Includes code for loading weights of larger pretrained models
- Provided as Jupyter Notebooks
Best for
Readers who want to understand how LLMs work by coding one themselves. It is written for learning and produces a small model, and it accompanies the book.
- Upstream
- rasbt/LLMs-from-scratch
- Fork on GitHub
- Guo-astro/LLMs-from-scratch
- Upstream stars
- 106k
- Category
- Learning, interviews and curated lists
- Language
- Jupyter Notebook
- License
- Custom license (see repository)
- Forked
- 2026-08-10
- Sync status
- In syncLast synced 2026-10-20
More in Learning, interviews and curated lists
A structured Linux study course based on Linux Basics for Hackers, with notes, command examples, diagrams, and exercises for learning in a personal lab.
Forked 2026-10-19Last synced 2026-10-20No license declaredLearning, interviews and curated listsGitHub
A community-curated Android rooting resource hub with guides and a catalog of root apps and modules. Search the website or browse by category to find setup and troubleshooting resources.
Forked 2026-10-19Last synced 2026-10-20License: MITLearning, interviews and curated listsGitHub
A rated, auto-refreshed directory of game decompilations, recompilations, source ports, remakes and browser ports. Browse and filter projects without links to game files.
Forked 2026-10-19Last synced 2026-10-20License: CC0-1.0Learning, interviews and curated listsGitHub
Open-source engineering handbooks for high-level system design and data structures and algorithms. It gives learners a structured, free curriculum with practical study materials and citations.
Forked 2026-10-18Last synced 2026-10-20License: CC-BY-SA-4.0Learning, interviews and curated listsGitHub