Mail text emotion recognition method and device, emotion recognition model and storage medium

By using a sentiment recognition model defined by a BERT pre-trained model to train and recognize email text, the problem of existing technologies being unable to accurately identify complex semantic and emotional changes is solved, achieving higher accuracy and comprehensiveness in email text sentiment recognition and supporting more effective customer service processing.

CN121598950APending Publication Date: 2026-03-03GUANGZHOU TANTU TIANXIA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411599989.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2024-08-19
Filing Date
2024-11-11
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing Naive Bayes classification algorithms and logistic regression classification algorithms cannot effectively capture complex semantic and emotional changes in email sentiment recognition, resulting in inaccurate recognition results and an inability to obtain comprehensive and accurate text semantic features, thus limiting the accuracy and comprehensiveness of sentiment recognition.

Method used

A sentiment recognition model is defined using a BERT pre-trained model. By training the model on a dataset, the trained sentiment recognition model is used to perform sentiment recognition on email text, obtaining comprehensive and accurate semantic features, thereby improving the comprehensiveness and accuracy of sentiment recognition in email text.

Benefits of technology

By using the BERT pre-trained model, we can capture the deep semantics and emotional nuances in email text, understand complex contexts, enhance the ability to recognize emotions in email text, automatically extract more comprehensive and accurate semantic features, improve the accuracy and comprehensiveness of emotion recognition, and support customer service to reply to emails faster and more specifically.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121598950A_ABST
    Figure CN121598950A_ABST
Patent Text Reader

Abstract

The invention relates to a mail text emotion recognition method and device, an emotion recognition model and a storage medium. The method comprises the following steps: defining an emotion recognition model based on a BERT pre-training model; inputting the preprocessed data set into the emotion recognition model, and training the emotion recognition model by adopting the data set to obtain a trained emotion recognition model; and performing emotion recognition on a mail text by using the trained emotion recognition model to obtain an emotion category of the mail text. According to the scheme provided by the invention, emotion recognition can be carried out on the mail text with complex semantic and emotion expressions, comprehensive and accurate semantic features of the mail text are obtained, and comprehensiveness and accuracy of emotion recognition of the mail text are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of text processing technology, and in particular to a method, apparatus, emotion recognition model and storage medium for email text emotion recognition. Background Technology

[0002] In related technologies, email sentiment recognition is performed using either Naive Bayes classification or logistic regression classification algorithms. Naive Bayes classification, which calculates the conditional probability of each feature under a given category, is a probability-based classification algorithm. Logistic regression, which maps the results of linear regression to a probability range of [0, 1] using a sigmoid function, is a binary classification algorithm.

[0003] Because Naive Bayes and Logistic Regression classification algorithms have certain limitations in handling complex semantics and emotional nuances, they cannot effectively capture subtle emotional changes in text. Furthermore, these algorithms primarily rely on manual feature engineering, selecting and designing features based on experience and domain knowledge. This introduces subjectivity and uncertainty in capturing emotional changes, preventing them from capturing deep semantic information and fully utilizing the text's semantic content. Additionally, Naive Bayes and Logistic Regression are based on simplified assumptions that cannot handle complex semantic and emotional expressions. Naive Bayes assumes features are independent, while Logistic Regression assumes a linear relationship between features and output. These simplified assumptions limit their ability to handle complex semantic and emotional expressions.

[0004] Therefore, the accuracy and comprehensiveness of feature extraction in email emotion recognition based on Naive Bayes classification or logistic regression classification algorithms are limited. They cannot handle complex semantics and emotional expressions, and cannot obtain comprehensive and accurate text semantic features, which limits the accuracy and comprehensiveness of emotion recognition. As a result, the recognition results are not accurate enough and cannot accurately determine the emotional state of the email. Summary of the Invention

[0005] To address or partially address the problems existing in related technologies, this application provides an email text emotion recognition method, apparatus, emotion recognition model, and storage medium, which can perform emotion recognition on email text with complex semantics and emotional expression, obtain comprehensive and accurate semantic features of email text, and improve the comprehensiveness and accuracy of email text emotion recognition.

