The loss in Equation 1 allows the transformer to learn but it associates equal probabilities (i.e. same negative log-likelihood) to all the target compounds associated to the same source molecule. This uniform assignment occurs because the model observes these target compounds an equal number of times. This behaviour is not ideal since during inference we would like the probability of generating a target molecule given a specific source molecule, p(t|s), to be proportional to the similarity between the molecules. To mitigate this issue, we introduce in Equation 2, a regularization term to the loss in Equation 1 which penalizes the NLL if the order relative to a similarity metric is not respected. Ω((s i , t i ), (s j , t j )) = max(0, sign(κ(s i , t i ) -κ(s j , t j ))