rasbt/LLMs-from-scratch
Implement a ChatGPT-like LLM in PyTorch from scratch, step by step
From the publisher
README & documentation
Source previewRead the project’s overview, installation instructions and usage examples. The original README is the source of truth.
This repository contains the code for developing, pretraining, and finetuning a GPT-like LLM and is the official code repository for the book Build a Large Language Model (From Scratch). In Build a Large Language Model (From Scratch), you'll learn and understand how large language models (LLMs) work from the inside out by coding them from the ground up, step by step. In this book, I'll guide you through creating your own LLM, explaining each stage with clear text, diagrams, and examples. The method described in this book for training and developing your own small-but-functional model for educational purposes mirrors the approach used in creating large-scale foundational models such as those behind ChatGPT. In addition, this book includes code for loading the weights of larger pretrained models for finetuning. To download a copy of this repository, click on the Download ZIP button or execute the following command in your terminal: (If…
Read the full README ↗ · Preview checked 2026-10-29T18:41:34.858Z
Inside the original README — Document outline
- Build a Large Language Model (From Scratch)
- Table of Contents
- Prerequisites
- Hardware Requirements
- Video Course
- Companion Book / Sequel
- Exercises
- Bonus Material
- Questions, Feedback, and Contributing to This Repository
- Citation
Headings are captured from the source. Links open the publisher’s document, not a locally hosted copy.
Links from the README
References supplied by the publisher, not independently verified endorsements. Check the destination before downloading files or entering credentials.
- README.md
- Troubleshooting Guide
- PyTorch in One Hour: From Tensors to Training Neural Networks on Multiple GPUs
- Installing Python Packages and Libraries Used in This Book
- Docker Environment Setup Guide
- Pretraining GPT on the Project Gutenberg Dataset
- Adding Bells and Whistles to the Training Loop
- Optimizing Hyperparameters for Pretraining
- PyTorch Performance Tips for Faster LLM Training
- Finetuning Different Models on the 50k IMDb Movie Review Dataset
- Dataset Utilities for Finding Near Duplicates and Creating Passive Voice Entries
- Evaluating Instruction Responses Using the OpenAI API and Ollama
Documentation belongs to its respective authors. Reported project/model license: Other. A listing is not a grant of reuse or training rights. Confirm the document’s own terms at the source.
What this repository does
Implement a ChatGPT-like LLM in PyTorch from scratch, step by step
Repository facts
- Owner
- rasbt
- Primary language
- Jupyter Notebook
- Stars
- 107,629
- Forks
- 16,611
- Open issues + pull requests
- 1
- License
- Other
- Archived
- No
- Default branch
- main
- Created
- 2023-07-23T18:15:57.000Z
- Last push
- 2026-10-30T02:15:16.000Z
Topics and intended use
Owner-supplied topics: ai, artificial-intelligence, attention-mechanism, deep-learning, finetuning, from-scratch, generative-ai, gpt, instruction-tuning, language-model, large-language-models, llm, machine-learning, natural-language-processing, pretraining, python, pytorch, tokenizer, transformers
Review the README for scope, installation, examples and limitations. We do not run repository code or certify it.
Evaluate before installing
Review licensing and dependencies, inspect recent commits and unresolved issues, and test in an isolated environment before production use. Stars and forks alone cannot answer these questions.
Source and freshness
Source: GitHub. Metadata observed 2026-11-01T13:20:54.848Z. Daily imports are snapshots, not real-time monitoring.
Popularity and source listings do not establish security, suitability, licensing rights or benchmark performance.