Training Agents 3: Reinforcement Learning
- Source
- youtube.com
- Author
- Hugging Face
- Date
Context
This third session of a Hugging Face live series on training agents covers GRPO, group relative policy optimization, the reinforcement learning method in Hugging Face's TRL library. The useful idea is in the name: the model is never told how good an answer is in absolute terms. For each prompt it produces several attempts, a reward function scores them, and each attempt is pushed up or down by how far its score sits above or below the group's average, divided by the group's spread. The TRL documentation states the same formula, and calls the number of attempts per prompt num_generations.
That design explains most of the practical advice in the stream. Ben, presenting the theory, points out that if every attempt in a group succeeds, or every one fails, there is no difference to learn from, and a single success among many failures gives very little. He compares it to chess: always playing grandmasters or always playing beginners teaches you nothing. So the things you actually adjust are the size of the group, how hard the prompts are, and the reward itself, for example adding an easy format reward alongside a harder correctness reward so a struggling model still gets some signal. Compared with the covered in part 2, which gives feedback at every , this reward arrives once at the end of an attempt, and Ben describes typical pipelines as using distillation-style supervised training first and RL after it, sometimes cycling between them, rather than treating them as rivals.
Sergio's experiments in the stream make the point concrete. Scoring Python solutions by how many unit tests pass, a quick check before training gave a small model of about 0.6 billion parameters a mean reward of 0.22, which they read as hard enough to leave room to learn but not hopeless; they then trained it with groups of 2, 8 and 16 attempts. A third run used a deliberately gameable reward that paid out for writing Python code blocks: training reward rose to its ceiling while reward on the held-out test split did not. These are live demonstration runs, not benchmarks, but they show the failure the presenters warn about most, reward hacking, where the score climbs without the model learning the task.
Their answer is less a setting than a habit. Ben says the KL penalty, which limits how far the model drifts from where it started, will discourage some hacks but is not a fix; the real defence is a reward function that cannot be gamed, a dry run of that function on sample text, a short smoke test that shows at least some reward variation, and reading actual trajectories rather than admiring a rising curve. The next session, part 4, keeps GRPO but swaps simple reward functions for full environments. The full stream is on YouTube.
- GRPO's advantage is each completion's reward minus the group mean, divided by the group's standard deviation, so a group where every rollout succeeds or every rollout fails gives no learning signal; the hosts aim for mixed outcomes in each group.
- To create that variation they suggest adjusting prompt difficulty or adding easier partial rewards, such as a format check alongside a correctness check, because swapping the model is rarely possible in a real pipeline.
- Two limit drift: clipping (epsilon) bounds how far a reused batch moves, and the KL penalty (beta) bounds drift from the starting policy over the run; the session notes TRL defaults both to zero.
- In the reward-hacking demo, a reward for emitting four Python code blocks pushed training reward to its ceiling of 1 while test reward did not follow; the hosts say KL alone will not fix hacking and you should read trajectories.
- Their pre-launch routine: dry-run the reward function on sample text, then a roughly five-step smoke test; with four generations over five steps, no reward variation at all means the run is not ready to launch.
- distillation — Training a small, cheap model to imitate a big one's outputs, keeping much of the capability at a fraction of the cost.
- token — The chunk of text a model reads and writes in — roughly three-quarters of a word — and the unit AI usage is billed in.
- guardrails — The checks around a model that block bad inputs and outputs — filters, validators, and permission rules the model itself can't override.
- videoTraining Agents 2: Live tutorial on model distillation for training custom agents.
- videoTraining Agents: Live tutorial on how to fine-tune a coding agent for continual learning
- videoRL for Agents Workshop - Deep Dive on Training Agents with RL and Open Source
- videoAgentic Evaluations Workshop - Deep Dive on the Future on Evals for Agents.
Checking sign-in…
Loading comments…
