Back to Module 6. Use the unbiased sample standard deviation, and use
Problem 6.1 (A mixed group).Rewards are
. Compute the mean, the unbiased standard deviation, and the four advantages. Which rollout is reinforced?
Solution
Solution to Problem 6.1.
The mean is
. The squared deviations are and three copies of , which sum to . Divide by to get variance , so the standard deviation is . The denominator is
. The advantages are that is about
. Only the first rollout has positive advantage, so the update increases its probability and decreases the other three.
Problem 6.2 (A tied group).Repeat the calculation for rewards
. What is the policy-gradient loss, and why is a zero loss the desired outcome rather than a bug?
Solution
Solution to Problem 6.2.
Every deviation from the mean is
, so every advantage is even though the standard deviation in the denominator is only the floor. Lemma 6.1 applies. The loss is a sum of zeros. There is no contrast inside the group. A gradient step cannot tell the optimizer which tokens were responsible for a success that every sample shared. Draw another question, or sample at a higher temperature so some rollouts fail.
Problem 6.3 (Detach).Advantages are computed from rewards, and rewards are computed from the sampled text. Why are the advantages detached before they multiply
?
Solution
Solution to Problem 6.3.
The reward is a verifier call on decoded text. It is not a differentiable function of the logits. Leaving the advantage attached either breaks the backward pass or routes the gradient through a path that is not the policy gradient. Detach keeps
as a constant weight. The only tensors that receive gradient are the sequence log probabilities.
Problem 6.4 (Sum, not mean).Two correct rollouts have the same advantage. One is 20 tokens long and one is 200 tokens long, and every token log probability equals
. Under the summed objective, which rollout contributes the larger-magnitude term ? What would dividing by length do to that comparison?
Solution
Solution to Problem 6.4.
The sums are
and . With the same positive advantage, the short rollout contributes and the long one contributes . The long one dominates the average. That is a real length bias of the summed objective. Dividing each sum by its length would make both token-averages equal to
, so the two rollouts would contribute equally. Module 6 does not divide, because that rescaling is a different objective. The bias is revisited when the KL term and the clip are added.