User generated content emotion recognition method and device, terminal and medium

By combining pre-trained language models and convolutional neural networks with multi-head attention mechanisms, the problem of low accuracy of emotion analysis on social media platforms is solved, and efficient recognition of complex emotional scenarios is achieved.

CN120492632AInactive Publication Date: 2025-08-15GUANGDONG UNIV OF TECH
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510976596.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-16
Publication Date
2025-08-15
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing emotion analysis methods are difficult to take into account both global semantic understanding and local emotion phrase capture on social media platforms, resulting in low analysis accuracy in complex emotional scenarios.

Method used

The pre-trained language model is used to extract word vector sequences of context dependence and global position information, combine with convolutional neural network to extract local semantic features, and fuse global channel dependence through a multi-head attention mechanism to form a sentence vector representation for emotional classification.

Benefits of technology

It improves the accuracy of emotion analysis in complex emotional scenarios, can more accurately identify complex emotional expressions such as irony and metaphors, and improves the emotional classification recognition performance of social media content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120492632A_ABST
    Figure CN120492632A_ABST
Patent Text Reader

Abstract

The invention discloses a user generated content emotion recognition method and device, a terminal and a medium, and relates to the technical field of computers.According to the scheme, context dependency and global position information is extracted through a pre-training language model, local semantic features are captured in combination with a convolutional neural network, and the emotion recognition efficiency is improved. And a multi-head attention mechanism is utilized to fuse a global channel dependency relationship, and context clues are associated to judge a real emotional tendency, so that the technical problem that global semantic understanding and local emotional phrase capture cannot be considered in a traditional method is effectively solved, and the method has the advantage of improving the analysis accuracy in a complex emotional scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, terminal, and medium for identifying emotions in user-generated content. Background Art

[0002] Currently, social media platforms like Weibo, Douyin, and Xiaohongshu have become core platforms for users to express their opinions and emotions, generating massive amounts of user-generated content (UGC) daily, including comments, comments, posts, and status updates. Sentiment analysis of this text (determining positive / neutral / negative sentiment) can aid in key applications such as public opinion monitoring, user profiling, and content ecosystem governance.

[0003] Traditional sentiment analysis methods typically employ feature engineering or rule-based approaches, or use a single deep learning model structure to extract features from text data for sentiment classification. However, in practical application scenarios, existing models struggle to simultaneously balance global semantic understanding with the capture of local sentiment phrases, resulting in low analysis accuracy when faced with complex emotional scenarios such as irony and metaphor. Summary of the Invention

[0004] The present application provides a method, device, terminal and medium for identifying emotions in user-generated content, which are used to solve the technical problem of low accuracy of existing emotion analysis methods.

[0005] To solve the above technical problems, the first aspect of the present application provides a method for identifying emotions in user-generated content, comprising:

[0006] Obtaining samples of user-generated content;

[0007] Based on the user-generated content sample, extracting a word vector sequence containing context dependency and global position information through a pre-trained language model;

[0008] Based on the word vector sequence, feature extraction is performed using multiple convolution kernels in a convolutional neural network model to obtain multiple local semantic feature vectors;

[0009] Pooling is performed on each local semantic feature vector, and then the obtained pooled vectors are spliced to obtain the total feature vector;

[0010] Performing global channel dependency extraction on the total feature vector through multi-head attention processing to obtain a sentence vector representation;

[0011] Classification is performed based on the sentence vector representation to obtain a sentiment classification recognition result of the user-generated content.

[0012] Preferably, the pre-trained language model is specifically: MPNET language model.

[0013] Preferably, the step of performing feature extraction based on the word vector sequence through multiple convolution kernels in a convolutional neural network model to obtain multiple local semantic feature vectors specifically includes:

[0014] Based on the word vector sequence, feature extraction is performed through multiple convolution kernels in the TextCNN model to obtain multiple local semantic feature vectors, wherein the convolution kernel includes: three two-dimensional convolution kernels with different window sizes.

[0015] Preferably, the pooling process is performed on each local semantic feature vector, and then the obtained pooled vectors are concatenated to obtain the total feature vector, which includes:

[0016] Each local semantic feature vector is subjected to maximum pooling and average pooling respectively, and then the obtained maximum pooling vectors and average pooling vectors are concatenated to obtain the total feature vector.

[0017] Preferably, extracting global channel dependencies from the total feature vector using a multi-head attention processing method to obtain a sentence vector representation includes:

[0018] According to the total feature vector, obtain the QKV feature corresponding to the total feature vector through QKV mapping;

