Alignment Algorithms Zoo · Problem 2 of 5
Implement SimPO (length-normalized, reference-free) and KTO losses and unit-test on toy data.
Implement the function/class skeleton in the editor. Any correct approach is accepted.
import torch
import torch.nn.functional as F
def simpo_loss(pi_logps_w, pi_logps_l, len_w, len_l, beta=2.0, gamma=1.0):
raise NotImplementedError
def kto_loss(pi_logps, ref_logps, labels, beta=0.1, lam_d=1.0, lam_u=1.0):
raise NotImplementedError
def _test():
raise NotImplementedErrorReady when you are
Submit your solution and a structured review appears here — verdict, score, and concrete feedback. Any correct approach passes.
Implement SimPO (length-normalized, reference-free) and KTO losses and unit-test on toy data.
Implement the function/class skeleton in the editor. Any correct approach is accepted.