[0006] The first aspect of this application provides a method for email text sentiment recognition, the method comprising: Defining an emotion recognition model based on a BERT pre-trained model; The preprocessed dataset is input into the emotion recognition model, and the emotion recognition model is trained using the dataset to obtain the trained emotion recognition model. The trained emotion recognition model is used to perform emotion recognition on email text to obtain the emotion category of the email text.

[0007] Preferably, defining the emotion recognition model based on the BERT pre-trained model includes: defining the parameters of the emotion recognition model based on the BERT pre-trained model, wherein the parameters include one or more of the following: loss function, hyperparameters, learning rate, and emotion category.

[0008] Preferably, inputting the preprocessed dataset into the emotion recognition model includes: The dataset is composed of a set number of email texts. The email texts in the dataset are labeled with different emotion categories to obtain the labeled dataset; The labeled dataset is divided into a training set and a validation set. The training set and validation set are input into the emotion recognition model.

[0009] Preferably, training the emotion recognition model using the dataset to obtain the trained emotion recognition model includes: The emotion recognition model is iteratively trained using the training set, and the loss function value of the emotion recognition model is calculated for each iteration of the training based on the loss function. Based on the loss function value, the iterative training of the emotion recognition model ends; Based on the emotion recognition model trained iteratively, the emotion category and confusion matrix are output by performing emotion recognition on the validation set to obtain the trained emotion recognition model.

[0010] Preferably, the step of obtaining the trained emotion recognition model by performing emotion recognition on the validation set based on the emotion category and confusion matrix output by the iteratively trained emotion recognition model includes: The emotion recognition model after iterative training is validated using the validation set to obtain the emotion category and confusion matrix corresponding to the validation set, which are output by the iteratively trained emotion recognition model for the validation set. Based on the emotion category and confusion matrix corresponding to the validation set, calculate the accuracy and recall of the emotion recognition model after iterative training; If the accuracy rate meets the set accuracy rate, then the trained emotion recognition model is obtained; and / or, If the recall rate meets the set recall rate, then the trained emotion recognition model is obtained.

[0011] Preferably, the method further includes: If the accuracy rate does not meet the set accuracy rate, the emotion recognition model is iteratively trained using the training set, and the loss function value for each iteration of the training is calculated based on the loss function; and / or, If the recall rate does not meet the set recall rate, the emotion recognition model is iteratively trained using the training set, and the loss function value of each iteration of the training is calculated based on the loss function.

[0012] Preferably, the emotion categories include no emotion, slight disappointment, great disappointment, anger, and satisfaction.

[0013] A second aspect of this application provides an email text sentiment recognition device, the device comprising: The definition module is used to define an emotion recognition model based on a BERT pre-trained model. The training module is used to input the preprocessed dataset into the emotion recognition model defined by the definition module, and to train the emotion recognition model using the dataset to obtain the trained emotion recognition model. The acquisition module is used to perform emotion recognition on email text using the emotion recognition model trained by the training module, and obtain the emotion category of the email text.

[0014] A third aspect of this application provides an emotion recognition model, including: Processor; and A memory that stores executable code, which, when executed by the processor, causes the processor to perform the method described above.

[0015] A fourth aspect of this application provides a computer-readable storage medium having executable code stored thereon, which, when executed by a processor of an emotion recognition model, causes the processor to perform the method described above.

