Navigation überspringen
Reasoning from scratch, round number 6!
0:00 / 1:26:53

Reasoning from scratch, round number 6!

Sebastian Raschka

@rasbt546.707 Follower

Auf X besuchen
1.605 LikesHerunterladenOriginalbeitrag

77.111 Aufrufe

Reasoning from scratch, round number 6! An introduction (and implementation) of Reinforcement Learning with Verifiable Rewards (RLVR) and Group Relative Policy Optimization (GRPO). 00:00 Introduction 01:54 What makes a reasoning model different? 04:25 Reasoning traces and model capability 08:29 Accuracy and format rewards 11:34 Aha moments and DeepSeek-R1 training 14:41 Reasoning effort and answer length 18:38 RLHF and RLVR 23:04 GRPO vs. PPO 26:40 GRPO explained with a cooking analogy 31:43 The KL term and simplified GRPO 35:04 Loading the pretrained model 36:07 Loading the MATH training data 39:26 Sampling model responses 46:30 Computing verifiable rewards 49:55 Computing advantages 51:54 Token and sequence log probabilities 55:29 Implementing sequence log probabilities 57:37 Fixing the inference-mode error 1:02:24 Computing the GRPO loss 1:04:37 Putting the GRPO step together 1:09:19 The GRPO training loop 1:12:57 Training settings, logging, and checkpoints 1:17:24 Running training and inspecting outputs 1:19:28 Loading and evaluating checkpoints 1:22:33 MATH-500 results and training stability 1:24:05 Memory requirements and next steps

49 Kommentare

Kommentare aus dem Originalbeitrag auf X (Twitter)

  • Profilbild von Sebastian Raschka

    @rasbt

    And a link to the YouTube version:

    37 Likes

  • Profilbild von Fireply.ai

    @fireplyai

    loading the pretrained model at 35:04 and sampling responses by 39:26. that's a tight path from nothing to something you can inspect

    3 Likes

  • Profilbild von Daniel Priscu

    @daniel_priscu

    grpo walked through with actual code is rare, most explainers stop at the diagram

    2 Likes

  • Profilbild von Sebastian Raschka

    @rasbt

    And it’s used to train a pretty solid model too

  • Profilbild von Rohan

    @proxy_vector

    Does the GRPO part sample the whole group in one batched generate call?

    2 Likes

  • Profilbild von Sebastian Raschka

    @rasbt

    It's sequential to keep the compute resource requirements low, but I also have a batched version that does that (I mentioned it somewhere in the video)

  • Profilbild von Marius Laurusevicius

    @MLaurusevicius

    Chapter list alone is worth it. Going to start with the cooking analogy one.

    2 Likes

  • Profilbild von Debora Lauriola

    @DeboraLauriola

    Your breakdown of RLVR and GRPO is a valuable contribution to the discussion around AI reasoning. I’d be interested in your perspective for an upcoming TechCrunch story.

    2 Likes

  • Profilbild von Saksham Jain

    @sakshjn

    worth pairing with dr grpo after this. dividing by response length means long wrong answers get penalized less per token, so outputs creep longer

    2 Likes

  • Profilbild von Sebastian Raschka

    @rasbt

    Spoiler: GRPO improvements are covered in the 2-hour follow-up video :)

    2 Likes

  • Profilbild von Saksham Jain

    @sakshjn

    oh nice, 2 hours is generous. does it get into dapo's clip-higher too or mostly the length norm stuff

  • Profilbild von Mathias 🇺🇸

    @MathiasEngineer

    Loved the book! Now I can watch this to reinforce my learning :) thank you

    2 Likes

  • Profilbild von classeve

    @classevelabs

    does the from-scratch GRPO loop stay practical on a CPU-only laptop, or is a GPU the real floor for the MATH run?

    2 Likes

  • Profilbild von Sebastian Raschka

    @rasbt

    I wouldn't run it on a laptop for too long, it would get very hot

  • Profilbild von classeve

    @classevelabs

    ha, fair. hand warmer with a loss curve then. is one colab-tier GPU enough for the whole chapter?

  • Profilbild von Gol Tiro

    @gol_tiro

    round 6 already, this series is the way to actually get grpo instead of just using it. does the from-scratch version fit on a single consumer gpu or does it want more?

    2 Likes

  • Profilbild von Sebastian Raschka

    @rasbt

    The (small) default settings are ok for single GPU

    2 Likes

  • Profilbild von Buswe

    @buswe_com

    Dropping the critic is what makes GRPO fit on one GPU: the group mean is the baseline, so there is no second model to hold.

    2 Likes

  • Profilbild von AI Quanting

    @AIQuanting

    The inference-mode error fix at 57:37 is my favourite thing in that list. That bug eats an afternoon and it almost never makes the cut.

    2 Likes

  • Profilbild von Sebastian Raschka

    @rasbt

    Fun fact: I added it earlier in the video, deliberately, for demo purposes

    1 Like