Group-relative advantages for GRPO
Normalize rollout rewards within each prompt for a group-relative policy objective.
What’s going wrong
Original LLM Architecture lab. Implement the missing behavior in solve(data) and keep the supplied JSON interface. Use Python’s standard library.
Input groups is a list of reward lists (one list per prompt) and epsilon > 0. Return means and advantages in group order. Use population standard deviation inside each group and divide centered rewards by (std + epsilon). Empty groups have mean 0 and empty advantages. This lab implements the advantage normalization stage.
Small, well-formed JSON inputs and standard-library Python arithmetic. Keep full precision during computation. The supplied output wrapper rounds results to six decimal places.
Expected behavior
Normalize rollout rewards within each prompt for a group-relative policy objective.
Reproduction
{"groups":[[1,2,3],[100,200]],"epsilon":0.001}{"means":[2,150],"advantages":[[-1.223247,0,1.223247],[-0.99998,0.99998]]}{"groups":[[]],"epsilon":0.001}{"means":[0],"advantages":[[]]}{"groups":[[4,4]],"epsilon":0.001}{"means":[4],"advantages":[[0,0]]}Before you begin
- Python functions, lists and dictionaries
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.