rasbt/LLMs-from-scratch

Implement a ChatGPT-like LLM in PyTorch from scratch, step by step

Open original source ↗

From the publisher

README & documentation

Source preview

Read 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…

rasbt/LLMs-from-scratch on GitHub A short preview, not the full document.

Read the full README ↗ · Preview checked 2026-10-29T18:41:34.858Z

Inside the original README — Document outline
  1. Build a Large Language Model (From Scratch)
  2. Table of Contents
  3. Prerequisites
  4. Hardware Requirements
  5. Video Course
  6. Companion Book / Sequel
  7. Exercises
  8. Bonus Material
  9. Questions, Feedback, and Contributing to This Repository
  10. 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.

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.

README and project files

Issues and maintenance discussion

Releases and changelog

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.

Open original source

Related repositories

jackfrued/Python-100-Days

microsoft/generative-ai-for-beginners

microsoft/ML-For-Beginners

microsoft/AI-For-Beginners

pathwaycom/llm-app

GokuMohandas/Made-With-ML