A data processing method, device, computer device, and storage medium
Through the feature processing and attribute fusion modules in the emotion classification model, the fusion vector representation of the emotion classification model is generated, which solves the problem of insufficient accuracy of emotion classification in the prior art and achieves more efficient emotion classification.
Patent Information
- Application Number
- CN202111017198.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-31
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2041-08-31
AI Technical Summary
The method of introducing attribute information through weight matrix and single-layer fully connected network or attention mechanism in the prior art has failed to significantly improve the accuracy of emotional classification and has a high calculation cost.
The feature processing module in the emotion classification model is used to extract feature vectors, combine the attribute fusion module to perform feature fusion, generate fusion vector representations through the full connection layer and the activation function, and finally generate emotional categories using the classification function.
It improves the accuracy and computing efficiency of emotional classification and simplifies the process of integrating attribute information.
Smart Images

Figure CN114328809B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technologies, and in particular, to a data processing method, apparatus, computer device, and storage medium. Background Art
[0002] In current sentiment classification methods, in order to improve the accuracy of sentiment classification, attribute information is generally considered to be introduced to improve accuracy. The attribute information includes user attribute information and product attribute information. Currently, the methods for introducing attribute information mainly include introducing attribute information through a weight matrix, introducing attribute information through a single-layer fully connected network, and introducing attribute information through an attention mechanism. However, the methods of introducing attribute information through a weight matrix and a single-layer fully connected network do not significantly improve the accuracy of sentiment classification, and introducing attribute information through an attention mechanism requires stacking multiple layers of attention, increasing the computational cost. Summary of the Invention
[0003] Embodiments of this application provide a data processing method, apparatus, computer device, and storage medium, which can improve the accuracy of sentiment classification and computational efficiency.
[0004] One aspect of the embodiments of this application provides a data processing method, which may include:
[0005] Obtain target corpus data for detecting sentiment categories;
[0006] Based on a feature processing module in a sentiment classification model, obtain a feature vector representation of the target corpus data;
[0007] Based on an attribute fusion module in the sentiment classification model, perform feature fusion on the feature vector representation and attribute information to generate a fusion vector representation of the target corpus data; the attribute fusion module includes attribute information;
[0008] Generate a sentiment category of the target corpus data according to the sentiment classification model and the fusion vector representation.
[0009] In a feasible implementation manner, it further includes:
[0010] Obtain an initial sentiment classification model and a set of sample corpus data; the initial sentiment classification model includes initial attribute information; the set of sample corpus data includes sample corpus data and sentiment category labels carried by the sample corpus data;
[0011] Based on the sample corpus data and the initial attribute information in the initial sentiment classification model, generate an initial sentiment category corresponding to the sample corpus data;
[0012] Generate a sentiment classification model based on the initial sentiment category corresponding to the sample corpus data and the sentiment category label carried by the sample corpus data.
[0013] In a feasible implementation manner, the generating the initial sentiment category corresponding to the sample corpus data based on the sample corpus data and the initial attribute information in the initial sentiment classification model includes:
[0014] Input the sample corpus data into the initial sentiment classification model, and obtain the initial feature vector representation of the sample corpus data through the initial feature processing module of the sentiment classification model;
[0015] Based on the initial attribute fusion module in the initial sentiment classification model, perform feature fusion on the initial feature vector representation and the initial attribute information to generate an initial fusion vector representation;
[0016] Generate an initial sentiment category according to the initial fusion vector representation and the initial sentiment classification model.
[0017] In a feasible implementation manner, the generating a sentiment classification model based on the initial sentiment category corresponding to the sample corpus data and the sentiment category label carried by the sample corpus data includes:
[0018] Adjust the model parameters of the initial sentiment classification model according to the initial sentiment category and the sentiment category label carried by the sample corpus data, where the model parameters of the initial sentiment classification model include the initial attribute information in the initial attribute fusion module;
[0019] When the adjusted initial sentiment classification model meets the convergence condition, determine the initial sentiment classification model including the adjusted model parameters as the sentiment classification model.
[0020] In a feasible implementation manner, the obtaining the feature vector representation of the target corpus data based on the feature processing module in the sentiment classification model includes:
[0021] Extract the word vectors of each word in all sentences in the target corpus data through the feature processing module in the sentiment classification model; the target corpus data includes multiple sentences, each sentence includes multiple words, and each word corresponds to a word vector;
[0022] Generate the feature vector representation corresponding to the target corpus data according to the word vectors corresponding to the target corpus data.
[0023] In a feasible implementation manner, the performing feature fusion on the feature vector representation and the attribute information based on the attribute fusion module in the sentiment classification model to generate the fusion vector representation of the target corpus data includes:
[0024] Based on the attribute fusion module in the sentiment classification model, vector splicing is performed on the feature vector representation and the attribute information to generate a spliced vector.
[0025] Through the fully connected layer and the activation function in the attribute fusion module, non-linear transformation is performed on the spliced vector to generate the fused vector representation corresponding to the target corpus data.
[0026] In a feasible implementation manner, the performing non-linear transformation on the spliced vector through the fully connected layer and the activation function in the attribute fusion module to generate the fused vector representation corresponding to the target corpus data includes:
[0027] Through the first weight matrix and the first bias vector corresponding to the first fully connected layer and the first activation function in the attribute fusion module, an intermediate fused vector representation is generated from the spliced vector.
[0028] Through the second weight matrix and the second bias vector corresponding to the second fully connected layer and the second activation function in the attribute fusion module, the fused vector representation corresponding to the target corpus data is generated from the intermediate fused vector representation.
[0029] In a feasible implementation manner, the generating the sentiment category of the target corpus data according to the sentiment classification model and the fused vector representation includes:
[0030] Based on the fully connected layer in the sentiment classification model, fully connected processing is performed on the fused vector representation to generate a fully connected vector.
[0031] Through the classification function in the sentiment classification model, the sentiment category of the target corpus data is generated based on the fully connected vector.
[0032] One aspect of the embodiments of the present application provides a data processing device, which may include:
[0033] A data acquisition unit, configured to acquire target corpus data for detecting sentiment categories.
[0034] A feature vector generation unit, configured to obtain the feature vector representation of the target corpus data based on the feature processing module in the sentiment classification model.
[0035] A fused vector generation unit, configured to perform feature fusion on the feature vector representation and the attribute information based on the attribute fusion module in the sentiment classification model to generate the fused vector representation of the target corpus data; the attribute fusion module includes attribute information.
[0036] A sentiment category generation unit, configured to generate the sentiment category of the target corpus data according to the sentiment classification model and the fused vector representation.
[0037] In a feasible implementation manner, it further includes:
[0038] A sample data acquisition unit, configured to acquire an initial sentiment classification model and a sample corpus data set; the initial sentiment classification model includes initial attribute information; the sample corpus data set includes sample corpus data and sentiment category labels carried by the sample corpus data;
[0039] An initial category generation unit, configured to generate an initial sentiment category corresponding to the sample corpus data based on the sample corpus data and the initial attribute information in the initial sentiment classification model;
[0040] A classification model generation unit, configured to generate a sentiment classification model based on the initial sentiment category corresponding to the sample corpus data and the sentiment category labels carried by the sample corpus data.
[0041] In a feasible implementation manner, the initial category generation unit is specifically configured to:
[0042] Input the sample corpus data into the initial sentiment classification model, and obtain an initial feature vector representation of the sample corpus data through an initial feature processing module of the sentiment classification model;
[0043] Based on an initial attribute fusion module in the initial sentiment classification model, perform feature fusion on the initial feature vector representation and the initial attribute information to generate an initial fusion vector representation;
[0044] Generate an initial sentiment category according to the initial fusion vector representation and the initial sentiment classification model.
[0045] In a feasible implementation manner, the classification model generation unit is specifically configured to:
[0046] Adjust model parameters of the initial sentiment classification model according to the initial sentiment category and the sentiment category labels carried by the sample corpus data, where the model parameters of the initial sentiment classification model include the initial attribute information in the initial attribute fusion module;
[0047] When the adjusted initial sentiment classification model meets the convergence condition, determine the initial sentiment classification model including the adjusted model parameters as the sentiment classification model.
[0048] In a feasible implementation manner, the feature vector generation unit is specifically configured to:
[0049] Extract word vectors of each word in all sentences in the target corpus data through a feature processing module in the sentiment classification model; the target corpus data includes multiple sentences, each sentence includes multiple words, and each word corresponds to a word vector;
[0050] Generate a feature vector representation corresponding to the target corpus data according to the word vectors corresponding to the target corpus data.
[0051] In a feasible implementation manner, the fusion vector generation unit includes:
[0052] A splicing vector generation subunit, configured to perform vector splicing on the feature vector representation and the attribute information based on the attribute fusion module in the sentiment classification model to generate a splicing vector;
[0053] A fusion vector generation subunit, configured to perform a non-linear transformation on the splicing vector through the fully connected layer and the activation function in the attribute fusion module to generate a fusion vector representation corresponding to the target corpus data.
[0054] In a feasible implementation manner, the fusion vector generation subunit is specifically configured to:
[0055] Generate an intermediate fusion vector representation from the splicing vector through the first weight matrix and the first bias vector corresponding to the first fully connected layer and the first activation function in the attribute fusion module;
[0056] Generate a fusion vector representation corresponding to the target corpus data from the intermediate fusion vector representation through the second weight matrix and the second bias vector corresponding to the second fully connected layer and the second activation function in the attribute fusion module.
[0057] In a feasible implementation manner, the sentiment category generation unit is specifically configured to:
[0058] Perform a fully connected process on the fusion vector representation based on the fully connected layer in the sentiment classification model to generate a fully connected vector;
[0059] Generate the sentiment category of the target corpus data based on the fully connected vector through the classification function in the sentiment classification model.
[0060] One aspect of the embodiments of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program is adapted to be loaded and executed by a processor to perform the above method steps.
[0061] One aspect of the embodiments of the present application provides a computer device, including: a processor, a memory, and a network interface; the processor is connected to the memory and the network interface, wherein the network interface is used to provide network communication functions, the memory is used to store program codes, and the processor is used to call the program codes to perform the above method steps.
[0062] One aspect of the embodiments of the present application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above method steps.
[0063] In the embodiments of the present application, by obtaining target corpus data for detecting emotion categories, and based on a feature processing module in an emotion classification model, obtaining a feature vector representation of the target corpus data, and further based on an attribute fusion module in the emotion classification model, performing feature fusion on the feature vector representation and attribute information to generate a fusion vector representation of the target corpus data. The attribute fusion module includes attribute information. Finally, an emotion category of the target corpus data is generated according to the emotion classification model and the fusion vector representation. By using the above method, the attribute information is incorporated into the feature vector representation of the target corpus data through a simple-structured attribute fusion module in the emotion classification model, improving the accuracy and computational efficiency of emotion classification of the target corpus data. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0065] Figure 1 is a network architecture diagram of data processing provided by the embodiments of the present application;
[0066] Figure 2 is a schematic flowchart of a data processing method provided by the embodiments of the present application;
[0067] Figure 3 is a schematic flowchart of a data processing method provided by the embodiments of the present application;
[0068] Figure 4a is an example schematic diagram of an attribute fusion module provided by the embodiments of the present application;
[0069] Figure 4b is an example schematic diagram of emotion classification based on BERT provided by the embodiments of the present application;
[0070] Figure 4c is an example schematic diagram of emotion classification based on the combination of BERT and an attribute fusion module provided by the embodiments of the present application;
[0071] Figure 5 It is a schematic structural diagram of a data processing device provided by an embodiment of the present application;
[0072] Figure 6 It is a schematic structural diagram of a computer device provided by an embodiment of the present application. Specific embodiments
[0073] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0074] Please refer to Figure 1 , Figure 1 It is a network architecture diagram of data processing provided by an embodiment of the present application. The network architecture diagram may include a service server 100 and a user terminal cluster. The user terminal cluster may include user terminals 10a, 10b,..., 10c. Among them, there may be communication connections between the user terminal clusters. For example, there is a communication connection between user terminal 10a and user terminal 10b, and there is a communication connection between user terminal 10b and user terminal 10c. Moreover, any user terminal in the user terminal cluster may have a communication connection with the service server 100. For example, there is a communication connection between user terminal 10a and service server 100, and there is a communication connection between user terminal 10b and service server 100.
[0075] Among them, the above user terminal cluster (including the above user terminals 10a, 10b, and 10c) can all be integrated with a target application installed. Optionally, the target application may include an application with functions of displaying data information such as text, images, and videos. The emotion classification model and the sample corpus data set for training and generating the emotion classification model are stored in the database 10d. In a feasible implementation manner, the user terminal obtains target corpus data for detecting emotion categories, and based on the feature processing module in the emotion classification model, obtains the feature vector representation of the target corpus data. The user terminal further, based on the attribute fusion module in the emotion classification model, performs feature fusion on the feature vector representation and the attribute information to generate the fusion vector representation of the target corpus data. The attribute fusion module includes attribute information. Finally, the user terminal generates the emotion category of the target corpus data according to the emotion classification model and the fusion vector representation. Optionally, the above user terminal may be any one of the user terminals selected in the user terminal cluster corresponding to the above Figure 1 corresponding embodiment, for example, the user terminal may be the above user terminal 10b.
[0076] It is understandable that the method provided by the embodiments of the present application can be executed by a computer device, which includes but is not limited to a terminal or a server. The service server 100 in the embodiments of the present application can be a computer device, and the user terminals in the user terminal cluster can also be computer devices, without limitation here. The above service server can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, as well as big data and artificial intelligence platforms. The above terminal can include: intelligent terminals with image recognition functions such as smart phones, tablet computers, laptop computers, desktop computers, smart TVs, smart speakers, desktop computers, smart watches, etc., but is not limited thereto. Among them, the user terminal and the service server can be directly or indirectly connected through wired or wireless communication methods, and the present application does not make any restrictions here.
[0077] Further, for ease of understanding, please refer to Figure 2 , Figure 2 which is a schematic flowchart of the data processing method provided by the embodiments of the present application. This method can be executed by a user terminal (for example, the user terminal shown above Figure 1 ), or jointly executed by a user terminal and a service server (such as the service server 100 in the corresponding embodiment above Figure 1 ). For ease of understanding, this embodiment will be described by taking the execution of this method by the above user terminal as an example. Among them, the data processing method can at least include the following steps S101-S104:
[0078] S101, obtaining target corpus data for detecting emotion categories;
[0079] Specifically, the user terminal can obtain the target corpus data. It is understandable that the target corpus data is used to detect emotion categories, and the emotion categories are the emotion polarity and emotion intensity of the user towards the corpus. For example, for user A, the emotion category of "good" means very good, and the emotion category of "bad" means very bad. The target corpus data is a piece of text, which can be Chinese, English or other types of languages. Specifically, it can be a passage containing a series of sentences. For example, the target corpus data is [s1,…,s i ,…s n , where s i is the i-th sentence in the passage.
[0080] S102, obtaining a feature vector representation of the target corpus data based on a feature processing module in an emotion classification model;
[0081] Specifically, the user terminal obtains the feature vector representation of the target corpus data based on the feature processing module in the sentiment classification model. It can be understood that the sentiment classification model is a classification model based on a classifier or a neural network combined with an attribute fusion module. The attribute fusion model is used to fuse the attribute information into the feature vector representation of the target corpus data. For example, the sentiment classification model can be a classification model based on BERT combined with an attribute fusion module or a classification model based on LSTM combined with an attribute fusion module.
[0082] The specific steps for obtaining the feature vector representation of the target corpus data are as follows: The user terminal extracts the word vectors of each word in all sentences of the target corpus data through the feature processing module in the sentiment classification model. The feature extraction module is used to extract the word vectors of the target corpus data. Specifically, in BERT, the feature extraction module is the word vector layer and the encoding layer. The target corpus data includes multiple sentences, each sentence includes multiple words, and each word corresponds to a word vector. Further, according to the word vectors corresponding to the target corpus data, the feature vector representation corresponding to the target corpus data is generated.
[0083] The following takes a passage containing a series of sentences as the target corpus data for illustration. The sentiment classification model is a classification model based on BERT combined with an attribute fusion module, and the target corpus data is [s1,…,s i ,…s n , where s i is the i-th sentence in the passage. w ij represents the j-th word in the i-th sentence of the passage, and l i is the length of the sentence. First, the target corpus data is input into the word vector layer to obtain the word vectors where E ij refers to the vector representation of the corresponding word. d e is the dimension of the word vector. Further, the word vectors pass through the BERT encoder layer to obtain the feature vector representation C of the target corpus data. d h is the dimension of the BERT output vector.
[0084] S103. Based on the attribute fusion module in the sentiment classification model, perform feature fusion on the feature vector representation and the attribute information to generate the fusion vector representation of the target corpus data; the attribute fusion module includes attribute information.
[0085] Specifically, the user terminal generates a fused vector representation of the target corpus data by fusing the feature vector representation and the attribute information based on the attribute fusion module in the sentiment classification model. It can be understood that the attribute fusion module is used to fuse the feature vector representation and the attribute information, specifically, it can be an Attribute Fusion Network (AFN). The attribute information includes user attributes and product attributes. The user attributes are reflected in that for the same target corpus data, the sentiment polarity (positive / negative) and sentiment intensity (strong / weak) expressed by different users will be different. The product attributes are reflected in that for the same text, the sentiment polarity (positive / negative) and sentiment intensity (strong / weak) expressed in different product scenarios will be different.
[0086] The specific steps for generating the fused vector representation of the target corpus data are as follows:
[0087] The user terminal splices the feature vector representation and the attribute information into a splicing vector based on the attribute fusion module in the sentiment classification model. For example, the feature vector representation is a vector with dimension d D The attribute information includes user attributes with dimension d e and product attributes with dimension d e After being spliced by the attribute fusion module, a vector with dimension d c = d D + d e + d e is generated. It should be noted that the fusion of attribute information can be performed for a single user attribute or product attribute, or both user attributes and product attributes can be fused simultaneously. Further, the user terminal performs a non-linear transformation on the splicing vector through the fully connected layer and activation function in the attribute fusion module to generate the fused vector representation corresponding to the target corpus data. The activation function can be the ReLU function. The fused vector representation generated through the non-linear transformation has the same dimension as the feature vector representation.
[0088] S104. Generate the sentiment category of the target corpus data according to the sentiment classification model and the fused vector representation.
[0089] Specifically, the user terminal generates the sentiment category of the target corpus data according to the sentiment classification model and the fusion vector representation. It can be understood that the user terminal performs a full connection process on the fusion vector representation based on the fully connected layer in the sentiment classification model to generate a fully connected vector. Further, through the classification function in the sentiment classification model, the sentiment category of the target corpus data is generated based on the fully connected vector. Specifically, the classification function can be softmax. The fully connected vector is input into the softmax, and the sentiment category of the target corpus data is output through the softmax.
[0090] In the embodiment of the present application, by obtaining target corpus data for detecting sentiment categories, and based on the feature processing module in the sentiment classification model, obtaining the feature vector representation of the target corpus data, and further based on the attribute fusion module in the sentiment classification model, performing feature fusion on the feature vector representation and attribute information to generate the fusion vector representation of the target corpus data. The attribute fusion module includes attribute information, and finally, the sentiment category of the target corpus data is generated according to the sentiment classification model and the fusion vector representation. By using the above method, the attribute information is incorporated into the feature vector representation of the target corpus data through the attribute fusion module with a simple structure in the sentiment classification model, improving the accuracy and calculation efficiency of the sentiment classification of the target corpus data.
[0091] Please refer to Figure 3 , Figure 3 which is a schematic flowchart of the data processing method provided by the embodiment of the present application. This method can be executed by a user terminal (for example, the user terminal shown above Figure 1 ), or jointly executed by the user terminal and a service server (such as the service server 100 in the corresponding embodiment above Figure 1 ). For ease of understanding, this embodiment is described by taking the method being executed by the above user terminal as an example. Among them, this data processing method can at least include the following steps S201-step S207:
[0092] S201, obtain an initial sentiment classification model and a sample corpus data set;
[0093] Specifically, the user terminal obtains an initial sentiment classification model and a sample corpus data set. It can be understood that the initial sentiment classification model includes initial attribute information, which is randomly initialized, and the sample corpus data set includes sample corpus data and the sentiment category labels carried by the sample corpus data.
[0094] S202, generate the initial sentiment category corresponding to the sample corpus data based on the sample corpus data and the initial attribute information in the initial sentiment classification model;
[0095] Specifically, the user terminal inputs the sample corpus data into the initial sentiment classification model, which includes an initial feature processing module and an initial attribute fusion module. Further, an initial feature vector representation of the sample corpus data is obtained through the initial feature processing module of the sentiment classification model. Further, based on the initial attribute fusion module in the initial sentiment classification model, the initial feature vector representation and the initial attribute information are fused to generate an initial fusion vector representation, and an initial sentiment category is generated according to the initial fusion vector representation and the initial sentiment classification model.
[0096] S203. Generate a sentiment classification model based on the initial sentiment category corresponding to the sample corpus data and the sentiment category label carried by the sample corpus data.
[0097] Specifically, the user terminal adjusts the model parameters of the initial sentiment classification model according to the initial sentiment category and the sentiment category label carried by the sample corpus data. The model parameters of the initial sentiment classification model include the initial attribute information in the initial attribute fusion module. When the adjusted initial sentiment classification model meets the convergence condition, the initial sentiment classification model including the adjusted model parameters is determined as the sentiment classification model.
[0098] S204. Obtain target corpus data for detecting sentiment categories;
[0099] For the step S204 in the embodiment of the present invention, refer to Figure 2 the specific description of step S101 in the embodiment shown, which will not be elaborated here.
[0100] S205. Based on the feature processing module in the sentiment classification model, obtain a feature vector representation of the target corpus data;
[0101] For the step S205 in the embodiment of the present invention, refer to Figure 2 the specific description of step S102 in the embodiment shown, which will not be elaborated here.
[0102] S206. Based on the attribute fusion module in the sentiment classification model, splice the feature vector representation and the attribute information to generate a spliced vector;
[0103] Specifically, the user terminal splices the feature vector representation and the attribute information to generate a spliced vector based on the attribute fusion module in the sentiment classification model. For example, the feature vector representation is a vector with dimension d D and the attribute information includes a user attribute with dimension d e and a product attribute with dimension d e After vector splicing through the attribute fusion module, a vector with dimension d is generatedc = d D + d e + d e For the vectors of c = d, D + d, e + d, e , it should be noted that the fusion of attribute information can be carried out for a single user attribute or product attribute, or both user attributes and product attributes can be fused simultaneously.
[0104] S207. Through the fully connected layer and activation function in the attribute fusion module, perform a non-linear transformation on the concatenated vector to generate the fused vector representation corresponding to the target corpus data.
[0105] Specifically, the attribute fusion module consists of two fully connected layers and two activation function non-linear transformations, namely the first fully connected layer and the second fully connected layer, the first activation function and the second activation function, and the attribute fusion module can use standard dropout and residual connections. Please refer to Figure 4a , Figure 4a which is an example schematic diagram of the attribute fusion module provided by the embodiments of the present application. As Figure 4a shown, the specific process of generating the fused vector representation corresponding to the target corpus data is as follows. The concatenated vector is generated by concatenating the feature vector representation, user attributes, and product attributes. The user terminal uses the first weight matrix and the first bias vector corresponding to the first fully connected layer and the first activation function in the attribute fusion module to generate an intermediate fused vector representation from the concatenated vector. Specifically, it can be generated through the formula r = ReLU(W (0) ·[D; E u ; E p + b (0) ), where r is the intermediate fused vector representation, ReLU is the first activation function, W (0) is the first weight matrix, D is the feature vector representation, E u is the user attribute, E p is the product attribute, [D; E u ; E p is the concatenated vector, and b (0) is the first bias vector.
[0106] Furthermore, the user terminal uses the second weight matrix and the second bias vector corresponding to the second fully connected layer and the second activation function in the attribute fusion module to generate the fused vector representation corresponding to the target corpus data from the intermediate fused vector representation. Specifically, it can be generated through the formula Generate a fused vector representation, where D is the fused vector representation, ReLU is the second activation function, W1 is the second weight matrix, W(1) ∈ Rdr×dh, b1 is the first bias vector, b(1) ∈ Rdh, and dh is the dimension of the output vector of the sentiment classification model.
[0107] S208. Generate the sentiment category of the target corpus data according to the sentiment classification model and the fused vector representation.
[0108] Among them, for step S208 in the embodiments of the present invention, refer to Figure 2 the specific description of step S104 in the embodiments shown, which will not be elaborated here.
[0109] Next, in combination with Figure 4b and Figure 4c , a specific implementation scenario provided by the embodiments of the present application will be described. Figure 4b FIG. is an example schematic diagram of sentiment classification based on BERT provided by the embodiments of the present application. Figure 4c FIG. is an example schematic diagram of sentiment classification based on BERT combined with an attribute fusion module provided by the embodiments of the present application. As Figure 4b shown, taking BERT as an example for illustration, the process of the sentiment classification model of BERT is as follows: The target corpus data is a text passage [s1,..., s i ,... s n , where s i is the i-th sentence in the passage, w ij represents the j-th word in the i-th sentence of the passage, and l i is the length of this sentence. First, the input is subjected to feature extraction through a word vector layer to obtain word vectors where E ij refers to the vector representation of the corresponding word, d e is the dimension of the word vector. Then, through the encoding layer in BERT, the context representation C of the entire passage is obtained, d h is the dimension of the BERT output vector. Finally, the context representation passes through a fully connected layer and a softmax layer to obtain the predicted sentiment category.
[0110] As Figure 4c shown, taking BERT combined with an attribute fusion module to illustrate the sentiment classification model in this solution. The process of the sentiment classification model is as follows: The target corpus data is a text passage [s1,..., s i ,... s n , where s i is the i-th sentence in the passage, w ijrepresents the j-th word in the i-th sentence in the passage, and l i is the length corresponding to this sentence. First, the input undergoes feature extraction through the word vector layer to obtain word vectors where E ij refers to the vector representation of the corresponding word, d e is the dimension of the word vector. In the word vector layer, the attribute fusion module incorporates attribute information (user attributes and product attributes) into the word vector E ij to obtain a new word vector representation The new word vector representation passes through the encoding layer in BERT to obtain the context representation C of the entire passage. Further, the attribute fusion module incorporates attribute information (user attributes and product attributes) into the output of the BERT encoding layer (i.e., the context representation C of the entire passage) to obtain the fused passage representation Finally, the context representation passes through the fully connected layer and the softmax layer to obtain the predicted sentiment category. It should be noted that for the incorporation of attribute information, attribute fusion can be selected at different positions in the sentiment classification model. For example, it can be chosen to incorporate attribute information only in a single word vector layer, or in a single encoding layer, or it can also be chosen to incorporate attribute information simultaneously in the word vector layer and the encoding layer.
[0111] Next, this solution is verified through three publicly available datasets, IMDB, Yelp2013, and Yelp2014. At the same time, for the sentiment classification models based on LSTM and based on Bert, the LSTM-based models include UPA, CMA, DUPMN, HUAPA, CHIM, and the model in this solution (fusing user attributes and product attributes), and the Bert-based models include IUPC, BERT VANILLA, fusing attribute information in the word vector layer, fusing attribute information in the encoding layer, fusing product attributes in the word vector layer and the encoding layer, fusing user attributes in the word vector layer and the encoding layer, and the model in this solution (fusing user attributes and product attributes in the word vector layer and the encoding layer). Please refer to Table 1, where Table 1 shows the accuracy (ACC) and root mean square error (RMSE) of various models in the three publicly available datasets.
[0112] Table 1 ACC and RMSE of models in the three publicly available datasets
[0113]
[0114] As can be seen from Table 1, the accuracy (ACC) and root mean square error (RMSE) in the three public datasets using the proposed scheme are almost higher than those of other existing attribute fusion methods (only the method based on LSTM combined with the attribute fusion module is not the best in terms of RMSE in the Yelp2013 dataset, but it is close to the best). Therefore, the method in the proposed scheme can effectively improve the accuracy of sentiment classification. At the same time, the structure of the attribute fusion module is very simple and can be easily migrated to other text encoders.
[0115] It should be noted that in this scheme, the language model BERT is taken as an example for introduction, but the technical solution of the present invention is also applicable to other pre-trained language models such as Roberta, as well as different models such as Convolution Neural Network (CNN) and Recurrent Neural Network (RNN), and even other models that mix RNN, CNN, and self-attention. At the same time, this technical solution is proposed for the document-level sentiment classification task, but the method of the present invention can be used in all natural language processing tasks that require attribute information fusion, such as education, recommendation scenarios, etc.
[0116] In the embodiment of the present application, by obtaining target corpus data for detecting sentiment categories, and based on the feature processing module in the sentiment classification model, obtaining a feature vector representation of the target corpus data, and further based on the attribute fusion module in the sentiment classification model, performing feature fusion on the feature vector representation and attribute information to generate a fusion vector representation of the target corpus data, the attribute fusion module includes attribute information, and finally generating the sentiment category of the target corpus data according to the sentiment classification model and the fusion vector representation. By using the above method, the attribute information is incorporated into the feature vector representation of the target corpus data through the simple-structured attribute fusion module in the sentiment classification model, improving the accuracy and computational efficiency of the sentiment classification of the target corpus data.
[0117] Please refer to Figure 5 , Figure 5 which is a schematic structural diagram of a data processing device provided by an embodiment of the present application. The data processing device may be a computer program (including program code) running in a computer device. For example, the data processing device is an application software; the device can be used to execute the corresponding steps in the method provided by the embodiment of the present application. As Figure 5 shown, the data processing device 1 in the embodiment of the present application may include: a data acquisition unit 11, a feature vector generation unit 12, a fusion vector generation unit 13, and a sentiment category generation unit 14.
[0118] A data acquisition unit 11, configured to acquire target corpus data for detecting sentiment categories in a language;
[0119] A feature vector generation unit 12, configured to obtain a feature vector representation of the target corpus data based on a feature processing module in a sentiment classification model;
[0120] A fusion vector generation unit 13, configured to perform feature fusion on the feature vector representation and attribute information based on an attribute fusion module in the sentiment classification model to generate a fusion vector representation of the target corpus data; the attribute fusion module includes attribute information;
[0121] A sentiment category generation unit 14, configured to generate a sentiment category of the target corpus data according to the sentiment classification model and the fusion vector representation.
[0122] Please refer to Figure 5 , the data processing device 1 in the embodiment of the present application may further include: a sample data acquisition unit 15, an initial category generation unit 16, and a classification model generation unit 17.
[0123] A sample data acquisition unit 15, configured to acquire an initial sentiment classification model and a sample corpus data set; the initial sentiment classification model includes initial attribute information; the sample corpus data set includes sample corpus data and sentiment category labels carried by the sample corpus data;
[0124] An initial category generation unit 16, configured to generate an initial sentiment category corresponding to the sample corpus data based on the sample corpus data and the initial attribute information in the initial sentiment classification model;
[0125] A classification model generation unit 17, configured to generate a sentiment classification model based on the initial sentiment category corresponding to the sample corpus data and the sentiment category labels carried by the sample corpus data.
[0126] In a feasible implementation manner, the initial category generation unit 16 is specifically configured to:
[0127] Input the sample corpus data into the initial sentiment classification model, and obtain an initial feature vector representation of the sample corpus data through an initial feature processing module of the sentiment classification model;
[0128] Based on an initial attribute fusion module in the initial sentiment classification model, perform feature fusion on the initial feature vector representation and the initial attribute information to generate an initial fusion vector representation;
[0129] Generate an initial sentiment category according to the initial fusion vector representation and the initial sentiment classification model.
[0130] In a feasible implementation manner, the classification model generation unit 17 is specifically configured to:
[0131] Adjust the model parameters of the initial sentiment classification model according to the initial sentiment category and the sentiment category label carried in the sample corpus data, where the model parameters of the initial sentiment classification model include the initial attribute information in the initial attribute fusion module;
[0132] When the adjusted initial sentiment classification model meets the convergence condition, determine the initial sentiment classification model including the adjusted model parameters as the sentiment classification model.
[0133] In a feasible implementation manner, the feature vector generation unit 12 is specifically configured to:
[0134] Extract the word vectors of each word in all sentences of the target corpus data through the feature processing module in the sentiment classification model; the target corpus data includes multiple sentences, each sentence includes multiple words, and each word corresponds to a word vector;
[0135] Generate a feature vector representation corresponding to the target corpus data according to the word vectors corresponding to the target corpus data.
[0136] Please refer to Figure 5 , the fusion vector generation unit 13 in the embodiment of the present application may further include: a splicing vector generation subunit 131 and a fusion vector generation subunit 132.
[0137] The splicing vector generation subunit 131 is configured to perform vector splicing on the feature vector representation and the attribute information based on the attribute fusion module in the sentiment classification model to generate a splicing vector;
[0138] The fusion vector generation subunit 132 is configured to perform a non-linear transformation on the splicing vector through the fully connected layer and the activation function in the attribute fusion module to generate a fusion vector representation corresponding to the target corpus data.
[0139] In a feasible implementation manner, the fusion vector generation subunit 132 is specifically configured to:
[0140] Generate an intermediate fusion vector representation from the splicing vector through the first weight matrix and the first bias vector corresponding to the first fully connected layer and the first activation function in the attribute fusion module;
[0141] Generate a fusion vector representation corresponding to the target corpus data from the intermediate fusion vector representation through the second weight matrix and the second bias vector corresponding to the second fully connected layer and the second activation function in the attribute fusion module.
[0142] In a feasible implementation manner, the emotion category generation unit 14 is specifically configured to:
[0143] Perform a fully connected process on the fusion vector representation based on the fully connected layer in the emotion classification model to generate a fully connected vector;
[0144] Generate the emotion category of the target corpus data based on the fully connected vector through the classification function in the emotion classification model.
[0145] In the embodiments of the present application, by obtaining target corpus data for detecting emotion categories, and based on the feature processing module in the emotion classification model, obtaining the feature vector representation of the target corpus data, and further based on the attribute fusion module in the emotion classification model, performing feature fusion on the feature vector representation and attribute information to generate the fusion vector representation of the target corpus data. The attribute fusion module includes attribute information. Finally, the emotion category of the target corpus data is generated according to the emotion classification model and the fusion vector representation. By adopting the above method, the attribute information is incorporated into the feature vector representation of the target corpus data through the attribute fusion module with a simple structure in the emotion classification model, improving the accuracy and computational efficiency of the emotion classification of the target corpus data.
[0146] Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of a computer device provided by the embodiments of the present application. As Figure 6 shown, the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, the user interface 1003 may include a display screen (Display), and optionally, the user interface 1003 may further include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a random access memory (Random Access Memory, RAM), or a non-volatile memory (non-volatile memory, NVM), such as at least one disk memory. Optionally, the memory 1005 may further be at least one storage device located far from the aforementioned processor 1001. As Figure 6 shown, in the memory 1005 as a computer storage medium, there may be included an operating system, a network communication module, a user interface module, and a data processing application program.
[0147] In Figure 6In the computer device 1000 shown, the network interface 1004 can provide network communication functions, and the user interface 1003 is mainly used to provide an interface for users to input; while the processor 1001 can be used to call the data processing application program stored in the memory 1005 to implement the above Figures 2 - 4c description of the data processing method in any of the corresponding embodiments, which will not be elaborated here.
[0148] It should be understood that the computer device 1000 described in the embodiments of the present application can execute the description of the data processing method in any of the previous Figures 2 - 4c corresponding embodiments, and can also execute the description of the data processing device in the previous Figure 5 corresponding embodiments, which will not be elaborated here. In addition, the description of the beneficial effects of using the same method will not be elaborated either.
[0149] In addition, it should be pointed out here that: the embodiments of the present application also provide a computer-readable storage medium, and the computer-readable storage medium stores the computer program executed by the data processing device mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the description of the data processing method in any of the previous Figures 2 - 4c corresponding embodiments. Therefore, it will not be elaborated here. In addition, the description of the beneficial effects of using the same method will not be elaborated either. For the technical details not disclosed in the embodiments of the computer-readable storage medium involved in the present application, please refer to the description of the method embodiments of the present application. As an example, the program instructions can be deployed to be executed on one computing device, or on multiple computing devices located at one location, or, on multiple computing devices distributed at multiple locations and interconnected through a communication network. The multiple computing devices distributed at multiple locations and interconnected through a communication network can form a blockchain system.
[0150] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The above program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above various methods. Among them, the above computer-readable storage medium can be a data processing device provided in any of the foregoing embodiments or an internal storage unit of the above device, such as the hard disk or memory of an electronic device. The computer-readable storage medium can also be an external storage device of the electronic device, such as a plug-in hard disk equipped on the electronic device, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. The above computer-readable storage medium can also include magnetic disks, optical disks, read-only memory (ROM), or random access memory, etc. Further, the computer-readable storage medium can also include both the internal storage unit of the electronic device and the external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the electronic device. The computer-readable storage medium can also be used to temporarily store the data that has been output or will be output.
[0151] The terms "first", "second", etc. in the claims, the description, and the drawings of the present invention are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products, or devices. The mention of "embodiment" in this article means that a specific feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present invention. The display of this phrase at various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments. The term "and / or" used in the description and claims of the present invention refers to any combination and all possible combinations of one or more of the related listed items, and includes these combinations.
[0152] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0153] In each embodiment of the present application, the functional units can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0154] The above-disclosed are only the preferred embodiments of the present application. Of course, the scope of the rights of the present application cannot be limited thereby. Therefore, equivalent changes made according to the claims of the present application still fall within the scope covered by the present application.
Claims
1. A data processing method, characterized in that, Including: Obtaining target corpus data for detecting emotion categories; Obtaining a feature vector representation of the target corpus data based on a feature processing module in an emotion classification model; Based on an attribute fusion module in the emotion classification model, performing vector splicing on the feature vector representation and attribute information to generate a spliced vector; the attribute fusion module includes attribute information; Generating an intermediate fusion vector representation from the spliced vector through a first weight matrix and a first bias vector corresponding to a first fully connected layer and a first activation function in the attribute fusion module; Generating a fusion vector representation corresponding to the target corpus data from the intermediate fusion vector representation through a second weight matrix and a second bias vector corresponding to a second fully connected layer and a second activation function in the attribute fusion module; Generating an emotion category of the target corpus data according to the emotion classification model and the fusion vector representation.
2. The method according to claim 1, wherein Also including: Obtaining an initial emotion classification model and a set of sample corpus data; the initial emotion classification model includes initial attribute information; the set of sample corpus data includes sample corpus data and emotion category labels carried by the sample corpus data; Generating an initial emotion category corresponding to the sample corpus data based on the sample corpus data and the initial attribute information in the initial emotion classification model; Generating an emotion classification model based on the initial emotion category corresponding to the sample corpus data and the emotion category labels carried by the sample corpus data.
3. The method according to claim 2, wherein The generating an initial emotion category corresponding to the sample corpus data based on the sample corpus data and the initial attribute information in the initial emotion classification model includes: Inputting the sample corpus data into the initial emotion classification model, and obtaining an initial feature vector representation of the sample corpus data through an initial feature processing module of the emotion classification model; Based on an initial attribute fusion module in the initial emotion classification model, performing feature fusion on the initial feature vector representation and the initial attribute information to generate an initial fusion vector representation; Generating an initial emotion category according to the initial fusion vector representation and the initial emotion classification model.
4. The method according to claim 3, characterized in that The generating an emotion classification model based on the initial emotion category corresponding to the sample corpus data and the emotion category labels carried by the sample corpus data includes: Adjusting model parameters of the initial emotion classification model according to the initial emotion category and the emotion category labels carried by the sample corpus data, where the model parameters of the initial emotion classification model include the initial attribute information in the initial attribute fusion module; When the adjusted initial emotion classification model meets a convergence condition, determining the initial emotion classification model including the adjusted model parameters as the emotion classification model.
5. The method according to claim 1, characterized in that, The obtaining a feature vector representation of the target corpus data based on a feature processing module in the emotion classification model includes: Extracting word vectors of each word in all sentences of the target corpus data through a feature processing module in the emotion classification model; the target corpus data includes multiple sentences, each sentence includes multiple words, and each word corresponds to a word vector; Generate a feature vector representation corresponding to the target corpus data based on the word vectors corresponding to the target corpus data.
6. The method according to claim 1, wherein Generating the sentiment category of the target corpus data according to the sentiment classification model and the fused vector representation includes: Based on the fully connected layer in the sentiment classification model, perform a fully connected process on the fused vector representation to generate a fully connected vector; Based on the fully connected vector, generate the sentiment category of the target corpus data through the classification function in the sentiment classification model.
7. A data processing device, characterized in that, Including: A data acquisition unit for acquiring target corpus data for detecting sentiment categories; A feature vector generation unit for obtaining a feature vector representation of the target corpus data based on a feature processing module in the sentiment classification model; A fused vector generation unit for, based on an attribute fusion module in the sentiment classification model, vector splicing the feature vector representation and attribute information to generate a spliced vector, generating an intermediate fused vector representation from the spliced vector through a first weight matrix and a first bias vector corresponding to a first fully connected layer and a first activation function in the attribute fusion module, and generating a fused vector representation corresponding to the target corpus data from the intermediate fused vector representation through a second weight matrix and a second bias vector corresponding to a second fully connected layer and a second activation function in the attribute fusion module; the attribute fusion module includes attribute information; A sentiment category generation unit for generating the sentiment category of the target corpus data according to the sentiment classification model and the fused vector representation.
8. A computer device, characterized in that, Including: A processor, a memory, and a network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide network communication functions, the memory is used to store program codes, and the processor is used to call the program codes to execute the method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, and the computer program is adapted to be loaded and executed by the processor to execute the method according to any one of claims 1-6.
10. A computer program product, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to execute the method according to any one of claims 1-6.
Citation Information
Patent Citations
Text emotion classification method and device for fusing user information
CN109213860A