Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Fine-Tuning and RL for Agents

Free · sign in to start and track progress

1 · Decide and prepare

  • 1Prompt, optimise or train?
  • 2Training data from traces

2 · Supervised and preference fine-tuning

  • 3SFT with LoRA on a free GPU
  • 4Preference optimisation

3 · Reinforcement learning for agents

  • 5GRPO in practice

    Exercise answers

    • Answer: GRPO the verifiable triage fields on a free GPU
    • Answer: Reproduce TRL's loss aggregations by hand
  • 6Designing rewards
  • 7Multi-turn RL environments
  • 8Reward hacking, regressions and shipping
CapstoneTrain a triage model, then decide whether to ship itReference implementation

Module 3 · Reinforcement learning for agents · Lesson 5

GRPO in practice

Run reinforcement learning with verifiable rewards on a small open model, from configuring TRL's GRPO trainer and its loss variants to keeping groups informative, reading the training curves and telling sharpening from new capability.

85 min 2 videos 3 exercises 8-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvFree GPUs on KaggleHugging Face account and CLIGet an OpenRouter keyLocal models with Ollama

By the end of this lesson you can

  • Configure a GRPO run (group size, completion length, loss type, clipping, KL coefficient, LoRA learning rate) and explain the problem each loss variant fixes
  • Compute the share of zero-variance groups from per-prompt success rates, and use difficulty filtering to keep a run learning
  • Diagnose healthy, stalled and collapsing runs from reward, reward spread, entropy, KL and completion-length curves
  • Compare pass@1, pass@k and pass^k before and after RL, and explain the evidence on whether RL adds capability or sharpens it
  • Explain why LoRA is enough for policy-gradient RL and why online RL tends to forget less than supervised fine-tuning

On this page

  • What changes when you leave the toy example
  • One GRPO step in TRL
  • The loss variants and what each one fixes
  • Group size, clipping and KL
  • Worked example: one triage group
  • Keep groups informative: difficulty filtering
  • Reading the curves
  • What fits in a free session
  • pass@1, pass@k and the sharpening debate
  • Why LoRA is enough, and why RL forgets less
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01What changes when you leave the toy example
  2. 02One GRPO step in TRL
  3. 03The loss variants and what each one fixes
  4. 04Group size, clipping and KL
  5. 05Worked example: one triage group
  6. 06Keep groups informative: difficulty filtering
  7. 07Reading the curves
  8. 08What fits in a free session
  9. 09pass@1, pass@k and the sharpening debate
  10. 10Why LoRA is enough, and why RL forgets less
  11. 11Connections
  12. 12Summary

Sources & further reading

  • DAPO: An Open-Source LLM Reinforcement Learning System at ScalePaper · Yu et al. · 2025The paper behind TRL's default loss. Section 3 names the four fixes (clip-higher, dynamic sampling, token-level loss, overlong reward shaping); each subsection shows the curve that motivated it.
  • Understanding R1-Zero-Like Training: A Critical Perspective (Dr. GRPO)Paper · Liu et al. · 2025Shows that GRPO's per-sequence length normalisation lengthens wrong answers and that dividing by the group's standard deviation biases training by question difficulty. Read the section on GRPO's optimisation bias.
  • Does Reinforcement Learning Really Incentivize Reasoning Capacity in LLMs Beyond the Base Model?Paper · Yue et al. · 2025The pass@k argument that RL with verifiable rewards mostly sharpens what the base model can already do. NeurIPS 2025. Read the abstract and the first pass@k figure, then compare with ProRL (linked in the lesson).
  • Group Sequence Policy OptimizationPaper · Zheng et al. · 2025Moves the importance ratio and clipping from tokens to whole sequences; the stability argument (especially for mixture-of-experts models) is in the introduction and the analysis section.
  • RL's Razor: Why Online Reinforcement Learning Forgets LessPaper · Shenfeld, Pari, Agrawal · 2025Evidence that forgetting after fine-tuning tracks the KL divergence from the base model on the new task, and that on-policy RL keeps that KL small. The abstract states the result.
  • LoRA Without RegretLab research · John Schulman et al. · Thinking Machines · 2025Why LoRA, even at rank 1, matches full fine-tuning for policy-gradient RL, why its best learning rate is about 10 times full fine-tuning's, and why every layer (especially the MLP) should get an adapter.
  • GRPO Trainer (TRL documentation)Docs · Hugging FaceThe reference for every knob and logged metric in this lesson: loss types, scale_rewards, the logged metrics list and how reward functions receive dataset columns. Pin the TRL version you read it for.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 12 more sections
  • 3 hands-on exercises
  • A 8-question quiz
  • Progress, quiz scores and bookmarks