[0019] Calculate the attention weight based on the dot product of the QKV feature and the corresponding Query and Key, and then apply each attention weight to the weighted sum of the Value to obtain a sentence vector representation. Preferably, the classification based on the sentence vector representation to obtain the sentiment classification recognition result of the user-generated content includes:

[0020] The sentence vector representation is input into the fully connected layer and then processed by the Softmax function to obtain the sentiment classification recognition result of the user-generated content.

[0021] Preferably, after obtaining the user-generated content sample, the method further includes:

[0022] Data cleaning is performed on the user-generated content sample, and then the emoticons in the user-generated content sample are converted into semantic tags using preset emoticon semantic mapping information.

[0023] A second aspect of the present application provides a device for identifying emotions in user-generated content, comprising:

[0024] A data acquisition unit, configured to acquire user-generated content samples;

[0025] A global word vector extraction unit, configured to extract a word vector sequence containing context dependency and global position information based on the user-generated content sample using a pre-trained language model;

[0026] A local semantic feature extraction unit is used to extract features based on the word vector sequence using multiple convolution kernels in a convolutional neural network model to obtain multiple local semantic feature vectors;

[0027] A local semantic processing unit is used to perform pooling processing on each local semantic feature vector and then concatenate the obtained pooled vectors to obtain a total feature vector;

[0028] a multi-head attention processing unit, configured to extract global channel dependencies from the total feature vector using a multi-head attention processing method to obtain a processed sentence vector representation;

[0029] The sentiment classification unit is used to perform classification based on the sentence vector representation to obtain a sentiment classification recognition result of the user-generated content.

[0030] A third aspect of the present application provides a user-generated content emotion recognition terminal, comprising: a memory and a processor;

[0031] The memory is used to store program code, and the program code is used to implement a method for identifying emotions in user-generated content as provided in the first aspect of the present application;

[0032] The processor is configured to read and execute the program code.

[0033] The fourth aspect of the present application provides a computer-readable storage medium, in which program code is stored. The program code is used for a processor to read and execute to implement a method for identifying emotions in user-generated content as provided in the first aspect of the present application.

[0034] It can be seen from the above technical solutions that this application has the following advantages:

[0035] The solution provided in this application extracts contextual dependencies and global position information through a pre-trained language model, combines it with a convolutional neural network to capture local semantic features, and uses a multi-head attention mechanism to fuse global channel dependencies, and associate contextual clues to judge true emotional tendencies. It effectively solves the technical problem that traditional methods cannot take into account both global semantic understanding and local emotional phrase capture, and has the advantage of improving analysis accuracy in complex emotional scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0037] Figure 1 A flowchart of an embodiment of a method for identifying emotions in user-generated content provided in this application.

[0038] Figure 2 This is an overall logical block diagram of an embodiment of a method for identifying emotions in user-generated content provided in this application.

[0039] Figure 3 This is a logical block diagram of the local semantic feature extraction part of an embodiment of a user-generated content emotion recognition method provided in this application.

[0040] Figure 4 This is a structural diagram of an embodiment of a device for identifying emotions in user-generated content provided in this application.

[0041] Figure 5 This is a structural diagram of an embodiment of a user-generated content emotion recognition terminal provided in this application. DETAILED DESCRIPTION

[0042] Existing technologies exist for user-generated content on social media platforms, which contains complex emotional expressions, such as irony, metaphor, and mixed emotions between text and images. Traditional sentiment analysis methods typically employ a single model architecture, such as convolutional neural networks that focus on local phrase features or recurrent neural networks that capture sequential dependencies. These methods struggle to simultaneously consider the global semantic coherence of the text and the relevance of local sentiment keywords, resulting in a significant decrease in classification accuracy when analyzing text containing multi-layered sentiment cues.

[0043] To address these issues, we analyzed the structural flaws of existing models and discovered that single-feature extraction approaches can easily lead to information loss. Consequently, we proposed a technical approach that combines the local feature capture capabilities of deep learning with the global correlation modeling of the attention mechanism. First, we use a pre-trained language model to establish word-level semantic representations. Then, we use multi-scale convolution operations to capture contextual relationships at different scales. Finally, we leverage the attention mechanism to dynamically integrate dependencies between features, forming a text representation that balances both local and global considerations.

[0044] In view of this, the embodiments of the present application provide a method, device, terminal and medium for identifying emotions in user-generated content, which are used to solve the technical problem of low accuracy of existing emotion analysis methods.

[0045] In order to make the purpose, features, and advantages of the invention of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the embodiments described below are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0046] See also Figure 1 , an embodiment of the present application provides a method for identifying emotions in user-generated content, comprising:

[0047] Step 101: Obtain user-generated content samples;

