4 hidden checks

Implement the reward-model loss used in RLHF, plus two scaling calculations.

  • preference_prob(r_a, r_b): the Bradley–Terry probability that A is preferred, . Works element-wise on arrays.
  • reward_loss(r_chosen, r_rejected): the mean of over arrays of rewards. Compute it stably: , which np.logaddexp(0, -m) gives without overflow.
  • training_flops(n_params, n_tokens): the estimate.
  • chinchilla_loss(N, D): the fitted formula from the lesson with , , , , .
checks
  • preference_probnot run
  • reward_loss matches the formula and is stablenot run
  • training_flopsnot run
  • chinchilla_lossnot run
python sleeps until you press run

Press Run & check. Your code runs first, then the hidden checks on the left.