Open-source repo trains a Transformer LLM from scratch — 13M params on a single Colab T4

Roger_M_Taylor · x · 2026-09-19

A step-by-step open-source repo walks you through building and training a Transformer from scratch in PyTorch, following the original "Attention is All You Need" paper: MLP, single-head and multi-head attention, transformer blocks, and the full model, each coded and explained with detailed diagrams.

Training data comes from The Pile, an 825GB open-source dataset spanning books, articles, code and websites, with scripts for downloading, preprocessing and tokenizing via tiktoken, storing in HDF5, and feeding training batches. The author demonstrates training a 13M-parameter model on a single Colab T4 GPU, at which point the model starts producing proper grammar and coherent short sentences.

Original post →

More from coding & agent

coding & agent channel →