[0048] Step 102: Based on the user-generated content sample, a word vector sequence containing context dependency and global position information is extracted using a pre-trained language model;

[0049] Step 103: Based on the word vector sequence, feature extraction is performed using multiple convolution kernels in a convolutional neural network model to obtain multiple local semantic feature vectors;

[0050] Step 104: pooling the local semantic feature vectors, and then concatenating the obtained pooled vectors to obtain a total feature vector;

[0051] Step 105: extract global channel dependencies from the total feature vector using a multi-head attention process to obtain a sentence vector representation;

[0052] Step 106: Classify based on the sentence vector representation to obtain a sentiment classification recognition result of the user-generated content.

[0053] It should be noted that the solution of the embodiment of the present application proposes that after obtaining user-generated content samples, a word vector sequence containing contextual dependency and global position information is extracted through a pre-trained language model, and local semantic feature vectors are extracted using multiple convolution kernels in a convolutional neural network. After pooling and splicing the feature vectors, a multi-head attention mechanism is used to extract global channel dependencies to form a sentence vector representation. Based on the three-layer architecture of global semantic encoding + local feature extraction + cross-layer attention mechanism feature fusion, the technical solution for sentiment classification is finally completed, thereby improving the analysis performance of complex emotional scenes in social media scenarios and meeting the dual requirements of accuracy and real-time performance in practical applications.

[0054] Among them, the pre-trained language model mentioned in this embodiment refers to a neural network model with context understanding capabilities obtained through large-scale corpus training. Specifically, it can be implemented using the MPNET model, and its bidirectional attention mechanism can effectively capture long-distance dependencies between words. The multiple convolution kernels in the convolutional neural network model refer to filter groups with different receptive fields. Specifically, multiple two-dimensional convolution kernels of different widths can be used to extract the association patterns of word combinations at different distances. Pooling processing refers to the dimensionality reduction operation on the feature map. Specifically, a combination of maximum pooling and average pooling can be used to enhance feature robustness while retaining significant features. The multi-head attention processing method refers to mapping the feature vector to multiple subspaces for parallel attention calculation, which is specifically implemented through QKV mapping and can capture semantic association patterns of different dimensions. Specifically, user-generated content is input into the pre-trained language model after data cleaning to generate a word vector sequence containing context position encoding. This sequence is input into the convolution layer configured with multi-scale convolution kernels to extract local semantic features of different scales. The feature map output by each convolution kernel is spliced along the feature dimension to form a fused feature vector after maximum pooling and average pooling. The vector passes through a multi-head attention layer, generates multiple attention subspaces through multiple learnable projection matrices, calculates the attention weights of each subspace and performs weighted fusion, and finally generates a sentence vector containing multi-level semantic information for classification decision-making.

[0055] Compared with existing technologies, traditional methods typically use convolutional networks or attention mechanisms alone, making it difficult to balance local feature capture and global relationship modeling. For example, while the TextCNN model can effectively extract n-gram features, it lacks the ability to model long-range semantic associations; models that rely solely on attention mechanisms may overlook the recognition of key local phrases. This solution uses a cascade design of multi-scale convolution and attention mechanisms to preserve local semantic patterns in the feature extraction stage and establish global associations in the feature integration stage, forming a complementary feature representation mechanism. Through this technical solution, user-generated content containing complex emotional expressions can be accurately identified. When analyzing comments with an ironic tone, the convolutional layer effectively captures the combination pattern of negative words and emotional words, while the attention mechanism associates contextual clues to determine the true emotional tendency. This multi-level feature fusion mechanism improves the semantic understanding ability of the sentiment classification model in complex scenarios.

[0056] More specifically, the present application also proposes that after obtaining the user-generated content sample, the user-generated content sample is cleaned, and then the emoticons in the user-generated content sample are converted into semantic labels through preset emoticon semantic mapping information.

[0057] Data cleaning involves filtering out noise and standardizing the format of raw text. This can be done by using regular expression matching to remove special characters, redundant spaces, and invalid links. For example, filtering rules can be set to remove HTML tags irrelevant to semantic analysis. This step eliminates data interference and improves the purity of subsequent model input. Emoji semantic mapping information involves converting non-text symbols into a set of labels that can identify emotional tendencies. Specifically, a pre-built mapping table can be used to establish the correspondence between symbols and emotional labels.

[0058] Specifically, the collected raw text often contains special symbols, forwarding structures, emoticons, web links, and so on. To adapt to the model input format, the text needs to be standardized. This includes: removing components without actual semantic information, such as @, #, URLs, and punctuation marks; and converting them into semantic tags using the Weibo emoticon mapping table (containing more than 200 commonly used emoticons). Using Chinese word segmentation tools (such as Jieba and THULAC), the text is segmented, retaining words with actual emotional connotations. After tokenizing each Weibo text, it is padded or truncated to a fixed length (such as 64 tokens) to meet the input requirements of the Transformer structure. The processed samples are then fed into the embedding layer of the pre-trained language model to generate a word vector matrix.