[0016] The technical solution provided in this application may include the following beneficial effects: The technical solution of this application defines an emotion recognition model based on a BERT pre-trained model; the pre-processed dataset is input into the emotion recognition model, and the model is trained using the dataset to obtain a trained emotion recognition model; the trained emotion recognition model is used to perform emotion recognition on email text to obtain the emotion category of the email text; the emotion recognition model is defined based on a BERT pre-trained model, and a trained emotion recognition model is obtained through training on a large number of email texts in the dataset. The emotion recognition model learns rich language representations and can capture deep semantics and emotional color in email text. Compared with the emotion recognition based on Naive Bayes classification algorithm or logistic regression classification algorithm in related technologies, the email text emotion recognition method of this application, which identifies the emotion category of email text through a trained emotion recognition model, is better at handling and understanding complex contexts, is better at capturing the contextual relationship between words in email text, and can consider the information of the whole sentence when processing each word. Even in long sentences, it can understand the subtle emotional changes in email text, thus enhancing the ability to recognize emotions in email text. The email text emotion recognition method of this application embodiment uses a trained emotion recognition model that can automatically learn features from email text in a dataset through training. It can automatically extract more comprehensive and accurate semantic features without manual intervention and can capture the non-linear relationship between features and emotions, thus classifying emotions more accurately. This email text emotion recognition method utilizes the trained emotion recognition model to perform emotion recognition on email text, obtaining the emotion category of the email text. It can perform emotion recognition on email text with complex semantics and emotional expression, obtaining comprehensive and accurate semantic features of the email text, improving the comprehensiveness and accuracy of email text emotion recognition. Customer service representatives can quickly understand the emotional tendency of email text based on its emotion category, providing data support for improving the efficiency of customer service in processing email text, responding to email text more specifically, and providing better service. It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0017] The above and other objects, features and advantages of this application will become more apparent from the more detailed description of exemplary embodiments thereof in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments thereof.

[0018] Figure 1 This is a flowchart illustrating the email text sentiment recognition method according to an embodiment of this application; Figure 2 This is another schematic flowchart illustrating the email text sentiment recognition method shown in the embodiments of this application; Figure 3This is a schematic diagram of the structure of the email text emotion recognition device shown in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the emotion recognition model shown in the embodiments of this application. Detailed Implementation

[0019] Embodiments of this application will now be described in more detail with reference to the accompanying drawings. While embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to make this application more thorough and complete, and to fully convey the scope of this application to those skilled in the art.

[0020] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0021] It should be understood that although the terms "first," "second," "third," etc., may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.

[0022] This application provides an email text emotion recognition method that can perform emotion recognition on email text with complex semantics and emotional expression, obtain comprehensive and accurate semantic features of email text, and improve the comprehensiveness and accuracy of email text emotion recognition.

[0023] The technical solutions of the embodiments of this application are described in detail below with reference to the accompanying drawings.

[0024] Figure 1 This is a flowchart illustrating the email text sentiment recognition method according to an embodiment of this application.

[0025] See Figure 1 A method for email text sentiment recognition, comprising: Step 101: Define an emotion recognition model based on the BERT pre-trained model.

[0026] In one embodiment, an emotion recognition model for identifying the emotion category of email text can be defined based on a BERT (Bidirectional Encoder Representation from Transformer) pre-trained model, and the parameters of the emotion recognition model can be defined.

[0027] Step 102: Input the preprocessed dataset into the emotion recognition model, and use the dataset to train the emotion recognition model to obtain a trained emotion recognition model.

[0028] In one embodiment, the dataset used to train the emotion recognition model can be a publicly available dataset or a dataset created by collecting email text. The dataset is preprocessed and labeled; the labeled dataset is then divided into a training set and a validation set; the training and validation sets are input into the emotion recognition model, and the model is iteratively trained using the training set. The iterative training of the emotion recognition model ends based on the loss function value of each iteration; the trained emotion recognition model is then validated using the validation set, and the trained emotion recognition model is obtained based on the emotion recognition results output by the model using the validation set.

[0029] Step 103: Use the trained emotion recognition model to perform emotion recognition on the email text and obtain the emotion category of the email text.

[0030] In one embodiment, the email text whose emotion category to be identified can be input into a trained emotion recognition model, and the trained emotion recognition model can be used to identify the emotion category of the email text to obtain the emotion category of the email text.

