Learning to summarize from human feedback (Stiennon et al., 2020) fine-tunes a summarizer with reinforcement learning, while keeping it close to a supervised reference. The penalty is a per-sequence KL estimate: how much more likely each sampled token is under the policy than under the reference.
Implement per_token_kl(logp_policy, logp_ref), summing the per-token log-ratio over the sequence.
Subtract the reference log-probabilities from the policy log-probabilities and sum.
No results yet
Run your code to check it against the examples, or submit to run every test.