[0059] On the basis of the above basic embodiments, the present application further proposes that the pre-trained language model is specifically the MPNET language model.

[0060] The MPNET language model is a pre-trained model based on the joint optimization of masked language modeling and permutation language modeling. It is implemented using a bidirectional encoder structure based on the Transformer architecture. By integrating sentence-level positional encoding with a dynamic masking strategy, this model can simultaneously capture global positional associations and deep semantic dependencies in text sequences. Permutation language modeling randomly shuffles the order of the input sequence and predicts the original permutation, enabling the model to learn more robust contextual representation capabilities.

[0061] Specifically, when processing user-generated content samples, the MPNET language model first divides the text into a sequence of word units and adds special tags. After the word units are mapped to initial vectors through the embedding layer, they are passed through a multi-layer Transformer encoder for bidirectional context modeling. When each layer of the encoder performs self-attention calculations, a dynamic masking mechanism is used to randomly mask the input sequence, forcing the model to reconstruct the masked part based on global position information. The resulting word vector sequence not only contains the local associations between adjacent words, but also retains sentence-level structural features through position encoding. The MPNET language model enhances the model's adaptability to long-distance dependencies and position deviations by jointly optimizing mask prediction and permutation reconstruction tasks. For example, when processing complex emotional expressions containing inverted sentences or spanning multiple sentences, the model can more accurately parse the association path between semantic focus and emotional tendency.

[0062] For example, suppose the input text sequence is:

[0063] , where V is the vocabulary and n is the length of the text;

[0064] Use the pre-trained MPNet model to input text Encoded as context-dependent word vector representation:

[0065] ,in For words The encoding vector under the context condition has dimension d;

[0066] The training objective function of MPNet is as follows:

[0067]

[0068] Where z is a random permutation of the word index, c is the non-prediction interval boundary, Refers to the mask information of the masked prediction bit.

[0069] This output vector retains contextual dependency information and serves as the input for the subsequent convolutional neural network model. MPNet uses the Masked and Permuted Language Modeling (MPLM) mechanism to perform global semantic modeling on the input sequence. Compared to traditional BERT or XLNet, it maintains better compatibility between mask structure and sequential perception.

[0070] At the same time, further, regarding step 103 mentioned in the above embodiment, this step can be specifically refined as follows: based on the word vector sequence, feature extraction is performed through multiple convolution kernels in the TextCNN model to obtain multiple local semantic feature vectors, wherein the convolution kernel includes three two-dimensional convolution kernels with different window sizes.

[0071] The TextCNN model is a convolutional neural network specifically designed for text classification tasks. It is implemented using a structure consisting of multiple parallel convolutional layers, which extract local semantic features of varying granularity from text using convolutional kernels of different sizes. Three different-sized two-dimensional convolutional kernels have different window lengths, for example, covering three, four, or five adjacent words, respectively. These window lengths capture semantic association patterns across short, medium, and long spans.

[0072] Specifically, if Figure 2 and Figure 3 As shown in the figure, when the word vector sequence output by the MPNET language model is input into the TextCNN model, three two-dimensional convolutional kernels of different sizes are slidingly computed along the sequence dimension. Each convolutional kernel performs a dot product operation with a local region of the input sequence using a weight matrix to generate a corresponding feature map. For example, a convolutional kernel with a window length of 3 can capture the characteristics of three-word phrases such as "very good," while a convolutional kernel with a window length of 5 can identify long-range transition relationships such as "although the price is expensive, the quality is good." The feature maps output by each convolutional kernel are processed by a nonlinear activation function to form a set of local feature vectors containing semantic information of different granularities. This multi-scale feature extraction mechanism enables the model to capture precise short-range sentiment word combinations while also perceiving long-range semantic transition relationships.

[0073] For example, the word vector sequence output by MPNet is fed into the TextCNN module, where one-dimensional convolution operations are performed using 3×d, 4×d, and 5×d kernels to extract local semantic features of different n-gram windows. The output of each convolution kernel undergoes maximum pooling and average pooling to preserve the significance and global trends of each feature map.

[0074] The MPNet output H is regarded as a two-dimensional feature map, and a one-dimensional convolution operation with different convolution window sizes k∈{3,4,5} is performed:

[0075]

[0076] in: is the convolution kernel parameter; , m is the number of output channels for each window; Represents the local area formed by the concatenation of word vectors from i to i+k-1.