[0031] The email text emotion recognition method of this application embodiment defines an emotion recognition model based on a BERT pre-trained model; it inputs a pre-processed dataset into the emotion recognition model and trains the model using the dataset to obtain a trained emotion recognition model; it then uses the trained model to perform emotion recognition on email text to obtain the emotion category of the email text. By defining the emotion recognition model based on a BERT pre-trained model and training it with a large number of email texts in the dataset, a trained emotion recognition model is obtained. This emotion recognition model learns rich linguistic representations and can capture deep semantics and emotional nuances in email text. Compared to related technologies based on Naive Bayes classification or logistic regression classification algorithms, the email text emotion recognition method of this application embodiment, which identifies the emotion category of email text using a trained emotion recognition model, is better able to handle and understand complex contexts, is better at capturing the contextual relationships between words in email text, and considers the information of the entire sentence when processing each word. Even in long sentences, it can understand subtle emotional changes in email text, thus enhancing the ability to recognize emotions in email text. The email text emotion recognition method of this application embodiment uses a trained emotion recognition model that can automatically learn features from email text in a dataset through training. It can automatically extract more comprehensive and accurate semantic features without manual intervention and can capture the non-linear relationship between features and emotions, thus classifying emotions more accurately. This email text emotion recognition method utilizes the trained emotion recognition model to perform emotion recognition on email text, obtaining the emotion category of the email text. It can perform emotion recognition on email text with complex semantics and emotional expression, obtaining comprehensive and accurate semantic features of the email text, improving the comprehensiveness and accuracy of email text emotion recognition. Customer service representatives can quickly understand the emotional tendency of email text based on its emotion category, providing data support for improving the efficiency of customer service in processing email text, responding to email text more specifically, and providing better service.

[0032] Figure 2 This is another flowchart illustrating the email text sentiment recognition method shown in the embodiments of this application. Figure 2 relatively Figure 1 The technical solution of this application is described in more detail.

[0033] See Figure 2 A method for email text sentiment recognition, comprising: Step 201: Define an emotion recognition model based on the BERT pre-trained model.

[0034] In one embodiment, the BERT pre-trained model is a language model built on a bidirectional Transformer architecture. Pre-trained on a large-scale text corpus, it learns rich semantic information and possesses stronger semantic modeling capabilities. The Transformer architecture is a revolutionary neural network architecture that achieves efficient information processing in natural language processing tasks through self-attention mechanisms and feedforward networks, used to learn the contextual relationships between words in text. A basic Transformer includes an encoder to read the text input and a decoder to generate predictions about the task. Since the goal of the BERT pre-trained model is to generate a language representation model, it only requires the encoder part. The input to the encoder of the BERT pre-trained model is a sequence of strings (whose elements are generally called tokens, or words), which is first converted into vectors and then processed in the neural network.

[0035] In one embodiment, an emotion recognition model for identifying the emotion category of email text can be defined based on a BERT pre-trained model. This includes defining the parameters of the emotion recognition model for identifying the emotion category of email text based on the BERT pre-trained model. The parameters of the emotion recognition model include one or more of the following: loss function, hyperparameters, learning rate, and emotion category.

[0036] In one embodiment, an emotion recognition model for identifying the emotion category of email text can be defined using the BertForSequenceClassification provided by the HuggingFaceTransformers library in the Python programming language. The specified model is loaded as the emotion recognition model, and parameters of the emotion recognition model such as loss function, hyperparameters, learning rate, emotion category (label), and number of emotion categories (number of labels) are defined.

[0037] Step 202: Obtain the training set and validation set for training the emotion recognition model.

[0038] In one embodiment, a dataset can be formed by collecting a set number of email texts; the email texts in the dataset can be labeled with different emotion categories to obtain a labeled dataset; the labeled dataset can be divided into a training set and a validation set to obtain the training set and validation set for training the emotion recognition model.

[0039] In one embodiment, the dataset including a set number of email texts can be a publicly available dataset or can be created by collecting email texts from emails. The dataset is preprocessed by removing symbols and links unrelated to emotion from the email texts and converting emotion-related emoticons into text. Then, the email texts in the dataset are labeled with different emotion categories. Finally, the labeled dataset is divided into a training set and a validation set according to a set ratio.

[0040] In one specific embodiment, a dataset consisting of a set number of email texts can be collected. A Large Language Model (LLM) is used to pre-annotate the email texts in the dataset. Then, through manual verification and adjustment, the email texts in the dataset are labeled with different emotion categories, resulting in a labeled dataset. The emotion categories include no emotion, slight disappointment, very disappointment, anger, and satisfaction. 80% of the labeled dataset is divided into a training set and 20% into a validation set. The tokenizer tool corresponding to the BERT pre-trained model is loaded, and the tokenizer tool is used to encode the training and validation sets, converting the text-formatted training and validation sets into the input format required for training the emotion recognition model, thus obtaining the training and validation sets for training the emotion recognition model.

