{mvGPT}

mvGPT: Minimum Viable GPT: A Language Model from Scratch

Understand language models from the ground up.

Define a GPT in PyTorch, then take it through the whole training pipeline, from pretraining to reinforcement learning, with the evaluation and metrics that show what it learned, and deploy it for anyone to talk to.

docsGitHub stars

  1. define
  2. pretrain
  3. fine-tune
  4. deploy
  5. align

Talk to mvGPT

ep003-sft · 8-bit · in your browser
    Features:

    A summary, or a few words to use (sun, kite, brave), and it writes a children's story. It doesn't answer questions, and each message is a new story. The first one downloads the model, about 15 MB, from Hugging Face.

    Watch the seriesTry it in your browserRead the codeDocs

    Start here

    1. Watch the first episode

      A small GPT written from scratch in PyTorch, from its parameters to how a prompt flows through it to the next token.

      Watch episode 01 · 32 min
    2. Follow the code

      Each step of an episode is a tag in the code's repository, so you can check out the code as it was at that point in the video.

      git checkout ep001/step-1Browse the code
    3. Read about the series

      What it covers, who it's for, and where it's heading.

      About the series

    Latest episodes

    All 35 episodes
    1. Our GPT's own GPU kernels in Mojo on a Mac

      We write our GPT's writing path as GPU kernels in Mojo, call them from Python, check them against PyTorch, and make them faster in three versions, racing PyTorch and MLX on this Mac.

      37 min

    2. Measuring and fixing our C++ BPE tokenizer

      We measure episode eleven's C++ tokenizer on web pages, its memory, its time, its threads and its long chunks, and fix what we find with an LRU cache, a GIL-free encoder, a cache per call and a heap.

      50 min

    3. Sparse autoencoder features inside our GPT

      We train a sparse autoencoder on the residual stream of our web model, read what its features fire on, measure what it costs the model, and steer the model's writing with a feature.

      26 min

    4. Our GPT in Apple's MLX vs PyTorch on a Mac

      We port our GPT from PyTorch to MLX, Apple's array library for its own chips, check that it gives the same numbers, and race the two on this Mac at writing and at training.

      24 min

    Explore by topic