Deep semantic recognition model for public security event analysis and its construction method

By combining the BERT and bidirectional GRU models, using the Transformer encoder and attention mechanism to extract text semantic features, and integrating multiple emotion classifiers through the ensemble learning method, it solves the problem of difficult to capture word context differences and long-distance semantic correlations in emotion recognition. problem, achieving more efficient emotion recognition and better generalization capabilities.

CN114564565BActive Publication Date: 2024-10-22HUBEI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210203781.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-02
Publication Date
2024-10-22
Estimated Expiration
2042-03-02

AI Technical Summary

Technical Problem

The existing technology has problems in emotion recognition, such as difficulty in identifying word context differences, neglect of long-distance contextual semantic correlation, and insufficient generalization ability of a single model.

Method used

The BERT pre-training model is combined with the bidirectional GRU to extract the contextual semantic features of the text through the Transformer encoder and attention mechanism, and the integrated learning method of data perturbation and voting strategy is used to fuse the results of multiple emotion classifiers.

Benefits of technology

It achieves a more accurate emotion recognition effect, improves the model's ability to capture long-distance contextual emotional semantics and generalization performance, and significantly improves the accuracy and stability of emotion classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114564565B_ABST
    Figure CN114564565B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of natural language processing sentiment analysis, and discloses a deep semantic recognition model for public safety event analysis and a construction method thereof. The contextual semantic feature representation of the comment text is obtained through the BERT pre-training model, and then the deep nonlinear feature vector is extracted in combination with the bidirectional GRU to achieve the optimal effect under a single model; multiple sentiment classifiers with excellent performance and differentiation are trained based on the BERT series pre-training models; and the ensemble learning method of data perturbation and voting strategy is used to achieve the full integration of the deep features of each model. The present invention makes full use of the differences between models, adopts ensemble learning and voting strategies to fuse multiple models, and trains a stable sentiment classification model with balanced performance in all aspects; experimental results show that the BERT‑BiGRU model has better sentiment recognition effect on two public data sets than other traditional models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of natural language processing sentiment analysis, and in particular relates to a deep semantic recognition model for public safety event analysis and a construction method thereof. Background Art

[0002] At present, emotion recognition is a machine-based perception and understanding of the emotional intentions expressed by humans through text, images and other media, and is one of the key technologies of artificial intelligence. At present, social networking sites are an important platform for people to pay attention to current affairs and share personal opinions. A large number of unstructured text comments are generated every day, and these comments usually carry the subjective emotional intentions of the publisher. Emotion recognition of social comments is of great significance to public opinion control, commercial marketing, social governance, etc., and is one of the research hotspots in the field of natural language processing in recent years.

[0003] Social network texts have typical characteristics such as rich emotional semantics and different text lengths. How to judge the emotional polarity from texts of different lengths is a key problem that the current emotion recognition system urgently needs to solve. The traditional word2vec or glove word vector pre-training model can learn the context information of words to a certain extent, but there is a semantic deviation in the model where the same word expresses the same semantics in different contexts. For example, "This car has a really high cost performance" and "This car has a really high fuel consumption", where "really high" expresses a positive comment in the former and a negative comment in the latter, which is difficult to identify by this method. When using the traditional convolutional neural network model (CNN) for text classification tasks, although it can effectively extract local features in word representation, it ignores the semantic correlation between long-distance contexts.

[0004] Nowadays, most models use machine learning or deep learning methods to predict text sentiment, and have made great progress. However, most models are single models. Due to the randomness of single models, they can only perform well in one aspect, but lack generalization ability.

[0005] Through the above analysis, the problems and defects of the prior art are as follows:

[0006] (1) Traditional word2vec or glove word vector pre-training models have semantic deviations in which the same word expresses the same meaning in different contexts, making it difficult to identify.

[0007] (2) When using the traditional convolutional neural network (CNN) model for text classification tasks, the semantic correlation between long-distance contexts is ignored.

[0008] (3) Most of the existing models are single models. Due to the randomness of single models, they can only perform well in one aspect but lack generalization ability.

[0009] The difficulty of solving the above problems and defects is:

[0010] The accuracy of traditional machine learning is better than that of sentiment dictionary methods, but it requires high-quality feature construction and professional domain knowledge and does not have good generalization capabilities. When capturing semantic correlations between long-distance contexts, it is difficult to determine which information to discard or retain. A single model often only works well in a specific field, and it is difficult to improve its generalization ability.

[0011] The significance of solving the above problems and defects is:

[0012] For specific tasks, we can mine the deep semantic information between text comments to obtain the optimal sentiment recognition effect under a single model, achieve the purpose of multiple uses of a single model, and enable the integrated model to obtain the best prediction results and generalization performance. Summary of the invention

[0013] In view of the problems existing in the prior art, the present invention provides a deep semantic recognition model for public safety event analysis and a construction method thereof, aiming to solve the problems of the prior art in that the deep emotional semantic features of text are insufficiently extracted and the generalization ability is limited.

[0014] The present invention is implemented in this way: a method for constructing a deep semantic recognition model for public security event analysis, the method for constructing a deep semantic recognition model for public security event analysis comprising:

[0015] The contextual semantic feature representation of the comment text is obtained through the BERT pre-training model, and then combined with the bidirectional GRU to extract the deep nonlinear feature vector to achieve the best effect under a single model; based on the BERT series pre-training models, multiple sentiment classifiers with excellent performance and differentiation are trained; the integrated learning method of data perturbation and voting strategy is used to achieve the full integration of the deep features of each model.

