# #8 Determining if longer responses are better by tracking token-weighted mean advantage of a batch

Author: Paulius Rauba
Canonical URL: https://www.pauliusrauba.com/notes/8-determining-if-longer-responses-are-better-by-tracking-token-weighted-mean-advantage-of
Published: 2026-11-27T17:36:30.469Z
Updated: 2026-11-27T17:36:30.469Z

The pressure to have RL produce token-efficient rollouts has never been higher: a lot of post-training efforts incorporate length penalties of various sorts. However, there's also a trade-off between quality and length: it is *typically* the case that longer responses within a group are better.

You can only optimize what you measure, so it would be useful to track the relationship between quality and length over the course of your training run. Of course, you need to take into account that some tasks will induce longer responses since they are more difficult. Ideally, such a measure would have the following properties: 
1. It would be higher when longer responses are better and shorter when shorter responses are better
2. It would be free to compute
3. It would take into account task-difficulty
4. We can monitor it over the course of a training run
5. It is sensitive to the size of how much longer vs shorter responses are better.

One such measure is the normalized token-weighted mean advantage. Advantages sum to 0 within a group but when we compute our loss (per-token), and (aggregate A * per-token-weight), we get that the sum of advantage x generated tokens across the batch is either positive or negative. We can normalize this value and see if the updates within groups push toward longer or shorter responses (which is also bounded between [-1, 1]). 

![image.png](https://www.pauliusrauba.com/notes/files/944c5e1f-18ac-434d-af09-83c82d8763e2)


