where m n denotes the representation of the newly constructed n th molecule. λ and K (where n > K) can be tuned as hyperparameters. This form of regularization will compute the cosine similarity of the newly generated molecule to each of the last K molecules. Taking the mean of the squares (L 2 norm) instead of the mean of the values (L 1 norm) gives more weight to higher similarity values. K determines how many previous molecules to use for regularization. We use K = 50 for our case. When λ = 1, it varies between 0 (no regularization) and 1 (maximum possible regularization). If the molecule is not synthesizable, it still receives a fixed negative reward of -1.