[0016] Furthermore, the method for constructing a deep semantic recognition model for public safety event analysis includes the following steps:

[0017] Step 1: preprocess the original data set to remove noise data;

[0018] Step 2: Build a single emotion recognition model, concatenate the BERT pre-trained language model with BiGRU to obtain a text classification model, and use the text classification model to obtain the classification result;

[0019] Step three, build an integrated emotion recognition model, obtain multiple emotion-based classifiers through data perturbation and BERT series pre-training models, and vote on the classification results of step two and the results output by the integrated module.

[0020] Furthermore, the BERT model in step 2 adopts the Transformer encoder as the main model structure, mines the relationship between words based on the attention mechanism, is used for parallel training and considers global information.

[0021] In text classification tasks, text is usually represented by word vectors. The BERT model adds position vectors based on word vectors and segment vectors, and saves word order information through position embedding, thereby adding different vectors to characters or words in different positions to distinguish them:

[0022]

[0023]

[0024] Among them, pos represents the position index, d model is the word vector dimension, PE represents the position code corresponding to the pos position, which is generated by the sine sin and cosine cos functions and then added to the corresponding position word vector; the beginning of the sentence is marked with [CLS], and the separation and end of the sentence are marked with [SEP].

[0025] After obtaining the input representation of the sentence, BERT uses the masked language model MLM and the next sentence prediction NSP for joint training. MLM refers to randomly masking the words in the text with [MASK] and letting the model make predictions. NSP refers to randomly selecting two sentences from the corpus and concatenating them to predict whether they are from the same text.

[0026] The core of the BERT model is the encoder of the Transformer model. Multi-head attention is an important part of the Transformer. The attention mechanism uses the similarity between the target word Query and its context word Key as the weight, and integrates the Value of the upper and lower words into the Query of the target word to obtain an enhanced semantic vector representation of the target word. It projects Q (Query), K (Key), and V (Value) through multiple linear transformations, and finally concatenates different attention results to form multi-head attention, so that the model can learn relevant information in different representation subspaces, thereby obtaining enhanced semantic vectors of words in different semantic spaces.

[0027] MultiHead(Q,K,V)=Concat(head 1 , ..., head k )WO ;

[0028]

[0029] The Transformer encoder adds residual and normalization modules, which are connected to each submodule on the Encoder and Decoder ends; the residual is used to solve the problem of multi-layer network training, allowing the network to only focus on the current difference part, to prevent network degradation and accelerate convergence. Normalization refers to Layer Normalization, which is used to normalize the activation values ​​of each layer; α and β are training parameters, and μ and σ represent deviation and variance; after the feedforward neural network, linear transformation and ReLu activation function are performed to obtain the output of the encoder, as shown in the formula:

[0030]

[0031] FNN=max(0,xW 1 +b 1 )W 2 +b 2 .

[0032] Furthermore, the semantic representation obtained by the BERT model is used as the input of the bidirectional GRU model. In the bidirectional GRU, each GRU unit contains two gate structures, the update gate and the reset gate, which are represented by r and t , z t , in order to maintain and update the state information and transmit it. The update gate functions similarly to the forget gate and input gate of LSTM, determining the extent to which the state information of the previous moment is brought into the current state. The reset gate controls the extent to which the state information of the previous moment is ignored. The smaller the value of the reset gate, the more it is ignored. The bidirectional GRU model is used to handle the timing problem, using the information of the entire text sequence, including the relationship information between each word, and using the information to process each word.

[0033] Furthermore, the output of BERT is forwarded Get the complete context information of all past time series, and then reverse Get the complete context for all future time series, calculated as follows:

[0034]

[0035]

[0036] Among them, w is the weight connecting the two layers, b is the bias vector, and f is the activation function. and They are the positive GRU and negative GRU outputs respectively.

[0037] The bidirectional GRU represents the input d in the positive and negative hidden layers n Calculate and get d n Hidden state h t , the positive and negative GRU adopts the splicing strategy:

[0038]

[0039] Get the hidden state of the bidirectional GRU, the calculation formula is as follows:

[0040] H=(h 1 ,h 1 ,...,h d};

[0041] Use global average pooling to replace the fully connected layer. The global average pooling layer has no parameters, integrates global information, and outputs multi-dimensional features. After global average pooling, it obtains a one-dimensional feature vector and sends it to the softmax function to obtain the sentiment category of the comment text, as shown in the formula:

[0042] TEXT C =softmax(W t ·H+b t );

[0043] Among them, W t represents the weight parameter of the global average pooling layer, b t Represents the bias value, and finally the output TEXT_C of the BERT-BiGRU model is obtained.

[0044] Furthermore, in step three, after obtaining multiple base classifiers with differences, the results of the base classifiers are fused through a combination strategy to achieve the best prediction effect of the model after ensemble learning. Multiple BERT, BERT-BiLSTM and BERT-BiGRU models are used as base classifiers, and the output categories of all classifiers are counted. A majority voting strategy is used to make decisions based on the generated category probability distribution of emotion recognition. Given the same weight for the classification results of all individual classifiers, each base classifier can only cast one vote, and the principle of minority obeys majority is adopted. The category with the highest number of votes will be used as the final prediction result of the comment. The voting formula is as follows:

[0045]