[0077] This solution achieves comprehensive coverage of semantic features of different spans in the text by deploying multi-sized convolution kernels in parallel. For example, when analyzing the ironic sentence "This service is so efficient that it is unforgettable," a smaller window can accurately identify the positive lexical features of "efficient," while a larger window can capture the semantic reversal relationship between "unforgettable" and the context. This technical solution can effectively solve the problem of traditional models' inadequate capture of multi-scale semantic features in complex emotional expressions. The collaborative work of multi-sized convolution kernels not only retains the precise local features of sentiment words, but also enhances the model's perception of long-range semantic associations, thereby improving the accuracy of analysis of complex emotional scenes such as irony and transitions.

[0078] Furthermore, regarding step 104 mentioned in the above embodiment, this step can be specifically refined as follows: performing maximum pooling and average pooling processing on each local semantic feature vector respectively, and then splicing the obtained maximum pooling vectors and average pooling vectors to obtain the total feature vector.

[0079] Among them, maximum pooling refers to extracting the maximum value of each feature channel from the local semantic feature vector. Specifically, it can be achieved by traversing the feature dimensions with a sliding window and selecting the maximum value. Its function is to capture the most significant emotional features in the local semantics. Average pooling refers to calculating the average value of each feature channel in the local semantic feature vector. Specifically, it can be achieved by performing a sliding average operation on the feature dimensions. Its function is to preserve the overall distribution characteristics of the local semantics. Splicing processing refers to connecting the vectors output by different pooling methods in dimensional order. Specifically, it can be achieved by tensor splicing operations. Its function is to fuse semantic information of different granularities to enhance feature expression capabilities.

[0080] Specifically, after the convolutional neural network extracts multiple local semantic feature vectors, each feature vector is fed into a maximum pooling layer and an average pooling layer in parallel. For example, for a local semantic vector containing 256-dimensional features, the maximum pooling layer outputs a 256-dimensional maximum value vector, and the average pooling layer outputs a 256-dimensional average value vector. The two pooling results are then concatenated along the feature dimension to form a 512-dimensional vector. This results in a total feature vector that incorporates both the salient and statistical features of the local semantics, enabling the subsequent attention mechanism to more comprehensively capture semantic associations at different levels.

[0081] For example, based on the local semantic features obtained in step 103, the feature map output by each convolution is The global feature representation is obtained by maximum pooling and average pooling operations respectively:

[0082]

[0083] Then, concatenate all pooled vectors to get the total feature vector :

[0084]

[0085] By fusing the results of two pooling methods, this solution preserves the prominence of sentimental keywords while also taking into account the overall trend of contextual semantics, effectively avoiding the information loss caused by single pooling. This technical solution improves the model's ability to represent complex emotional expressions. For example, when processing sentences containing irony, maximum pooling can capture keywords with strong sentiment, while average pooling mitigates interference from ambiguous words by leveraging the overall semantic distribution. The combination of these two methods enables the model to more accurately identify true sentiment.

[0086] Furthermore, regarding step 105 mentioned in the above embodiment, this step can be specifically refined as follows: extracting global channel dependencies from the total feature vector through a multi-head attention processing method to obtain a sentence vector representation, including: obtaining the QKV features corresponding to the total feature vector through QKV mapping based on the total feature vector; calculating the attention weight based on the dot product of the QKV features with the corresponding query and key, combined with the attention weight calculation formula, and then splicing the outputs of each attention head to obtain the final sentence vector representation. Among them, QKV mapping refers to the process of projecting the input feature vector into a query vector, a key vector, and a value vector respectively. Specifically, it can be implemented using a linear transformation layer, and the total feature vector is decomposed into subspace features of different dimensions through a parameter matrix. The attention weight calculation formula refers to calculating the similarity between the query vector and the key vector through a scaled dot product method. Specifically, the Softmax function can be used to normalize the similarity score so that the model can focus on key semantic information. Splicing processing refers to connecting the vectors output by multiple attention heads along the feature dimension. Specifically, it can be implemented using a tensor splicing operation to retain the diverse semantic features captured by different attention heads.

[0087] Specifically, the total feature vector undergoes a linear transformation to generate multiple independent QKV feature groups, with attention weights calculated for each feature group. Each attention head calculates the similarity between the query vector and the key vector via a scaled dot product, and then performs a weighted summation with the value vector to obtain a local attention feature. The output vectors of multiple attention heads are concatenated into a sentence vector representation, allowing different attention heads to focus on semantic associations at different locations in the text, for example, capturing long-range dependencies between sentiment keywords and modifiers.

