Per-token normalization aggregates policy losses over active completion tokens, giving every token equal gradient weight. Longer sequences therefore exert proportionally more influence than shorter ones. section 6.3.2
For per-token losses ℓᵢ,ₜ, batch size B, and completion lengths |aᵢ|, compute the sum of all active-token losses divided by the total number of active tokens. Prompt positions remain excluded by the completion mask. section 6.3.2
Unequal sequence lengths
A five-token sequence with mean loss 2.8 and a ten-token sequence with mean loss 1.9 produce a per-token loss of (14 + 19) / 15 = 2.2. Every active token receives equal gradient magnitude, unlike per-sequence normalization. section 6.3.2
Equation 6.47
\[\label{eq:loss_per_token} L = \frac{\sum_{i=1}^{B} \sum_{t=1}^{|a_i|} \ell_{i,t}}{\sum_{i=1}^{B} |a_i|}.\]Formalizes normalization across all active tokens in the batch. section 6.3.2