[0046] Among them, n and T represent the number of categories and the number of base classifiers of sentiment classification respectively, C i,j Indicates that the predicted category of base classifier i in the test set x is j, It represents the total number of votes for the test set x in all base classifiers whose predicted category results are j. The category with the most votes is taken as the final category result of the predicted sample x.

[0047] Another object of the present invention is to provide a deep semantic recognition model for public security incident analysis obtained by constructing each of the deep semantic recognition models for public security incident analysis.

[0048] Another object of the present invention is to provide a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and when the computer program is executed by the processor, the processor performs the following steps:

[0049] The contextual semantic feature representation of the comment text is obtained through the BERT pre-training model, and then combined with the bidirectional GRU to extract the deep nonlinear feature vector to achieve the best effect under a single model; based on the BERT series pre-training models, multiple sentiment classifiers with excellent performance and differentiation are trained; the integrated learning method of data perturbation and voting strategy is used to achieve the full integration of the deep features of each model.

[0050] Another object of the present invention is to provide a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the following steps:

[0051] The contextual semantic feature representation of the comment text is obtained through the BERT pre-training model, and then combined with the bidirectional GRU to extract the deep nonlinear feature vector to achieve the best effect under a single model; based on the BERT series pre-training models, multiple sentiment classifiers with excellent performance and differentiation are trained; the integrated learning method of data perturbation and voting strategy is used to achieve the full integration of the deep features of each model.

[0052] Another object of the present invention is to provide an information data processing terminal, which is used to implement the deep semantic recognition model for public security event analysis.

[0053] Combined with all the above technical solutions, the advantages and positive effects of the present invention are as follows: the deep semantic recognition model for public safety event analysis provided by the present invention uses a Transformer-based bidirectional encoder representation model (Bidirectional Encoder Representations from Transformers, BERT), dynamically adjusts the semantic features of word vectors, and uses a bidirectional gated recurrent unit (Bidirectional Gated Recurrent Unit, BiGRU) for semantic encoding to enhance the semantic expression of the text, thereby mining deeper long-distance contextual emotional semantic information in network texts. The present invention makes full use of the differences between models, and studies the use of ensemble learning and voting strategies to fuse multiple models, aiming to train a stable and balanced sentiment classification model. Experimental results show that the BERT-BiGRU model has better emotion recognition effects on two public data sets (COV19 and ChnSenti) than other traditional models.

[0054] The present invention adopts the BERT pre-training model to replace the word embedding layer of the traditional model to obtain the implicit semantic word vector representation of the comment text, and then extracts the deep semantic features of the context through the bidirectional GRU to improve the model's ability to extract the emotional semantics of the comment text; through the integrated learning of data perturbation and voting strategies, a plurality of excellent and differentiated emotion recognition models are integrated to obtain a stable and balanced performance emotion classifier, which improves the generalization ability of the model; multiple groups of comparative experiments are carried out on public data sets, and the results show that the deep semantic recognition model for public safety incident analysis proposed in the present invention can effectively identify emotional tendencies and has better emotion classification effect.

[0055] Focusing on the research hotspot of emotion recognition of social network text, this paper proposes a deep emotion semantic recognition model based on BERT-BiGRU multi-modal ensemble learning. First, the model uses the BERT pre-trained model to replace the word embedding layer of the traditional model to obtain the implicit semantic word vector representation of the comment text, and then extracts the deep semantic features of the context through the bidirectional GRU, which solves the problem of weak ability to extract polysemous words and deep emotion semantics in different contexts in the traditional language model, and achieves the optimal emotion recognition effect under a single model. In order to improve the generalization ability of the model, the model applies the idea of ​​ensemble learning to emotion recognition on the basis of comprehensive analysis of the variance and deviation of the model, observes the performance of different models on different parameters and data sets, and trains the data set in a cross-validation manner. Then, the voting strategy is combined with the base classifier composed of multiple BERT pre-trained models, so that they have the ability to correct each other, thereby obtaining a better integration result. Finally, by designing experiments on three-class and two-class corpora, it is shown that the BERT-BiGRU model is superior to most existing emotion recognition models in multiple evaluation indicators. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0057] Figure 1 It is a BERT input representation diagram provided by an embodiment of the present invention.

[0058] Figure 2 This is a diagram of the GRU unit architecture provided by an embodiment of the present invention.

[0059] Figure 3 It is a structural diagram of the BERT-BiGRU model provided by an embodiment of the present invention.

[0060] Figure 4 It is a flow chart of an algorithm provided by an embodiment of the present invention.

[0061] Figure 5 It is a multi-modal fusion emotion semantic recognition model diagram under the integrated learning framework provided by an embodiment of the present invention.

[0062] Figure 6 It is a flow chart of a method for constructing a deep semantic recognition model for public safety incident analysis provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0064] Traditional word2vec or glove word vector pre-training models have model semantic deviations where the same word expresses the same semantics in different contexts, making them difficult to identify. When using traditional convolutional neural network (CNN) models for text classification tasks, the semantic relevance between long-distance contexts is ignored. Most existing models are single models. Due to the randomness of single models, they can only perform well in one aspect, but their generalization ability is insufficient.

[0065] In view of the problems existing in the prior art, the present invention provides a deep semantic recognition model for public safety event analysis and a construction method thereof. The present invention is described in detail below in conjunction with the accompanying drawings.

