{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.

  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 seriesRead 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 34 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. 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

    3. 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

    4. Mixture of experts from scratch in PyTorch

      We replace each block's MLP in our GPT with a mixture of eight experts and a router, write it as a loop and then as one batched multiply, balance it three ways, and train it next to the dense model at the same compute per token.

      37 min

    Explore by topic