Implement GAE (the backward recursion) given per-token rewards and value estimates

RLHF: Reward Models, PPO & GRPO2 / 7

Chapter 122 / 7

RLHF: Reward Models, PPO & GRPO

Implement GAE (the backward recursion) given per-token rewards and value estimates

Medium
Target interface
compute_gae(rewards, values, gamma=0.99, lam=0.95, last_value=0.0)

Complete the starter code in the editor. Any correct approach is accepted.

Hints0 / 2
Reference solution
Your own code stays in the editor.