[0066] like Figure 6 As shown, the method for constructing a deep semantic recognition model for public security event analysis provided by an embodiment of the present invention includes the following steps:

[0067] S101, obtain the contextual semantic feature representation of the comment text through the BERT pre-training model;

[0068] S102, combined with bidirectional GRU to extract deep nonlinear feature vectors, to achieve the best effect under a single model;

[0069] S103, based on the BERT series pre-trained models, multiple sentiment classifiers are trained; the integrated learning method of data perturbation and voting strategy is used to achieve full integration of the deep features of each model.

[0070] The technical solution of the present invention is further described below in conjunction with specific embodiments.

[0071] At present, most of the commonly used classification models in the field of emotion recognition are shallow architectures, which usually require complex feature engineering, ignore the semantic relationship between words, and focus on the classification output of shallow features. The present invention proposes a deep semantic recognition model for public safety event analysis. First, the feature vector of the text comment is extracted through the BERT pre-trained language model, which can effectively capture the bidirectional context information of the sentence, dynamically adjust the word vector, and avoid the limitations of the traditional language model. Then, the text feature vector extracted by BERT is used as the input of the BiGRU network. By superimposing GRU in the forward and reverse directions, the feature information before and after is associated, so as to better explore the potential connection between each emotional feature and obtain the emotional tendency of the comment text.

[0072] In addition, due to the limited ability of a single model to learn features, it is slightly insufficient in improving accuracy and generalization ability. To address this problem, the present invention uses the idea of ​​ensemble learning to build multiple classification models to solve this problem, and balances the variance and bias of the model through data perturbation and voting, so that the performance of the integrated classification model is better.

[0073] The algorithm model flow of the deep semantic recognition model for public safety incident analysis proposed in the present invention is mainly divided into the following three steps. The first step is to preprocess the original data set to remove noise data; the second step is to build a single emotion recognition model, splicing the BERT pre-trained language model with BiGRU to obtain a text classification model, which is superior to other single models in performance; the third step, in order to enhance the versatility of the emotion recognition model, the present invention constructs an integrated emotion recognition model. Multiple emotion-based classifiers are obtained by data perturbation and based on the BERT series pre-trained model, and the classification results of step two are voted on with the results output by the integrated module, thereby improving the overall classification effect and model generalization ability.

[0074] BERT refers to the Chinese BERT pre-trained model, which uses Chinese Wikipedia data for large-scale training to obtain the final model. Compared with BERT, BERT-wwm-ext uses Chinese Wikipedia data and general (encyclopedia, news, Q&A) data, and increases the number of training steps. BERT-BiLSTM uses the BERT pre-trained model to obtain the feature vector of each text, and uses it as the input of the bidirectional LSTM to mine deeper long-distance contextual sentiment semantic information in network text.

[0075] The present invention uses the BERT series of pre-trained language models to obtain the semantic representation of the input text, which represents the maximum input length of the model. If the text length is less than n, the output text semantic representation less than n obtained by the BERT model is padded with multiple m-dimensional zero vectors until the output sequence length is n; if the text length is greater than n, only the semantic representation of the text of the first n length is output.

[0076] In this embodiment, the deep semantic recognition model for public safety incident analysis is applicable to sentence-level sentiment classification. Figure 1 It is the BERT input representation used in this invention.

[0077] The BERT model uses the Transformer encoder as the main model structure and mines the relationship between words based on the attention mechanism, so that the model can be trained in parallel while taking into account global information.

[0078] In text classification tasks, text is usually represented by word vectors. Unlike language models such as Word2Vec and Glove, the BERT model adds position vectors on the basis of using word vectors and segment vectors, and saves word order information through position embedding, thereby adding different vectors to characters or words in different positions to distinguish them:

[0079]

[0080]

[0081] Among them, pos represents the position index, d model is the word vector dimension, PE represents the position code corresponding to the pos position, which is generated by the sine sin and cosine cos functions and then added to the corresponding position word vector. The input representation is as follows Figure 1 As shown, the beginning of a sentence is marked with [CLS], and the separation and end of a sentence are marked with [SEP].

[0082] After obtaining the input representation of the sentence, BERT proposed a new training method to perform unsupervised training on massive corpus, using Masked Language Model (MLM) and Next Sentence Prediction (NSP) for joint training. MLM refers to randomly masking some words in the text with [MASK] and letting the model make predictions. Compared with the one-way prediction of traditional language models, the MLM task can predict masked words from any direction, allowing the model to learn more domain knowledge at the word level. NSP refers to randomly selecting two sentences from the corpus to concatenate and predict whether they are from the same text, and further considers the learning of sentence pair relationships. The combination of these two methods enables the model to not only identify noise data, but also understand the deep semantics of sentences more accurately.

[0083] The core of the BERT model is the encoder using the Transformer model, such as Figure 2 As shown in the figure, multi-head attention is an important part of Transformer. First, the attention mechanism uses the similarity between the target word Query and its context word Key as the weight, and integrates the Value of the upper and lower words into the Query of the target word to obtain the enhanced semantic vector representation of the target word. Secondly, in order to obtain the enhanced vector representation in different spaces, Q (Query), K (Key), and V (Value) are projected through multiple linear transformations, and finally different attention results are spliced ​​to form multi-head attention, so that the model can learn relevant information in different representation subspaces, thereby obtaining enhanced semantic vectors of words in different semantic spaces.

[0084] MultiHead(Q,K,V)=Concat(head 1 , ..., head k )W O

