As a unique art form, traditional music protection is facing increasingly severe challenges as the times change, and traditional music inheritance is becoming more and more difficult. Based on analyzing the contemporary value of traditional music, the article describes the specific application of artificial intelligence technology in the protection and inheritance of traditional music. In order to realize the innovative development of traditional music, this article designs the CT Music database. Then the random mask is combined with Transformer to construct RM-Transformer model for generating traditional music chords, and GCT model is designed for traditional music generation. The results show that compared with the mainstream model, the number of parameters and the average time of generating music of the GCT model are reduced by 0.98MB and 3.22s, respectively, and the scores of the generated traditional music are all higher than 34.5 on the subjective evaluation of listening. The full application of artificial intelligence technology can significantly improve the generation quality of traditional music and provide a development path for the protection and inheritance of traditional music.