KL Divergence Optimization formulation derivation
Many thanks for your great open source work and detailed technical report! This is super beneficial for the community advancement. After reading your technical report, I am wondering that how is this new KL divergence estimator is derived? Why this is bias-free estimator with lower variance? Is it possible to elaborate more in details? Many thanks for your time!
We observed that the KL estimator proposed in http://joschu.net/blog/kl-approx.html, which was adopted in GRPO, has the form:
The gradient can be interpreted as the cross-entropy loss scaled by the relative diff between the current policy and the reference policy, as shown in
However, when the probabilities are small, numerical precision errors and model updates can cause significant fluctuations in this relative error, leading to gradient spikes. To address this issue, we modified the KL estimation to use absolute error instead of relative error. While this approach introduces bias in the KL estimation, it effectively eliminates gradient spikes, thereby stabilizing the RL training process.