[0085]

[0086] On top of this, the Transformer encoder adds a residual and normalization module, which is connected to each submodule on the Encoder and Decoder sides. Residuals are usually used to solve the problem of multi-layer network training, allowing the network to focus only on the current difference. It is used to prevent network degradation and accelerate convergence. Normalization refers to Layer Normalization, which is used to normalize the activation values ​​of each layer, as shown in the above formula. α and β are training parameters, and μ and σ represent deviation and variance. Finally, after passing through the feedforward neural network, it is linearly transformed and ReLu activated to obtain the output of the encoder, as shown in the formula:

[0087]

[0088] FNN=max(0,xW 1 +b 1 )W 2 +b 2

[0089] Figure 2 This is the GRU unit architecture diagram.

[0090] like Figure 2 As shown in Figure 1, in order to further obtain the intrinsic connection between texts, the present invention uses the semantic representation obtained by the BERT model as the input of the bidirectional GRU model. In the bidirectional GRU, each GRU unit contains two gate structures, the update gate and the reset gate, which are represented by r and t , z t , in order to maintain and update the status information and transmit it, such as Figure 3 As shown in the figure. The update gate functions similarly to the forget gate and input gate of LSTM, and it determines the extent to which the state information of the previous moment is brought into the current state. The reset gate controls the extent to which the state information of the previous moment is ignored. The smaller the value of the reset gate, the more it is ignored. Compared with LSTM, GRU has fewer tensor operations, so it is faster. Therefore, the bidirectional GRU model is often used to deal with time-series problems. It can make full use of the information of the entire text sequence, including the relationship information between each word, and use this information to process each word.

[0091] Figure 3It is the BERT-BiGRU model structure.

[0092] The output of BERT is forwarded To obtain the complete context information of all past time series, and then reverse Get the complete context for all future time series, calculated as follows:

[0093]

[0094]

[0095] Among them, w is the weight connecting the two layers, b is the bias vector, and f is the activation function. and They are the positive GRU and negative GRU outputs respectively.

[0096] The bidirectional GRU represents the input d in the positive and negative hidden layers n Calculate and get d n Hidden state h t , the present invention adopts the splicing strategy for positive and negative GRU:

[0097]

[0098] Get the hidden state of the bidirectional GRU, the calculation formula is as follows:

[0099] H=(h 1 ,h i ,...,h d}

[0100] Finally, global average pooling is used to replace the fully connected layer. The global average pooling layer has no parameters and can avoid overfitting. At the same time, it can also integrate global information, and the multi-dimensional features of the output are subjected to global average pooling to obtain a one-dimensional feature vector, which is sent to the softmax function to obtain the sentiment category of the comment text. As shown in the formula:

[0101] TEXT C =softmax(W t ·H+b t )

[0102] Among them, W t represents the weight parameter of the global average pooling layer, b t Represents the bias value, and finally the output TEXT_C of the BERT-BiGRU model is obtained. The model structure is as follows Figure 3 shown.

[0103] Figure 4 It is the algorithm flow chart.

[0104] like Figure 4 As shown in the figure, BERT refers to the Chinese BERT pre-trained model, which uses Chinese Wikipedia data for large-scale training to obtain the final model. Compared with BERT, BERT-wwm-ext uses Chinese Wikipedia data and general (encyclopedia, news, Q&A) data, and increases the number of training steps. BERT-BiLSTM uses the BERT pre-trained model to obtain the feature vector of each text, and uses it as the input of the bidirectional LSTM to mine deeper long-distance contextual sentiment semantic information in network text.

[0105] Figure 5 It is a multi-modal fusion sentiment semantic recognition model under the integrated learning framework.

[0106] In order to make the models different, the present invention adopts different Chinese BERT pre-training models, which use a large amount of unlabeled text corpus and are finally trained by continuously improving hyperparameters. For example, the BERT-base model uses data from Chinese Wikipedia, and BERT-wwm-ext uses Chinese Wikipedia data and general (encyclopedia, news, question and answer) data, while increasing the number of training steps. Therefore, the present invention uses the BERT pre-training model and two methods of adding BiLSTM and BiGRU after the BERT pre-training model to obtain different emotion recognition results. In addition, after analyzing the samples, the present invention adopts different training parameters, such as learning rate, training batch, text segmentation length, etc. The method of obtaining multiple base classifiers through this parallel training can effectively reduce variance and solve the overfitting problem.

[0107] After obtaining multiple base classifiers with differences in the above manner, the present invention fuses the results of the base classifiers through a combination strategy to achieve the best prediction effect of the model after ensemble learning. First, multiple BERT, BERT-BiLSTM and BERT-BiGRU models are used as base classifiers, and the output categories of all classifiers are counted. A majority voting strategy is used to make decisions based on the generated category probability distribution of emotion recognition. Given the same weight for the classification results of all individual classifiers, each base classifier can only cast one vote, and the principle of minority obeys majority is adopted. The category with the highest number of votes will be used as the final prediction result of the comment, such as Figure 5 The voting formula is as follows:

[0108]

[0109] Among them, n and T represent the number of categories and the number of base classifiers of sentiment classification respectively, C i,j Indicates that the predicted category of base classifier i in the test set x is j, It represents the total number of votes for the test set x in all base classifiers whose predicted category results are j. The category with the most votes is taken as the final category result of the predicted sample x.

