Back to directory

LLMs from Scratch

A hands-on tutorial that builds a ChatGPT-style language model in PyTorch step by step, covering tokenization, embeddings, attention, and the transformer block through interactive notebooks.

Visit website (opens in a new tab)awesomeneuron.substack.com
LLMs from Scratch

LLMs from Scratch is a hands-on guide to building a ChatGPT-like large language model in PyTorch. It breaks the architecture into simple parts and explains each one in turn: tokenization, token embeddings, positional embeddings, the self-attention mechanism, masked multi-head attention, feedforward networks, residual connections, layer normalization, and the transformer block, ending in a small resulting model.

Each topic has a matching interactive Jupyter notebook that walks through the code for that component, so a reader can follow the model's construction piece by piece rather than reading a single large implementation.

It requires installing PyTorch and other dependencies from a requirements file, and is licensed under the MIT license.

More in Tutorials

See all 478
  • BootLife

    github.com

    Conway's Game of Life implemented to run directly from a 512-byte x86 boot sector in assembly, using VGA memory itself as the simulation grid.

  • A technical blog post deriving the Y combinator as a composition of combinator birds in an array language, and examining how eager evaluation changes fixed-point recursion compared with the usual lazy telling.

  • System Design Atlas

    atlas-sysdes.vercel.app

    A free reference of worked system design problems with interactive architecture diagrams, covering ranked designs such as a feed, a chat app, a URL shortener, and a rate limiter, plus pages on the technologies behind them.