Opinion classification model training method, opinion classification method, device and medium
By training the opinion classification model through the gated recurrent unit neural network model, the problem of low efficiency of opinion classification in the customer service system is solved, efficient opinion information mining and classification is achieved, and labor costs are reduced.
Patent Information
- Application Number
- CN202311253073.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2043-09-26
AI Technical Summary
In the existing technology, the customer service system is inefficient in classifying user feedback and is unable to efficiently mine effective information, resulting in high labor costs and untimely information processing.
The opinion classification model is trained using a gated recurrent unit neural network model. The parameters are optimized through loss functions and optimization algorithms. Combined with word embedding technology and cross-entropy loss function, efficient classification of opinion word segmentation feature vectors is achieved to predict question categories and sentiment categories.
It improves the accuracy and efficiency of opinion classification, can efficiently mine the question category and sentiment category information in opinions, reduce labor costs and improve work efficiency.
Smart Images

Figure CN117194664B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates at least to the field of data analysis technology, and in particular to an opinion classification model training method, an opinion classification method, an opinion classification model training device, an opinion classification device, and a computer-readable storage medium. Background Art
[0002] With the large amount of user feedback received by the customer service system, it is necessary to categorize and organize repeated and similar feedback to understand the different types of problems in the operator system, the frequency of problems, and the user's emotional experience of the problems. Obviously, categorizing feedback based solely on simple category fields or manually identifying and categorizing similar feedback results in high labor costs, low work efficiency, and an inability to timely extract useful information from the feedback. Summary of the Invention
[0003] The technical problem to be solved by the present disclosure is to address the above-mentioned deficiencies and provide an opinion classification model training method, an opinion classification method, an opinion classification model training device, an opinion classification device and a computer-readable storage medium to solve the problem of how to fully mine the effective information in user feedback opinions.
[0004] In a first aspect, the present disclosure provides a method for training an opinion classification model, comprising:
[0005] Obtaining a training set including multiple historical opinion classification data, each historical opinion classification data including: a historical opinion word segmentation feature vector, an actual question category vector, and an actual sentiment category vector;
[0006] The historical opinion segmentation feature vector in the training set is used as the training input of the iterative opinion classification model to obtain the training output question category vector and the training output sentiment category vector.
[0007] The loss function is used to calculate the average loss between the training output question category vector and the training output emotion category vector and the actual question category vector and the actual emotion category vector.
[0008] The optimization algorithm is used to control the parameter update and iteration of the opinion classification model so that the average loss is gradually reduced.
[0009] Until the training end condition is reached, the trained opinion classification model is obtained.
[0010] Furthermore, a training set including multiple historical opinion classification data is obtained, specifically including:
[0011] Label historical opinion texts with question categories and sentiment categories;
[0012] Perform word segmentation feature extraction on each historical opinion text to obtain a historical opinion word segmentation feature vector;
[0013] According to the number n and m of question categories and sentiment categories, for each historical opinion segmentation feature vector, the dimension where the marked question category and sentiment category are located is assigned a, and the remaining dimensions are assigned b, where a≠b, to obtain an n-dimensional actual question category vector and an m-dimensional actual sentiment category vector;
[0014] Combine each historical opinion word segmentation feature vector with the corresponding actual question category vector and actual sentiment category vector to obtain classification data for each historical opinion;
[0015] All historical opinion classification data are divided into training set and test set.
[0016] Furthermore, before using the historical opinion segmentation feature vectors in the training set as training inputs for the iterative opinion classification model, the training method further includes:
[0017] Select the gated recurrent unit neural network model as the opinion classification model, and set the weights and activation functions of the reset gate and update gate of the gated recurrent unit neural network model.
[0018] Furthermore, the historical opinion segmentation feature vectors in the training set are used as the training input of the iterative opinion classification model to obtain the training output question category vector and the training output sentiment category vector, specifically including:
[0019] Input the historical opinion segmentation feature vector in the training set into the input layer of the gated recurrent unit neural network model obtained in each iteration;
[0020] The input layer is trained with the hidden layer of the gated recurrent unit neural network model obtained in each iteration. During the training, the reset gate and the update gate each calculate a gate value according to the weight and activation function, and the update of the hidden layer state of the neural network is jointly adjusted according to the respective gate values.
[0021] Obtain the training output question category vector and the training output emotion category vector of the output layer of the gated recurrent unit neural network model obtained at each iteration after the hidden layer training.
[0022] Furthermore, the average loss between the training output question category vector and the training output emotion category vector and the actual question category vector and the actual emotion category vector is calculated using a loss function, specifically including:
[0023] The average cross entropy loss for each training is calculated according to the following formula:
[0024] loss=-1 / (k*(n+m))*∑(y*log(y_pred)+(1-y)*log(1-y_pred))
[0025] At this time, a=1, b=0, where: k is the number of historical opinion classification data in the training set, y is each dimension of the actual question category vector and the actual sentiment category vector, and y_pred is each dimension of y corresponding to the training output question category vector and the training output sentiment category vector.
[0026] Furthermore, an optimization algorithm is used to control the parameter update and iteration of the opinion classification model so that the average loss is gradually reduced, specifically including:
[0027] Along the gradient direction that reduces the average loss, the updated parameter new_weight of the opinion classification model is obtained according to the following formula:
[0028] new_weight=weight-learning_rate*gradient
[0029] Where: weight is the current weight value, gradient is the gradient of the loss function with respect to the weight, and learning_rate is the learning rate;
[0030] Use new_weight to update the opinion classification model used in the next iteration of training.
[0031] Furthermore, after obtaining the trained opinion classification model, the training method further includes:
[0032] Input the historical opinion segmentation feature vector in the test set into the trained opinion classification model to obtain the test output question category vector and the test output sentiment category vector.
[0033] Calculate a first model performance evaluation value between the test output question category vector and the actual question category vector, and a second model performance evaluation value between the test output emotion category vector and the actual emotion category vector,
[0034] In response to the first model performance evaluation value being less than a first preset value and / or the second model performance evaluation value being less than a second preset value, the opinion classification model is retrained.
[0035] In a second aspect, the present disclosure provides an opinion classification method, comprising:
[0036] Perform word segmentation feature extraction on the opinion text to be analyzed to obtain the word segmentation feature vector of the opinion to be analyzed;
[0037] Input the opinion segmentation feature vector to be analyzed into the trained opinion classification model obtained according to the opinion classification model training method described above to obtain a predicted question category vector and a predicted sentiment category vector;
[0038] Obtain the question category description and emotion category description corresponding to the predicted question category vector and the predicted emotion category vector;
[0039] The opinion text to be analyzed is classified according to the problem category description and the sentiment category description.
[0040] In a third aspect, the present disclosure provides an opinion classification model training device, comprising:
[0041] A first data processing module is used to obtain a training set including a plurality of historical opinion classification data, each of which includes: a historical opinion segmentation feature vector, an actual question category vector, and an actual emotion category vector;
[0042] The model training module is connected to the first data processing module and is used to:
[0043] The historical opinion segmentation feature vector in the training set is used as the training input of the iterative opinion classification model to obtain the training output question category vector and the training output sentiment category vector.
[0044] The loss function is used to calculate the average loss between the training output question category vector and the training output emotion category vector and the actual question category vector and the actual emotion category vector.
[0045] The optimization algorithm is used to control the parameter update and iteration of the opinion classification model so that the average loss is gradually reduced.
[0046] Until the training end condition is reached, the trained opinion classification model is obtained.
[0047] In a fourth aspect, the present disclosure provides an opinion classification device, comprising:
[0048] The second data processing module is used to extract word segmentation features of the opinion text to be analyzed to obtain a word segmentation feature vector of the opinion to be analyzed;
[0049] A prediction module, connected to the second data processing module, configured to input the opinion segmentation feature vector to be analyzed into the trained opinion classification model obtained according to the opinion classification model training method described above, to obtain a predicted question category vector and a predicted sentiment category vector;
[0050] The description module is connected to the prediction module and is used to obtain the problem category description and the emotion category description corresponding to the predicted problem category vector and the predicted emotion category vector;
[0051] The classification module is connected to the description module and is used to classify the opinion text to be analyzed according to the problem category description and the sentiment category description.
[0052] In a fifth aspect, the present disclosure provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the opinion classification model training method and / or the opinion classification method as described above are implemented.
[0053] The present disclosure provides an opinion classification model training method, an opinion classification method, a corresponding device and a medium. By training the opinion classification model on the historical opinion word segmentation feature vectors, the actual question category vectors and the actual emotion category vectors of the historical opinion classification data, a trained opinion classification model is obtained, which can simultaneously predict the question category vectors and the emotion category vectors based on the opinion word segmentation feature vectors. During the training process, the loss function and the optimization algorithm are used to improve the accuracy of the model in predicting the question category and the emotion category, so that the obtained opinion classification model can simultaneously and efficiently mine the question category information and the emotion category information in the opinions, thereby improving the model's efficiency in information mining and classification of opinions. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 is a flow chart of a method for training an opinion classification model according to an embodiment of the present disclosure;
[0055] Figure 2 is a flow chart of an opinion classification method according to an embodiment of the present disclosure;
[0056] Figure 3 is a flow chart of another opinion classification method according to an embodiment of the present disclosure;
[0057] Figure 4 Schematic diagram of the structure of an opinion classification model training device according to an embodiment of the present disclosure;
[0058] Figure 5 It is a structural diagram of an opinion classification device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0059] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the embodiments of the present disclosure will be described in further detail below with reference to the accompanying drawings.
[0060] It should be understood that the specific embodiments and drawings described herein are only used to explain the present disclosure rather than to limit the present disclosure.
[0061] It can be understood that, in the absence of conflict, the various embodiments and features in the embodiments of the present disclosure can be combined with each other.
[0062] It will be understood that, for the convenience of description, the drawings of the present disclosure only show parts related to the present disclosure, while parts irrelevant to the present disclosure are not shown in the drawings.
[0063] It can be understood that each unit and module involved in the embodiments of the present disclosure may correspond to only one physical structure, or may be composed of multiple physical structures, or multiple units and modules may be integrated into one physical structure.
[0064] It will be understood that, without conflict, the functions and steps marked in the flowcharts and block diagrams of the present disclosure may occur in an order different from that marked in the drawings.
[0065] It is understood that the flowcharts and block diagrams of the present disclosure illustrate the possible architectures, functions, and operations of the systems, devices, equipment, and methods according to the various embodiments of the present disclosure. Each box in the flowchart or block diagram may represent a unit, module, program segment, or code, which contains executable instructions for implementing the specified functions. Moreover, each box or combination of boxes in the block diagram and flowchart may be implemented by a hardware-based system that implements the specified functions, or by a combination of hardware and computer instructions.
[0066] It can be understood that the units and modules involved in the embodiments of the present disclosure can be implemented by software or hardware, for example, the units and modules can be located in a processor.
[0067] Example 1:
[0068] like Figure 1 As shown, the present disclosure provides an opinion classification model training method, the training method comprising:
[0069] S11. Obtain a training set including multiple pieces of historical opinion classification data, each piece of historical opinion classification data including: a historical opinion segmentation feature vector, an actual question category vector, and an actual sentiment category vector;
[0070] S12, using the historical opinion segmentation feature vector in the training set as the training input of the iterative opinion classification model, to obtain the training output question category vector and the training output sentiment category vector,
[0071] The loss function is used to calculate the average loss between the training output question category vector and the training output emotion category vector and the actual question category vector and the actual emotion category vector.
[0072] The optimization algorithm is used to control the parameter update and iteration of the opinion classification model so that the average loss is gradually reduced.
[0073] Until the training end condition is reached, the trained opinion classification model is obtained.
[0074] Specifically, in this embodiment, a new dimension for viewing data is added based on intelligent means, that is, feedback is classified based on similarity, which can be used to process user feedback received by the telecommunications customer service system, facilitate maintenance and management by customer service personnel, reduce labor costs, and improve work efficiency. By training the historical opinion word segmentation feature vectors, actual question category vectors, and actual emotion category vectors of the historical opinion classification data, an opinion classification model (also known as a similarity recognition model, a similarity analysis model, etc.) is obtained, which can simultaneously predict the question category vector and the emotion category vector based on the opinion word segmentation feature vector. During the training process, the loss function and optimization algorithm are used to improve the accuracy of the model's prediction of the question category and emotion category, so that the obtained opinion classification model can simultaneously and efficiently mine the question category information and emotion category information in the opinions, thereby improving the model's information mining and classification efficiency for opinions.
[0075] In a more specific example, this application includes two parts: one is the part of applying the model to classify opinions, including: using intelligent analysis technology to read the opinion feedback database, classifying similar data content through data preparation, feature extraction, and model application, and marking each data with a classification label, and then storing it in the database again. After the above analysis, the data in the database are marked with classification labels, and can be subsequently classified and displayed as needed; the other is the part of building and correcting the model (i.e., model training), including: using a classification vocabulary and opinion feedback templates to train the opinion feedback data, building a recurrent neural network model, model training and evaluation, and other steps to generate a similarity recognition model. Based on the classification results, manual review and processing are then performed. If the classification results are found to be incorrect, the opinion feedback data and the manually analyzed categories can be input into the similarity recognition model to correct the model analysis results and improve the subsequent recognition accuracy. The key technologies involved include: using a classification vocabulary and word embedding technology to digitize the opinion text, designing a learning model based on a gated recurrent unit (GRU), and using a cross-entropy loss function and a stochastic gradient descent algorithm to control the model training process.
[0076] In one embodiment, obtaining a training set including a plurality of historical opinion classification data specifically includes:
[0077] Label historical opinion texts with question categories and sentiment categories;
[0078] Perform word segmentation feature extraction on each historical opinion text to obtain a historical opinion word segmentation feature vector;
[0079] According to the number n and m of question categories and sentiment categories, for each historical opinion segmentation feature vector, the dimension where the marked question category and sentiment category are located is assigned a, and the remaining dimensions are assigned b, where a≠b, to obtain an n-dimensional actual question category vector and an m-dimensional actual sentiment category vector;
[0080] Combine each historical opinion word segmentation feature vector with the corresponding actual question category vector and actual sentiment category vector to obtain classification data for each historical opinion;
[0081] All historical opinion classification data are divided into training set and test set.
[0082] Specifically, in this embodiment, the model is trained using labeled historical opinion data, including:
[0083] 1) Data Preparation: First, you need to prepare a well-labeled telecom customer service feedback dataset. This dataset typically contains a series of comments or feedback text, along with corresponding labels indicating the type of feedback and whether the user's feedback sentiment is positive or negative. The dataset should be preprocessed, including tokenization, stop word removal, and case conversion. The following is an example of how to prepare a telecom customer service feedback dataset:
[0084] Example: Text data (comments) | Tags
[0085] Sorry, my network is so slow, please help me check | Network problem | Neutral emotion
[0086] My phone signal is always poor and I can't make calls | Signal issues | Negative emotions
[0087] I want to terminate my contract. Please tell me the specific process | Refund issues | Neutral sentiment
[0088] Bill error, incorrect charge amount | Billing issues | Negative sentiment
[0089] There are always problems with my top-up, and the money I recharged never arrives | Top-up issues | Negative emotions
[0090] In the above example, each row represents a user's feedback. The "Text Data" column contains the user's comments or feedback content, and the "Label" column is the label of the category to which the feedback belongs. To prepare such a dataset, you can obtain user feedback through different channels, such as online chat records, user-submitted feedback forms, social media, etc. Then, classify and annotate each feedback based on its content and context.
[0091] 2) Feature extraction: Apply a feature extraction method to the input text to convert the text into a numerical representation so that the neural network can process it. This time, word embedding is used. Word embedding is a technology that can map words to a vector space. Using word embedding is a common feature extraction method that can convert text data into a numerical representation while retaining the semantic relationship between words. In this embodiment, a pre-trained word embedding model can be used for feature extraction. The following is an example of how to use word embedding for feature extraction: Select a word embedding model: First, you need to select a suitable pre-trained word embedding model, such as Word2Vec, FastText, GloVe or BERT, etc. These models have been trained on large-scale text corpora and have learned to map words into high-dimensional vector spaces; Load a pre-trained word embedding model: Download and load the selected word embedding model. You can use Python's related libraries, such as Gensim (for Word2Vec), spaCy (for FastText), torchtext (for BERT), etc. After loading the model, you can use it to convert single words in the text data. Convert words to word embedding vectors; Preprocessing of text data: For the text data in the opinions, it is necessary to first perform preprocessing, including word segmentation, removal of stop words, lowercase, etc., which will make the text data more suitable for input into the word embedding model; Convert text to word embedding vectors: For each word in each text document, use the loaded word embedding model to convert it into the corresponding word embedding vector. Usually, the word embedding vectors of the words can be added or averaged to obtain a representation of the entire text document. For example, for a text document, the word embedding vectors of all its words can be added to obtain a document-level word embedding vector; Obtain feature representation: Ultimately, each text document will be represented as a numerical vector, which can be used as the input feature of the neural network, and these features can be used to train the text classification model. The following is a simple example that demonstrates how to use the Gensim library to load a pre-trained Word2Vec word embedding model and convert text data into word embedding vectors:
[0092] import gensim
[0093] from gensim.modles import word2Vec
[0094] #Load the pre-trained word2Vec model
[0095] word2vec_model=word2vec.load("path_to_word2vec_model")
[0096] # Sample text data
[0097] text="This application involves natural language processing tasks"
[0098] #Preprocess the text (word segmentation, removal of stop words, etc.)
[0099] #Omit text preprocessing steps
[0100] #Convert the words in the text into word embedding vectors and calculate the document vector
[0101] word=text.split()#word segmentation
[0102] word_vectors=[word2vec_model[word]for word in words if wordinword2vec_model]
[0103] #Calculate document vector
[0104] document_vector=sum(word_vectors) / len(word_vectors)if word_vectorselse None
[0105] #document_vector now contains the word embedding representation of the text document
[0106] 3) Constructing label vectors: In order to meet the needs of information mining of telecommunications customer service feedback data, two labels are set for text data, namely, question type labels and sentiment category labels. Question types may include network problems, signal problems, refund problems, bill problems, recharge problems, etc., and n types can be set manually according to the actual classification needs of the customer service system; sentiment classification is a task of text classification, and its goal is to determine the sentiment or emotion contained in the text. In the sentiment classification task, the text can be divided into m different sentiment categories according to specific needs, for example: positive sentiment: feedback from users expressing satisfaction with the product or service, negative sentiment: feedback from users expressing dissatisfaction with the product or service, neutral sentiment: users raising general questions or comments, and no expression Express obvious emotional tendencies, other emotional categories: other emotional categories can be defined as needed, such as suggestions, questions, etc.; since the number of categories is not fixed, in order to flexibly construct data, the labels are represented by vectors. For example, for the five types of questions mentioned above, the order of the five types of questions is first arranged, and then the labels of the specific question types are assigned in order. For example, when it belongs to a network problem, the vector is [1,0,0,0,0], and when it belongs to a signal problem, the vector is [0,1,0,0,0]. Similarly, the emotional classification is arranged in order of positive, negative, and neutral emotions. When it belongs to a positive emotion, the vector is [1,0,0], and so on. The use of vectors to represent all labels is not only convenient for representing classifications of multiple dimensions, but also convenient for testing subsequent model training.
[0107] 4) After digitizing all the prepared data, a data set that can be used for model training is obtained. In order to be able to test the effect of model training in a timely manner, the data set is divided into a training set and a test set.
[0108] In one embodiment, before using the historical opinion segmentation feature vectors in the training set as training inputs for the iterative opinion classification model, the training method further includes:
[0109] Select the gated recurrent unit neural network model as the opinion classification model, and set the weights and activation functions of the reset gate and update gate of the gated recurrent unit neural network model.
[0110] Specifically, in this embodiment, before training the model, a model structure for training is first constructed, a recurrent neural network is used to build a similarity analysis model, and a recurrent neural network model improved by a gated recurrent unit is used. By introducing reset gates and update gates, the problems of gradient vanishing and gradient exploding are alleviated, thereby better capturing long-term dependencies. Long-term dependencies refer to dependencies between distant time steps in sequence data. When processing long-term dependencies, traditional RNN models will face the problems of gradient vanishing and gradient exploding, making it difficult to correctly learn and capture such dependencies. By introducing reset gates and update gates, GRU can better handle long-term dependencies, effectively transmit and update information, and better capture and model long-term dependencies in sequence data in recurrent neural networks. Vanishing Gradient and Exploding Gradient are common training problems encountered in Recurrent Neural Networks (RNNs): Vanishing Gradient: When training an RNN model, during the iterative process of time expansion, the gradients are continuously multiplied during the back propagation process, causing the gradients to gradually become smaller and eventually approach zero. This makes it impossible for the network to effectively learn the dependencies in longer time series, and information cannot be transmitted and updated in the network; Exploding Gradient: In contrast to the vanishing gradient, the gradient value becomes very large during back propagation, resulting in excessive weight updates, making the model unstable and difficult to converge. To solve these problems, the gated recurrent unit introduces a reset gate and an update gate: Reset Gate: In the gated recurrent unit, the reset gate determines how much old information should be forgotten. It uses a sigmoid activation function to calculate a value between 0 and 1 to control whether the past state should be mixed into the current state; Update Gate: The update gate determines how much new information should be added to the current state. It uses another sigmoid activation function to calculate a value between 0 and 1. It determines the weight of the past state and the current input to determine the degree of update.
[0111] In one embodiment, the historical opinion segmentation feature vectors in the training set are used as the training input of the iterative opinion classification model to obtain the training output question category vector and the training output sentiment category vector, specifically including:
[0112] Input the historical opinion segmentation feature vector in the training set into the input layer of the gated recurrent unit neural network model obtained in each iteration;
[0113] The input layer is trained with the hidden layer of the gated recurrent unit neural network model obtained in each iteration. During the training, the reset gate and the update gate each calculate a gate value according to the weight and activation function, and the update of the hidden layer state of the neural network is jointly adjusted according to the respective gate values.
[0114] Obtain the training output question category vector and the training output emotion category vector of the output layer of the gated recurrent unit neural network model obtained at each iteration after the hidden layer training.
[0115] Specifically, in this embodiment, based on the above-mentioned gated recurrent unit neural network model, the model structure includes an input layer, a hidden layer, and an output layer. The hidden layer can have multiple layers, and the output layer includes two nodes for outputting a question category vector and a sentiment category vector. In the hidden layer training, the specific usage of the reset gate and the update gate in the gated recurrent unit is as follows: the input gate controls the influence of the input data of the current time step on the hidden state; the reset gate controls the influence of the previous hidden state on the input of the current time step; the update gate controls whether to update the hidden state, balancing the previous hidden state and the input of the current time step. Specifically, the reset gate and the update gate use a set of weights in the gated recurrent unit to calculate the gate value and adjust the update of the hidden state according to the gate value. This can effectively capture long-term dependencies and better handle the flow of information in the input sequence.
[0116] In one embodiment, the average loss between the training output question category vector and the training output emotion category vector and the actual question category vector and the actual emotion category vector is calculated using a loss function, specifically including:
[0117] The average cross entropy loss for each training is calculated according to the following formula:
[0118] loss=-1 / (k*(n+m))*∑(y*log(y_pred)+(1-y)*log(1-y_pred))
[0119] At this time, a=1, b=0, where: k is the number of historical opinion classification data in the training set, y is each dimension of the actual question category vector and the actual sentiment category vector, and y_pred is each dimension of y corresponding to the training output question category vector and the training output sentiment category vector.
[0120] Specifically, after dividing the dataset into training and test sets, the training set is used to train the similarity analysis model. During the model training process, it is necessary to define a loss function (cross-entropy loss function) and an optimization algorithm (stochastic gradient descent algorithm), and gradually update the model parameters based on the samples in the training set. A commonly used loss function is the cross-entropy loss function (Cross-Entropy Loss), which is used to measure the difference between the model output and the sample label. The formula is as follows: loss = -1 / k*∑(y*log(y_pred)+(1-y)*log(1-y_pred)), where "y" is the actual label value (for example, 0 for negative sentiment and 1 for positive sentiment), and "y_pred" is the model's predicted output. This formula is averaged over k samples to obtain the final average cross-entropy loss. In this embodiment, the above formula needs to be improved to: loss = -1 / (k*(n+m))*∑(y*log(y_pred)+(1-y)*log(1-y_pred)). This is because this embodiment uses a vector to represent the output, calculates the difference between the output and the label once for each dimension of the vector, and then averages the total. To adapt to the above formula, the assignment is represented by 0 and 1, and the difference in each dimension can be obtained in a balanced manner. When other values are used for the assignment, the above formula can be adaptively modified.
[0121] In one embodiment, an optimization algorithm is used to control the parameter update and iteration of the opinion classification model so as to gradually reduce the average loss, specifically including:
[0122] Along the gradient direction that reduces the average loss, the updated parameter new_weight of the opinion classification model is obtained according to the following formula:
[0123] new_weight=weight-learning_rate*gradient
[0124] Where: weight is the current weight value, gradient is the gradient of the loss function with respect to the weight, and learning_rate is the learning rate;
[0125] Use new_weight to update the opinion classification model used in the next iteration of training.
[0126] Specifically, the optimization algorithm usually uses the stochastic gradient descent (SGD) algorithm or its variants. Stochastic gradient descent is a gradient-based optimization algorithm used to adjust the parameters of the model and minimize the loss function. In this embodiment, the basic idea is to adjust the parameters in small steps along the gradient direction of the loss function. The formula is as follows: new_weight = weight - learning_rate * gradient, where "weight" is the value of the current weight, "gradient" is the gradient (slope) of the loss function with respect to the weight, and "learning_rate" is the learning rate, which is a hyperparameter that controls the step size of each gradient update. During the training process, the gradient of the loss function is calculated and an optimization algorithm (such as SGD) is used to update the parameters of the model. The model gradually reduces the value of the loss function through continuous iteration and parameter updates, thereby improving the prediction accuracy of the model.
[0127] In one embodiment, after obtaining the trained opinion classification model, the training method further includes:
[0128] Input the historical opinion segmentation feature vector in the test set into the trained opinion classification model to obtain the test output question category vector and the test output sentiment category vector.
[0129] Calculate a first model performance evaluation value between the test output question category vector and the actual question category vector, and a second model performance evaluation value between the test output emotion category vector and the actual emotion category vector,
[0130] In response to the first model performance evaluation value being less than a first preset value and / or the second model performance evaluation value being less than a second preset value, the opinion classification model is retrained.
[0131] Specifically, in this embodiment, a test set is used to evaluate the performance of the trained model. Common evaluation indicators include accuracy, precision, recall, and F1 value. Model parameters can be optimized or the model structure can be adjusted based on the evaluation results. In this embodiment, since there are two types of prediction results, they can be evaluated separately. After the evaluation, if the evaluation results do not meet the requirements, targeted model improvement training can be carried out. For example, if the question classification results do not meet expectations, the question classification part can be retrained separately. If the sentiment classification results do not meet expectations, the sentiment classification part can be retrained separately. If both do not meet the standards, the entire model can be retrained.
[0132] Common evaluation metrics include: Accuracy: This is calculated as the ratio of the number of samples correctly predicted by the model to the total number of samples, using the following formula: accuracy = (TP + TN) / (TP + TN + FP + FN), where TP represents true positives, TN represents true negatives, FP represents false positives, and FN represents false negatives. For example, if there are 100 samples in the test set, 80 of them are correctly classified as positive (TP = 80), 10 are incorrectly classified as positive (FP = 10), 5 are correctly classified as negative (TN = 5), and 5 are incorrectly classified as negative (FN = 5), then the accuracy is (80 + 5) / 100 = 0.85, or 85%. Precision: Calculates the proportion of true positive examples among the samples predicted by the model as positive. The formula is as follows: precision = TP / (TP+FP). For example, if the model predicts 100 samples as positive (TP=80, FP=10), the precision is 80 / (80+10) = 0.89, or 89%. Recall: Calculates the proportion of samples correctly predicted as positive to the number of true positive examples. The formula is as follows: recall = TP / (TP+FN). For example, if there are 90 positive examples in the test set (TP=80, FN=10), the recall is 80 / (80+10) = 0.89, or 89%. F1 value: The F1 value is the harmonic average of precision and recall, which comprehensively considers the performance of precision and recall. The formula is as follows: F1 = 2*(precision*recall) / (precision+recall). For example, if the precision is 0.89 and the recall is 0.89, then the F1 value is 2*(0.89*0.89) / (0.89+0.89)=0.89.
[0133] After evaluating the model, you can optimize the model parameters or adjust the model structure based on the evaluation results to further improve the model performance. Some optimization and adjustment methods include: Parameter tuning: Adjust the hyperparameters of the model, such as learning rate, regularization coefficient, hidden layer size, etc. You can use grid search, Bayesian optimization and other methods to find the optimal parameter combination. Model structure adjustment: Try to use a deeper network structure, increase the width and depth of the model, add regularization layers or batch normalization layers, etc. to improve model performance. Data enhancement: Use data enhancement techniques (such as rotation, translation, scaling, adding noise, etc.) to expand the training data and improve the generalization ability of the model. Transfer learning: You can use pre-trained models (such as BERT, GloVe, etc.) to initialize the model parameters and fine-tune them on the current task to improve model performance. Ensemble learning: Try to use ensemble learning methods (such as voting, averaging, stacking, etc.) to combine the prediction results of multiple models to obtain better performance.
[0134] Example 2:
[0135] like Figure 2 As shown, the present disclosure provides an opinion classification method, which includes:
[0136] S21, extracting word segmentation features from the opinion text to be analyzed to obtain a word segmentation feature vector for the opinion to be analyzed;
[0137] S22. Input the opinion segmentation feature vector to be analyzed into the trained opinion classification model obtained according to the opinion classification model training method to obtain a predicted question category vector and a predicted emotion category vector;
[0138] S23, obtaining the question category description and the emotion category description corresponding to the predicted question category vector and the predicted emotion category vector;
[0139] S24. Classify the opinion text to be analyzed according to the problem category description and the sentiment category description.
[0140] Specifically, in this embodiment, the opinion classification model training method is as described in Example 1. After the model training and evaluation of Example 1 are completed, the model can be used to predict the question and sentiment classification of unlabeled new feedback text. A more specific example of the above method is as follows: Figure 3 Shown, including:
[0141] 1) Obtaining opinion data to be analyzed, specifically, connecting to and reading an opinion feedback database, and obtaining data for classification in batches;
[0142] 2) Data is input into the opinion classification model. Specifically, the data can be passed into the trained recurrent neural network model after feature extraction to cluster the text;
[0143] 3) Classify the opinions according to the classification results. Specifically, the clustered data can be marked with classification identifiers according to the classification vocabulary to facilitate subsequent classification and viewing by customer service personnel. The classification vocabulary is a list of predefined words or phrases used to mark the classification identifiers of the clustered data. These words or phrases are usually keywords related to the feedback field and are used to describe the theme or problem of the feedback. A common method of constructing a classification vocabulary is through manual annotation. Professionals or domain experts read and analyze some sample data, and then extract related themes or problems based on the keywords or phrases that appear in them. These keywords or phrases can include specific product names, common problems, descriptive words, etc. The clustering data can be labeled based on the words or phrases in the classification vocabulary to determine the corresponding classification identifier. For each cluster, the degree of match between the feedback and the keywords in the classification vocabulary can be calculated, and the keyword with the highest match can be selected as the classification identifier for the cluster. The matching of multiple keywords can also be considered as needed for more fine-grained classification. Based on the classification identifier, customer service staff can easily view and filter feedback belonging to different categories. The classification identifier can be used to store the clustered data in a specific category folder or add the classification identifier as an additional column to the original data for subsequent review and analysis.
[0144] 4) Review whether the classification is correct, specifically by manually intervening to check the accuracy of the clustered data;
[0145] 5) Increase model training data and perform model correction. If the classification results are found to be incorrect, the feedback data and the classification of manual analysis can be input into the opinion classification model to correct the model analysis results and improve the subsequent recognition accuracy.
[0146] Example 3:
[0147] like Figure 4 As shown, the present disclosure provides an opinion classification model training device, the training device comprising:
[0148] A first data processing module 11 is configured to obtain a training set comprising a plurality of historical opinion classification data, each of which comprises: a historical opinion segmentation feature vector, an actual question category vector, and an actual sentiment category vector;
[0149] The model training module 12 is connected to the first data processing module 11 and is used to:
[0150] The historical opinion segmentation feature vector in the training set is used as the training input of the iterative opinion classification model to obtain the training output question category vector and the training output sentiment category vector.
[0151] The loss function is used to calculate the average loss between the training output question category vector and the training output emotion category vector and the actual question category vector and the actual emotion category vector.
[0152] The optimization algorithm is used to control the parameter update and iteration of the opinion classification model so that the average loss is gradually reduced.
[0153] Until the training end condition is reached, the trained opinion classification model is obtained.
[0154] In one embodiment, the first data processing module 11 specifically includes:
[0155] Annotation unit, used to annotate historical opinion texts with question categories and sentiment categories;
[0156] A feature extraction unit is used to extract word segmentation features from each historical opinion text to obtain a historical opinion word segmentation feature vector;
[0157] The classification assignment unit is used to assign a value to the dimension where the marked question category and sentiment category are located, and b value to the remaining dimensions, where a≠b, according to the number of question categories and sentiment categories n and m, respectively, corresponding to each historical opinion segmentation feature vector, to obtain an n-dimensional actual question category vector and an m-dimensional actual sentiment category vector;
[0158] A data combination unit is used to combine each historical opinion segmentation feature vector with the corresponding actual question category vector and actual sentiment category vector to obtain classification data for each historical opinion;
[0159] The data partitioning unit is used to divide all historical opinion classification data into a training set and a test set.
[0160] In one embodiment, the model training module 12 further includes:
[0161] The model setting unit is used to select the gated recurrent unit neural network model as the opinion classification model and set the weights and activation functions of the reset gate and update gate of the gated recurrent unit neural network model.
[0162] In one embodiment, the model training module 12 specifically includes:
[0163] The input layer unit is used to input the historical opinion segmentation feature vector in the training set into the input layer of the gated recurrent unit neural network model obtained in each iteration;
[0164] Hidden layer unit, used to train the hidden layer of the gated recurrent unit neural network model obtained by each iteration of the input layer. During training, the reset gate and the update gate each calculate the gate value according to the weight and activation function, and jointly adjust the update of the hidden layer state of the neural network according to their respective gate values;
[0165] The output layer unit is used to obtain the training output question category vector and the training output emotion category vector of the output layer of the gated recurrent unit neural network model obtained in each iteration after the hidden layer training.
[0166] In one embodiment, the model training module 12 specifically includes:
[0167] The loss calculation unit is used to calculate the average cross entropy loss of each training according to the following formula:
[0168] loss=-1 / (k*(n+m))*∑(y*log(y_pred)+(1-y)*log(1-y_pred))
[0169] At this time, a=1, b=0, where: k is the number of historical opinion classification data in the training set, y is each dimension of the actual question category vector and the actual sentiment category vector, and y_pred is each dimension of y corresponding to the training output question category vector and the training output sentiment category vector.
[0170] In one embodiment, the model training module 12 specifically includes:
[0171] The optimization iteration unit is used to obtain the updated parameter new_weight of the opinion classification model according to the following formula along the gradient direction that reduces the average loss:
[0172] new_weight=weight-learning_rate*gradient
[0173] Where: weight is the current weight value, gradient is the gradient of the loss function with respect to the weight, and learning_rate is the learning rate;
[0174] Use new_weight to update the opinion classification model used in the next iteration of training.
[0175] In one embodiment, the training device further comprises a model verification module for:
[0176] Input the historical opinion segmentation feature vector in the test set into the trained opinion classification model to obtain the test output question category vector and the test output sentiment category vector.
[0177] Calculate a first model performance evaluation value between the test output question category vector and the actual question category vector, and a second model performance evaluation value between the test output emotion category vector and the actual emotion category vector,
[0178] In response to the first model performance evaluation value being less than a first preset value and / or the second model performance evaluation value being less than a second preset value, the opinion classification model is retrained.
[0179] Example 4:
[0180] like Figure 5 As shown, the present disclosure provides an opinion classification device, comprising:
[0181] The second data processing module 21 is used to extract word segmentation features of the opinion text to be analyzed to obtain a word segmentation feature vector of the opinion to be analyzed;
[0182] A prediction module 22, connected to the second data processing module 21, is configured to input the opinion segmentation feature vector to be analyzed into the trained opinion classification model obtained according to the opinion classification model training method described in Example 1 to obtain a predicted question category vector and a predicted sentiment category vector;
[0183] The description module 23 is connected to the prediction module 22 and is used to obtain the question category description and the emotion category description corresponding to the predicted question category vector and the predicted emotion category vector;
[0184] The classification module 24 is connected to the description module 23 and is used to classify the opinion text to be analyzed according to the question category description and the emotion category description.
[0185] Specifically, the opinion classification device described in this embodiment can be integrated with the opinion classification model training device described in Example 3, and the second data processing module 21 can be included in the first data processing module 11. Figure 3 After the apparatus of this embodiment completes the opinion classification, the opinion classification model can be retrained.
[0186] Example 5:
[0187] Embodiment 5 of the present disclosure provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the opinion classification model training method described in embodiment 1 and / or the opinion classification method described in embodiment 2 are implemented.
[0188] The computer-readable storage medium includes volatile or non-volatile, removable or non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, computer program modules or other data). Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable read only memory), flash memory or other memory technology, CD-ROM (Compact Disc Read-Only Memory), digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer.
[0189] In addition, the present disclosure may also provide a computer device, including a memory and a processor, wherein a computer program is stored in the memory. When the processor runs the computer program stored in the memory, the processor executes the opinion classification model training method described in Example 1 and / or the opinion classification method described in Example 2.
[0190] The memory is connected to the processor, the memory may be a flash memory, a read-only memory or other memory, and the processor may be a central processing unit or a single-chip microcomputer.
[0191] Embodiments 1-5 of the present disclosure provide an opinion classification model training method, an opinion classification method, a corresponding device and a medium. By training the opinion classification model on the historical opinion word segmentation feature vectors, the actual question category vectors and the actual emotion category vectors of the historical opinion classification data, a trained opinion classification model is obtained, which can simultaneously predict the question category vector and the emotion category vector based on the opinion word segmentation feature vectors. During the training process, the loss function and the optimization algorithm are used to improve the accuracy of the model's prediction of the question category and the emotion category, so that the obtained opinion classification model can simultaneously and efficiently mine the question category information and the emotion category information in the opinions, thereby improving the model's efficiency in information mining and classification of opinions.
[0192] It is understood that the above embodiments are only intended to illustrate the principles of the present disclosure.
[0193] The exemplary embodiments are used, but the present disclosure is not limited thereto.
[0194] It is for ordinary technicians in the field to
[0195] Various modifications and improvements can be made, which are also considered as the present disclosure.
[0196] Scope of protection.
Claims
1. A method for training an opinion classification model, characterized in that: include: Obtain a training set including multiple historical opinion classification data. Each historical opinion classification data includes: historical opinion word segmentation feature vector, actual question category vector and actual sentiment category vector, specifically including: Label the historical opinion text with question categories and sentiment categories. Perform word segmentation feature extraction on each historical opinion text to obtain the historical opinion word segmentation feature vector. According to the number n and m of question categories and sentiment categories, the dimension of the marked question category and sentiment category is assigned a for each historical opinion segmentation feature vector, and the remaining dimensions are assigned b, a≠b, to obtain the n-dimensional actual question category vector and the m-dimensional actual sentiment category vector. Combine each historical opinion segmentation feature vector with the corresponding actual question category vector and actual sentiment category vector to obtain the classification data of each historical opinion. Divide all historical opinion classification data into training set and test set; The historical opinion segmentation feature vector in the training set is used as the training input of the iterative opinion classification model to obtain the training output question category vector and the training output sentiment category vector. The loss function is used to calculate the average loss between the training output question category vector and the training output emotion category vector and the actual question category vector and the actual emotion category vector, including: The average cross entropy loss for each training is calculated according to the following formula: loss=-1 / (k*(n+m))*∑(y*log(y_pred)+(1-y)*log(1-y_pred)) At this time, a=1, b=0, where: k is the number of historical opinion classification data in the training set, y is each dimension of the actual question category vector and the actual sentiment category vector, y_pred is each dimension of y corresponding to the training output question category vector and the training output sentiment category vector, The optimization algorithm is used to control the parameter update and iteration of the opinion classification model so that the average loss is gradually reduced. Specifically, it includes: Along the gradient direction that reduces the average loss, the updated parameter new_weight of the opinion classification model is obtained according to the following formula: new_weight=weight-learning_rate*gradient Where: weight is the current weight value, gradient is the gradient of the loss function with respect to the weight, learning_rate is the learning rate, Use new_weight to update the opinion classification model used in the next iteration training. Until the training end condition is reached, the trained opinion classification model is obtained.
2. The opinion classification model training method according to claim 1, characterized in that: Before using the historical opinion segmentation feature vectors in the training set as the training input for the iterative opinion classification model, the following steps are also included: Select the gated recurrent unit neural network model as the opinion classification model, and set the weights and activation functions of the reset gate and update gate of the gated recurrent unit neural network model.
3. The opinion classification model training method according to claim 2, characterized in that: The historical opinion segmentation feature vectors in the training set are used as the training input of the iterative opinion classification model to obtain the training output question category vector and the training output sentiment category vector, specifically including: Input the historical opinion segmentation feature vector in the training set into the input layer of the gated recurrent unit neural network model obtained in each iteration; The input layer is trained with the hidden layer of the gated recurrent unit neural network model obtained in each iteration. During the training, the reset gate and the update gate each calculate a gate value according to the weight and activation function, and the update of the hidden layer state of the neural network is jointly adjusted according to the respective gate values. Obtain the training output question category vector and the training output emotion category vector of the output layer of the gated recurrent unit neural network model obtained at each iteration after the hidden layer training.
4. The opinion classification model training method according to claim 1, characterized in that: After obtaining the trained opinion classification model, it also includes: Input the historical opinion segmentation feature vector in the test set into the trained opinion classification model to obtain the test output question category vector and the test output sentiment category vector. Calculate a first model performance evaluation value between the test output question category vector and the actual question category vector, and a second model performance evaluation value between the test output emotion category vector and the actual emotion category vector, In response to the first model performance evaluation value being less than a first preset value and / or the second model performance evaluation value being less than a second preset value, the opinion classification model is retrained.
5. A method for classifying opinions, characterized in that: include: Perform word segmentation feature extraction on the opinion text to be analyzed to obtain the word segmentation feature vector of the opinion to be analyzed; Inputting the opinion segmentation feature vector to be analyzed into the trained opinion classification model obtained by the opinion classification model training method according to any one of claims 1 to 4 to obtain a predicted question category vector and a predicted emotion category vector; Obtain the question category description and emotion category description corresponding to the predicted question category vector and the predicted emotion category vector; The opinion text to be analyzed is classified according to the problem category description and the sentiment category description.
6. An opinion classification model training device, characterized in that: include: The first data processing module is used to obtain a training set including multiple historical opinion classification data, each of which includes: a historical opinion word segmentation feature vector, an actual question category vector, and an actual sentiment category vector, specifically for: Label the historical opinion text with question categories and sentiment categories. Perform word segmentation feature extraction on each historical opinion text to obtain the historical opinion word segmentation feature vector. According to the number n and m of question categories and sentiment categories, the dimension of the marked question category and sentiment category is assigned a for each historical opinion segmentation feature vector, and the remaining dimensions are assigned b, a≠b, to obtain the n-dimensional actual question category vector and the m-dimensional actual sentiment category vector. Combine each historical opinion segmentation feature vector with the corresponding actual question category vector and actual sentiment category vector to obtain the classification data of each historical opinion. Divide all historical opinion classification data into training set and test set; The model training module is connected to the first data processing module and is used to: The historical opinion segmentation feature vector in the training set is used as the training input of the iterative opinion classification model to obtain the training output question category vector and the training output sentiment category vector. The loss function is used to calculate the average loss between the training output question category vector and the training output emotion category vector and the actual question category vector and the actual emotion category vector. Specifically, it is used for: The average cross entropy loss for each training is calculated according to the following formula: loss=-1 / (k*(n+m))*∑(y*log(y_pred)+(1-y)*log(1-y_pred)) At this time, a=1, b=0, where: k is the number of historical opinion classification data in the training set, y is each dimension of the actual question category vector and the actual sentiment category vector, y_pred is each dimension of y corresponding to the training output question category vector and the training output sentiment category vector, The optimization algorithm is used to control the parameter update and iteration of the opinion classification model so that the average loss is gradually reduced. Specifically, it is used to: Along the gradient direction that reduces the average loss, the updated parameter new_weight of the opinion classification model is obtained according to the following formula: new_weight=weight-learning_rate*gradient Where: weight is the current weight value, gradient is the gradient of the loss function with respect to the weight, learning_rate is the learning rate, Use new_weight to update the opinion classification model used in the next iteration training. Until the training end condition is reached, the trained opinion classification model is obtained.
7. An opinion classification device, characterized in that: include: The second data processing module is used to extract word segmentation features of the opinion text to be analyzed to obtain a word segmentation feature vector of the opinion to be analyzed; A prediction module, connected to the second data processing module, configured to input the opinion segmentation feature vector to be analyzed into a trained opinion classification model obtained by the opinion classification model training method according to any one of claims 1 to 4, to obtain a predicted question category vector and a predicted emotion category vector; The description module is connected to the prediction module and is used to obtain the problem category description and the emotion category description corresponding to the predicted problem category vector and the predicted emotion category vector; The classification module is connected to the description module and is used to classify the opinion text to be analyzed according to the problem category description and the sentiment category description.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the opinion classification model training method according to any one of claims 1 to 4 and / or the opinion classification method according to claim 5 are implemented.
Citation Information
Patent Citations
User emotion analysis model training method and device, electronic equipment and storage medium
CN114925159A
Training method of pre-training language model and text sentiment classification method and device
CN116127062A