[0110] The technical solution of the present invention is further described below in conjunction with specific embodiments.

[0111] The present invention adopts two groups of comparative experiments. Experiment 1 is a comparison between the BERT-BiGRU of the present invention and traditional deep learning models, including classic TextCNN, BiGRU, BiGRU-ATT and BERT models.

[0112] (1) TextCNN: Use word2vec to encode the input text and send it to the convolutional neural network. Use multiple convolution kernels of different sizes to extract text features, and finally perform classification through the fully connected layer.

[0113] (2) BiGRU. Word2vec is used to train word vectors and then fed into the bidirectional GRU. By superimposing the GRUs in the positive and negative directions, the feature information before and after is associated, the potential connections between the various sentiment features are mined, and the sentiment tendency of the comment text is obtained.

[0114] (3) BiGRU-ATT: Based on the bidirectional GRU to extract text features, the attention mechanism is used to capture the contribution of each word in the comment text to the sentiment semantics, and weighted calculation is performed to obtain the final classification result.

[0115] (4) BERT. It uses a deep bidirectional Transformer model to extract features using the contextual information of words and dynamically adjusts word vectors based on the contextual information to obtain contextual semantic feature representations of comment texts.

[0116] (5) BERT-BiGRU. First, the implicit semantics of the text is expressed through the BERT pre-trained model. Then, the bidirectional GRU model, which is simpler in structure and faster in operation than the bidirectional LSTM model, is used to mine the deep semantic information between text comments and obtain the final sentiment recognition result.

[0117] Table 1 Experimental results of multiple models on COV19

[0118]

[0119] Table 1 shows the precision, recall and F1 value comparison results of the model of the present invention and the comparison model on the COV19 dataset. It can be seen that the F1 value of the BERT model reaches a classification accuracy of 71.7%, which is 8.3% and 5.6% higher than the 63.4% of the CNN model and 66.1% of the BiGRU model, respectively, which verifies that the BERT pre-training model is significantly better than the traditional word vector training model. Among them, the word vector model based on word2vec has low indicators, mainly affected by the polysemy of Chinese expressions. It is difficult to understand the meaning of the same word under different semantics, resulting in inaccurate feature extraction. The BERT model will dynamically change the word vector according to the meaning of the context, which can more accurately reflect the semantic information of the sentence. Similarly, the addition of multiple attentions within the BERT model is also very critical. It is the focus of the input text weight distribution, which distinguishes the contribution of each word in the text to the emotional semantics. It can be seen that the BERT model is 5.3% higher than the BiGRU-ATT model that adds a single attention mechanism to BiGRU. Under the same word2vec word vector model, the BiGRU model is 2.7% higher than the CNN model. It can be seen that the use of BiGRU is more effective than CNN in extracting text features. This is because text is naturally long-term information, and recurrent neural networks are better at capturing long-term features, while convolutional neural networks are good at learning spatial features, focusing on local features, and have weak long-distance modeling capabilities. Therefore, the classification effect of BiGRU after BERT has achieved the best classification effect, indicating that adding BiGRU to the output of BERT can extract deeper emotional features in sentences, thereby improving classification accuracy.

[0120] The results of Experiment 1 show that the model of the present invention can achieve better classification results in emotion recognition. However, the research goal of the present invention is not only to consider the optimal model effect, but also to make the model more applicable. In order to verify the universality of the integration idea in the field of emotion recognition, Experiment 2 connected the BERT pre-trained model to different networks, and used different training batches and training methods to achieve different results by taking advantage of the differences in training corpus and training steps. Finally, the voting strategy was used to achieve the integration effect, and the experiments were conducted on the datasets of two-class and three-class emotion classification. The model description is as follows:

[0121] (1) BERT. The BERT-base pre-trained model was used to extract text features and obtain the contextual semantic feature representation of the comment text. The training batches were set to 32 and 16, respectively, and the maximum text truncation lengths were 128 and 140, respectively. After three rounds of training, Model 1 (M1) and Model 2 (M2) were obtained.

[0122] (2) The pre-trained model uses BERT-wwm-ext, the training batch size is 32, the maximum text truncation length is 128, and the training results are Model 3 (M3).

[0123] (3) BERT-BiLSTM. The BERT-base pre-trained model is used to obtain the features of each text, and the bidirectional LSTM is used to mine the deeper long-distance contextual sentiment semantic information in the network text. A 5-fold cross-validation is performed, the training batch is set to 16, the maximum text truncation length is 140, and the training results are Model 4 (M4).

[0124] (4) BERT-BiLSTM. The training method is the same as (3), the batch size is set to 48, and the training results in Model 5 (M5).

[0125] (5) BERT-BiGRU. The BERT-base pre-trained model was used to obtain the features of each text. After the output of the bidirectional GRU, a 5-fold cross-validation was performed. The training batches were set to 16, 48, and 64, respectively, and the maximum text truncation length was set to 140, 140, and 128, respectively. Model 6 (M6), Model 7 (M7), and Model 8 (M8) were obtained through training.

[0126] Table 2 Experimental results of base classifier on COV19

[0127]

[0128] The experiment compares and analyzes the classification effects of each base classifier on the COV19 dataset. Different hyperparameter sets are used to train different base classifiers, and the classification effect of the model on the test set is observed to select the optimal classifier.

