Abstract One of the major challenges in the development of universal machine learning interatomic potentials is accurately reproducing phonon properties. This issue appears to arise from the limitations of available datasets rather than the models themselves. To address this, we develop an extensive dataset of phonon calculations using density-functional perturbation theory. We then show how this dataset can be used to train neural-network force fields, by implementing the training and the prediction of force constants in periodic crystals. This approach improves the quality of phonon properties prediction while reducing the number of structures needed for neural network training. We demonstrate the efficiency of this method using two examples of ternary phase diagrams: Ti—Nb—Ta and Li—B—C. In both cases, neural network predictions for the energy and forces show a considerable improvement, while phonon properties are predicted with high precision for all structures across the entire phase diagrams.