A classification method for public opinion big data in the field of education
By using the continuously pre-trained coding model, absolute rotation position coding, and head-to-tail importance recurrent neural network in public opinion classification in the education field, combined with multi-task learning, the problems of high labeling cost and low classification accuracy in the existing technology are solved, and the More efficient public opinion and sentiment classification.
Patent Information
- Application Number
- CN202311357715.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-19
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-10-19
AI Technical Summary
Existing public opinion classification methods have high annotation costs and low efficiency, and fail to effectively utilize the characteristics of social media texts, resulting in poor classification accuracy.
Using the continuous pre-trained encoding model combined with the attention mechanism of the absolute rotation position encoding method, the public opinion text features are extracted through the head-to-tail importance recurrent neural network, and the loss function of multi-task learning is combined for public opinion and emotion classification.
While reducing annotation costs, we improve classification accuracy. We use absolute rotation position encoding and head-to-tail importance recurrent neural networks to enhance feature extraction. We use annotation data more comprehensively through multi-task learning to improve classification accuracy.
Smart Images

Figure CN117407527B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of natural language processing, and specifically relates to a method for classifying public opinion big data in the field of education. Background Art
[0002] With the rise of social media, people can freely disseminate their thoughts and opinions on various issues through the media. Education is the foundation of a nation, and the field of education has always been a focus of public attention. Educational events often spark widespread discussion and dissemination. Teachers and students, as the primary carriers of the education sector, are very active on social media and have a strong connection to the internet. This results in public opinion in the education sector being characterized by rapid dissemination, affecting many people, and having a wide range of influence. As the primary responsible parties in the education sector, schools and relevant departments should actively monitor the emotional trends of speech related to education, intervene in and formulate plans for potential public opinion events, and promptly control the development of public opinion, which is conducive to a harmonious and stable school atmosphere and the development of policies that benefit the people.
[0003] Existing public opinion classification methods have the disadvantages of high labeling costs and time-consuming labeling, and do not take into account the characteristics of text data on social media, resulting in problems such as poor classification accuracy and low efficiency. Summary of the Invention
[0004] In view of the shortcomings of the existing technology, the present invention proposes a method for classifying public opinion big data in the field of education, which includes:
[0005] S1: Obtain public opinion texts in the field of education and annotate them with public opinion categories and sentiment categories to obtain a public opinion dataset in the field of education;
[0006] S2: Use the pre-trained encoding model to encode the education field public opinion dataset to obtain the public opinion text vector; the encoding model is pre-trained and integrates the attention mechanism of absolute rotation position encoding;
[0007] S3: Use the head-tail importance recurrent neural network to extract the public opinion text feature vector from the public opinion text vector; the public opinion text feature vector includes tail-focused features and head-focused features;
[0008] S4: Fuse the public opinion text feature vector and the public opinion text vector to obtain the final feature vector; use two different classifiers to process the final feature vector to obtain the first probability matrix of the public opinion category and the first probability matrix of the emotion category;
[0009] S5: Construct prompt templates and multiple-choice question templates based on public opinion texts in the education field; Based on the prompt templates and multiple-choice question templates, use multi-task learning to obtain the second probability matrix of the public opinion category and the second probability matrix of the emotion category;
[0010] S6: The first probability matrix and the second probability matrix of the public opinion category are integrated to obtain the public opinion classification result, and the first probability matrix and the second probability matrix of the emotion category are integrated to obtain the emotion classification result.
[0011] Preferably, when labeling public opinion categories in the education field, the labeling categories include 10 categories: education policy, education assessment, education resources, academic management, teacher ethics, teaching quality, academic research, campus safety, campus culture and university employment; when labeling emotional categories, the labeling categories include 8 categories: dissatisfaction, opposition, anger, worry, satisfaction, support, like and recognition.
[0012] Preferably, the attention mechanism of the absolute rotation position encoding method is expressed as:
[0013]
[0014] Among them, self-attenrion mn represents the attention score of the token at position m and the token at position n, softmax represents the softmax normalization function; ω represents the attention hyperparameter, q m represents the query vector after the word vector corresponding to the mth token integrates the absolute rotation position information, k n represents the key vector after the word vector corresponding to the nth token integrates the absolute rotation position information, v n Indicates the value vector after the word vector corresponding to the nth token integrates the absolute position information, d k Indicates the dimension of the key vector.
[0015] Furthermore, the vector q m 、k n and v n The calculation formulas are:
[0016] q m =W q (x m +sin(m / 10000 i / d ))e imθ
[0017] k n =W k (x n +cos(n / 10000 i / d ))e inθ
[0018] v n =W v (x n +cos(n / 10000 i / d))
[0019] Among them, W q , W k , W v Represent the first, second, and third randomly initialized linear transformation matrices, x m 、x n They represent the word vectors corresponding to the tokens at the mth and nth positions of the text sequence, respectively. i represents the i-th position in the token vector dimension, θ represents the principal value of the angle, and d represents the dimension of the word embedding.
[0020] Preferably, the process of extracting the public opinion text feature vector includes:
[0021] S31: Send the public opinion text vector into the head-tail importance recurrent neural network in the original order to obtain the tail emphasis feature ch order ;
[0022] S32: Send the public opinion text vector into the head-tail importance recurrent neural network in the reverse order of the original order to obtain the head-focused feature ch reverse .
[0023] Preferably, the head-tail importance recurrent neural network is expressed as:
[0024]
[0025] o t =relu(V*s t )
[0026] Among them, s t represents the state of the hidden layer at step t, tanh represents the tanh activation function, U represents the input layer connection matrix, x t represents the input vector of step t, W represents the weight matrix, s t-1 Represents the state of the hidden layer at the previous moment, Indicates that x is included t The number of words, n word Indicates the number of words in the document, sum text Indicates the total number of documents, Indicates that x is included t The total number of documents, o t Represents the output of the tth step, relu represents the relu activation function, and V represents the connection matrix of the output layer.
[0027] Preferably, the process of fusing the public opinion text feature vector and the public opinion text vector includes:
[0028] Splice the public opinion text vector, the tail-focused features, and the head-focused features to obtain a comprehensive feature vector;
[0029] The linear layer is used to reduce the dimensionality of the comprehensive feature vector to obtain the final feature vector.
[0030] Preferably, the classifier consists of a linear layer, an activation layer and a softmax layer.
[0031] Preferably, the loss function for multi-task learning is:
[0032]
[0033] Among them, loss represents the total loss of training, Indicates the number of categories at the first masking position, y m Indicates whether the true label of the current sample is m, p m Indicates the predicted probability that the current sample belongs to m, Indicates the number of categories at the second masking position, y n Indicates whether the true label of the current sample is n, p n Indicates the predicted probability that the current sample belongs to n, ω′ represents the weight coefficient, n choice represents the number of categories of the multiple-choice task, α t Represents a list of multi-task learning hyperparameters, h represents the one-hot vector of the current sample's true category, p t represents the output probability distribution, and γ represents the multi-task learning hyperparameter.
[0034] The beneficial effects of the present invention are:
[0035] 1. Continuing to pre-train the encoding model on public datasets can reduce the labeling cost of new data while ensuring classification results;
[0036] 2. The proposed absolute rotation position encoding method combines the advantages of absolute position encoding and rotation position encoding, and can carry more useful position information when embedding text;
[0037] 3. The proposed head-tail importance recurrent neural network takes into account the fact that the preceding and following texts on the Internet carry more information, thereby increasing the effective information carried in the feature vector and improving classification accuracy.
[0038] 4. Use a weighted loss function to simultaneously complete prompt learning and multiple-choice question learning, making more comprehensive use of labeled data and improving classification accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 This is a flow chart of the method for classifying public opinion big data in the education field in the present invention. DETAILED DESCRIPTION
[0040] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0041] This paper proposes a method for classifying public opinion big data in the field of education. Figure 1 As shown, the method includes the following contents:
[0042] S1: Obtain public opinion texts in the field of education and annotate them with public opinion categories and sentiment categories to obtain a public opinion dataset in the field of education.
[0043] To obtain public opinion texts in the field of education, public opinion texts related to the field of education can be collected from major mainstream social media platforms. Public opinion texts include article titles, emoticons, keywords, all comments involved, etc.; public opinion texts in the field of education are labeled with public opinion categories and sentiment categories.
[0044] Preferably, when labeling public opinion categories in the education sector, the labeling categories include 10 categories: education policy, education assessment, education resources, educational management, teacher ethics, teaching quality, academic research, campus safety, campus culture, and university employment. When labeling emotional categories, the labeling categories include 8 categories: dissatisfaction, opposition, anger, worry, satisfaction, support, like, and approval.
[0045] S2: Use the pre-trained encoding model to encode the public opinion dataset in the education field to obtain the public opinion text vector; the attention mechanism of absolute rotation position encoding is integrated in the pre-training process of the encoding model.
[0046] The encoding model parameters are initialized using the weights of the pre-trained encoding model. The encoding model continues pre-training by integrating an attention mechanism using absolute rotation position encoding. Pre-training is completed on the Weibo dataset to obtain the encoding model M. M is used to encode the education field public opinion dataset to obtain the corresponding public opinion text vector.
[0047] The pre-training task in this paper uses the random mask pre-training task (MLM, Masked Language Modeling) of Mac-BERT (a modified Transformers-based bidirectional encoding representation model for the MLM task). The encoding model is further pre-trained using the Weibo dataset, a public sentiment classification dataset containing 100,000 positive and negative comments from Sina Weibo.
[0048] The attention mechanism of absolute rotation position encoding is expressed as:
[0049]
[0050] Among them, self-attention mn represents the attention score of the token at position m and the token at position n, where m and n represent the positions of the mth and nth tokens in the text sequence; softmax represents the softmax normalization function; ω represents the attention hyperparameter, q m represents the query vector after the word vector corresponding to the mth token integrates the absolute rotation position information, k n represents the key vector after the word vector corresponding to the nth token integrates the absolute rotation position information, v n Indicates the value vector after the word vector corresponding to the nth token integrates the absolute position information, d k Indicates the dimension of the key vector.
[0051] Preferably, in the attention mechanism of the absolute rotation position encoding method, the vector q m 、k n and v n The calculation formulas are:
[0052] q m =W q (x m +sin(m / 10000 i / d ))e imθ
[0053] k n =W k (x n +cos(n / 10000 i / d ))e inθ
[0054] v n =W v (x n +cos(n / 10000 i / d ))
[0055] Among them, W q , W k , W v Represent the first, second, and third randomly initialized linear transformation matrices, x m 、x n They represent the word vectors corresponding to the tokens at the mth and nth positions of the text sequence, respectively. i represents the i-th position in the token vector dimension, θ represents the principal value of the angle, and d represents the dimension of the word embedding.
[0056] The public opinion dataset in the education field is encoded through a pre-trained encoding model based on the absolute rotation position encoding attention mechanism to obtain the public opinion text vector.
[0057] S3: Use the head-tail importance recurrent neural network to extract the public opinion text feature vector from the public opinion text vector; the public opinion text feature vector includes tail-focused features and head-focused features.
[0058] The first and last importance recurrent neural network is expressed as:
[0059]
[0060] o t =relu(V*s t )
[0061] Among them, s t represents the state of the hidden layer at step t, tanh represents the tanh activation function, U represents the input layer connection matrix, x t represents the input vector of step t, W represents the weight matrix, s t-1 Represents the state of the hidden layer at the previous moment, Indicates that x is included t The number of words, n word Indicates the number of words in the document, sum text Indicates the total number of documents, Indicates that x is included t The total number of documents, o t Represents the output of the tth step, relu represents the relu activation function, and V represents the connection matrix of the output layer.
[0062] The process of extracting public opinion text feature vectors includes:
[0063] S31: Send the public opinion text vector into the head-tail importance recurrent neural network in the original order to obtain the tail emphasis feature ch order ;
[0064] S32: Send the public opinion text vector into the head-tail importance recurrent neural network in the reverse order of the original order to obtain the head-focused feature ch reverse .
[0065] S4: Fuse the public opinion text feature vector and the public opinion text vector to obtain the final feature vector; use two different classifiers to process the final feature vector to obtain the first probability matrix of the public opinion category and the first probability matrix of the emotion category.
[0066] The process of fusing the public opinion text feature vector and the public opinion text vector includes:
[0067] Splicing public opinion text vector, tail focus feature ch order and the first part focuses on the feature ch reverse ; Get the comprehensive feature vector;
[0068] The linear layer is used to reduce the dimensionality of the comprehensive feature vector to obtain the final feature vector.
[0069] Two different classifiers are used to process the final feature vectors, resulting in the first probability matrix for the public opinion category and the first probability matrix for the sentiment category. The two classifiers have similar structures, both consisting of a linear layer, an activation layer, and a softmax layer, but they have different linear layer parameters to accommodate the two classification tasks of public opinion and sentiment.
[0070] S5: Construct prompt templates and multiple-choice question templates based on public opinion texts in the education field; based on the prompt templates and multiple-choice question templates, use multi-task learning to obtain the second probability matrix of the public opinion category and the second probability matrix of the emotion category.
[0071] The process of building prompt templates and multiple-choice question templates includes:
[0072] S51: construct a prompt learning template for the current text: [This belongs to the [MASK1] event] [Current text] [The emotional tendency is [MASK2]];
[0073] S52: The template for constructing multiple-choice questions for the current text is: [Current Text] [Which educational event is described? What is the author's attitude?];
[0074] S53: Assume that the current public opinion categories are [c 1, c2, c3, ...], the emotion categories are [b 1, b2,b3,……], then the answer to the multiple choice question is [[c1,b 1, ],[c 1, b2],[c 1, b3],……].
[0075] The process of obtaining the second probability matrix of the public opinion category and the second probability matrix of the emotion category using multi-task learning includes:
[0076] Initialize the model using the pre-trained BERT-base (Bidirectional Encoder Representation from Transformers) model; learn the prompt template and the multiple-choice question template based on the prompt, and use a multi-task loss function to train both tasks simultaneously. The two tasks share a set of model parameters.
[0077] The second probability matrix of public opinion category is expressed as:
[0078]
[0079] Among them, p x represents the probability of MASK1 being identified as x, choice represents the set of multiple-choice question options, s represents the probability matrix of multiple-choice question prediction, i represents the result of the first option of the multiple-choice question, j represents the result of the second option of the multiple-choice question, and s [i,j] It represents the probability that the first option of the multiple-choice question is i and the second option is j.
[0080] The second probability matrix of emotion category is expressed as:
[0081]
[0082] Among them, e x Indicates the probability that MASK2 is identified as x.
[0083] During the training process of multi-task learning, the loss function is:
[0084]
[0085] Among them, loss represents the total loss of training, Indicates the number of categories at the first masking position, y m Indicates whether the true label of the current sample is m, p m Indicates the predicted probability that the current sample belongs to m, Indicates the number of categories at the second masking position, y n Indicates whether the true label of the current sample is n, p n Indicates the predicted probability that the current sample belongs to n, ω′ represents the weight coefficient, n choice represents the number of categories of the multiple-choice task, α t Represents a list of multi-task learning hyperparameters, h represents the one-hot vector of the current sample's true category, p t represents the output probability distribution, and γ represents the multi-task learning hyperparameter.
[0086] S6: The first probability matrix and the second probability matrix of the public opinion category are integrated to obtain the public opinion classification result, and the first probability matrix and the second probability matrix of the emotion category are integrated to obtain the emotion classification result.
[0087] The first probability matrix of public opinion category and the second probability matrix of public opinion category are combined to obtain the public opinion classification result of the public opinion text in the education field. The first probability matrix of emotion category and the second probability matrix of emotion category are combined to obtain the emotion classification result of the public opinion text in the education field. Preferably, the fusion method can be linear weighting.
[0088] In summary, the present invention completes the continued pre-training of the encoding model on a public dataset, scientifically and effectively integrates the information of social media into the pre-training model, reduces the magnitude of the dataset required for fine-tuning, and saves a lot of annotation time and cost. Absolute rotation position encoding is proposed, which integrates absolute position and relative position, so that the position information carried when the text is embedded can be more accurate, and the model's ability to express text is enhanced. By using the head-tail importance recurrent neural network, more attention is paid to the key information of the head and tail when extracting features, which is very suitable for text classification on social media. Combined prompt learning and multiple-choice question learning can discover more text information in limited fine-tuning samples and improve the accuracy of classification.
[0089] By accurately classifying public opinion texts in the field of education, the present invention can complete accurate classification of public opinion texts in the field of education with little labeled data, which is beneficial for schools and relevant departments to grasp the development of public opinion in advance and respond in a timely manner. It is also beneficial to the management of ideology in the field of education and the good development of policies, and can build a more harmonious and beautiful online environment for the public.
[0090] The above embodiments further illustrate the purpose, technical solutions and advantages of the present invention in detail. It should be understood that the above embodiments are only preferred implementation plans of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made to the present invention within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for classifying big data of public opinion in the field of education, characterized in that: include: S1: Obtain public opinion texts in the field of education and annotate them with public opinion categories and sentiment categories to obtain a public opinion dataset in the field of education; S2: The education field public opinion dataset is encoded using the pre-trained encoding model to obtain the public opinion text vector; the attention mechanism of the absolute rotation position encoding method is integrated in the pre-training process of the encoding model; the attention mechanism of the absolute rotation position encoding method is expressed as: Among them, self-attention mn represents the attention score of the token at position m and the token at position n, softmax represents the softmax normalization function; ω represents the attention hyperparameter, q m represents the query vector after the word vector corresponding to the mth token integrates the absolute rotation position information, k n represents the key vector after the word vector corresponding to the nth token integrates the absolute rotation position information, v n Represents the value vector after the word vector corresponding to the nth token integrates the absolute position information, d k Indicates the dimension of the key vector; S3: The head-tail importance recurrent neural network is used to extract the public opinion text feature vector from the public opinion text vector; the public opinion text feature vector includes tail-focused features and head-focused features; The process of extracting public opinion text feature vectors includes: S31: Send the public opinion text vector into the head-tail importance recurrent neural network in the original order to obtain the tail emphasis feature ch order ; S32: Send the public opinion text vector into the head-tail importance recurrent neural network in the reverse order of the original order to obtain the head-emphasis feature ch reverse ; The first and last importance recurrent neural network is expressed as: o t =relu(V*s t ) Among them, s t represents the state of the hidden layer at step t, tanh represents the tanh activation function, U represents the input layer connection matrix, x t represents the input vector of the tth step, W represents the weight matrix, s t-1 represents the state of the hidden layer at the previous moment, Indicates that x is included t The number of words, n word Indicates the number of words in the document, sum text Represents the total number of documents, Indicates that x is included t The total number of documents, o t represents the output of the tth step, relu represents the relu activation function, and V represents the connection matrix of the output layer; S4: Fuse the public opinion text feature vector and the public opinion text vector to obtain the final feature vector; use two different classifiers to process the final feature vector to obtain the first probability matrix of the public opinion category and the first probability matrix of the sentiment category; S5: Construct a prompt template and a multiple-choice question template based on the public opinion text in the education field; Based on the prompt template and the multiple-choice question template, use multi-task learning to obtain the second probability matrix of the public opinion category and the second probability matrix of the emotion category; The prompt learning template for the current text is: [This belongs to the [MASK1] event][Current text][The emotional tendency is [MASK2]]; The template for constructing multiple-choice questions for the current text is: [Current text] [Which educational event is described? What is the author’s attitude?]; The loss function of multi-task learning is: Among them, loss represents the total training loss, Indicates the number of categories at the first masking position, y m Indicates whether the true label of the current sample is m, p m Indicates the predicted probability that the current sample belongs to m, Indicates the number of categories at the second masking position, y n Indicates whether the true label of the current sample is n, p n represents the predicted probability that the current sample belongs to n, ω′ represents the weight coefficient, n choice represents the number of categories of the multiple-choice task, α t represents a list of multi-task learning hyperparameters, h represents the one-hot vector of the true category of the current sample, p t represents the output probability distribution, γ represents the multi-task learning hyperparameter; S6: The first probability matrix of the public opinion category and the second probability matrix of the public opinion category are integrated to obtain the public opinion classification result, and the first probability matrix of the emotion category and the second probability matrix of the emotion category are integrated to obtain the emotion classification result.
2. According to claim 1, a method for classifying big data of public opinion in the field of education is characterized in that: When labeling public opinion categories in the education field, the labeling categories include 10 categories: education policy, education assessment, education resources, academic management, teacher ethics, teaching quality, academic research, campus safety, campus culture and university employment; when labeling emotional categories, the labeling categories include 8 categories: dissatisfaction, opposition, anger, worry, satisfaction, support, like and recognition.
3. According to claim 1, a method for classifying big data of public opinion in the field of education is characterized in that: Vector q m , k n and v n The calculation formulas are: q m =W q (x m +sin(m / 10000 i / d ))e imθ k n =W k (x n +cos(n / 10000 i / d ))e inθ v n =W v (x n +cos(n / 10000 i / d )) Among them, W q , W k , W v Respectively represent the first, second, and third randomly initialized linear transformation matrices, x m 、x n They represent the word vectors corresponding to the tokens at the mth and nth positions of the text sequence respectively, i represents the i-th position in the token vector dimension, θ represents the principal value of the angle, and d represents the dimension of word embedding.
4. According to claim 1, a method for classifying big data of public opinion in the field of education is characterized in that: The process of fusing the public opinion text feature vector and the public opinion text vector includes: Concatenate the public opinion text vector, the tail-focused features, and the head-focused features to obtain a comprehensive feature vector; The linear layer is used to reduce the dimension of the comprehensive feature vector to obtain the final feature vector.
5. According to claim 1, a method for classifying big data of public opinion in the field of education is characterized in that: The classifier consists of a linear layer, an activation layer and a softmax layer.
Citation Information
Patent Citations
Emotion recognition method and device
CN112069316A
Emotion analysis method for environment type network public opinions
CN114692623A
Public opinion text sentiment analysis method and device, computer equipment and medium
CN116263786A
Simple aspect-level sentiment classification method for sentiment knowledge enhancement prompt tuning
CN116304063A
Public opinion analysis method combining deep learning and language logical reasoning
CN116340511A