[0088] For example, the pooled features are concatenated and then fed into the multi-head attention module. This module models the interaction between features in different regions by computing multiple Query-Key-Value mappings in parallel, strengthening the interaction between important information in the sentence, thereby enhancing the feature expression capability. More specifically, the multi-head attention mechanism is used to enhance The interactions and dependencies between channels in the ,specific expressions are as follows:

[0089]

[0090]

[0091]

[0092] Among them, Q (Query), K (Key), V (Value); Q represents the query vector, which is used to inquire about the relationship between other words and it; K is the key vector, which is used to match the query; V is the value vector, which represents the actual content of other positions; In the self-attention mechanism provided in this embodiment, the three core vectors Q, K, and V vectors all come from the same input source. , generated by different linear transformations and used for self-attention calculation to capture the dependencies within the features. is a learnable parameter for training. Z represents the feature vector extracted by the multi-head attention mechanism of TextCNN. Sentence vector representation obtained after global channel dependency modeling.

[0093] This method uses multi-head attention to process features from different subspaces in parallel, effectively identifying emotional cues and implicit associations across sentences. For example, in ironic scenarios, multiple attention heads are used to capture the contradictory relationship between literal descriptions and context, thereby improving the ability to parse complex emotional patterns. This technical solution overcomes the problem of traditional models' inability to capture discrete semantic features, enabling the emotion recognition system to simultaneously focus on semantic information at multiple key locations in the text. For example, in mixed text and image content, the multi-head attention mechanism can link text descriptions with implicit visual emotional cues, thereby improving the recognition accuracy of multi-dimensional emotional expressions.

[0094] Furthermore, regarding step 106 mentioned in the above embodiment, this step can be specifically refined as follows: inputting the sentence vector representation into the fully connected layer, and then processing it through the Softmax function to obtain the sentiment classification recognition result of the user-generated content.

[0095] Among them, the fully connected layer refers to a neural network layer with a multi-layer perception structure, which can be implemented by combining linear transformation with activation function. Its function is to map the high-dimensional sentence vector to a low-dimensional space that matches the number of emotion categories, thereby extracting the discriminative features required for classification; the Softmax function refers to a normalized exponential function, which can be implemented by a multi-classification probability conversion formula. Its function is to convert the numerical value output by the fully connected layer into a probability distribution, so that the prediction results of each emotion category are interpretable and comparable.

[0096] Specifically, after the sentence vector representation undergoes a linear transformation through the fully connected layer, the weight matrix weights and combines the semantic features of different dimensions to form a preliminary classification feature vector. The classification feature vector is then normalized using the Softmax function to calculate the probability value corresponding to each sentiment category. The category with the highest probability value is determined as the final sentiment classification result, such as positive, neutral, or negative. During this process, the fully connected layer learns the contribution of different semantic features to sentiment classification by adjusting the weight parameters, while the Softmax function ensures the stability and rationality of the probability output.

[0097] For example, the sentence vector 𝑍 after attention enhancement is input into the classifier for three classifications. The classifier is a fully connected layer with an output dimension of 3, representing the logits of the three categories of emotions. Then the Softmax function is used to normalize the logits into a probability distribution, as follows:

[0098]

[0099] The cross-entropy loss function is used for model training; the output result is a sentiment probability vector. Targeting high-noise scenarios on Weibo, confidence calibration is performed and a dynamic classification threshold is set. When the predicted probability difference is less than 0.15 (e.g., 0.45 for positive and 0.40 for negative), it is judged as neutral, reducing misjudgments caused by noise.

[0100]

[0101] Among them, c is the number of emotion categories, The weight matrix of the classifier, Bias vector for the classifier.

[0102] This solution, by combining fully connected layers with the Softmax function, can more fully exploit the latent classification information in sentence embeddings while enhancing the model's ability to distinguish ambiguous semantics through probability distribution. This technical solution addresses the low classification accuracy of traditional models in complex emotional scenarios. This is particularly true when dealing with complex emotions such as irony and metaphor. This solution can more accurately identify the emotional tendencies of user-generated content based on probability distribution, improving the reliability and robustness of sentiment classification.

[0103] Table 1 below shows the statistical data of the sentiment analysis model classification report based on the Weibo comment test set (1,770 samples):

[0104]

[0105] The statistical data demonstrates that the model exhibits excellent overall performance: an overall accuracy of 91.75% and a weighted F1 score of 92.08%. The model's performance is most balanced for positive samples (i.e., positive reviews) (F1 score of 93.03%), while negative samples (i.e., negative comments) exhibit a small number of misclassifications (accuracy of 90.28%). Neutral samples are the most reliable in predicting neutral content (accuracy of 94.74%). The macro-average and weighted metrics are highly consistent, demonstrating that the model exhibits no sample bias and is suitable for deployment in the high-noise environments of social media.