[0129] Table 2 shows the prediction results of each base classifier. It can be seen from the table that the same network structure, trained with different sets of hyperparameters, will produce very different classification results. For example, the gap between the BERT models reached 1.0%, while BERT-BiLSTM and BERT-BiGRU used different hyperparameters, with a difference between 0.2% and 0.4%. Compared with the traditional single partitioning of the data set, the five-fold cross-validation added in the present invention divides the training data set multiple times so that the data sets do not intersect with each other, greatly reducing the randomness caused by the random partitioning of the data set and enhancing the stability of the model. At the same time, it was found that BERT-BiLSTM and BERT-BiGRU achieved the best results among similar models in batches of 48 and a maximum text capture length of 140, respectively.

[0130] In summary, the present invention is based on two prerequisites of ensemble learning. First, the classification effect of the base classifier must achieve a certain superiority. If the classification error rate of the base classifier is too high, the accuracy of the ensemble learning will be reduced. Second, there must be differences between the base classifiers, that is, the prediction results need diversity. If the differences are too small, the ensemble results will basically remain unchanged. Therefore, it can be concluded from Table 2 that the present invention selects M2, M3, M5, and M7 as the base classifiers for ensemble learning, and uses the majority voting method to obtain the final classification results for the prediction results of the test set. The ensemble results are shown in Table 3.

[0131] Table 3 Final integrated experimental results of COV19

[0132]

[0133] The result after integration reaches 73.2%, which is 0.3% higher than the optimal single model BERT-BiGRU. In order to further verify the generalization ability of the model proposed in this invention, the above model is tested on the ChnSenti corpus. The results are shown in Table 4.

[0134] Table 4 Experimental results of ensemble learning on ChnSenti

[0135]

[0136] Table 4 shows the classification effects of the four single models and the integrated model on the hotel corpus. As can be seen from the table, BERT-BiGRU surpasses the other three models in the evaluation indicators, with improvements of 1.4%, 2.8% and 0.8% respectively. It proves that BERT-BiGRU can tap deeper semantic features than other models, and also verifies that the method proposed in the present invention of accessing the BiGRU model after BERT output representation is effective and superior. The F1 values ​​of each model are all above 0.92, indicating that the performance of each single model in the two-class classification is relatively excellent, resulting in the difference between the models is not strong enough, and the improvement of the F1 value after integration is not obvious enough. It is only 0.1% higher than the best model BERT-BiGRU. It can be seen that the correctness of the integrated learning method used in the present invention requires the integration of models with excellent performance and large differences to obtain a significant improvement effect.

[0137] Focusing on the research hotspot of emotion recognition of social network text, this paper proposes a deep emotion semantic recognition model based on BERT-BiGRU multi-modal ensemble learning. First, the model uses the BERT pre-trained model to replace the word embedding layer of the traditional model to obtain the implicit semantic word vector representation of the comment text, and then extracts the deep semantic features of the context through the bidirectional GRU, which solves the problem of weak ability to extract polysemous words and deep emotion semantics in different contexts in the traditional language model, and achieves the optimal emotion recognition effect under a single model. In order to improve the generalization ability of the model, the model applies the idea of ​​ensemble learning to emotion recognition on the basis of comprehensive analysis of the variance and deviation of the model, observes the performance of different models on different parameters and data sets, and trains the data set in a cross-validation manner. Then, the voting strategy is combined with the base classifier composed of multiple BERT pre-trained models, so that they have the ability to correct each other, thereby obtaining a better integration result. Finally, by designing experiments on three-class and two-class corpora, it is shown that the BERT-BiGRU model is superior to most existing emotion recognition models in multiple evaluation indicators.

[0138] The BERT-BiGRU model is applied in the food safety big data sentiment analysis system. The system analyzes the public opinion heat, netizens' sentiment polarity and changes in topics of concern from a multi-dimensional perspective, displays the risk knowledge map related to food safety incidents, the whole chain trajectory of food safety, and obtains the knowledge map and sampling information of the food involved in the food safety incident. The BERT-BiGRU model can accurately analyze the sentiment polarity of netizens across the country, obtain the textual tendency of each user's comment, visualize the data to see the temporal and spatial evolution trend of public opinion, and assist decision makers in public opinion analysis. Multi-dimensional statistical analysis of Internet information is carried out to calculate the public opinion indexes such as region, emotion, and hot words to provide support for public opinion analysis.

[0139] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principle of the present invention should be covered by the protection scope of the present invention.

Claims