[0041] Step 203: Use the training set to iteratively train the emotion recognition model to obtain the iteratively trained emotion recognition model.

[0042] In one embodiment, a training set is input into the emotion recognition model, and the emotion recognition model is iteratively trained using the training set. The loss function value of the emotion recognition model is calculated for each iteration of the training based on the loss function value. Based on the loss function value, the iterative training of the emotion recognition model is terminated, and the iteratively trained emotion recognition model is obtained.

[0043] In one embodiment, the emotion recognition model is iteratively trained using a training set. The loss function value of the emotion recognition model is calculated for each iteration of the training based on the loss function, and the emotion recognition model after each iteration is saved. Based on the loss function value of the emotion recognition model in each iteration of the training, the decreasing trend of the loss function value is evaluated. When the loss function value stops decreasing significantly, that is, when the loss function value tends to stabilize and reaches the set loss function value, the iterative training of the emotion recognition model is ended, and the iteratively trained emotion recognition model is obtained.

[0044] In one specific embodiment, the emotion recognition model can be trained iteratively a set number of times (e.g., 15 times) using a training set to obtain the emotion category output by the emotion recognition model based on the training set in each iteration of training. Using the Python programming language and the cross-entropy loss function provided by torch, the cross-entropy loss function value of the emotion recognition model in each iteration of training is calculated based on the input (training set) and output (emotion category corresponding to the training set) of the emotion recognition model in each iteration of training.

[0045] Step 204: Use the validation set to validate the iteratively trained emotion recognition model, and obtain the emotion category and confusion matrix corresponding to the validation set output by the iteratively trained emotion recognition model for emotion recognition on the validation set.

[0046] In one embodiment, a validation set can be input into the iteratively trained emotion recognition model, and the iteratively trained emotion recognition model can be validated using the validation set to obtain the emotion category and confusion matrix corresponding to the validation set output by the iteratively trained emotion recognition model.

[0047] Step 205: Calculate the accuracy and recall of the emotion recognition model after iterative training based on the emotion category and confusion matrix corresponding to the validation set.

[0048] In one embodiment, the accuracy and recall of the iteratively trained emotion recognition model can be calculated based on the emotion recognition output of the validation set by the iteratively trained emotion recognition model, the emotion category corresponding to the validation set, and the confusion matrix.

[0049] In one specific embodiment, the structure of the confusion matrix is ​​shown in Table 1 below: Table 1:

[0050] In Table 1, TP (True Positive) indicates that the actual value is positive and the prediction is also positive. FN (False Negative) means that the actual value is positive, but the prediction is negative. FP (False Positive) means that the actual value is negative, but the prediction is positive. TN (True Negative) indicates that the actual class is negative and the prediction is also negative.

[0051] For example, if the actual emotion category of an email text is "satisfaction" (positive category), and the emotion recognition model identifies it as "slight disappointment" (negative category), then the emotion recognition model's value for the emotion category of the email text in the confusion matrix is ​​FN.

[0052] The accuracy P (Precision) of an emotion recognition model reflects how many samples of email text the emotion recognition model identifies as positive are actually positive; where P = TP / (TP + FP).

[0053] The recall rate R of an emotion recognition model reflects how many actual positive samples are correctly identified by the emotion recognition model; where R = TP / (TP + FN).

[0054] Step 206: Obtain the trained emotion recognition model based on the accuracy and recall of the emotion recognition model after iterative training.

[0055] In one embodiment, the trained emotion recognition model can be obtained by performing emotion recognition on the validation set based on the emotion category and confusion matrix output by the iteratively trained emotion recognition model.

[0056] In one embodiment, the accuracy and recall of the iteratively trained emotion recognition model can be calculated based on the emotion recognition output of the validation set, the emotion category corresponding to the validation set, and the confusion matrix. Based on the accuracy and recall of the iteratively trained emotion recognition model, a trained emotion recognition model can be obtained.

