This paper takes the integration of AI technology into piano teaching as the starting point, generates accompaniment rhythms through AI computation, adopts deep learning model to generate accompaniment, and builds a multi-level accompaniment effect generation mechanism. Taking the MuseFlow model as the base model, the generative adversarial network and variational autoencoder are introduced to optimize the structure in a limited arithmetic environment. Quantitative and manual evaluations are used to measure the accompaniment generation effect of the proposed mechanism, and controlled experiments are designed to explore its practical application effect. The results show that the improved MuseFlow model generates accompaniment with an average pitch distance of 0.92, which is 0.15 smaller than that of MMM, and the overall score reaches 4.18. The scores of the experimental group in all six abilities are significantly higher than those of the control group, the degree of students’ positive response to each ability increases to some extent, and the number of students who consider the ability of melodic creation to be at a satisfactory level is 18 more than that of the pre-experiment after the experiment.