The rapid development of artificial intelligence has broken the boundaries and modes of education, making the online education model increasingly mature and widely popular. The study is oriented to senior medical students, and the core lies in transforming the massive online learning behavior data into the understanding of students’ learning motivation. Faced with numerous behavioral sequences, a Hidden Markov-based Bayesian model L²S is constructed to decipher students’ stable learning styles from their click data. And self-determination theory was introduced as a scale to plan students into intrinsic motivation (IMS), extrinsic motivation (EMS), and no apparent motivation (UMS).The L²S model had an average classification accuracy of 78.03% in distinguishing learning styles such as practicing, planning, etc., which was significantly better than the comparative baseline models such as LSTM and KNN. Cluster analysis outlined the portraits of 64 intrinsically motivated students, 89 extrinsically motivated students, and 14 students with no apparent motivation, and IMS excelled in content exploration and video learning, with scores averaging 4.77 and 4.58 on a five-point scale, whereas all dimensions of the UMS were below 2, and the differences in the portraits were extremely sharp. The constructed psychological intervention model reached statistically significant levels of enhancement for all dimensions, both in the group and pre- and post-experiment interaction items, with p-values of <0.05. Its booster effects on intrinsic motivation (F=16.189) and self-efficacy (F=17.977) were particularly strong.