[0057] In one embodiment, if the accuracy of the iteratively trained emotion recognition model meets a set accuracy, then a trained emotion recognition model is obtained; and / or, if the recall of the iteratively trained emotion recognition model meets a set recall, then a trained emotion recognition model is obtained.

[0058] In one embodiment, if the accuracy of the iteratively trained emotion recognition model meets the set accuracy and recall meets the set recall, then the emotion recognition model whose accuracy meets the set accuracy and recall meets the set recall can be determined as the trained emotion recognition model.

[0059] In one embodiment, if the accuracy of the iteratively trained emotion recognition model does not meet the set accuracy, then step 203 is executed: the emotion recognition model is iteratively trained using the training set, and the loss function value for each iteration of the training is calculated based on the loss function; based on the loss function value, the iterative training of the emotion recognition model is terminated, and the iteratively trained emotion recognition model is obtained; and / or, if the accuracy and recall of the iteratively trained emotion recognition model do not meet the set recall, then step 203 is executed: the emotion recognition model is iteratively trained using the training set, and the loss function value for each iteration of the training is calculated based on the loss function; based on the loss function value, the iterative training of the emotion recognition model is terminated, and the iteratively trained emotion recognition model is obtained; until the accuracy and recall of the iteratively trained emotion recognition model meet the set accuracy and recall, a trained emotion recognition model is obtained.

[0060] In one embodiment, if the accuracy of the iteratively trained emotion recognition model does not meet the set accuracy, and / or the accuracy-recall ratio does not meet the set recall ratio, the hyperparameters (batch size), learning rate (step size), and other parameters of the emotion recognition model can be adjusted using the Adam optimizer provided by Torch in the Pytho programming language, combined with momentum and the AdaGrad algorithm, based on the accuracy, recall, and loss function value of the iteratively trained emotion recognition model. The adjusted emotion recognition model is then iteratively trained using a training set, and the loss function value for each iteration is calculated based on the loss function. Finally, the iterative training of the emotion recognition model is terminated based on the loss function value, resulting in the iteratively trained emotion recognition model.

[0061] In one embodiment, the emotion recognition model can be trained using the Adam optimizer with the cross-entropy loss function as the optimization objective. Specifically, by comparing the real labels with the predicted labels output by the emotion recognition model, the cross-entropy loss function value is calculated. The cross-entropy loss function value is backpropagated to update the parameters of the emotion recognition model. The emotion recognition model is then iteratively trained. When the cross-entropy loss function value tends to stabilize in two consecutive iterations, the training process of the emotion recognition model is terminated, and the trained emotion recognition model is obtained.

[0062] In one embodiment, updating the parameters of the emotion recognition model through the Adam optimizer can accelerate the convergence speed of the emotion recognition model training and improve the training efficiency of the emotion recognition model.

[0063] In one embodiment, the BERT pre-trained model achieves an accuracy of over 90% in identifying emotion categories on a standard email text classification dataset. The accuracy and recall of the emotion recognition model can be set based on the accuracy and recall of the BERT pre-trained model in identifying emotion categories on the standard email text classification dataset.

[0064] Step 207: Use the trained emotion recognition model to perform emotion recognition on the email text and obtain the emotion category of the email text.

[0065] In one embodiment, the email text whose emotion category to be identified can be input into a trained emotion recognition model, and the trained emotion recognition model can be used to identify the emotion category of the email text to obtain the emotion category of the email text.

[0066] Corresponding to the aforementioned application function implementation method embodiments, this application also provides an email text emotion recognition device, an emotion recognition model, and corresponding embodiments.

[0067] Figure 3 This is a schematic diagram of the structure of an email text emotion recognition device shown in an embodiment of this application.

[0068] See Figure 3 An email text emotion recognition device includes a definition module 301, a training module 302, and an acquisition module 303.

[0069] Define module 301, which is used to define an emotion recognition model based on the BERT pre-trained model.

[0070] In one embodiment, the definition module 301 can define an emotion recognition model for identifying the emotion category of email text based on the BERT pre-trained model, and define the parameters of the emotion recognition model.

