Text classification method and device, computer device and storage medium
By incorporating graph data into the text classification model and training it by combining local and global information, the problem that conventional models cannot take into account global features is solved, thus improving the accuracy of text classification, especially the classification results of unlabeled text data.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MASHANG CONSUMER FINANCE CO LTD
- Filing Date
- 2022-07-13
- Publication Date
- 2026-04-28
AI Technical Summary
Conventional text classification models cannot take into account the global features of the text in the corpus, resulting in low classification accuracy.
When training a text classification model, graph data is incorporated. By constructing graph data based on text similarity and combining local and global information, the model is trained using a semi-supervised learning method, requiring only a portion of the text data to have classification labels.
It improves the accuracy of text classification, especially the classification results for unlabeled text data, and is suitable for training scenarios with a small number of labeled data.
Smart Images

Figure CN116150307B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of natural language processing, and in particular to a text classification method, apparatus, computer device, and storage medium. Background Technology
[0002] Text classification is a common task in the field of natural language processing. It can be applied to various business scenarios, such as determining whether customer service scripts are appropriate or whether a customer's statement addresses a specific issue. Conventional text classification models can only consider local features of the text and cannot take into account the global features of the text within the corpus; therefore, the accuracy of conventional text classification methods needs improvement. Summary of the Invention
[0003] The purpose of the embodiments in this specification is to provide a text classification method, apparatus, computer device, and storage medium that can improve the accuracy and processing efficiency of text classification.
[0004] To achieve the above technical solution, the embodiments in this specification are implemented as follows:
[0005] Firstly, an embodiment of this specification provides a text classification method, including:
[0006] Obtain multiple text data corresponding to multiple similar texts stored in a corpus, wherein some of the multiple text data have classification labels, and the classification labels are used to indicate the text classification result of the text data;
[0007] Graph data is constructed based on the text similarity between every two text data in the plurality of text data, wherein each text data is used to indicate local information of the plurality of similar texts, and the graph data is used to indicate global information of the plurality of similar texts;
[0008] Each text data and the graph data are input into the text classification model to be trained to obtain the trained text classification model and the text classification results of the text data without classification labels among the multiple text data.
[0009] Secondly, an embodiment of this specification provides a text classification device, comprising:
[0010] The data acquisition unit is used to acquire multiple text data corresponding to multiple similar texts stored in the corpus. Some of the text data has classification labels, and the classification labels are used to indicate the text classification result of the text data.
[0011] The graph construction unit is used to construct graph data based on the text similarity between every two text data in the plurality of text data, wherein each text data is used to indicate local information of the plurality of similar texts, and the graph data is used to indicate global information of the plurality of similar texts;
[0012] The text classification unit is used to input each text data and the graph data into the text classification model to be trained for model training, so as to obtain the trained text classification model and the text classification results of the text data without classification labels in the multiple text data.
[0013] Thirdly, an embodiment of this specification provides a computer device comprising: a processor; and a memory arranged to store computer-executable instructions configured to be executed by the processor, the computer-executable instructions being used to perform the steps of the method described in the first aspect above.
[0014] Fourthly, an embodiment of this specification provides a storage medium for storing computer-executable instructions that cause a computer to perform the steps described in the first aspect above.
[0015] In this embodiment, firstly, multiple text data corresponding to multiple similar texts stored in the corpus are acquired. Some of the text data have classification labels, which indicate the text classification result. Then, graph data is constructed based on the text similarity between every two text data points. Each text data point indicates local information about the multiple similar texts, while the graph data indicates global information. Finally, each text data point and the graph data are input into a text classification model to be trained, resulting in a trained text classification model and the text classification results for the text data points without classification labels. As can be seen, in this embodiment, each text data point indicates local information about the multiple similar texts, and the graph data indicates global information. Therefore, during model training, both local and global information of similar texts are considered, resulting in a high text classification accuracy for the trained model, which is beneficial for improving overall text classification accuracy. Furthermore, since the text classification model is a semi-supervised learning model, only a portion of the text data needs to have classification labels. By inputting text data with and without classification labels from multiple text datasets into the text classification model, and learning from the labeled text data, the text classification results of the unlabeled text data from multiple text datasets can be obtained. This model is suitable for training scenarios with a small amount of labeled text data. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in one or more of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A flowchart illustrating a text classification method provided in one embodiment of this specification;
[0018] Figure 2 A schematic diagram of a graph represented by graph data provided in one embodiment of this specification;
[0019] Figure 3 A schematic diagram of the structure of a text classification model to be trained provided in one embodiment of this specification;
[0020] Figure 4 This is a schematic diagram illustrating a scenario for discovering excellent sales techniques, provided as an embodiment of this specification.
[0021] Figure 5 This is a schematic diagram of the structure of a text classification device provided in one embodiment of this specification;
[0022] Figure 6 This is a schematic diagram of the structure of a computer device provided in one embodiment of this specification. Detailed Implementation
[0023] To enable those skilled in the art to better understand the technical solutions in one or more of this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of one or more of this specification, and not all embodiments. Based on the embodiments in one or more of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of this specification.
[0024] It should be noted that, unless otherwise specified, one or more embodiments and features described in this specification can be combined with each other. The embodiments of this specification will now be described in detail with reference to the accompanying drawings and examples.
[0025] Considering that conventional text classification models can only take into account local features of the text and cannot consider the global features of the text in the corpus, resulting in low accuracy, this specification provides a text classification method, apparatus, computer device, and storage medium in one embodiment, which can improve the accuracy of text classification. The text classification method in this embodiment can be applied to and executed by a computer device, specifically a server dedicated to model training and text classification.
[0026] The technical concept in the various embodiments of this specification is to incorporate graph data when training a text classification model. Specifically, multiple text data corresponding to multiple similar texts stored in a corpus are obtained, and graph data is constructed based on the text similarity between every two text data. Each text data is used to indicate the local information of multiple similar texts, and the graph data is used to indicate the global information of multiple similar texts. Thus, during model training, not only the local information of similar texts is considered, but also the global information of similar texts is taken into account. As a result, the text classification model trained has a high text classification accuracy, which is beneficial to improving the accuracy of text classification.
[0027] In addition, the text classification model to be trained in this embodiment is a semi-supervised model. Among the multiple text data obtained, some text data have classification labels. The classification labels are used to indicate the text classification results of the text data. After inputting each text data and graph data into the text classification model to be trained, the trained text classification model and the text classification results of the text data without classification labels can be obtained. The text classification results of the text data without classification labels have high accuracy and are suitable for training scenarios with a small amount of labeled text data.
[0028] Figure 1 This is a flowchart illustrating a text classification method provided in one embodiment of this specification, as shown below. Figure 1 As shown, the process includes the following steps:
[0029] Step S102: Obtain multiple text data corresponding to multiple similar texts stored in the corpus. Some of the text data have classification labels, which are used to indicate the text classification results of the text data.
[0030] In step S102 above, multiple text data corresponding to multiple similar texts stored in the corpus are obtained. Specifically, the corpus stores multiple similar texts. In this step, some or all of the texts from the multiple similar texts stored in the corpus can be used as text data and extracted from the corpus to obtain multiple text data. The corpus can be a pre-constructed corpus that stores multiple similar texts. Similar texts can be texts containing similar words, texts with similar semantics, or texts containing similar words and similar semantics.
[0031] Of the multiple text data sets acquired, some have category labels indicating their classification results, while others do not. Specifically, the text data consists of sentences with specific classification results. For example, text data might be scripts spoken by customer service representatives to customers; these scripts can be categorized as excellent or non-excellent, meaning the classification results include both excellent and non-excellent scripts. Similarly, text data might be questions asked by customers; these questions can be categorized as those specific to a particular project or those not. Therefore, among the acquired text data sets, some have category labels, such as "excellent script" or "non-excellent script," while others do not. Typically, the number of text data sets with category labels is less than the number of text data sets without category labels.
[0032] Taking text classification as an example of distinguishing between excellent and non-optimized sales scripts, we can obtain a large number of non-repeating sales scripts that customer service representatives have said to customers in the past. We can store these non-repeating sales scripts in a corpus and extract some or all of the sales scripts from the corpus as text data. Furthermore, we can add classification labels to some of the extracted text data. The classification labels are used to indicate whether the text data is an excellent sales script. For example, a classification label of "0" indicates that the text data is a non-excellent sales script, and a classification label of "1" indicates that the text data is an excellent sales script.
[0033] Step S104: Construct graph data based on the text similarity between every two text data in multiple text data, where each text data is used to indicate local information of multiple similar texts, and the graph data is used to indicate global information of multiple similar texts.
[0034] In step S104 above, graph data is constructed based on the text similarity between every two text data in the acquired multiple text data. In the acquired multiple text data, each text data is used to indicate the local information of multiple similar texts stored in the corpus, and the graph data is used to indicate the global information of multiple similar texts stored in the corpus. Figure 2 A schematic diagram of a graph represented by graph data provided in one embodiment of this specification, such as... Figure 2 As shown, the constructed graph data represents a graph containing multiple nodes, each node representing a piece of text data. Different nodes are connected, and the semantics between the two pieces of text data represented by the connected nodes meet the corresponding semantic similarity requirements, and the words they contain also meet the corresponding word similarity requirements.
[0035] like Figure 2 As shown, one node represents the text data "I will report your problem to my superiors", and another node represents the text data "I will report your problem to my superiors". The semantics between these two text data meet the corresponding semantic similarity requirements, and the words they contain also meet the corresponding word similarity requirements. Therefore, there is a connection between the two nodes. Figure 2 The text data represented by other nodes is not shown.
[0036] In this embodiment, among the acquired text data, each text data is used to indicate local information of multiple similar texts stored in the corpus, while the graph data is used to indicate global information of multiple similar texts stored in the corpus. Therefore, this embodiment can take into account both the local and global information of similar texts, thereby improving the accuracy of text classification.
[0037] In one embodiment, graph data is constructed based on the text similarity between every two text data points from the acquired multiple text data sets, specifically as follows:
[0038] (a1) Combine every two text data from the multiple acquired text data to obtain text data pairs;
[0039] (a2) Based on the text similarity between the two text data included in each text data pair, select the target text data pair from each text data pair;
[0040] (a3) Construct graph data for the two included text data based on the target text data.
[0041] Specifically, firstly, every two text data points from the acquired multiple text data sets are combined to obtain multiple text data pairs. For example, if 100 text data points are acquired, then every two text data points are combined to obtain 4950 text data pairs. It is understandable that among the obtained multiple text data pairs, some text data pairs contain text data points whose semantics satisfy the corresponding semantic similarity requirements, and the words they contain also satisfy the corresponding word similarity requirements. Other text data pairs contain text data points whose semantics do not satisfy the corresponding semantic similarity requirements, or the words they contain do not satisfy the corresponding word similarity requirements.
[0042] Next, target text data pairs are selected from each text data pair based on the text similarity between the two text data pieces included in each text data pair. In one embodiment, selecting target text data pairs from each text data pair based on the text similarity between the two text data pieces included in each text data pair specifically involves:
[0043] (a21) Determine the text similarity at the text level between the two text data included in each text data pair;
[0044] (a22) Select text data pairs from each text data pair that meet the first preset similarity requirement at the text level as candidate text data pairs;
[0045] (a23) Determine the semantic similarity between the two text data included in each candidate text data pair;
[0046] (a24) Select candidate text data pairs from the candidate text data pairs whose text similarity at the semantic level meets the second preset similarity requirement as target text data pairs.
[0047] First, for each text data pair, determine the text similarity at the word level between the two text data pieces included in the pair. For each text data piece in each pair, each word has a corresponding weight. The text similarity at the word level between the two text data pieces in each pair can be equal to the sum of the weights of the common words present in the two text data pieces. For example, if a text data pair includes two text data pieces, and these two text data pieces contain three common words, with weights of 10, 5, and 9 respectively, then the text similarity at the word level between these two text data pieces is 10 + 5 + 9, which equals 24. In a specific embodiment, the bm25 retrieval algorithm can be used to determine the text similarity at the word level between the two text data pieces included in each text data pair. It can be understood that one text data pair corresponds to one text similarity at the word level.
[0048] Then, from each text data pair, text data pairs whose text-level text similarity meets the first preset similarity requirement are selected as candidate text data pairs. The first preset similarity requirement can be that the sum of the above weights is greater than a preset threshold, that is, the text-level text similarity is greater than the preset threshold. Alternatively, the text data pairs can be sorted according to the text-level text similarity of the two included text data pairs, and a preset number of text data pairs with the highest text-level text similarity are selected from the sorted list as text data pairs whose text-level text similarity meets the first preset similarity requirement, that is, as candidate text data pairs.
[0049] Next, for each candidate text data pair, the semantic similarity between the two text data points in that pair is determined. Semantic similarity can be defined as semantic similarity. That is, for each candidate text data pair, the semantic similarity between the two text data points is determined. Semantic similarity determination models such as SimBert can be used to determine the semantic similarity between the two text data points in each candidate text data pair. It can be understood that one candidate text data pair corresponds to one semantic similarity level.
[0050] Finally, from each candidate text data pair, those whose semantic text similarity meets the second preset similarity requirement are selected as target text data pairs. Specifically, from each candidate text data pair, those whose semantic similarity between the two included text data is greater than a preset similarity threshold are selected as candidate text data pairs whose semantic text similarity meets the second preset similarity requirement, and thus are selected as target text data pairs.
[0051] As can be seen, in this embodiment, for each text data pair obtained by combining each text data pair, candidate text data pairs can be selected from the text data pairs first by text similarity at the text level, and then target text pairs can be selected from the candidate text data pairs by text similarity at the semantic level. Thus, through the double selection method, text data pairs containing two text data that are very similar at both the text level and the semantic level are obtained as target text data pairs. By selecting and extracting text data pairs, the amount of data processing is reduced, and the obtained graph data is more reliable. At the same time, after constructing graph data based on target text data pairs, using this graph data to train the text classification model to be trained is beneficial to improving the accuracy of the trained text classification model.
[0052] In one embodiment, in step (a3) above, constructing graph data based on the target text data for the two included text data specifically involves:
[0053] (a31) For each target text data pair, convert the two text data included in the target text data pair into two nodes, and establish the connection relationship between the two nodes;
[0054] (a32) Construct an adjacency matrix based on the connection relationships between the nodes corresponding to each target text data pair;
[0055] (a33) Construct a node feature matrix based on the feature vectors of the nodes corresponding to each target text data pair;
[0056] (a34) Construct graph data based on the adjacency matrix and the node feature matrix.
[0057] Specifically, for any pair of target text data, the two text data are treated as nodes, and a connection relationship is set between the two nodes. In this way, each text data in each pair of target text data is treated as a node, and a connection relationship is set between the nodes.
[0058] Furthermore, an adjacency matrix is constructed based on the connection relationships between the nodes corresponding to each target text data pair. First, the two nodes corresponding to each target text data pair are obtained. It is understood that nodes in different target text data pairs may be duplicated. Therefore, the two nodes corresponding to each target text data pair are deduplicated. Then, each deduplicated node is assigned an integer index starting from 1 and incrementing by 1. Assuming the maximum value of this index is N, an N x N matrix is constructed. The matrix value corresponding to any row and any column in this matrix is used to indicate whether there is a connection relationship between the node represented in that row and the node represented in that column. For example, if N is 5, a 5 x 5 matrix is constructed. The matrix value of the 3rd row and 2nd column is 1, indicating that there is a connection relationship between the node corresponding to the 3rd row and the node corresponding to the 2nd column. The matrix value of the 1st row and 2nd column is 0, indicating that there is no connection relationship between the node corresponding to the 1st row and the node corresponding to the 2nd column. The matrix obtained by setting the matrix values for the matrix constructed above based on the connection relationships between the nodes corresponding to each target text data pair is the adjacency matrix.
[0059] Schematic example: An adjacency matrix can be exemplified as follows This adjacency matrix is used to indicate that there is a connection between the node with index 1 and the node with index 2, a connection between the node with index 2 and the node with index 3, and no connection between the node with index 1 and the node with index 3.
[0060] Furthermore, a node feature matrix is constructed based on the feature vectors of the nodes corresponding to each target text data pair. First, the two nodes corresponding to each target text data pair are obtained. It's understood that nodes in different target text data pairs may be duplicated; therefore, the two nodes corresponding to each target text data pair are deduplicated. Then, each deduplicated node is assigned an integer index starting from 1 and incrementing by 1. Assuming the maximum value of this index is M, an M-row, 1-column matrix is constructed. The matrix value corresponding to any row in this matrix represents the feature vector of the node represented in that row. For example, if M is 5, a 5-row, 1-column matrix is constructed, and the matrix value in the 3rd row, 1st column is 1111, indicating that the feature vector of the node corresponding to the 3rd row is 1111. The matrix obtained by setting the matrix values for the constructed matrix based on the feature vectors of each node corresponding to each target text data pair is the node feature matrix. The feature vector of each node is the initial feature vector of the text data corresponding to that node, and the feature vector of each text data will change during model training.
[0061] Schematic example: The node feature matrix can be exemplified as follows The node feature matrix is used to represent the feature vector of node number 1 as 0000, the feature vector of node number 2 as 1111, and the feature vector of node number 3 as 2222.
[0062] It should be noted that since text data is obtained from the corpus in step S102, and the corpus includes multiple similar texts, any text data obtained in step S102 can be identified from all the obtained text data as having similar semantics and containing similar words. Therefore, each obtained text data can participate in the construction of graph data, and the node feature matrix can include the feature vector of each text data obtained in step S102.
[0063] Finally, the constructed adjacency matrix and the constructed node feature matrix are used together as graph data. Graph data is expressed in computer devices as an adjacency matrix and a node feature matrix.
[0064] Step S106: Input each text data and graph data into the text classification model to be trained to obtain the trained text classification model and the text classification results of the text data without classification labels in multiple text data.
[0065] Next, in Figure 1 In step S106, each text data and graph data is input into the text classification model to be trained for model training, and the trained text classification model and the text classification results of the text data without classification labels in multiple text data are obtained.
[0066] During model training, all text and graph data are input into the model for processing. The text and graph data with classification labels are used to adjust the parameters of the text classification model to obtain the trained model. The text data with classification labels is also used to adjust the model's classification results for the text data without classification labels. These classification results and model parameters are adjusted synchronously during model training. Once the model parameters converge, the model training is considered complete, resulting in a trained text classification model. At the time of training completion, the classification results of the text classification model for the text data without classification labels represent the text classification results for the text data without classification labels.
[0067] As can be seen, in this embodiment, firstly, multiple text data corresponding to multiple similar texts stored in the corpus are obtained. Some of the text data have classification labels, which indicate the text classification result. Then, graph data is constructed based on the text similarity between every two text data points. Each text data point indicates local information of the multiple similar texts, and the graph data indicates global information. Finally, each text data point and the graph data are input into a text classification model to be trained, resulting in a trained text classification model and text classification results for text data without classification labels. In this embodiment, each text data point indicates local information of the multiple similar texts, and the graph data indicates global information. Therefore, during model training, both local and global information of similar texts are considered, resulting in a high text classification accuracy for the trained model and a high accuracy for the text classification results for text data without classification labels, thus improving the overall text classification accuracy.
[0068] Figure 3 This is a schematic diagram of the structure of a text classification model to be trained provided in one embodiment of this specification. It can be understood that the structure of the text classification model to be trained is the same as the structure of the trained text classification model. For example... Figure 3 As shown, the text classification model to be trained includes a first classification network and a second classification network.
[0069] Figure 3 In this example, the first classification network is a GCN (Graph Convolutional Network), which consists of M graph convolutional layers, where M is an integer greater than or equal to 1. Figure 3 The following explanation uses a two-layer graph convolutional layer as an example. Figure 3In this context, the second classification network is a CNN (Convolutional Neural Network), which includes multiple convolutional networks. Figure 3 The following diagram uses three convolutional networks as an example. Each convolutional network consists of N convolutional layers and pooling layers, where N is an integer greater than or equal to 1. Figure 3 The diagram uses a single convolutional layer and a single pooling layer as an example. The kernel size is different in each convolutional network. Specifically, for each convolutional network, the kernel size of the N convolutional layers is different, and for all convolutional networks, the kernel size of all convolutional layers in all convolutional networks is also different.
[0070] As mentioned above, the first classification network GCN includes M graph convolutional layers, where M is an integer greater than or equal to 1. For example, the value of M can be 2. Accordingly, in one embodiment, in step S106 above, each text data and graph data is input into the text classification model to be trained for model training, specifically as follows:
[0071] (b1) The graph data is processed by graph convolution through each graph convolution layer in the first classification network to obtain the first processing result of the graph data; wherein, the input of the first graph convolution layer is the adjacency matrix and node feature matrix corresponding to the graph data; the input of the j-th graph convolution layer is the output of the (j-1)-th graph convolution layer and the adjacency matrix corresponding to the graph data; each graph convolution layer processes the input data by graph convolution; the output of the M-th graph convolution layer is the first processing result of the graph data; the first processing result of the graph data includes the first processing result of each text data; j is an integer greater than 1 and less than M.
[0072] Specifically, the adjacency matrix and node feature matrix corresponding to the graph data are input into the first graph convolutional layer for graph convolution processing. The output of this processing, along with the adjacency matrix, is used as the input to the second graph convolutional layer for graph convolution processing. This process is repeated for the third graph convolutional layer, and so on, until the output of the final (Mth) graph convolutional layer is obtained. The output of the Mth graph convolutional layer is the first processing result of the graph data. Since the graph data includes an adjacency matrix and a node feature matrix, and the node feature matrix includes the feature vector of each text data obtained in step S102, the first processing result of the graph data includes the first processing result of each text data obtained in step S102. The first processing result can be the updated feature vector of the text data nodes.
[0073] In a specific embodiment, the first classification network GCN includes two graph convolutional layers, through which the first processing result of each text data is learned. The processing of either of these two graph convolutional layers can be represented by the following formula (1).
[0074] Z (l+1) =GCN(A,X) (l) )=σ(AX (l) W (l) (1)
[0075] Formula (1), where l represents the number of layers in the graph convolutional layer, σ is the activation function, and A∈R V×V This represents the normalized adjacency matrix corresponding to the graph data, W∈R C×F Let X represent the parameters to be trained in the graph convolutional layer, used to perform an affine transformation on X, where X∈R. V×C For the input data, X is the node feature matrix for the first graph convolutional layer, and X is the output of the first graph convolutional layer for the second graph convolutional layer, Z∈R. V×F The output data is defined as follows: V represents the number of nodes in the graph data, C represents the input dimension of the input data, and F represents the output dimension of the output data.
[0076] When there are two graph convolutional layers, the processing of the first graph convolutional layer can be represented by the following formula (2), and the processing of the second graph convolutional layer can be represented by the following formula (3).
[0077] Z (1) =GCN(A,X) (0) (2)
[0078] Z (2) =GCN(A,Z) (1) (3)
[0079] In the formula, X is the node feature matrix, A is the normalized adjacency matrix corresponding to the graph data, and Z... (1) This is the output data of the first graph convolutional layer. Z (2) This is the first processing result of the graph data.
[0080] During graph convolution processing of graph data, any node in the graph can learn the features of its directly and indirectly adjacent nodes to update its own features. For text data with classification labels, its adjacent nodes in the graph data may be text data without classification labels, and vice versa. Therefore, through graph convolution processing of graph data, text data without classification labels can learn the features of its adjacent text data with classification labels to update its own features, and text data with classification labels can learn the features of its adjacent text data without classification labels to update its own features, thereby achieving the effect of learning global information and making the trained model more accurate.
[0081] As mentioned earlier, the second classification network is a CNN that includes multiple convolutional networks, such as... Figure 3 The three convolutional networks in the diagram. Each convolutional network consists of N convolutional layers and pooling layers, where N is an integer greater than or equal to 1, for example... Figure 3 The system consists of one convolutional layer and one pooling layer. The kernel size varies in each convolutional network. Specifically, for each convolutional network, the kernel size of the N convolutional layers is different, and for all convolutional networks, the kernel size of all convolutional layers is also different. Based on this, in step S106 above, each text data and graph data is input into the text classification model to be trained for model training, specifically:
[0082] (c1) Text data is processed by convolutional layers in multiple convolutional networks to obtain multiple convolutional processing results of the text data. Each convolutional processing result corresponds one-to-one with a convolutional network. In each convolutional processing of a convolutional network, the input of the first convolutional layer is the text data; the input of the i-th convolutional layer is the output of the (i-1)-th convolutional layer; each convolutional layer performs convolution processing on the input data; the output of the N-th convolutional layer is the convolutional processing result of the text data; i = is an integer greater than 1 and less than N.
[0083] (c2) The convolutional processing results of the text data are pooled through pooling layers in multiple convolutional networks to obtain multiple second processing results of the text data; the second processing results correspond one-to-one with the convolutional networks.
[0084] Specifically, for each piece of text data, each convolutional network in the second classification network processes the text data to obtain a second processing result. Therefore, the number of convolutional networks in the second classification network corresponds to the number of second processing results for the text data; one convolutional network corresponds to one second processing result. The following uses a single piece of text data as an example to illustrate the process of obtaining multiple second processing results for the text data.
[0085] First, the text data is segmented, such as through n-gram processing, and then input into the first convolutional layer of each convolutional network. Each first convolutional layer performs convolution on the input text data, and the output is input into the second convolutional layer of the corresponding network. The second convolutional layer then performs convolution on the input data, and the output is input into the third convolutional layer, and so on, until the output of the last convolutional layer is obtained. The output of the last convolutional layer represents the convolutional processing result of each convolutional network on the text data. Thus, multiple convolutional processing results for the text data are obtained, each corresponding one-to-one with a specific convolutional network.
[0086] In each convolutional network, the convolutional processing result of the text data is input into a pooling layer for further processing, resulting in a second processing result for the text data corresponding to each convolutional network. This leads to multiple second processing results for the text data, each corresponding one-to-one with a convolutional network. These second processing results can be the updated feature vectors of the text data. When the second classification network includes multiple convolutional networks, the pooling layer in each convolutional network can normalize the dimensionality of the convolutional processing result of the text data, ensuring that the dimensionality of the second processing result output by each convolutional network is the same.
[0087] In one specific embodiment, the second convolutional network (CNN) includes three convolutional networks, each of which includes one convolutional layer and one pooling layer. In this embodiment, the processing procedure of each convolutional network in the second CNN can be represented by the following formulas (4) and (5).
[0088]
[0089]
[0090] In the formula, X represents the text data after word segmentation. l represents the index of the convolutional layer, with a value of 0. n represents the sequence number of each convolutional network; when there are 3 convolutional networks, n can be 0, 1, or 2. n MaxPool represents the convolutional layer in the nth convolutional network.n This represents the pooling layer in the nth convolutional network.
[0091] In one embodiment, the text classification model to be trained further includes a concatenation layer and a fully connected layer. Accordingly, in step S106, each text data and graph data is input into the text classification model to be trained for model training, resulting in the trained text classification model, specifically:
[0092] (d1) The first processing result of the text data and the multiple second processing results corresponding to the text data in the first processing result of the graph data are combined by the splicing layer to obtain the third processing result of the text data.
[0093] (d2) The text data is classified by the fully connected layer based on the third processing result of the text data to obtain the target classification result of the text data;
[0094] (d3) Based on the target classification result corresponding to the text data with classification labels and the classification labels of the text data with classification labels, the first classification network and the second classification network are back-driven to adjust the parameters so that the target classification result is close to the classification label.
[0095] As mentioned earlier, the first processing result of the graph data includes the first processing result of each text data. Therefore, firstly, for each text data, the first processing result of the text data and the respective second processing results of the text data are concatenated to obtain the third processing result of the text data. This concatenation operation can be performed in the concatenation layer.
[0096] Then, for each text data point, a fully connected layer classifies the text data based on the third processing result, yielding the target classification result. Among the acquired text data, some have classification labels. These labeled text data are used to adjust the parameters of the text classification model to be trained. Therefore, finally, based on the target classification result corresponding to the labeled text data and the classification labels of the labeled text data, the first and second classification networks are back-driven to adjust their parameters, so that the target classification result approximates the classification label.
[0097] When there are parameters to be trained in the concatenation layer and the fully connected layer, the parameters in the concatenation layer and the fully connected layer can be adjusted in reverse according to the target classification result corresponding to the text data with classification labels and the classification label of the text data with classification labels, so as to make the target classification result approximate the classification label.
[0098] As mentioned above, for a text data, there is a first processing result, which is located in the first processing result of the graph data. The number of its second processing results is the same as the number of convolutional networks included in the second classification network. One convolutional network corresponds to one second processing result. In a specific embodiment, for a text data, there is one first processing result and three second processing results. In this embodiment, the concatenation of processing results can be achieved by the following formula (6).
[0099]
[0100] in, Z represents the second processing result output by the three convolutional networks. (2) Let E represent the first processing result of the text data output by the first classification network, and let E represent the third processing result of the text data. The third processing result of the text data can be the updated feature vector of the text data. Then, by concatenating one first processing result and three second processing results using formula (6), the third processing result of the text data is obtained.
[0101] In one embodiment, the process of classifying text data by a fully connected layer based on the third processing result of the text data to obtain the target classification result of the text data can be represented by the following formula (7).
[0102]
[0103] In the formula, E represents the third processing result of the text data. This represents the target classification result of the text data, and FC stands for fully connected layer.
[0104] As mentioned earlier, some text data has been labeled with classification tags. These tags indicate the classification result of the text data. For example, a classification tag of "1" indicates that the text data is excellent, while a classification tag of "0" indicates that the text data is not excellent. Based on this, after obtaining the target classification result of the text data with classification tags, the first classification network, the second classification network, the concatenation layer, and the fully connected layer are back-driven to adjust their parameters according to the target classification result and the classification tags of the text data with classification tags, so as to make the target classification result approximate the classification tags.
[0105] The parameters in the second classification network, the first classification network, the splicing layer, and the fully connected layer can be adjusted by using the loss function represented by the following formula (8).
[0106]
[0107] In the formula, λ is the adjustment parameter. C For text classification, the loss function L reg This is a penalty item. Y represents the target classification result of the text data, and J represents the cross-entropy function. θ refers to all parameters to be trained in the model, including those in the second classification network, the first classification network, the concatenation layer, and the fully connected layer. This loss function can achieve L2 regularization, reduce model complexity, and avoid overfitting.
[0108] Furthermore, in this embodiment, during model training, the following process can also be performed: updating the node feature matrix corresponding to the graph data based on the third processing result corresponding to the text data with classification labels, so as to activate the feature vector update of the nodes of the text data in the graph data that are adjacent to the text data with classification labels but do not have classification labels; updating the node feature matrix corresponding to the graph data based on the third processing result corresponding to the text data without classification labels, so as to activate the feature vector update of the nodes of the text data in the graph data that are adjacent to the text data without classification labels but have classification labels; the text classification model determines the classification result of the text data without classification labels based on the updated feature vectors of the nodes of the text data without classification labels.
[0109] In this embodiment, the text classification model is a semi-supervised model, which combines the model training process and the model application process. It can learn the labels of a large amount of unlabeled data based on a small amount of labeled data during the model training process.
[0110] Specifically, during model training, all text and graph data are input into the model for processing. Among them, the text and graph data with classification labels are used to adjust the parameters of the text classification model to be trained, so as to obtain the trained text classification model. Furthermore, during model training, the model continuously updates the feature vector of each text data through the first and second classification networks. The updated feature vector is the third processing result. The updated feature vector is back-introduced into the node feature matrix during model training to update the node feature matrix.
[0111] Based on the principle of graph convolution, in the updated node feature matrix, each node can learn the features of its surrounding nodes to update its own features. Therefore, after the feature vector corresponding to the text data with classification labels in the node feature matrix is updated, the text data without classification labels that are directly and indirectly adjacent to the text data with classification labels can learn the updated feature vector of the text data with classification labels to update their own features. Similarly, after the feature vector corresponding to the text data without classification labels in the node feature matrix is updated, the text data with classification labels that are directly and indirectly adjacent to the text data without classification labels can learn the updated feature vector of the text data without classification labels to update their own features.
[0112] Therefore, during model training, the node feature matrix corresponding to the graph data is updated based on the third processing result corresponding to the text data with classification labels, in order to stimulate the feature update of the text data without classification labels that are adjacent to the text data with classification labels in the graph data. The node feature matrix corresponding to the graph data is updated based on the third processing result corresponding to the text data without classification labels, in order to stimulate the feature update of the text data with classification labels that are adjacent to the text data without classification labels in the graph data.
[0113] Based on this, the model can update the classification result of text data without classification labels by updating the feature vector (i.e., the third processing result) based on the text data without classification labels. Therefore, it can be considered that the text data with classification labels is also used to adjust the classification result of the text classification model for the text data without classification labels. The classification result and the model parameters are adjusted synchronously during the model training process.
[0114] At the end of model training, the trained text classification model can classify text data without classification labels based on the updated feature vectors (i.e., the third processing result) of the text data without classification labels, obtaining the classification result of the text data without classification labels. This classification result is the classification result output by the model. Therefore, when the model training is complete, the classification result of the text classification model for the part of the text data without classification labels is the text classification result of the text data without classification labels.
[0115] The text classification method described above can be widely applied to customer service question and answer systems in various fields such as finance and e-commerce to distinguish whether customer service scripts are excellent and improve the quality of customer service.
[0116] In scenarios where customer service scripts are distinguished as excellent or not, Figure 4 This is a schematic diagram illustrating a scenario for identifying excellent sales techniques, as provided in one embodiment of this specification. Figure 4As shown, among the acquired text data, there is the text data "You can borrow it from a friend" without a category label. The graph data contains three statements: "I suggest you borrow it from relatives and friends," "You can borrow it from a friend," and "I suggest you borrow it from a friend." Since the graph data is constructed based on all the acquired text data, the graph data also contains the text data "You can borrow it from a friend" without a category label. The two text data adjacent to this text data are text data with category labels, both of which are excellent statements.
[0117] Through the above model training process, the features of the nodes adjacent to the node "You can borrow from your friend" can be continuously learned to update the features of the node "You can borrow from your friend". When the nodes adjacent to the node "You can borrow from your friend" are text data with classification labels, the classification result of the node "You can borrow from your friend" can be predicted as "excellent rhetoric" based on the classification label.
[0118] In summary, in this embodiment, each text data is used to indicate local information of multiple similar texts, and the graph data is used to indicate global information of multiple similar texts. Therefore, during model training, not only the local information of similar texts is considered, but also the global information of similar texts is taken into account. As a result, the text classification model trained has a high text classification accuracy, and the text classification results of the text data without classification labels among the multiple text data are also highly accurate, thus improving the accuracy of text classification.
[0119] Figure 5 This is a schematic diagram of the structure of a text classification device provided in one embodiment of this specification, as shown below. Figure 5 As shown, the device includes:
[0120] The data acquisition unit 51 is used to acquire multiple text data corresponding to multiple similar texts stored in the corpus. Some of the text data has classification labels, and the classification labels are used to indicate the text classification result of the text data.
[0121] Graph construction unit 52 is used to construct graph data based on the text similarity between every two text data in the plurality of text data, wherein each text data is used to indicate local information of the plurality of similar texts, and the graph data is used to indicate global information of the plurality of similar texts;
[0122] The text classification unit 53 is used to input each text data and the graph data into the text classification model to be trained for model training, so as to obtain the trained text classification model and the text classification results of the text data without classification labels in the multiple text data.
[0123] Optionally, the graph building unit 52 is specifically used for:
[0124] Combine every two text data points from the plurality of text data points to obtain a text data pair;
[0125] Based on the text similarity between the two text data included in each text data pair, target text data pairs are selected from each text data pair;
[0126] Graph data is constructed from the two included text data based on the target text data.
[0127] Optionally, the graph building unit 52 is also specifically used for:
[0128] Determine the text similarity at the word level between the two text data included in each text data pair;
[0129] Among the various text data pairs, text data pairs whose text similarity at the text level meets the first preset similarity requirement are selected as candidate text data pairs;
[0130] Determine the semantic similarity between the two text data included in each candidate text data pair;
[0131] Among the candidate text data pairs, those whose text similarity at the semantic level meets the second preset similarity requirement are selected as the target text data pairs.
[0132] Optionally, the graph building unit 52 is also specifically used for:
[0133] For each target text data pair, the two text data included in the target text data pair are converted into two nodes, and a connection relationship is established between the two nodes;
[0134] Based on the connection relationships between the nodes corresponding to each of the target text data pairs, an adjacency matrix is constructed;
[0135] Based on the feature vectors of the nodes corresponding to each of the target text data pairs, a node feature matrix is constructed;
[0136] The graph data is constructed based on the adjacency matrix and the node feature matrix.
[0137] Optionally, the text classification model to be trained includes a first classification network, which includes M graph convolutional layers, where M is an integer greater than or equal to 1; the text classification unit 53 is specifically used for:
[0138] The graph data is processed by graph convolutional layers in the first classification network to obtain a first processing result of the graph data; wherein, the input of the first graph convolutional layer is the adjacency matrix and the node feature matrix corresponding to the graph data; the input of the j-th graph convolutional layer is the output of the (j-1)-th graph convolutional layer and the adjacency matrix corresponding to the graph data; each graph convolutional layer processes the input data; the output of the M-th graph convolutional layer is the first processing result of the graph data; the first processing result of the graph data includes the first processing result of each text data; j is an integer greater than 1 and less than M.
[0139] Optionally, the text classification model to be trained further includes a second classification network, which comprises multiple convolutional networks, each with a different kernel size, and each convolutional network includes a pooling layer and N convolutional layers; where N is an integer greater than or equal to 1; the text classification unit 53 is specifically used for:
[0140] For each piece of text data, the text data is processed by convolutional layers in the plurality of convolutional networks to obtain multiple convolutional processing results for the text data. Each convolutional processing result corresponds one-to-one with a convolutional network. Specifically, in the convolutional processing of each convolutional network, the input of the first convolutional layer is the text data; the input of the i-th convolutional layer is the output of the (i-1)-th convolutional layer; each convolutional layer performs convolutional processing on the input data; the output of the N-th convolutional layer is the convolutional processing result of the text data; i = is an integer greater than 1 and less than N.
[0141] The convolutional processing results of the text data are pooled through the pooling layers in the multiple convolutional networks to obtain multiple second processing results of the text data; the second processing results correspond one-to-one with the convolutional networks.
[0142] Optionally, the text classification model to be trained further includes a concatenation layer and a fully connected layer; the text classification unit 53 is specifically used for:
[0143] For each piece of text data, the first processing result of the text data in the first processing result of the graph data and the multiple second processing results corresponding to the text data are combined through the splicing layer to obtain the third processing result of the text data;
[0144] The fully connected layer classifies the text data based on the third processing result of the text data to obtain the target classification result of the text data.
[0145] Based on the target classification result corresponding to the text data with classification labels and the classification labels of the text data with classification labels, the first classification network and the second classification network are back-driven to adjust their parameters so that the target classification result approximates the classification label.
[0146] Optionally, the text classification unit 53 is also specifically used for:
[0147] The node feature matrix corresponding to the graph data is updated according to the third processing result corresponding to the text data with classification labels, so as to stimulate the feature vector update of the nodes of the text data without classification labels that are adjacent to the text data with classification labels in the graph data;
[0148] The node feature matrix corresponding to the graph data is updated according to the third processing result corresponding to the text data without classification labels, so as to stimulate the feature vector update of the nodes of the text data with classification labels that are adjacent to the text data without classification labels in the graph data;
[0149] The text classification model is further used to determine the text classification result of the text data without classification labels based on the updated feature vectors of the nodes of the text data without classification labels.
[0150] It should be noted that the text classification device in this embodiment can implement all the processes of the aforementioned text classification method embodiments and achieve the same effects and functions, which will not be repeated here.
[0151] This specification also provides a computer device according to one embodiment. Figure 6 This is a schematic diagram of the structure of a computer device provided in one embodiment of this specification, such as... Figure 6 As shown. Computer devices can vary considerably due to differences in configuration or performance, and may include one or more processors 1001 and memory 1002. Memory 1002 may store one or more application programs or data. Memory 1002 may be temporary or persistent storage. The application programs stored in memory 1002 may include one or more modules (not shown), each module may include a series of computer-executable instructions in the computer device. Furthermore, processor 1001 may be configured to communicate with memory 1002 and execute the series of computer-executable instructions in memory 1002 on the computer device. The computer device may also include one or more power supplies 1003, one or more wired or wireless network interfaces 1004, one or more input / output interfaces 1005, one or more keyboards 1006, etc.
[0152] In one specific embodiment, a computer device includes: a processor; and a memory arranged to store computer-executable instructions configured to be executed by the processor to perform the following process:
[0153] Obtain multiple text data corresponding to multiple similar texts stored in a corpus, wherein some of the multiple text data have classification labels, and the classification labels are used to indicate the text classification result of the text data;
[0154] Graph data is constructed based on the text similarity between every two text data in the plurality of text data, wherein each text data is used to indicate local information of the plurality of similar texts, and the graph data is used to indicate global information of the plurality of similar texts;
[0155] Each text data and the graph data are input into the text classification model to be trained to obtain the trained text classification model and the text classification results of the text data without classification labels among the multiple text data.
[0156] It should be noted that the computer device in this embodiment can implement the various processes of the aforementioned text classification method embodiments and achieve the same effects and functions, which will not be repeated here.
[0157] This specification also provides a storage medium for storing computer-executable instructions.
[0158] In one specific embodiment, the storage medium can be a USB flash drive, optical disc, hard disk, etc., and the computer-executable instructions stored in the storage medium, when executed by a processor, can achieve the following process:
[0159] Obtain multiple text data corresponding to multiple similar texts stored in a corpus, wherein some of the multiple text data have classification labels, and the classification labels are used to indicate the text classification result of the text data;
[0160] Graph data is constructed based on the text similarity between every two text data in the plurality of text data, wherein each text data is used to indicate local information of the plurality of similar texts, and the graph data is used to indicate global information of the plurality of similar texts;
[0161] Each text data and the graph data are input into the text classification model to be trained to obtain the trained text classification model and the text classification results of the text data without classification labels among the multiple text data.
[0162] It should be noted that the storage medium in this embodiment can implement all the processes of the aforementioned text classification method embodiments and achieve the same effect and function, which will not be repeated here.
[0163] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0164] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, the embodiments of this specification can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification can take the form of a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0165] This specification is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this specification. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0166] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0167] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0168] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0169] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0170] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0171] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0172] The embodiments described in this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can reside in local and remote computer storage media, including storage devices.
[0173] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0174] The above description is merely an embodiment of this document and is not intended to limit the scope of this document. Various modifications and variations can be made to this document by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this document should be included within the scope of the claims of this document.
Claims
1. A text classification method, characterized in that, include: Obtain multiple text data corresponding to multiple similar texts stored in a corpus, wherein some of the multiple text data have classification labels, and the classification labels are used to indicate the text classification result of the text data; Graph data is constructed based on the text similarity between every two text data in the plurality of text data, wherein each text data is used to indicate local information of the plurality of similar texts, and the graph data is used to indicate global information of the plurality of similar texts; Each text data and the graph data are input into a text classification model to be trained for model training, resulting in a trained text classification model and text classification results for text data without classification labels among the multiple text data; the text classification model includes a first classification network and a second classification network, the first classification network performs graph convolution processing on the graph data to obtain a first processing result for each text data, and the second classification network performs convolution and pooling processing on each text data to obtain a second processing result for each text data.
2. The method according to claim 1, characterized in that, The step of constructing graph data based on the text similarity between every two text data points in the plurality of text data includes: Combine every two text data points from the plurality of text data points to obtain a text data pair; Based on the text similarity between the two text data included in each text data pair, target text data pairs are selected from each text data pair; Graph data is constructed from the two included text data based on the target text data.
3. The method according to claim 2, characterized in that, The step of filtering target text data pairs from each text data pair based on the text similarity between the two text data pairs included in each text data pair includes: Determine the text similarity at the word level between the two text data included in each text data pair; Among the various text data pairs, text data pairs whose text similarity at the text level meets the first preset similarity requirement are selected as candidate text data pairs; Determine the semantic similarity between the two text data included in each candidate text data pair; Among the candidate text data pairs, those whose text similarity at the semantic level meets the second preset similarity requirement are selected as the target text data pairs.
4. The method according to claim 2, characterized in that, The step of constructing graph data from the two included text data based on the target text data includes: For each target text data pair, the two text data included in the target text data pair are converted into two nodes, and a connection relationship is established between the two nodes; Based on the connection relationships between the nodes corresponding to each of the target text data pairs, an adjacency matrix is constructed; Based on the feature vectors of the nodes corresponding to each of the target text data pairs, a node feature matrix is constructed; The graph data is constructed based on the adjacency matrix and the node feature matrix.
5. The method according to claim 4, characterized in that, The first classification network includes M graph convolutional layers, where M is an integer greater than or equal to 1; the step of inputting each text data and the graph data into the text classification model to be trained for model training includes: The graph data is processed by graph convolutional layers in the first classification network to obtain a first processing result of the graph data; wherein, the input of the first graph convolutional layer is the adjacency matrix and the node feature matrix corresponding to the graph data; the input of the j-th graph convolutional layer is the output of the (j-1)-th graph convolutional layer and the adjacency matrix corresponding to the graph data; each graph convolutional layer processes the input data; the output of the M-th graph convolutional layer is the first processing result of the graph data; the first processing result of the graph data includes the first processing result of each text data; j is an integer greater than 1 and less than M.
6. The method according to claim 5, characterized in that, The second classification network includes multiple convolutional networks, each with a different kernel size. Each convolutional network includes a pooling layer and N convolutional layers, where N is an integer greater than or equal to 1. The step of inputting each text data and the graph data into the text classification model to be trained for model training includes: For each piece of text data, the text data is processed by convolutional layers in the plurality of convolutional networks to obtain multiple convolutional processing results for the text data. Each convolutional processing result corresponds one-to-one with a convolutional network. Specifically, in the convolutional processing of each convolutional network, the input of the first convolutional layer is the text data; the input of the i-th convolutional layer is the output of the (i-1)-th convolutional layer; each convolutional layer performs convolutional processing on the input data; the output of the N-th convolutional layer is the convolutional processing result of the text data; i = is an integer greater than 1 and less than N. The convolutional processing results of the text data are pooled through the pooling layers in the multiple convolutional networks to obtain multiple second processing results of the text data; the second processing results correspond one-to-one with the convolutional networks.
7. The method according to claim 6, characterized in that, The text classification model to be trained further includes a concatenation layer and a fully connected layer; the step of inputting each text data and the graph data into the text classification model to be trained for model training includes: For each piece of text data, the first processing result of the text data in the first processing result of the graph data and the multiple second processing results corresponding to the text data are combined through the splicing layer to obtain the third processing result of the text data; The fully connected layer classifies the text data based on the third processing result of the text data to obtain the target classification result of the text data. Based on the target classification result and its classification label corresponding to the text data with classification labels, the first classification network and the second classification network are back-driven to adjust their parameters so that the target classification result approximates the classification label.
8. The method according to claim 7, characterized in that, The method further includes: The node feature matrix corresponding to the graph data is updated according to the third processing result corresponding to the text data with classification labels, so as to stimulate the feature vector update of the nodes of the text data without classification labels that are adjacent to the text data with classification labels in the graph data; The node feature matrix corresponding to the graph data is updated based on the third processing result corresponding to the text data without classification labels, so as to stimulate the feature vector update of the nodes of the text data with classification labels that are adjacent to the text data without classification labels in the graph data; The text classification model is further used to determine the text classification result of the text data without classification labels based on the updated feature vectors of the nodes of the text data without classification labels.
9. A text classification device, characterized in that, include: The data acquisition unit is used to acquire multiple text data corresponding to multiple similar texts stored in the corpus. Some of the text data has classification labels, and the classification labels are used to indicate the text classification result of the text data. The graph construction unit is used to construct graph data based on the text similarity between every two text data in the plurality of text data, wherein each text data is used to indicate local information of the plurality of similar texts, and the graph data is used to indicate global information of the plurality of similar texts; A text classification unit is used to input each text data and the graph data into a text classification model to be trained for model training, to obtain the trained text classification model and the text classification results of the text data without classification labels in the multiple text data; the text classification model includes a first classification network and a second classification network, the first classification network performs graph convolution processing on the graph data to obtain a first processing result for each text data, and the second classification network performs convolution and pooling processing on each text data to obtain a second processing result for each text data.
10. A computer device, characterized in that, The device includes: Processor; and A memory is configured to store computer-executable instructions configured to be executed by the processor for performing steps in the text classification method as described in any one of claims 1-8.
11. A storage medium, characterized in that, The storage medium is used to store computer-executable instructions that cause a computer to perform the steps in the text classification method as described in any one of claims 1-8.
Citation Information
Patent Citations
Text classification method based on semi-supervised graph convolutional neural network
CN113792144A