All problems
Process Reward Step Values
Problem
Compute the discounted process-reward value at every step.
Walking backward, V[t] = step_rewards[t] + gamma * V[t + 1] with the value after the last step equal to 0. Return the list of values; an empty episode returns [].
Hint
A process reward model scores each reasoning step, not just the final answer.
Test cases
case 1
in: [[1,1,1],0.5]
expected: [1.75,1.5,1]
case 2
in: [[1,1,1],0]
expected: [1,1,1]
case 3
in: [[0.5],0.9]
expected: [0.5]
case 4
in: [[],0.9]
expected: []
Starter codePython
def prm_step_values(step_rewards, gamma):
# Your code here
pass4 test cases · run your code against them in the editor