[0071] The training module 302 is used to input the preprocessed dataset into the emotion recognition model defined by the definition module 301, and to train the emotion recognition model using the dataset to obtain a trained emotion recognition model.

[0072] In one embodiment, the dataset used to train the emotion recognition model can be a publicly available dataset or a dataset created by collecting email text. The training module 302 preprocesses and labels the dataset; it divides the labeled dataset into a training set and a validation set; it inputs the training set and validation set into the emotion recognition model, iteratively trains the emotion recognition model using the training set, and terminates the iterative training of the emotion recognition model based on the loss function value of each iteration; it validates the iteratively trained emotion recognition model using the validation set, and obtains the trained emotion recognition model based on the emotion recognition results output by the iteratively trained emotion recognition model according to the validation set.

[0073] The acquisition module 303 is used to perform emotion recognition on email text using the emotion recognition model trained by the training module 302, and obtain the emotion category of the email text.

[0074] In one embodiment, the acquisition module 303 can input the email text with the emotion category to be identified into a trained emotion recognition model, and use the trained emotion recognition model to perform emotion recognition on the email text to obtain the emotion category of the email text.

[0075] The technical solution of this application embodiment defines an emotion recognition model based on a BERT pre-trained model; the pre-processed dataset is input into the emotion recognition model, and the emotion recognition model is trained using the dataset to obtain a trained emotion recognition model; the trained emotion recognition model is used to perform emotion recognition on email text to obtain the emotion category of the email text; the emotion recognition model is defined based on a BERT pre-trained model, and a trained emotion recognition model is obtained through training on a large number of email texts in the dataset. The emotion recognition model learns rich language representations and can capture deep semantics and emotional color in email text. Compared with the emotion recognition based on Naive Bayes classification algorithm or logistic regression classification algorithm of related technologies, the email text emotion recognition method of this application embodiment, which identifies the emotion category of email text through a trained emotion recognition model, is better able to handle and understand complex contexts, is better at capturing the contextual relationship between words in email text, and can consider the information of the whole sentence when processing each word. Even in long sentences, it can understand the subtle emotional changes in email text, thus enhancing the ability to recognize emotions in email text. The email text emotion recognition method of this application embodiment uses a trained emotion recognition model that can automatically learn features from email text in a dataset through training. It can automatically extract more comprehensive and accurate semantic features without manual intervention and can capture the non-linear relationship between features and emotions, thus classifying emotions more accurately. This email text emotion recognition method utilizes the trained emotion recognition model to perform emotion recognition on email text, obtaining the emotion category of the email text. It can perform emotion recognition on email text with complex semantics and emotional expression, obtaining comprehensive and accurate semantic features of the email text, improving the comprehensiveness and accuracy of email text emotion recognition. Customer service representatives can quickly understand the emotional tendency of email text based on its emotion category, providing data support for improving the efficiency of customer service in processing email text, responding to email text more specifically, and providing better service.

[0076] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated further here.

[0077] Figure 4 This is a schematic diagram of the structure of the emotion recognition model shown in the embodiments of this application.

[0078] See Figure 4 The emotion recognition model 1000 includes a memory 1010 and a processor 1020.

