A multi-task learning (MTL) framework, called gradient kernel ridge regression, for nuclear masses and separation energies is developed by introducing gradient kernel functions to the kernel ridge regression (KRR) approach. By taking the WS4 mass model as an example, the gradient KRR network is trained with the mass model residuals, i.e., deviations between experimental and theoretical values of masses and one-nucleon separation energies, to improve the accuracy of theoretical predictions. Significant improvements are achieved by the gradient KRR approach in both the interpolation and the extrapolation predictions of nuclear masses and separation energies. This demonstrates the advantage of the present MTL framework that integrates the information of nuclear masses and separation energies and improves the predictions for both of them.