grpo-reward-hacking-fixed-cap-qwen05b
This is the reward-capping variant: the same GRPO setup and the same reward model, with the sentiment score clipped at 0.9 instead of a KL penalty. Once every completion in a group clears the cap their rewards are identical, the group-relative advantage collapses to zero, and the policy stops being paid to chase saturation.
What this is part of
A three-part demo of reward hacking in GRPO:
- Code and write-up: https://github.com/Rohanjain2312/grpo-reward-hacking-demo
- Interactive comparison: Hugging Face Space
- The other arms of the experiment:
Setup actually used
| base model | Qwen/Qwen2.5-0.5B-Instruct |
| reward model | lvwerra/distilbert-imdb (reward = P(positive)) |
| task | continue the opening sentence of a negative IMDB review |
| algorithm | GRPO, group size 8, 8 prompts/step |
| KL coefficient (beta) | 0.0 |
| reward cap | 0.9 |
| steps | 100 |
| learning rate | 1e-05 |
| max new tokens | 48 |
Results on the held-out eval prompts
| metric | step 0 | step 100 |
|---|---|---|
| sentiment reward (P(positive), held-out) | 0.563 | 0.996 |
| perplexity under frozen base model | 4.4 | 8.4 |
| distinct-2 within each completion | 0.997 | 1.000 |
Full metrics and generated samples for every checkpoint are in logs/metrics.jsonl and
logs/samples.jsonl in this repo. Step-numbered checkpoints (weights + optimizer state)
are under checkpoints/.
Intended use
Research demonstration only. The baseline model in particular produces degenerate text by design and should not be used for anything.