[0079] The processor 1020 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0080] Memory 1010 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. ROM may store static data or instructions required by processor 1020 or other modules of the computer. Permanent storage devices may be read-write storage devices. Permanent storage devices may be non-volatile storage devices that retain stored instructions and data even when the computer is powered off. In some embodiments, permanent storage devices use mass storage devices (e.g., magnetic or optical disks, flash memory) as permanent storage devices. In other embodiments, permanent storage devices may be removable storage devices (e.g., floppy disks, optical drives). System memory may be a read-write storage device or a volatile read-write storage device, such as dynamic random access memory. System memory may store some or all of the instructions and data required by the processor during operation. Furthermore, memory 1010 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (e.g., DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, the memory 1010 may include a removable storage device that is readable and / or writable, such as a laser disc (CD), a read-only digital multifunction optical disc (e.g., DVD-ROM, dual-layer DVD-ROM), a read-only Blu-ray disc, an ultra-high density optical disc, a flash memory card (e.g., SD card, mini SD card, Micro-SD card, etc.), a magnetic floppy disk, etc. Computer-readable storage media do not contain carrier waves or transient electronic signals transmitted wirelessly or via wired connections.

[0081] The memory 1010 stores executable code, which, when processed by the processor 1020, can cause the processor 1020 to execute part or all of the methods described above.

[0082] Furthermore, the method according to this application can also be implemented as a computer program or computer program product, which includes computer program code instructions for performing some or all of the steps in the method described above.

[0083] Alternatively, this application may be implemented as a computer-readable storage medium (or a non-transitory machine-readable storage medium or a machine-readable storage medium) storing executable code (or computer program or computer instruction code) thereon, which, when executed by the processor of an emotion recognition model (or electronic device, or server, etc.), causes the processor to perform part or all of the steps of the methods described above according to this application.

[0084] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for email text sentiment recognition, characterized in that: Defining an emotion recognition model based on a BERT pre-trained model; The preprocessed dataset is input into the emotion recognition model, and the emotion recognition model is trained using the dataset to obtain the trained emotion recognition model. The trained emotion recognition model is used to perform emotion recognition on email text to obtain the emotion category of the email text.

2. The method according to claim 1, characterized in that, The emotion recognition model defined based on the BERT pre-trained model includes: defining the parameters of the emotion recognition model based on the BERT pre-trained model, wherein the parameters include one or more of the following: loss function, hyperparameters, learning rate, and emotion category.

3. The method according to claim 2, characterized in that, The step of inputting the preprocessed dataset into the emotion recognition model includes: The dataset is composed of a set number of email texts. The email texts in the dataset are labeled with different emotion categories to obtain the labeled dataset; The labeled dataset is divided into a training set and a validation set. The training set and validation set are input into the emotion recognition model.

4. The method according to claim 3, characterized in that, The step of training the emotion recognition model using the dataset to obtain the trained emotion recognition model includes: The emotion recognition model is iteratively trained using the training set, and the loss function value of the emotion recognition model is calculated for each iteration of the training based on the loss function. Based on the loss function value, the iterative training of the emotion recognition model ends; Based on the emotion recognition model trained iteratively, the emotion category and confusion matrix are output by performing emotion recognition on the validation set to obtain the trained emotion recognition model.

5. The method according to claim 4, characterized in that, The step of performing emotion recognition on the validation set based on the iteratively trained emotion recognition model to output the emotion category and confusion matrix, and obtaining the trained emotion recognition model, includes: The emotion recognition model after iterative training is validated using the validation set to obtain the emotion category and confusion matrix corresponding to the validation set, which are output by the iteratively trained emotion recognition model for the validation set. Based on the emotion category and confusion matrix corresponding to the validation set, calculate the accuracy and recall of the emotion recognition model after iterative training; If the accuracy rate meets the set accuracy rate, then the trained emotion recognition model is obtained; and / or, If the recall rate meets the set recall rate, then the trained emotion recognition model is obtained.

6. The method according to claim 5, characterized in that, The method further includes: If the accuracy rate does not meet the set accuracy rate, the emotion recognition model is iteratively trained using the training set, and the loss function value for each iteration of the training is calculated based on the loss function; and / or, If the recall rate does not meet the set recall rate, the emotion recognition model is iteratively trained using the training set, and the loss function value of each iteration of the training is calculated based on the loss function.

7. The method according to any one of claims 1-6, characterized in that: The emotion categories include no emotion, slight disappointment, great disappointment, anger, and satisfaction.

8. A mood recognition device for email text, characterized in that, include: The definition module is used to define an emotion recognition model based on a BERT pre-trained model. The training module is used to input the preprocessed dataset into the emotion recognition model defined by the definition module, and to train the emotion recognition model using the dataset to obtain the trained emotion recognition model. The acquisition module is used to perform emotion recognition on email text using the emotion recognition model trained by the training module, and obtain the emotion category of the email text.

9. An emotion recognition model, characterized in that, include: processor; as well as A memory having executable code stored thereon, which, when executed by the processor, causes the processor to perform the method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: It stores executable code that, when executed by the processor of the emotion recognition model, causes the processor to perform the method as described in any one of claims 1-7.