Semantic sentiment analysis method and device and electronic equipment
By using corpus preprocessing, emotional feature extraction model and multi-task prompt learning interaction framework in semantic sentiment analysis, the problem of lack of context and sentiment analysis of text in the existing technology is solved, and the accuracy of semantic sentiment analysis is improved. , especially effective when dealing with complex emotions and sarcastic emotions.
Patent Information
- Application Number
- CN202311444816.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-01
- Publication Date
- 2024-10-18
AI Technical Summary
Existing semantic sentiment analysis methods lack analysis of context and emotion in text, resulting in low accuracy of recognition results, especially when dealing with mixed emotion modes and sarcastic emotions.
Using corpus preprocessing, emotional feature extraction model, prompt encoder and multi-task prompt learning interaction framework, the emotional features of sentences are extracted through preset tags, the correlation and correlation between sentences are established, and the mask language model is input for semantic analysis Sentiment analysis.
It improves the accuracy of semantic sentiment analysis, can more effectively analyze the context and emotion of text, and improves the accuracy of recognition results, especially when dealing with complex emotions and sarcastic emotions.
Smart Images

Figure CN118797397A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of dialogue sentiment classification, and in particular to a semantic sentiment analysis method, device and electronic equipment. Background Art
[0002] With the development of the Internet and the popularity of real-time communication platforms, a variety of opportunities for people to exchange opinions and attitudes have been provided, leading to closer interpersonal communication. More and more people use social media to meet their business, entertainment and other needs, becoming producers, consumers and disseminators of data. A huge amount of conversation information is recorded on the Internet every day. This information often comes from the real feelings of users and carries the users' specific views and emotions. These conversations often contain multiple emotional patterns, such as emotions, moods and sarcasm, which are often expressed in a mixed way. The interaction between different emotional patterns and the correlation between different emotional types bring opportunities and challenges to multimodal emotion detection, especially in conversational contexts. Semantic sentiment analysis aims to detect the emotional patterns conveyed during the conversation process and study the impact of the commonality and uniqueness between different patterns on the final classification results.
[0003] At present, the methods for semantic sentiment analysis in text usually adopt language models with fixed architectures. For example, text or audio with semantic sentiment is input into the language model, and the fixed understanding of the text is recognized, analyzed and judged during model training. The recognized results can only simply analyze the meaning, ignoring the correlation and interaction between different sentences, and also do not make specific analysis of emotions, such as sarcasm and irony. As a result, the accuracy of semantic recognition results is low. Summary of the invention
[0004] In view of this, the present application provides a semantic sentiment analysis method, device and electronic device, the main purpose of which is to improve the current semantic sentiment analysis that lacks analysis of the context and emotion of the text, resulting in low accuracy of semantic recognition results.
[0005] In a first aspect, the present application provides a semantic sentiment analysis method, comprising:
[0006] Acquire a preprocessed corpus; the target sentence in the corpus is marked with a preset tag;
[0007] By using the sentiment feature extraction model, feature extraction is performed on the corpus with preset tags to obtain the sentiment feature of each sentence;
[0008] Processing the emotional features using a prompt encoder to obtain a task prompt code;
[0009] Using the task prompt encoding as the input of a multi-task prompt learning interaction framework to obtain an emotional prompt result;
[0010] The emotional prompt result is input into the masked language model to obtain the semantic sentiment analysis result.
[0011] Optionally, obtaining the preprocessed corpus includes: checking the text integrity of the corpus; performing sentiment analysis on sentences in the corpus, and marking corresponding preset tags according to the sentiment analysis results; and randomly selecting from the corpus according to a preset ratio to obtain the preprocessed corpus.
[0012] Optionally, the emotional feature extraction model is used to extract features from the corpus with preset tags to obtain the emotional features of each sentence, including: the emotional feature extraction model is used to extract features from the corpus based on preset tasks to obtain the emotional features of each sentence; wherein the preset tasks include sentiment analysis, emotion recognition and sarcasm detection.
[0013] Optionally, the task prompt code includes a single-task prompt code; the emotional feature is processed by a prompt encoder to obtain a single-task prompt code, including: based on a single preset task, globally marking the text containing the emotional feature, and screening out the emotional feature corresponding to the single preset task; the emotional feature corresponding to the single preset task is input into the prompt encoder to obtain the single-task prompt code corresponding to the single preset task.
[0014] Optionally, the task prompt encoding includes multi-task shared prompt encoding; the emotional features are processed by the prompt encoder to obtain the multi-task shared prompt encoding, including: based on multiple preset tasks, globally marking the text containing the emotional features, and screening out the emotional features corresponding to the multiple preset tasks; the emotional features corresponding to the multiple preset tasks are input into the prompt encoder to obtain the multi-task shared prompt encoding.
[0015] Optionally, the multi-task prompt learning interaction framework includes a gate control network and a multi-mask prompt template set based on the preset task; the task prompt code is used as the input of the multi-task prompt learning interaction framework to obtain an emotional prompt result, including: inputting the task prompt code into the gate control network to obtain a weight matrix based on different preset tasks; using the multi-mask prompt template to map the weight matrix to determine the emotional prompt result.
[0016] Optionally, the task prompt code is input into the gate control network to obtain a weight matrix based on different preset tasks, including: using the gate control network to establish the correlation between the single-task prompt code and the multi-task shared prompt code according to the preset task, and obtaining weight scores corresponding to different preset tasks; performing weighted combination of the weight scores to obtain the weight matrix.
[0017] In a second aspect, the present application provides a semantic sentiment analysis device, comprising:
[0018] An acquisition unit is configured to acquire a preprocessed corpus, wherein the target sentence in the corpus is marked with a preset mark;
[0019] An extraction unit is configured to extract features from the corpus with preset tags through a sentiment feature extraction model to obtain sentiment features of each sentence;
[0020] A processing unit, configured to process the emotional feature using a prompt encoder to obtain a task prompt code;
[0021] An analysis unit is configured to use the task prompt encoding as an input of a multi-task prompt learning interaction framework to obtain an emotional prompt result;
[0022] The result recognition unit is configured to input the emotion prompt result into a mask language model to obtain a semantic emotion analysis result.
[0023] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the semantic sentiment analysis method described in the first aspect.
[0024] In a fourth aspect, the present application provides an electronic device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the semantic sentiment analysis method described in the first aspect when executing the computer program.
[0025] By means of the above technical scheme, the present application provides a semantic sentiment analysis method, device and electronic device. The present application first obtains a corpus with preset marks in the preprocessed sentences, and extracts features from the corpus with preset marks to obtain the sentiment features of each sentence. The sentiment features are used to characterize the sentiment, emotion or irony expressed by the current sentence. Then, the sentiment features are processed by the prompt encoder to obtain the task prompt code and input it into the multi-task prompt learning interaction framework, with the purpose of establishing the correlation and relevance between the emotion of a single sentence and the emotion of multiple sentences, and the emotional prompt result obtained at the same time, which can be used to indicate the emotional association between the previous and next sentences. Finally, the emotional prompt result is input into the masked language model to obtain the semantic sentiment analysis result. Compared with the conventional recognition result output only by the semantic model, the present application uses the task prompt code with preset mark conversion to represent the sentiment features of each sentence, and establishes the interactivity and relevance between different sentiment features through the multi-task prompt learning interaction framework, which effectively improves the accuracy of the semantic sentiment analysis results, and improves the current semantic sentiment analysis lacks the analysis of the text before and after relevance and emotion, resulting in the problem of low accuracy of semantic recognition results.
[0026] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0029] Figure 1 A flowchart of a semantic sentiment analysis method provided by an embodiment of the present application is shown;
[0030] Figure 2 A schematic diagram of another semantic sentiment analysis method provided in an embodiment of the present application is shown;
[0031] Figure 3 A structural schematic diagram of a semantic sentiment analysis device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0032] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0033] A semantic sentiment analysis method proposed in this embodiment is applied to a semantic sentiment analysis device or electronic device, which can be installed or integrated in some large-scale interconnected devices or interconnected systems, and can execute any of the semantic sentiment analysis methods mentioned below during operation. Specifically, it can be applied to at least IT network system architectures such as customer service voice service satisfaction prediction systems. In addition, the implementation of the neural network models proposed in the embodiments of the present application, such as the sentiment feature extraction model, the masked language model (MLM) and other algorithms, can be set in physical hardware such as a physical chip or a hardware control unit.
[0034] In order to improve the problem that the current semantic sentiment analysis lacks analysis of the context and sentiment of the text, resulting in a low accuracy rate of the semantic recognition result, this embodiment provides a semantic sentiment analysis method, such as Figure 1 As shown, the method includes:
[0035] S101, obtaining a preprocessed corpus.
[0036] The corpus includes dialogue samples with various emotions, recording the text utterances of the speaker, which can be in Chinese, English or other languages. Preprocessing can specifically include checking the text integrity of the corpus, for example, checking text sentences, correcting text spelling errors and illegal characters, etc. Sentiment analysis is performed on the sentences in the corpus, and corresponding preset tags are marked according to the sentiment analysis results. The target sentence of each dialogue contains emotion (positive, negative or neutral), mood (happy, sad, etc.) and irony (sarcastic, non-sarcastic) tags.
[0037] S102, using a sentiment feature extraction model, extracting features from a corpus with preset tags to obtain sentiment features of each sentence.
[0038] Pre-trained models are used to extract features for different preset tasks, which may include sentiment analysis, emotion recognition, and sarcasm detection. In practice, the sentiment feature, i.e., the output of the pre-trained model, is a word embedding vector that represents the text features of each sentence and the preset tags corresponding to the sentence.
[0039] S103, using a prompt encoder to process the emotional features to obtain a task prompt code.
[0040] The task prompt coding in this embodiment includes single-task prompt coding and multi-task shared prompt coding. The single-task prompt coding is the prompt coding obtained based on one of the above-mentioned preset tasks (for example, the single-task prompt coding obtained only based on emotion recognition); the multi-task shared prompt coding is the prompt coding obtained based on multiple tasks in the above-mentioned preset tasks (for example, the multi-task shared prompt coding obtained based on the dual tasks of sentiment analysis and emotion recognition). The multi-task shared prompt coding can better reflect the continuity and difference between the selected multiple tasks, that is, it represents two different tasks and their correlation in the same text. In addition, the prompt encoder can use the same encoder, or it can distinguish between single tasks and multi-tasks and set encoders separately.
[0041] S104, using the task prompt encoding as the input of the multi-task prompt learning interaction framework to obtain the emotional prompt result.
[0042] The multi-task prompt learning interaction framework can also be called a multi-task prompt interaction learning layer (MPIL). MPIL sets a gating network for each preset task to simulate the interaction between different prompts, where each gating network is composed of a linear transformation and a self-attention mechanism. The three gating networks output three sets of weight scores for each input prompt, indicating the probability of each prompt encoding layer output result being selected. Each preset task selects the output of the prompt encoding layer through the gating network, and performs weighted summation as the underlying input, thereby establishing the interactivity and correlation between different emotional features, and the obtained emotional prompt results are more accurate.
[0043] S105, inputting the emotion prompt result into the mask language model to obtain the semantic emotion analysis result.
[0044] The emotional prompt results are input into the masked language model, and the emotional prompt results are classified and calculated to obtain the final semantic sentiment analysis results.
[0045] In this embodiment, firstly, a corpus with preset marks in the preprocessed sentences is obtained, and the features of the corpus with preset marks are extracted to obtain the emotional features of each sentence. The emotional features are used to characterize the emotions, moods or irony expressed by the current sentence. Then, the emotional features are processed by the prompt encoder to obtain the task prompt encoding and input into the multi-task prompt learning interaction framework, the purpose of which is to establish the correlation and relevance between the emotions of a single sentence and the emotions of multiple sentences, and the emotional prompt results obtained at the same time, which can be used to indicate the emotional association between the previous and next sentences. Finally, the emotional prompt results are input into the masked language model to obtain the semantic sentiment analysis results. Compared with the conventional recognition results output only by the semantic model, this embodiment uses the task prompt encoding with preset mark conversion to represent the emotional features of each sentence, and establishes the interactivity and relevance between different emotional features through the multi-task prompt learning interaction framework, which effectively improves the accuracy of the semantic sentiment analysis results, and improves the current semantic sentiment analysis. The lack of analysis of the text before and after relevance and emotions leads to the problem of low accuracy of semantic recognition results.
[0046] Optionally, obtaining a preprocessed corpus includes: checking the text integrity of the corpus; performing sentiment analysis on sentences in the corpus and marking corresponding preset tags according to the sentiment analysis results; and randomly selecting from the corpus according to a preset ratio to obtain a preprocessed corpus.
[0047] In this embodiment, preprocessing includes checking the text integrity of the corpus, such as checking text sentences, correcting text spelling errors and illegal characters, etc. Sentiment analysis is performed on the sentences in the corpus, and corresponding preset tags are marked according to the sentiment analysis results. The target sentences of each conversation contain emotion (positive, negative or neutral, etc.), mood (happy, sad, etc.) and irony (sarcastic, non-sarcastic) tags. By preprocessing and adding preset tags in advance, it is convenient to directly extract features from the corpus later. Randomly select from the corpus according to a preset ratio. For example, after adding preset tags, some sentences can be randomly selected as a training set according to a preset ratio, such as 70%, and the other 30% as a test set, so that the results are more universal.
[0048] Optionally, feature extraction is performed on a corpus with preset tags through a sentiment feature extraction model to obtain the sentiment feature of each sentence, including: feature extraction is performed on the corpus based on preset tasks through a sentiment feature extraction model to obtain the sentiment feature of each sentence; wherein the preset tasks include sentiment analysis, emotion recognition and sarcasm detection.
[0049] In this embodiment, feature extraction is performed on the corpus mainly based on three dimensions, including sentiment analysis, emotion recognition, and sarcasm detection. These three dimensions are conducive to better identifying the emotions contained in the speaker's text.
[0050] Optionally, the task prompt encoding includes single-task prompt encoding; the emotional features are processed using a prompt encoder to obtain a single-task prompt encoding, including: based on a single preset task, globally marking the text containing the emotional features, and screening out the emotional features corresponding to the single preset task; the emotional features corresponding to the single preset task are input into the prompt encoder to obtain the single-task prompt encoding corresponding to the single preset task.
[0051] In this embodiment, the task prompt encoding includes single-task prompt encoding, which is a prompt encoding obtained based on a task in the preset tasks. The specific steps are as follows: first, the text is globally marked to screen out the emotional features corresponding to the single preset task; the emotional features corresponding to the single preset task are input into the prompt encoder, and the P-tuning method is specifically used to obtain the prompt encoding of the three tasks (i.e., sentiment analysis, emotion recognition, and sarcasm detection); the input is converted into a word embedding vector through an embedding layer, and then a prompt vector consisting of several learnable prompt tags (i.e., p0…p m ), these prompt tags can be converted into trainable embedding vectors (i.e., h0…h m In the prompt encoder, a bidirectional long short-term memory network (BiLSTM) is used to optimize the prompt tokens in the continuous space, and a multilayer perceptron (MLP) is used to encourage discreteness. Finally, the single-task prompt is obtained through training: P sa , P er , P sd (sa, er, sd correspond to sentiment analysis, emotion recognition, and sarcasm detection respectively)
[0052]
[0053] P i =MLP i (BiLSTM i (p0…p m )) (Formula 2)
[0054] in Represents a pre-trained language model, with the help of downstream loss The cue embedding is optimized by parameter θ. m is the length of the cue token, i∈{sa,er,sd}.
[0055] Optionally, the task prompt encoding also includes multi-task shared prompt encoding; the emotional features are processed using the prompt encoder to obtain multi-task shared prompt encoding, including: based on multiple preset tasks, globally marking the text containing emotional features, and screening out the emotional features corresponding to multiple preset tasks; the emotional features corresponding to multiple preset tasks are input into the prompt encoder to obtain multi-task shared prompt encoding.
[0056] In this embodiment, the task prompt coding also includes multi-task shared prompt coding, which is a prompt coding obtained based on multiple tasks in the above-mentioned preset tasks. First, the text is globally marked based on multiple preset tasks, and the emotional features corresponding to multiple preset tasks are screened out. It should be noted that the emotional features corresponding to multiple preset tasks are marked, which is not the same concept as the preset marking. The preset marking is to process the target sentence of the corpus to obtain the preset marking. The purpose is to pre-process the sentence to prompt that the sentence contains emotional, sentimental, and sarcastic labels; and here the text is globally marked based on multiple preset tasks, with the purpose of screening out the emotional features that have been extracted previously, so as to facilitate the subsequent input into the encoder. Then, the emotional features corresponding to the multiple preset tasks are input into the prompt encoder, the marking is optimized through back propagation, and the multi-task shared prompt coding is obtained in the same way as the above-mentioned single-task prompt coding, for example, P (sa,er) Represents emotional and sentimental tasks.
[0057]
[0058] where i∈{sa,er,sd}, sa,er,sd represent sentiment, emotion and sarcasm tasks respectively, and y i represents the label corresponding to the preset task. Finally, we can minimize To train embeddings for multi-task shared prompts.
[0059] Optionally, the multi-task prompt learning interaction framework includes a gate control network and a multi-mask prompt template based on preset task settings; the task prompt encoding is used as the input of the multi-task prompt learning interaction framework to obtain an emotional prompt result, including: inputting the task prompt encoding into the gate control network to obtain a weight matrix based on different preset tasks; using the multi-mask prompt template to map the weight matrix to determine the emotional prompt result.
[0060] In this embodiment, in order to establish the correlation and difference between multi-task and single-task prompt encoding, a multi-task prompt interactive learning layer is introduced in sentiment analysis, emotion recognition and sarcasm detection, which includes a gate control network and a multi-mask prompt template. The gate control network can be specifically set based on the number of preset tasks. In this embodiment, three corresponding to the above three preset tasks. The weight matrix is obtained through the gate control network, and then the weight matrix is calculated and mapped using the multi-mask prompt template to determine the emotional prompt result, thereby achieving the purpose of establishing the interactivity between multi-task and single-task prompt encoding.
[0061] Specifically, the multi-mask prompt template, the prompt template P composed of sub-prompts of multiple tasks T With the help of , each task is redefined and the final template can be expressed as:
[0062]
[0063] Among them, MASK da , MASK er , MASK sd denote the predicted labels for sentiment, emotion, and sarcasm tasks, respectively. Emotional prompt results for sentiment analysis, emotion recognition, and sarcasm detection, respectively.
[0064] Furthermore, the emotion prompt result is input into the masked language model to obtain the semantic emotion analysis result: T The input to the masked language model predicts the probability of the label corresponding to each preset task by maximizing the score of the language model, and maps the result to the label of the corresponding task to obtain the results of sentiment, emotion and sarcasm classification.
[0065]
[0066] Among them, i∈{sa, er, sd}, y i Indicates the prediction label corresponding to each preset task, is a subset of the entire vocabulary of task i.
[0067] Optionally, the task prompt code is input into the gate control network to obtain a weight matrix based on different preset tasks, including: using the gate control network to establish the correlation between the single-task prompt code and the multi-task shared prompt code according to the preset task, and obtaining weight scores corresponding to different preset tasks; weighted combination of the weight scores to obtain a weight matrix.
[0068] In this embodiment, each gating network is composed of a linear transformation and a self-attention mechanism. The three gating networks encode and output three sets of weight scores (α sa , αer , α sd ), represents the probability of each prompt encoding layer output being selected. Each preset task selects the output of the prompt encoding layer through the gating network and performs weighted summation as the bottom layer input:
[0069] α sa = self-attention(W sa (P sa , P (sa,er) ,P (sa,sd) , P (sa,er,sd) )+b sa )
[0070] α er = self-attention(W er (P er , P (sa,er) ,P (er,sd) , P (sa,er,sd) )+b er )
[0071] α sd = self-attention(W sd (P sd , P (sa,sd) ,P (er,sd) , P (sa,er,sd) )+b sd )
[0072]
[0073]
[0074]
[0075] Among them, W sa , W er , W sd Represents the weight matrices of sentiment, emotion, and sarcasm tasks, respectively, and b sa , b er , b sd is the weight bias, is a four-dimensional vector.
[0076] Furthermore, a specific implementation method is given, taking the emotional dialogue data set heard by customer service as an example, such as Figure 2 As shown, it is a flow chart of another semantic sentiment analysis method provided in an embodiment of the present application, including:
[0077] S201, collects dialogue data containing emotions, sentiments, and sarcasm.
[0078] An English multi-emotional dialogue corpus is collected from the incoming voice text of a customer service hotline. The corpus includes dialogue samples with multiple emotions, and the total number of samples in the corpus is N. The dialogue records the textual discourse of the speaker, and the target sentence of each dialogue also contains emotions.
[0079] S202, adding preset tags to the corpus.
[0080] First, the speech data set is preprocessed to check the text sentences and correct spelling errors and illegal characters. Then, the sentiment, emotion and sarcasm of each conversation sentence are counted for sentiment analysis, and the corresponding preset tags are marked according to the sentiment analysis results. The target sentence of each conversation contains emotion (positive, negative or neutral), emotion (happy, sad, etc.) and sarcasm (sarcastic, non-sarcastic) tags.
[0081] S203, performing feature extraction through a sentiment feature extraction model to obtain sentiment features of each sentence.
[0082] For the preprocessed dialogue corpus, the pre-trained sentiment feature extraction model is used to extract the features of different sentiment tasks. For the three preset tasks of sentiment analysis, sentiment recognition, and sarcasm detection, the pre-trained model is used to obtain the text embedding vector of each sentence with mask words, that is, the sentiment feature: sa ,I er ,I sd (text embedding vectors representing sentiment, emotion, and sarcasm, respectively) are used to represent the text features of each sentence.
[0083] S2041, input single task prompt encoder.
[0084] S2042, input the multi-task prompt encoder.
[0085] In this embodiment, S2041 and S2042 are distinguished because two encoders are set, that is, they are set for single task and multi-task respectively, which is more in line with actual needs. However, if the same encoder is used, steps S2041 and S2042 can be combined.
[0086] The purpose of obtaining the prompt encoding is to conduct joint analysis of single tasks and multi-tasks in the future. Single-task prompts can improve the performance of the task itself, and multi-task prompts play an important role in all tasks. Specifically, the acquisition steps of single-task prompt encoding take sentiment analysis as an example. The sentiment analysis task prompt encoder is set to convert the globally marked sentiment features of "sentiment analysis" into word embedding vectors, and then construct a vector consisting of several learnable prompt tags (i.e., p0…p m ), these cue tags can be converted into trainable embedding tensors (i.e., h0…hm ). In the prompt encoder, a bidirectional long short-term memory network (BiLSTM) is used to optimize the prompt tokens in the continuous space, and a multilayer perceptron (MLP) is used to encourage discreteness, which improves the model performance. Finally, the parameters of the prompt encoder are updated through backpropagation to train the effective embedding of the sentiment analysis prompt token. Finally, the single-task prompt encoder P for sentiment analysis is obtained through training. sa .
[0087] The acquisition steps of multi-task cue shared encoding take the dual-task shared cue of sentiment analysis and emotion recognition as an example. First, a global tagging is designed for sentiment analysis and emotion recognition tasks to obtain the emotion features of sentiment analysis and emotion recognition after global tagging. Subsequently, the cue encoder is also input to obtain the shared cue P for sentiment analysis and emotion recognition tasks. (sa,er) .
[0088] S205, establish interactivity through the gate control network, and obtain weight matrices based on different preset tasks.
[0089] The multi-task prompt learning interaction framework includes a gate control network and a multi-mask prompt template. The single-task and multi-task prompt shared encoding is input into the multi-task prompt learning interaction framework to learn the correlation and difference between multi-task and single-task prompts. Each single-task prompt encoding and multi-task prompt encoding will be scored by three gate control networks to obtain three sets of weight scores based on three preset tasks, and then combined to obtain a weight matrix.
[0090] S206, mapping the weight matrix through the multi-mask prompt template to determine the emotion prompt result.
[0091] The weight matrix is calculated and mapped using the multi-mask prompt template to determine the emotional prompt result. The calculation process has been mentioned above and will not be repeated here.
[0092] S207, input the mask language model to obtain the semantic sentiment analysis result.
[0093] Furthermore, the emotion prompt result is input into the masked language model to obtain the semantic emotion analysis result: T The input to the masked language model predicts the probability of the label corresponding to each preset task by maximizing the score of the language model, and maps the result to the label of the corresponding task to obtain the results of sentiment, emotion and sarcasm classification.
[0094] Specifically in the application scenario of customer voice calls, fine-grained sentiment classification is performed on the text data of daily business conversations between customer service and users. Through fine-grained sentiment analysis, the user's emotions in business conversations are detected, the user's business inquiry needs or intentions are indirectly or directly judged, and the opinions are fed back to the business end. At the same time, the attitude and emotional expression of customer service personnel in the process of communicating with users are supervised to improve customer service quality. The significance of fine-grained analysis of customer service speech recognition emotions is reflected in the user's attention to the business and the supervision of customer service personnel, which can better make decisions on the business and help improve customer service quality. In addition, this embodiment overcomes the current situation that multi-task interaction stays in shared representation, can make more full use of the interactive information between different modes (emotion, emotion, sarcasm), effectively improves the efficiency and accuracy of multi-emotion joint analysis, and provides new ideas for the development of future artificial intelligence systems and interactive emotion recognition systems. It is verified by experimental data that the average overall accuracy of the particle swarm optimization model can reach 0.86, which is 3% and 6% higher than the accuracy of the two models without the optimization algorithm, respectively. Among them, the recall rate of the model for text dialogues with a high degree of negative emotions is the highest, reaching 0.97.
[0095] Further, as Figure 1 and Figure 2 The specific implementation of the method shown in this embodiment provides a semantic sentiment analysis device, such as Figure 3 As shown, the device includes: an acquisition unit 31, an extraction unit 32, a processing unit 33, an analysis unit 34 and a result identification unit 35.
[0096] An acquisition unit 31 is configured to acquire a preprocessed corpus; the target sentence in the corpus is marked with a preset mark;
[0097] The extraction unit 32 is configured to extract features from the corpus with preset tags through a sentiment feature extraction model to obtain sentiment features of each sentence;
[0098] The processing unit 33 is configured to process the emotion feature using a prompt encoder to obtain a task prompt code;
[0099] An analyzing unit 34 is configured to use the task prompt encoding as an input of a multi-task prompt learning interaction framework to obtain an emotional prompt result;
[0100] The result recognition unit 35 is configured to input the emotion prompt result into a mask language model to obtain a semantic emotion analysis result.
[0101] In a specific application scenario, the acquisition unit 31 is specifically configured to check the text integrity of the corpus; perform sentiment analysis on the sentences in the corpus, and mark corresponding preset tags according to the sentiment analysis results;
[0102] The preprocessed corpus is obtained by randomly selecting from the corpus according to a preset ratio.
[0103] In a specific application scenario, the extraction unit 32 is further configured to perform feature extraction on the corpus based on a preset task through the sentiment feature extraction model to obtain the sentiment feature of each sentence; wherein the preset task includes sentiment analysis, emotion recognition and sarcasm detection.
[0104] In a specific application scenario, the processing unit 33 is further configured to globally mark the text containing the emotional features based on a single preset task, and filter out the emotional features corresponding to the single preset task; input the emotional features corresponding to the single preset task into the prompt encoder to obtain the single task prompt code corresponding to the single preset task.
[0105] In a specific application scenario, the processing unit 33 is further configured to globally mark the text containing the emotional features based on multiple preset tasks, and filter out the emotional features corresponding to the multiple preset tasks; input the emotional features corresponding to the multiple preset tasks into the prompt encoder to obtain the multi-task shared prompt code.
[0106] In a specific application scenario, the analysis unit 34 is further configured to input the task prompt code into the gate control network to obtain a weight matrix based on different preset tasks; and use the multi-mask prompt template to map the weight matrix to determine the emotional prompt result.
[0107] In a specific application scenario, the analysis unit 34 is further configured to utilize the gate control network to establish a correlation between the single-task prompt code and the multi-task shared prompt code according to the preset task, and obtain weight scores corresponding to different preset tasks; perform weighted combination on the weight scores to obtain the weight matrix.
[0108] It should be noted that for other corresponding descriptions of the functional units involved in the semantic sentiment analysis device provided in this embodiment, please refer to Figure 1 and Figure 2 The corresponding description in will not be repeated here.
[0109] Based on the above Figure 1 and Figure 2 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figure 1 and Figure 2 The method shown.
[0110] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0111] Based on the above Figure 1 and Figure 2 The method shown, and Figure 3 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides an electronic device, which can be configured on a computer terminal, etc. The device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 and Figure 2 The method shown.
[0112] Based on the above Figure 1 and Figure 2 The method shown, and Figure 3 In order to achieve the above-mentioned purpose, the embodiment of the virtual device shown in the embodiment of the present application further provides a chip, including one or more interface circuits and one or more processors; the interface circuit is used to receive a signal from the memory of the electronic device and send the signal to the processor, the signal including the computer instruction stored in the memory; when the processor executes the computer instruction, the electronic device executes the above-mentioned Figure 1 and Figure 2 The method shown.
[0113] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0114] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0115] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0116] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus the necessary general hardware platform, or by hardware. By applying the scheme of this embodiment, a corpus with preset marks in the preprocessed sentences is first obtained, and the features of the corpus with preset marks are extracted to obtain the emotional features of each sentence. The emotional features are used to characterize the emotions, moods or irony expressed by the current sentence. The emotional features are then processed by the prompt encoder to obtain the task prompt code and input it into the multi-task prompt learning interaction framework, with the aim of establishing the correlation and relevance between the emotion of a single sentence and the emotions of multiple sentences, and the emotional prompt results obtained at the same time, which can be used to indicate the emotional association between the previous and next sentences. Finally, the emotional prompt results are input into the masked language model to obtain the semantic sentiment analysis results. Compared with the conventional recognition results output only by the semantic model, this application encodes the task prompts with preset markers to represent the emotional characteristics of each sentence, and establishes the interactivity and correlation between different emotional characteristics through a multi-task prompt learning interaction framework, which effectively improves the accuracy of the semantic sentiment analysis results and improves the current semantic sentiment analysis that lacks analysis of the context and emotion of the text, resulting in low accuracy of the semantic recognition results.
[0117] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprises" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0118] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.
Claims
1. A semantic sentiment analysis method, characterized in that: include: Get the preprocessed corpus; The target sentences in the corpus are marked with preset tags; By using the sentiment feature extraction model, feature extraction is performed on the corpus with preset tags to obtain the sentiment feature of each sentence; Processing the emotional features using a prompt encoder to obtain a task prompt code; Using the task prompt encoding as the input of a multi-task prompt learning interaction framework to obtain an emotional prompt result; The emotional prompt result is input into the masked language model to obtain the semantic sentiment analysis result.
2. The method according to claim 1, characterized in that The step of obtaining the preprocessed corpus includes: Check the textual integrity of the corpus; Performing sentiment analysis on the sentences in the corpus, and marking corresponding preset tags according to the sentiment analysis results; The preprocessed corpus is obtained by randomly selecting from the corpus according to a preset ratio.
3. The method according to claim 1, characterized in that The emotional feature extraction model is used to extract features from the corpus with preset tags to obtain the emotional features of each sentence, including: By using the sentiment feature extraction model, feature extraction is performed on the corpus based on a preset task to obtain the sentiment feature of each sentence; Among them, the preset tasks include sentiment analysis, emotion recognition and sarcasm detection.
4. The method according to claim 3, characterized in that The task prompt coding includes single task prompt coding; The emotional features are processed using a prompt encoder to obtain a single-task prompt encoding, including: Based on a single preset task, globally mark the text containing the emotional feature, and filter out the emotional feature corresponding to the single preset task; The emotional feature corresponding to the single preset task is input into the prompt encoder to obtain the single task prompt code corresponding to the single preset task.
5. The method according to claim 3, characterized in that: The task prompt coding includes multi-task shared prompt coding; The emotional features are processed using a prompt encoder to obtain a multi-task shared prompt encoding, including: Based on multiple preset tasks, globally mark the text containing the emotional features, and filter out the emotional features corresponding to the multiple preset tasks; The emotion features corresponding to the plurality of preset tasks are input into the prompt encoder to obtain the multi-task shared prompt code.
6. The method according to claim 4 or 5, characterized in that: The multi-task prompt learning interaction framework includes a gate control network and a multi-mask prompt template based on the preset task settings; The task prompt encoding is used as the input of the multi-task prompt learning interaction framework to obtain the emotional prompt results, including: Inputting the task prompt code into the gate control network to obtain a weight matrix based on different preset tasks; The weight matrix is mapped using the multi-mask prompt template to determine the emotion prompt result.
7. The method according to claim 6, characterized in that The step of inputting the task prompt code into the gate control network to obtain a weight matrix based on different preset tasks includes: Using the gate control network, establishing the correlation between the single-task prompt code and the multi-task shared prompt code according to the preset task, and obtaining weight scores corresponding to different preset tasks; The weight scores are weighted and combined to obtain the weight matrix.
8. A semantic sentiment analysis device, characterized in that: include: An acquisition unit, configured to acquire a preprocessed corpus; The target sentences in the corpus are marked with preset tags; An extraction unit is configured to extract features from the corpus with preset tags through a sentiment feature extraction model to obtain sentiment features of each sentence; A processing unit is configured to process the emotional feature using a prompt encoder to obtain a task prompt code; An analysis unit is configured to use the task prompt encoding as an input of a multi-task prompt learning interaction framework to obtain an emotional prompt result; The result recognition unit is configured to input the emotion prompt result into a mask language model to obtain a semantic emotion analysis result.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