[0106] The above is a detailed description of an embodiment of a method for identifying emotions in user-generated content provided by this application. The following is a detailed description of an embodiment of a device for identifying emotions in user-generated content provided by this application.

[0107] See also Figure 4 , an embodiment of the present application provides a device for identifying emotions in user-generated content, comprising:

[0108] A data acquisition unit 201 is used to acquire user-generated content samples;

[0109] A global word vector extraction unit 202 is configured to extract a word vector sequence containing context dependency and global position information based on a user-generated content sample using a pre-trained language model;

[0110] A local semantic feature extraction unit 203 is configured to extract features based on the word vector sequence using multiple convolution kernels in a convolutional neural network model to obtain multiple local semantic feature vectors;

[0111] The local semantic processing unit 204 is used to perform pooling processing on each local semantic feature vector and then concatenate the obtained pooled vectors to obtain a total feature vector;

[0112] A multi-head attention processing unit 205 is used to extract global channel dependencies from the total feature vector using a multi-head attention processing method to obtain a processed sentence vector representation;

[0113] The sentiment classification unit 206 is used to perform classification based on the sentence vector representation to obtain a sentiment classification recognition result of the user-generated content.

[0114] In addition, the present application also provides a detailed description of an embodiment of a user-generated content emotion recognition terminal and a computer-readable storage medium, which are as follows:

[0115] like Figure 5As shown, the present application provides an embodiment of a user-generated content emotion recognition terminal, the implementation types of which include but are not limited to: personal computers, industrial computers, servers, and embedded electronic devices, and the main components of the terminal include: a memory 33 and a processor 31, and the memory 33 and the processor 31 can be connected via a communication bus 34;

[0116] The memory 33 is used to store program codes, which are used to implement a method for identifying emotions in user-generated content as provided in the first aspect of the present application;

[0117] The processor 31 is used to read and execute program codes.

[0118] Memory 33 is a hardware module used to store program code and model parameters. It can be implemented as a hard disk, solid-state drive, or flash memory chip. Its function is to store the algorithm logic and pre-trained model parameters required for the emotion recognition method. Processor 31 is an arithmetic unit that executes program code to run the emotion recognition method. It can be implemented as a central processing unit or graphics processing unit. Its function is to accelerate the text feature extraction and classification inference process through parallel computing.

[0119] Specifically, when the terminal is running, the program code stored in the memory is loaded by the processor and the following steps are executed in sequence: first, user-generated content samples in the social media platform are obtained, such as Weibo comments or short video comments; then, the text is converted into a word vector sequence containing contextual semantics through a pre-trained language model; then, multiple two-dimensional convolution kernels of different sizes are used to extract local semantic features from the word vector, and multi-granularity information is fused through pooling operations; further, the multi-head attention mechanism is used to capture global channel dependencies and generate sentence vector representations; finally, the sentiment classification results are output through the fully connected layer and the Softmax function.

[0120] In some embodiments, the memory capacity can be set to 512GB to accommodate large-scale pre-trained model parameters, and the number of computing cores of the processor can be configured to 8 to support parallel processing of multiple user-generated content samples. In addition, the program code can be stored in the memory in an encrypted manner to prevent unauthorized access or tampering.

[0121] The present application provides an embodiment of a computer-readable storage medium, in which program code is stored. The program code is used for a processor to read and execute to implement a method for identifying emotions in user-generated content as provided in the first aspect of the present application.

[0122] A computer-readable storage medium refers to a physical medium capable of persistently storing program code. Specifically, this can be implemented as a solid-state drive, USB flash drive, or optical disk. Its purpose is to ensure stable storage and rapid access to program code. Program code refers to a set of instructions executable by a processor. Specifically, it can be written in Python or C++. It contains the logical steps of the emotion recognition method and is used to drive the hardware device to complete data processing. A processor refers to the computing unit that executes program code. Specifically, it can be implemented as a multi-core CPU or GPU chip. Its purpose is to parse code instructions and control the flow of data between modules.

[0123] Specifically, after the program code is read by the processor, the following steps are performed: First, user-generated content is cleaned and semantically converted into emojis to eliminate noise interference; a pre-trained language model is then used to extract word vector sequences to capture contextual dependencies; multi-sized convolution kernels are then used to extract local semantic features, which are then integrated into a total feature vector through pooling and concatenation operations; a multi-head attention mechanism is further used to explore global dependencies between channels to generate sentence vector representations; and finally, a classifier is used to output the sentiment tendency judgment result. This solution enhances the model's ability to handle complex emotional expressions through multi-stage feature fusion and attention weighting mechanisms.

