Following Fialková et al. , we now show that minimizing J(θ) is equivalent to optimizing the expected reward of the policy. The generative process is cast as an on-policy RL problem by defining the state space, S t , and the action space, A t (s t ). S t denotes every intermediate sequence of tokens leading up to the fully constructed SMILES and A t (s t ) are the token sampling probabilities at every intermediate state. A t (s t ) is controlled by the policy, π θ , which is parameterized by the weights, θ, of the neural network. Given a reward function, R, the objective is to maximize the expected reward when taking actions defined by the policy (Equation ):