In order to solve the problems of the separation of topic identification and stance discrimination and the insufficient utilization of semantics in the analysis of ideological and political education texts, a collaborative modeling method under the framework of multi-task learning was constructed. The model is based on shared semantic coding, introduces topic prototype matching and feature fusion mechanism in the topic identification branch, and adds topic-guided attention and cross-task consistency constraint in the stance discrimination branch, so that the topic information and attitude information can be jointly optimized in a unified representation space. The experiment is carried out based on 58,000 ideological and political education texts, covering various scenarios such as course discussions, thematic learning experiences, policy interpretation texts and campus online comments. The results show that the perplexity of the topic recognition model is 638, the topic consistency is 0.731, and the silhouette coefficient is 0.517. The accuracy of stance discrimination model reaches 86.7%, and Macro-F1 is 85.3%, which is better than the comparison models. The research shows that this method can improve the ability of topic boundary identification and implicit stance capture of ideological and political education texts, and provide computational technical support for curriculum feedback analysis, network public opinion research and education governance intelligence.