where λ ≥ 0 is a hyper-parameter controlling the weight of the regularization term. The molecular similarity is in this study related to the notion of precedence. Precedence is learnt by a transformer model based on the training data and repre-sents the probability for a source compound to be transformed into a specific target compound. The NLL can be used as proxy for the precedence where a low NLL means a high precedence and vice versa. Figure illustrates an example where a nitrogen atom in penicillin is replaced by a oxygen atom, phosphorus atom, or arsenic atom, respectively. It is important to notice that the Tanimoto similarities (calculated with the count version of ECFP4 fingerprints) between Penicillin and the modified penicillin analogues are exactly the same, while their NLLs are different, as the penicillin analogue with an arsenic atom has lower precedence than the penicillin analogue with a phosphorus atom, and the penicillin analogue with a phosphorus atom has lower precedence than the penicillin analogue with an oxygen atom and the penicillin analogue with an oxygen has lower precedence than penicillin itself. We can therefore expect that the penicillin analogue with an oxygen atom will be retrieved with a much higher precedence (probability) during inference than the penicillin analogues with a phosphorous atom or arsenic atom, respectively. : Penicillin (used here as the source molecule) and its analogues where a nitrogen atom (N) is replaced with an oxygen atom (O), phosphorus atom (P), and arsenic atom (As), respectively. The molecular similarity between Penicillin and the modified analogues are the same, while their corresponding NLLs (precedence) are different. The molecular transformation from penicillin to the analogue with an arsenic atom has lower precedence (higher NLL) than transforming penicillin to the analogue with phosphorus and oxygen, respectively. The derivative with an oxygen atom has the highest precedence after penicillin. The Tanimoto similarity is denoted with the letter S on top of the penicillin analogues in the lower part of the figure.