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
- 108k
- Category
- Learning, interviews and curated lists
- Language
- Jupyter Notebook
- License
- Custom license (see repository)
- Forked
- 2026-08-10
- Sync status
- In syncLast synced 2026-11-09
More in Learning, interviews and curated lists
Chinese-language CSAPP third-edition study materials for reading chapters, checking exercise answers, and studying eight labs online or offline.
Forked 2026-10-20Last synced 2026-11-09No license declaredLearning, interviews and curated listsGitHub
A practical guide for university students and early-career readers handling communication and social situations, with scenario-based advice they can adapt to everyday interactions.
Forked 2026-10-20Last synced 2026-11-09Custom license (see repository)Learning, interviews and curated listsGitHub
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-11-09No 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-30License: MITLearning, interviews and curated listsGitHub