[0124] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the terminals, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0125] In the several embodiments provided in this application, it should be understood that the disclosed terminals, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.

[0126] The terms "first," "second," "third," "fourth," and the like (if any) in the specification of the present application and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present application described herein, for example, can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product, or apparatus.

[0127] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0128] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0129] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0130] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0131] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for identifying emotion in user-generated content, characterized in that: include: Obtaining samples of user-generated content; Based on the user-generated content sample, extracting a word vector sequence containing context dependency and global position information through a pre-trained language model; Based on the word vector sequence, feature extraction is performed using multiple convolution kernels in a convolutional neural network model to obtain multiple local semantic feature vectors; Pooling is performed on each local semantic feature vector, and then the obtained pooled vectors are spliced to obtain the total feature vector; Performing global channel dependency extraction on the total feature vector through multi-head attention processing to obtain a sentence vector representation; Classification is performed based on the sentence vector representation to obtain a sentiment classification recognition result of the user-generated content.

2. The method for identifying emotion in user-generated content according to claim 1, wherein: The pre-trained language model is specifically: MPNET language model.

3. The method for identifying emotion in user-generated content according to claim 2, wherein: The method of extracting features based on the word vector sequence using multiple convolution kernels in a convolutional neural network model to obtain multiple local semantic feature vectors specifically includes: Based on the word vector sequence, feature extraction is performed through multiple convolution kernels in the TextCNN model to obtain multiple local semantic feature vectors, wherein the convolution kernels include: three two-dimensional convolution kernels with different window sizes.

4. The method for identifying emotion in user-generated content according to claim 1, wherein: The pooling process is performed on each local semantic feature vector, and then the obtained pooled vectors are spliced to obtain the total feature vector, which includes: Each local semantic feature vector is subjected to maximum pooling and average pooling respectively, and then the obtained maximum pooling vectors and average pooling vectors are concatenated to obtain the total feature vector.

5. The method for identifying emotion in user-generated content according to claim 1, wherein: The global channel dependency extraction of the total feature vector by multi-head attention processing to obtain a sentence vector representation includes: According to the total feature vector, obtain the QKV feature corresponding to the total feature vector through QKV mapping; The attention weight is calculated based on the dot product of the QKV feature and the corresponding Query and Key, and then each attention weight is applied to the weighted sum of the Value to obtain the sentence vector representation.

6. The method for identifying emotion in user-generated content according to claim 1, wherein: The classifying based on the sentence vector representation to obtain the sentiment classification recognition result of the user-generated content includes: The sentence vector representation is input into the fully connected layer and then processed by the Softmax function to obtain the sentiment classification recognition result of the user-generated content.

7. The method for identifying emotion in user-generated content according to claim 1, wherein: Obtaining a sample of user-generated content also includes: Data cleaning is performed on the user-generated content sample, and then the emoticons in the user-generated content sample are converted into semantic tags using preset emoticon semantic mapping information.

8. A device for identifying emotions in user-generated content, characterized in that: include: A data acquisition unit, configured to acquire user-generated content samples; A global word vector extraction unit, configured to extract a word vector sequence containing context dependency and global position information based on the user-generated content sample using a pre-trained language model; A local semantic feature extraction unit is used to extract features based on the word vector sequence using multiple convolution kernels in a convolutional neural network model to obtain multiple local semantic feature vectors; A local semantic processing unit is used to perform pooling processing on each local semantic feature vector and then concatenate the obtained pooled vectors to obtain a total feature vector; a multi-head attention processing unit, configured to extract global channel dependencies from the total feature vector using a multi-head attention processing method to obtain a processed sentence vector representation; The sentiment classification unit is used to perform classification based on the sentence vector representation to obtain a sentiment classification recognition result of the user-generated content.

9. A user-generated content emotion recognition terminal, characterized in that: include: memory and processor; The memory is used to store program code, and the program code is used to implement the method for identifying emotions in user-generated content according to any one of claims 1 to 7; The processor is configured to read and execute the program code.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores program code, which is used for the processor to read and execute to implement the user-generated content emotion recognition method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Emotion recognition method and device, electronic equipment and storage medium

    CN112699679A

  • Text semantic recognition method and device, equipment and storage medium

    CN113326354A

  • Emotion analysis method and device based on domain information, equipment and storage medium

    CN113672731A

  • Multi-source cross-domain emotion classification method based on MPNet, Bi-LSTM and width learning

    CN114647724A

  • Small sample malicious website detection method based on CNN, Transform and transfer learning

    CN117408311A