1. A method for constructing a deep semantic recognition model for public safety event analysis, characterized in that: The method for constructing a deep semantic recognition model for public safety event analysis includes: obtaining contextual semantic feature representation of comment text through a BERT pre-training model, extracting deep nonlinear feature vectors in combination with a bidirectional GRU, and optimizing a single model; training multiple sentiment classifiers with excellent performance and differentiation based on a BERT series pre-training model; and integrating deep features of each model using an integrated learning method of data perturbation and voting strategy; The BERT model uses the Transformer encoder as the main model structure, mines the relationship between words based on the attention mechanism, is used for parallel training and considers global information; In text classification tasks, text is usually represented by word vectors. The BERT model adds position vectors based on word vectors and segment vectors, and saves word order information through position embedding, thereby adding different vectors to characters or words in different positions to distinguish them: Among them, pos represents the position index, d model is the word vector dimension, PE represents the position code corresponding to the pos position, which is generated by the sine sin and cosine cos functions and then added to the word vector of the corresponding position; the beginning of the sentence is marked with [CLS], and the separation and end of the sentence are marked with [SEP]; After obtaining the input representation of the sentence, BERT uses the masked language model MLM and the next sentence prediction NSP for joint training; MLM means randomly masking the words in the text with [MASK] and letting the model make predictions; NSP means randomly selecting two sentences from the corpus and concatenating them to predict whether they are from the same text; The core of the BERT model is the encoder of the Transformer model. Multi-head attention is an important part of the Transformer. The attention mechanism uses the similarity between the target word Query and its context word Key as the weight, and integrates the Value of the upper and lower words into the Query of the target word to obtain the enhanced semantic vector representation of the target word. Through multiple linear transformations, Q (Query), K (Key), and V (Value) are projected, and finally different attention results are spliced ​​to form multi-head attention, so that the model can learn relevant information in different representation subspaces, thereby obtaining enhanced semantic vectors of words in different semantic spaces. MultiHead(Q,K,V)=Concat(head1,...,head k )W O ; The Transformer encoder adds residual and normalization modules, which are connected to each submodule on the Encoder and Decoder ends; the residual is used to solve the problem of multi-layer network training, allowing the network to only focus on the current difference part, to prevent network degradation and accelerate convergence; standardization refers to LayerNormalization, which is used to normalize the activation values ​​of each layer; α and β are training parameters, and μ and σ represent deviation and variance; after the feedforward neural network, linear transformation and ReLu activation function are performed to obtain the output of the encoder, as shown in the formula: FNN=max(0,xW1+b1)W2+b2.

2. The method for constructing a deep semantic recognition model for public security event analysis according to claim 1, characterized in that: The method for constructing a deep semantic recognition model for public safety event analysis comprises the following steps: Step 1: preprocess the original data set to remove noise data; Step 2: Build a single emotion recognition model, concatenate the BERT pre-trained language model with BiGRU to obtain a text classification model, and use the text classification model to obtain the classification result; Step three, build an integrated emotion recognition model, obtain multiple emotion-based classifiers through data perturbation and based on the BERT series pre-training model, and vote on the classification results of step two and the results output by the integrated module.

3. The method for constructing a deep semantic recognition model for public security event analysis according to claim 1, characterized in that: The semantic representation obtained by the BERT model is used as the input of the bidirectional GRU model; in the bidirectional GRU, each GRU unit contains two gate structures, the update gate and the reset gate, which are represented by r t , z t , used to maintain and update state information and transmit it; the update gate functions like the forget gate and input gate of LSTM, determining the extent to which the state information of the previous moment is brought into the current state; the reset gate controls the extent to which the state information of the previous moment is ignored, and the smaller the value of the reset gate, the more it is ignored; the bidirectional GRU model is used to handle timing problems, using the information of the entire text sequence, including the relationship information between each word, and using the information to process each word.

4. The method for constructing a deep semantic recognition model for public security event analysis according to claim 1, characterized in that: The output of BERT is passed through the forward Get the complete context information of all past time series, and then reverse Get the complete context for all future time series, calculated as follows: Among them, w is the weight connecting the two layers, b is the bias vector, and f is the activation function. and They are positive GRU and negative GRU outputs respectively; The bidirectional GRU represents the input d in the positive and negative hidden layers n Calculate and get d n Hidden state h t , the positive and negative GRU adopts the splicing strategy: Get the hidden state of the bidirectional GRU, the calculation formula is as follows: H={h1,h1,...,h d }; Use global average pooling to replace the fully connected layer. The global average pooling layer has no parameters, integrates global information, and outputs multi-dimensional features. After global average pooling, it obtains a one-dimensional feature vector and sends it to the softmax function to obtain the sentiment category of the comment text, as shown in the formula: TEXT C =softmax(W t ·H+b t ); Among them, W t represents the weight parameter of the global average pooling layer, b t Represents the bias value, and finally the output TEXT_C of the BERT-BiGRU model is obtained.

5. The method for constructing a deep semantic recognition model for public security event analysis as claimed in claim 2, characterized in that: In the step 3, after obtaining a plurality of base classifiers with differences, the results of the base classifiers are fused through a combination strategy so that the prediction effect of the model after ensemble learning is the best; Multiple BERT, BERT-BiLSTM and BERT-BiGRU models are used as base classifiers. The output categories of all classifiers are counted, and a majority voting strategy is used to make decisions based on the category probability distribution of generated sentiment recognition. The classification results of all individual classifiers are given the same weight, and each base classifier can only cast one vote. The principle of minority obeys majority is adopted, and the category with the highest number of votes will be used as the final prediction result of the comment. The voting formula is as follows: Among them, n and T represent the number of categories and the number of base classifiers of sentiment classification, respectively, and c i,j Indicates that the predicted category of base classifier i in the test set x is j, It represents the total number of votes for the test set x in all base classifiers whose predicted category results are j. The category with the most votes is taken as the final category result of the predicted sample x.

6. A deep semantic recognition model for public security incident analysis obtained by constructing the deep semantic recognition model for public security incident analysis as described in any one of claims 1 to 5.

7. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method for constructing a deep semantic recognition model for public security event analysis as described in any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to perform the steps of a method for constructing a deep semantic recognition model for public security event analysis as described in any one of claims 1 to 5.

9. An information data processing terminal, characterized in that: The information data processing terminal is used to implement the deep semantic recognition model for public security event analysis as described in claim 6.