Downloads · 30 days
0
sergiopaniego/grpo-youtube-livestream-3-scripts
grpo-youtube-livestream-3-scripts is a reinforcement learning model from sergiopaniego. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Three GRPO runs that build on each other, from the Training Agents live stream (Class 3). Same trainer, same model, three rewards:
Downloads · 30 days
0
Access
Public
Updated Jul 27, 2026
Repo size
—
Likes
2
Public
Click a slice to open those files.
.py11.6 KB · 59%
From the Hugging Face model README
Three GRPO runs that build on each other, from the Training Agents live stream (Class 3). Same trainer, same model, three rewards:
train_grpo_minimal.py — the smallest run that works, from the
TRL quickstart: reward = be close to
20 characters long. No task, no labels. GRPO optimizes whatever number you return, and
the completions/mean_length curve shows it converging within a few steps.train_grpo.py — a verifiable reward: the model writes a Python function for an
MBPP problem, the reward
executes the problem's own asserts, reward = fraction that pass. The knob to play with is
--num_generations (the group size).train_grpo_pathological.py — reward hacking on purpose: trains on a deliberately
gameable reward (count the code blocks, run nothing) while logging the real tests reward
with weight 0. The trained reward saturates, the tests reward collapses, completion length
pins at the maximum: reward hacking, length gaming and collapse on one dashboard.Class 1 (SFT) scripts: burtenshaw/gemma4-pi-mono-youtube-livestream-1-scripts ·
Class 2 (distillation) scripts: sergiopaniego/pi-mono-youtube-livestream-2-scripts
Qwen/Qwen3-0.6B (thinking mode disabled: the completion is just the code)full (374 train problems, each with 3 asserts) for 2 and 3; trl-lib/tldr
prompts for 1. GRPO only needs prompts: the reward function replaces the labels.One A100 (a100-large), ~20 minutes per run.
# 1. Minimal: reward = be close to 20 characters
hf jobs uv run --flavor a100-large --secrets HF_TOKEN -d --timeout 1h train_grpo_minimal.py \
--model_name_or_path Qwen/Qwen3-0.6B --dataset_name trl-lib/tldr \
--dtype bfloat16 --bf16 True \
--use_vllm --vllm_mode colocate --vllm_gpu_memory_utilization 0.3 \
--num_generations 8 --per_device_train_batch_size 16 \
--max_completion_length 256 --temperature 0.7 --learning_rate 2e-6 \
--max_steps 300 --logging_steps 1 --log_completions \
--report_to trackio --project minimal --run_name reward-len \
--trackio_space_id sergiopaniego/trackio-training-agents-3 \
--output_dir qwen3-0.6b-tldr-lenreward
# 2. Verifiable: sweep the group size
for k in 2 8 16; do
hf jobs uv run --flavor a100-large --secrets HF_TOKEN -d --timeout 2h train_grpo.py \
--model_name_or_path Qwen/Qwen3-0.6B \
--dataset_name google-research-datasets/mbpp --dataset_config full \
--dtype bfloat16 --bf16 True \
--use_vllm --vllm_mode colocate --vllm_gpu_memory_utilization 0.3 \
--num_generations $k --per_device_train_batch_size 16 \
--max_completion_length 512 --temperature 0.7 --learning_rate 2e-6 \
--max_steps 300 --logging_steps 1 --log_completions \
--report_to trackio --project grpo-sweep --run_name grpo-k$k \
--trackio_space_id sergiopaniego/trackio-training-agents-3 \
--output_dir qwen3-0.6b-mbpp-grpo-k$k --push_to_hub \
--hub_model_id sergiopaniego/qwen3-0.6b-mbpp-grpo-k$k
done
# 3. Pathological: reward hacking on purpose
hf jobs uv run --flavor a100-large --secrets HF_TOKEN -d --timeout 2h train_grpo_pathological.py \
--model_name_or_path Qwen/Qwen3-0.6B \
--dataset_name google-research-datasets/mbpp --dataset_config full \
--dtype bfloat16 --bf16 True \
--use_vllm --vllm_mode colocate --vllm_gpu_memory_utilization 0.3 \
--num_generations 8 --per_device_train_batch_size 16 \
--max_completion_length 512 --temperature 0.7 --learning_rate 2e-6 \
--max_steps 300 --logging_steps 1 --log_completions \
--report_to trackio --project pathological --run_name hacked-reward \
--trackio_space_id sergiopaniego/trackio-training-agents-3 \
--output_dir qwen3-0.6b-mbpp-grpo-hacked
Run locally by dropping hf jobs uv run --flavor ... --secrets HF_TOKEN -d --timeout ... and
calling uv run <script> ....
One Trackio Space for the class, one project per run type (pick it in the project selector): https://huggingface.co/spaces/sergiopaniego/trackio-training-agents-3
minimal — the 20-characters rewardgrpo-sweep — the verifiable reward, k = 2 / 8 / 16pathological — the gameable reward| num_generations | reward (start → end) | groups with no variance |
|---|---|---|
| 2 | 0.41 → 0.58 | ~75% |
| 8 | 0.41 → 0.67 | ~40% |
| 16 | 0.39 → 0.61 | ~30% |
The group is the baseline, so the group size controls how many steps actually teach something. But bigger is not free: with a fixed batch, more generations per prompt means fewer distinct prompts per step (k=16 sees 1 prompt per step, k=2 sees 8).
Models: qwen3-0.6b-mbpp-grpo-k2 ·
k8 ·
k16
tests_reward runs model-generated code in a plain subprocess with a timeout, with no
sandbox. Inside a disposable job container this is acceptable for a demo, but the container
still holds your HF_TOKEN: beyond a demo, run rewards in a real sandbox. The natural fit is
Hugging Face Sandboxes, isolated
machines built on the same Jobs infrastructure, made for exactly this ("running untrusted or
AI-generated code"), with SandboxPool for fanning out RL rollouts:
from huggingface_hub import Sandbox
with Sandbox.create() as sbx:
result = sbx.run(["python", test_file], timeout=10)
E2B is the equivalent third-party option (it is what Open R1 uses for its code rewards).