A chemistry-motivated graph neural network called LocalTransform is proposed, which learns organic reactivity based on generalized reaction templates to describe the net changes in electron configuration between the reactants and products and exhibits state-of-the-art product prediction accuracy.