Multi-label classification method, device and equipment and computer readable storage medium

By fusing text features and label features in multi-label classification and using a deep learning model for label prediction, the problem of unsatisfactory classification results in existing technologies is solved, and more accurate label classification is achieved.

CN116361449BActive Publication Date: 2026-07-21SF TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SF TECH CO LTD
Filing Date
2021-12-23
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing multi-label classification methods only consider the features of the target text itself and the correlation between the features of each label, resulting in unsatisfactory classification results and misjudgments.

Method used

By extracting textual features from the target text and fusing them with trained label features, a fused feature is obtained. A deep learning model is then used for label prediction, which includes the correlation information between the various label features.

Benefits of technology

It improves the accuracy of multi-label classification by better reflecting the semantic correlation between labels through feature fusion, resulting in more accurate label classification results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116361449B_ABST
    Figure CN116361449B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a multi-label classification method, device and equipment and a computer readable storage medium. The method comprises: obtaining a target text to be classified; extracting a text feature of the target text; obtaining a fusion feature according to the text feature and a trained label feature; and determining a target classification label of the target text from a preset label according to the fusion feature. The multi-label classification method provided by the embodiment of the application fuses the text feature and the trained label feature after the text feature of the target text is extracted to obtain the fusion feature. Compared with the prior art which determines the label classification result of the target text by considering the correlation between the text feature of the target text and each label feature, the fusion feature also contains the correlation information between each label feature, so that a more accurate label classification result can be obtained by using the fusion feature subsequently.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of text classification technology, specifically to a multi-label classification method, apparatus, device, and computer-readable storage medium. Background Technology

[0002] Multi-label classification is a common problem with wide applications in industry, such as identifying which items are in an image or how many labels are contained in a text description.

[0003] Multi-label classification typically assigns multiple different labels to the target text, meaning that the labels are not independent of each other. However, in conventional multi-label classification techniques, such as text classification, only the correlation between the text's own features and the features of each label is considered to achieve multi-label classification of the text. This results in less than ideal multi-label classification performance and still leads to some misjudgments. Summary of the Invention

[0004] This application provides a multi-label classification method, apparatus, device, and computer-readable storage medium, aiming to solve the technical problem that the classification effect of existing multi-label classification methods is not ideal.

[0005] On the one hand, embodiments of this application provide a multi-label classification method, including:

[0006] Obtain the target text to be classified;

[0007] Extract the text features of the target text;

[0008] The fused features are obtained based on the text features and the trained label features;

[0009] The target classification label of the target text is determined from the preset labels based on the fusion features.

[0010] As an optional embodiment of this application, the step of extracting the text features of the target text includes:

[0011] The target text is input into the feature extraction layer of a trained classification model to obtain the text features of the target text;

[0012] The step of determining the target classification label of the target text from the preset labels based on the fusion features includes:

[0013] The fused features are input into the prediction layer of the classification model to obtain the classification probability of the target text corresponding to the preset label;

[0014] The target classification label of the target text is determined from the preset labels based on the classification probability.

[0015] As an optional embodiment of this application, before the step of inputting the target text into the feature extraction layer of a trained classification model to obtain the text features of the target text, the method further includes:

[0016] Obtain the initial classification model, initial label features, training text, and the real labels corresponding to the training text;

[0017] Based on the initial classification model and the initial label features, determine the predicted probability of the training text corresponding to the preset label;

[0018] The loss value of the initial classification model is determined based on the predicted probability and the true label;

[0019] The initial classification model and the initial label features are trained based on the loss value to obtain the trained classification model and trained label features.

[0020] As an optional embodiment of this application, the step of calculating the predicted probability of the training text corresponding to the preset label based on the initial classification model and the initial label features includes:

[0021] The training text is input into the initial feature extraction layer of the initial classification model to obtain the training text features of the training text;

[0022] The training fusion features are obtained based on the training text features and the initial label features;

[0023] The training fusion features are input into the initial prediction layer of the initial classification model to obtain the predicted probability of the training text corresponding to the preset label.

[0024] As an optional embodiment of this application, the step of determining the loss value of the initial classification model based on the predicted probability and the true label includes:

[0025] Calculate the cross-entropy between the prediction vector corresponding to the predicted probability and the training vector corresponding to the true label to obtain the first loss value;

[0026] The second loss value is obtained based on the similarity between the trained fusion features and the initial label features;

[0027] The sum of the first loss value and the second loss value is calculated to obtain the loss value of the initial classification model.

[0028] As an optional embodiment of this application, the step of obtaining the second loss value based on the similarity between the trained fusion features and the initial label features includes:

[0029] Calculate the label similarity between the label features corresponding to the real label and the training fusion features, and set the minimum value of the label similarity as the first similarity;

[0030] The labels other than the real labels in the preset labels are set as non-real labels, and the non-label similarity between the label features corresponding to the non-real labels and the training fusion features is calculated;

[0031] The maximum value among the unlabeled similarities is set as the second similarity;

[0032] The second loss value is obtained based on the first similarity and the second similarity.

[0033] As an optional embodiment of this application, the step of training the initial classification model and the initial label features based on the loss value to obtain the trained classification model and trained label features includes:

[0034] The initial classification model and the initial label features are updated based on the loss value to obtain the updated training classification model and training label features;

[0035] The loss value of the training classification model is determined based on the training classification model, the training label features, the training text, and the real label.

[0036] When the loss value of the training classification model meets the preset training completion condition, the training classification model is set as a trained classification model, and the training label features are set as trained label features.

[0037] As an optional embodiment of this application, the step of obtaining the fused features based on the text features and the trained label features includes:

[0038] Calculate the vector product between the text features and the trained label features to obtain the attention matrix;

[0039] The attention matrix is ​​normalized to obtain the weight matrix;

[0040] Calculate the vector product between the weight matrix and the text features to obtain the target matrix;

[0041] The fusion features are extracted from the target matrix.

[0042] On the other hand, embodiments of this application also provide a multi-label classification device, including:

[0043] The acquisition module is used to acquire the target text to be classified.

[0044] An extraction module is used to extract text features from the target text;

[0045] The fusion module is used to obtain fused features based on the text features and the trained label features;

[0046] The classification module is used to determine the target classification label of the target text from the preset labels based on the fusion features.

[0047] On the other hand, this application embodiment also provides a multi-label classification device, which includes a processor, a memory, and a multi-label classification program stored in the memory and executable on the processor. The processor executes the multi-label classification program to implement the steps in the multi-label classification method described above.

[0048] On the other hand, embodiments of this application also provide a computer-readable storage medium storing a multi-label classification program, which is executed by a processor to implement the steps in the multi-label classification method described above.

[0049] The classification method provided in this application, after extracting the text features of the target text, fuses the text features with the trained label features to obtain fused features. Compared with the prior art, which considers the correlation between the text features of the target text and each label feature separately to determine the label classification result of the target text, the fused features also contain the correlation information between each label feature, so that a more accurate label classification result can be obtained by using the fused features. Attached Figure Description

[0050] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0051] Figure 1 This is a flowchart illustrating the steps of a multi-label classification method provided in an embodiment of this application.

[0052] Figure 2 A flowchart illustrating the steps of another multi-label classification method provided in this application embodiment;

[0053] Figure 3 This application provides a flowchart illustrating the steps for synchronously training a classification model and label features in an embodiment of the present application.

[0054] Figure 4This application provides a schematic flowchart illustrating the steps for determining a prediction probability in an embodiment of the present application.

[0055] Figure 5 This application provides a schematic flowchart of a step for calculating a loss value in an embodiment of the present application.

[0056] Figure 6 A flowchart illustrating the steps for calculating a second loss value is provided in this application embodiment.

[0057] Figure 7 This application provides a schematic diagram of the steps for iteratively training a classification model and label features in an embodiment of the present application.

[0058] Figure 8 This is a schematic flowchart illustrating the steps for calculating fusion features in an embodiment of this application.

[0059] Figure 9 This is a schematic diagram of the structure of a multi-label classification device provided in an embodiment of this application;

[0060] Figure 10 This is a schematic diagram of the structure of a multi-label classification device provided in an embodiment of this application. Detailed Implementation

[0061] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of the present invention.

[0062] In this application, the term "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to implement and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be implemented without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in the embodiments of this application.

[0063] This application provides a multi-label classification method, apparatus, device, and computer-readable storage medium, which are described in detail below.

[0064] The multi-label classification method provided in this application embodiment is deployed in the form of a program within a multi-label classification device, which is itself configured as a processor within the multi-label classification equipment. The multi-label classification device executes the program corresponding to the multi-label classification method deployed on it to perform multi-label classification of the target, thereby outputting the multi-label classification result of the target. Specifically, in this application embodiment, the multi-label classification device mainly performs the following steps: acquiring the target text to be classified; extracting the text features of the target text; obtaining fusion features based on the text features and trained label features; and determining the target classification label of the target text from preset labels based on the fusion features.

[0065] To better illustrate the implementation scheme of the multi-label classification method provided in this application embodiment, we will take text multi-label classification as an example for explanation, and will provide a detailed description below.

[0066] like Figure 1 As shown, Figure 1 A flowchart illustrating the steps of a multi-label classification method provided in this application embodiment specifically includes steps 101 to 104:

[0067] 101. Obtain the target text to be classified.

[0068] In this application embodiment, the target text usually refers to the text that has been input by the user or other feasible means into the multi-label classification device for classification. Common text multi-label classification includes multi-label classification of the emotions contained in the text or the type to which the text belongs.

[0069] 102. Extract the text features of the target text.

[0070] In this embodiment, extracting text features typically refers to converting text represented by words into text features represented by high-dimensional numerical vectors; that is, text features can be understood as text feature vectors. Specifically, extracting text features usually requires processing steps such as encoding and convolution.

[0071] Typically, in order to enable the extracted text features to be used for subsequent label classification, text feature extraction usually relies on deep learning. Specifically, for example, feature extraction of the target text is achieved through a pre-set neural network in a multi-label classification device, where the neural network is trained based on deep learning.

[0072] 103. The fused features are obtained based on the text features and the trained label features.

[0073] In this embodiment, similar to text features, label features typically exist in vector form; that is, label features can be understood as label feature vectors. However, unlike conventional label classification methods, which independently calculate the relationships between text features and the label features of each label to classify multiple labels, this embodiment fuses the extracted text features and all trained label features to obtain fused features. These fused features not only contain the relationships between the text features of the target text and the individual label features, but also the relationships between the label features of each label. In other words, the fused features contain richer semantic information; they can be understood as text vector representations incorporating label information.

[0074] Furthermore, in label classification, especially in single-label classification where only one label is assigned to a target, the label features of each label are independent of each other. For example, typically, the label features are determined using a one-hot encoding method for each label. Taking the emotions implied in text as an example, if the labels include N labels such as happy, depressed, sad, optimistic, pessimistic, and sunny, then N-dimensional unit vectors are used as the label features for the above N labels respectively. That is, the label feature for happy is (1, 0, 0, 0, ..., 0), the label feature for depressed is (0, 1, 0, 0, ..., 0), and the label feature for sad is (0, 0, 1, 0, ..., 0). However, the label features obtained above ignore the semantic correlation between the labels themselves. For example, depressed, sad, and pessimistic often have a high degree of correlation, and their label features should also be more similar; happy, optimistic, and sunny often have a high degree of correlation, and their label features should also be more similar. In this embodiment, the label features of each label are obtained through training. Compared with the label features determined by the one-hot encoding method, the label features provided by this embodiment can better reflect the semantic correlation between each label.

[0075] Furthermore, as an optional embodiment of this application, the fusion of text features and label features is achieved based on an attention mechanism, as detailed in the subsequent sections. Figure 8 And its explanations and descriptions.

[0076] 104. Determine the target classification label of the target text from the preset labels based on the fusion features.

[0077] In this embodiment, after obtaining the fused features, that is, the text vector representation incorporating tag information, the target classification tag of the target text can be determined from the preset tags by decoding the text vector representation. Specifically, the preset tags are pre-defined and contain all the classification tags of the text to be classified. For example, taking the aforementioned emotion contained in the text as an example, the preset tags include happy, depressed, sad, optimistic, pessimistic, sunny, etc.

[0078] Similarly, to obtain more accurate target classification labels, the process of determining target classification labels based on fused features can also rely on deep learning. For example, the prediction of target classification labels can also be achieved through a pre-set neural network in a multi-label classification device.

[0079] As an optional embodiment of this application, considering that a deep learning-dependent neural network is also used in the aforementioned feature extraction step, the process of determining the target classification label based on the fused features and the process of extracting the text features of the target text can be linked and implemented through a classification model. Specifically, this classification model includes a feature extraction layer and a prediction layer. The neural network in the feature extraction layer is used to extract the text features of the target text, while the neural network in the prediction layer is used to predict the label based on the fused features, thus obtaining the target classification label of the target text. For a more detailed implementation scheme of multi-label classification, please refer to the subsequent sections. Figure 2 And its explanations and descriptions.

[0080] The classification method provided in this application, after extracting the text features of the target text, fuses the text features with the trained label features to obtain fused features. Compared with the prior art, which considers the correlation between the text features of the target text and each label feature separately to determine the label classification result of the target text, the fused features also contain the correlation information between each label feature, so that a more accurate label classification result can be obtained by using the fused features.

[0081] like Figure 2 As shown, Figure 2 A flowchart illustrating the steps of another classification method provided in this application embodiment is described in detail below.

[0082] In this embodiment of the application, with Figure 1 The difference in the flowchart of the classification method shown is that feature extraction and determination of the target classification label are based on a classification model trained by deep learning. This classification model includes a feature extraction layer and a prediction layer, specifically steps 201-205:

[0083] 201, Obtain the target text to be classified.

[0084] The target text refers to the text that has been input by the user or through other feasible means into the multi-label classification device for classification. This application will not elaborate further here; please refer to the aforementioned step 101 and its explanation for details.

[0085] 202. Input the target text into the feature extraction layer of the trained classification model to obtain the text features of the target text.

[0086] In this embodiment of the application, the feature extraction layer in the classification model mainly includes two parts: an encoding part and a feature extraction part. The encoding part is mainly used to encode the target text. For example, each character in the target text can be converted into a numerical ID by using a dictionary, thereby constructing the input of the feature extraction part. The feature extraction part is mainly used to extract text features. For example, the feature extraction part is usually trained based on the pre-trained model BERT.

[0087] 203. Based on the text features and the trained label features, the fused features are obtained.

[0088] The aforementioned step 103 has already provided a specific implementation scenario for the tag features and the fusion features obtained based on the text features and tag features in the embodiments of this application. The embodiments of this application will not repeat the details here. For details, please refer to the aforementioned step 103 and its explanation.

[0089] 204. Input the fused features into the prediction layer of the classification model to obtain the classification probability of the target text corresponding to the preset label.

[0090] In this embodiment, the prediction layer in the classification model mainly consists of two parts: a fully connected layer and an activation function layer. The fully connected layer is mainly used to perform further convolution processing on the obtained fused features, while the activation function is used to predict the classification probability. For example, the sigmoid activation function is usually chosen. Specifically, the output vector after processing by the fully connected layer has a dimension of N, corresponding to N preset labels. After further processing by the sigmoid activation function, the value of each dimension in the N-dimensional output vector is between (0, 1). Therefore, the values ​​of the N dimensions can be understood as the classification probability of the target text corresponding to the N labels.

[0091] 205. Determine the target classification label of the target text from the preset labels based on the classification probability.

[0092] In this embodiment, as described above, the value of each dimension in the N-dimensional output vector ranges from (0, 1), and the values ​​of the N dimensions can be understood as the classification probabilities of the target text corresponding to N tags. That is, the higher the classification probability, i.e., the closer it is to 1, the more likely the corresponding tag is to be the target classification tag of the target text. Therefore, by comparing the relationship between each classification probability and a preset classification probability threshold, tags with classification probabilities higher than the threshold can be used as target classification tags. Alternatively, the classification probabilities can be sorted in descending order, and the tags corresponding to the first few classification probabilities can be used as target classification tags. Of course, there are many specific implementation schemes for determining the target classification tag, which will not be elaborated upon here.

[0093] Furthermore, embodiments of this application provide a classification model trained using deep learning to extract features from target text and predict classification probabilities. Additionally, considering that the label features in these embodiments are also pre-trained using deep learning, as an optional embodiment of this application, the classification model and label features are simultaneously trained using deep learning and have a corresponding relationship. Specifically... Figure 3 A scheme for obtaining classification models and label features through simultaneous training is presented; details can be found in subsequent sections. Figure 3 And its explanations and descriptions.

[0094] like Figure 3 As shown, Figure 3 This application provides a flowchart illustrating the steps for simultaneously training a classification model and label features, specifically including steps 301-304:

[0095] 301. Obtain the initial classification model, initial label features, training text, and the real labels corresponding to the training text.

[0096] In this embodiment, during the training of the classification model based on deep learning, the result of the classification model remains unchanged; only the parameters within the model are altered. Therefore, as previously disclosed, the classification model includes a feature extraction layer and a prediction layer. The initial classification model also includes an initial feature extraction layer and an initial prediction layer. However, compared to the final trained classification model, the parameters in the initial feature extraction layer and the initial prediction layer are randomly generated and cannot be used to accurately achieve multi-label classification. Deep learning, on the other hand, utilizes a large amount of training text with known real labels. During training, it calculates the predicted labels for the training text and the difference between the predicted and real labels. By continuously learning and adjusting the model's parameters, the difference between the predicted and real labels is continuously reduced until the final predicted and real labels are almost indistinguishable. At this point, the predicted label obtained by the model is the true label result of the text, thus completing the training of the model. The true labels corresponding to the training text typically refer to those obtained by manually labeling the training text.

[0097] Furthermore, similar to the initial classification model, the parameters in the initial label features can also be randomly generated. Alternatively, as another optional implementation in this application, the initial label features can also be obtained by averaging the text feature vectors obtained from inputting each character in the label into the initial feature extraction layer.

[0098] Furthermore, in order to train the label features so that they can reflect the semantic information of the label text itself to a certain extent, this application embodiment proposes a new loss calculation function in addition to considering the difference between the predicted label and the true label during the training process. For details, please refer to subsequent steps 303 and... Figure 5 Explanation.

[0099] 302. Based on the initial classification model and the initial label features, determine the predicted probability of the preset label corresponding to the training text.

[0100] In this embodiment, the training text is input into a given initial classification model. Using the given initial label features, the predicted probability of the training text corresponding to a preset label can be obtained. The complete implementation steps are similar to the application stage, also using the feature extraction layer in the initial classification model to extract features from the training text, then fusing them with the initial label features, and finally inputting them into the prediction layer in the initial classification model to output the predicted probability. For details, please refer to the subsequent sections. Figure 4 And its explanations and descriptions.

[0101] 303. Determine the loss value of the initial classification model based on the predicted probability and the true label.

[0102] In this embodiment of the application, as described above, deep learning optimizes the model by reducing the difference between the predicted label calculated by the model and the true label. The predicted probability can be understood to some extent as the predicted label calculated by the model; therefore, the loss value of the initial classification model can be determined based on the predicted probability and the true label.

[0103] Furthermore, in this embodiment, besides optimizing the classification model using the difference between predicted and true labels, it is also necessary to optimize the label features to reflect the semantic information of the labels to a certain extent. Therefore, it is also necessary to consider the loss value related to the label features. As an optional embodiment of this application, the loss value related to the label features is obtained based on the similarity between the fused training features obtained by fusing training text features and initial label features during training and each initial label feature. For details, please refer to the following sections. Figure 5 And its explanations and descriptions.

[0104] 304. The initial classification model and the initial label features are trained based on the loss value to obtain the trained classification model and the trained label features.

[0105] In this embodiment of the application, after obtaining the loss, the initial classification model and initial label features are iteratively optimized based on the loss value, so that the trained classification model and label features can be finally obtained. At this time, the label features contain the semantic information of the label, and the classification model can perform the classification task of the target text well under the label features.

[0106] Specifically, the implementation scheme for iteratively training the initial classification model and initial label features until a trained classification model and label features are obtained can be found in subsequent articles. Figure 7 And its explanations and descriptions.

[0107] like Figure 4 As shown, Figure 4 This application provides a flowchart illustrating the steps for determining a prediction probability, specifically including steps 401 to 403:

[0108] 401. Input the training text into the initial feature extraction layer of the initial classification model to obtain the training text features of the training text.

[0109] In this embodiment of the application, similar to the feature extraction layer in the trained classification model, the initial feature extraction layer in the initial classification model also includes two parts: encoding and feature extraction. The training text is input into the initial feature extraction layer, and after encoding and feature extraction, the training text features of the training text can be obtained.

[0110] 402. The training fusion features are obtained based on the training text features and the initial label features.

[0111] In this embodiment, after obtaining the training text features, the training text features and the initial label features can also be fused based on an attention mechanism to obtain the fused training features. It should be noted that the specific implementation scheme in this step is the same as... Figure 1 Step 103, which involves using text features and label features to obtain fused features, differs only in the input data processed. Those skilled in the art can refer to... Figure 8 After showing the specific implementation steps for obtaining fused features using text features and label features, we can obtain the complete implementation steps for fusing training text features and initial label features to obtain training fused features in this step.

[0112] 403. Input the training fusion features into the initial prediction layer of the initial classification model to obtain the prediction probability of the preset label corresponding to the training text.

[0113] In this embodiment, similar to the prediction layer in the trained classification model, the initial prediction layer in the initial classification model also includes a fully connected layer and an activation function. After the training fusion features are processed by the fully connected layer and the activation function in the prediction layer, the prediction probability of the preset label corresponding to the training text can be obtained. This embodiment will not be described in detail here.

[0114] like Figure 5 As shown, Figure 5 A flowchart illustrating the steps for calculating a loss value, as provided in an embodiment of this application, is described in detail below.

[0115] In this embodiment of the application, a scheme for calculating the loss value that simultaneously considers the classification model and the label features is proposed. The loss value consists of two parts, corresponding to the loss value of the classification model and the loss value of the label features, respectively. Specifically, it includes steps 501 to 503:

[0116] 501. Calculate the cross-entropy between the prediction vector corresponding to the predicted probability and the training vector corresponding to the true label to obtain the first loss value.

[0117] In this embodiment, as described above, the difference between the predicted label obtained by the model from processing the training text and the corresponding real label of the training text can describe the model's loss value. Specifically, the predicted probability obtained by inputting the training text into the model is usually composed of an N-dimensional prediction vector, and the real label corresponding to the model can also constitute an N-dimensional training vector. Specifically, in the training vector, if a label is the real label corresponding to the training sample, the value of the dimension corresponding to that label is 1; if a label is not the real label corresponding to the training sample, the value of the dimension corresponding to that label is 0. The first loss value obtained by calculating the cross-entropy between the prediction vector and the training vector can be understood as the sum of the loss value between the value of the dimension corresponding to the real label in the prediction vector and 1, and the loss value between the value of the dimension corresponding to the non-real label and 0. Obviously, the larger the first loss value, the smaller the predicted value of the dimension corresponding to the real label in the prediction vector, and the larger the predicted value of the dimension corresponding to the non-real label, that is, the less accurate the predicted classification probability, and the worse the model's classification performance.

[0118] 502. Based on the similarity between the trained fusion features and the initial label features, a second loss value is obtained.

[0119] In this embodiment, if the label features can reflect the semantic information of the label itself, then for a given training text, the training text features and these real label features should be as similar as possible. That is, the similarity between the training fusion features obtained based on the training text and label features and these real labels should be sufficiently high, while the similarity with other non-real labels should be as low as possible. In other words, there should be a significant difference between the similarity between the training fusion features and real labels, and between the training fusion features and non-real labels. Based on this, this embodiment proposes an implementation scheme for obtaining a second loss value related to the label features using the similarity between the training fusion features and the initial label features. Specifically, the implementation scheme for calculating the second loss value related to the label features can be found in [reference needed]. Figure 6 And its explanations and descriptions.

[0120] 503. Calculate the sum of the first loss value and the second loss value to obtain the loss value of the initial classification model.

[0121] In this embodiment, the first loss value is related to the model, while the second loss value is related to the label features. At this time, by calculating the sum of the first and second loss values, the resulting loss value is related to both the model and the label features. In the subsequent training process of the model and label features based on this loss value, the performance of the classification model and the label features can be improved simultaneously. That is, the label features contain rich label semantic information, and the classification model can perform the classification task of the target text well under the label features.

[0122] As an optional embodiment of this application, during actual training, the weights of the first and second loss values ​​can be set to make the training process focus more on the loss value of the classification model or the label. For example, the weight of the first loss value can be higher than that of the second loss value, making the training process focus more on the main task, that is, more on the classification model itself. Of course, considering that the loss is dynamic, the weights can also be dynamically adjusted according to the ratio of the first and second loss values. But in any case, the weighted sum of the first and second loss values ​​needs to be calculated to obtain the final loss value.

[0123] like Figure 6 As shown, Figure 6 A flowchart illustrating the steps for calculating a second loss value, provided in an embodiment of this application, is described in detail below.

[0124] In this embodiment of the application, as described above, the similarity between the training fusion feature and the real label should be sufficiently high, while the similarity with other non-real labels should be as low as possible. That is, the second similarity is related to the difference between the similarity between the training fusion feature and the real label and the similarity between the training fusion feature and the non-real label. The larger this difference, the richer the semantic information contained in the label feature, and thus the smaller the second loss value. Specifically, calculating the second loss value includes steps 601-604:

[0125] 601. Calculate the label similarity between the label features corresponding to the real label and the training fusion features, and set the minimum value of the label similarity as the first similarity.

[0126] In this embodiment of the application, considering that the similarity between the training fusion features and the real labels should be as high as possible, the label similarity between the label features corresponding to each real label and the training fusion features can be calculated separately, and the minimum value among these label similarities can be used as the representative value of the label similarity between the label features corresponding to the real labels and the training fusion features. It can be understood that this minimum value should be as high as possible than the label similarity between the remaining label features and the training fusion features.

[0127] Specifically, cosine similarity can be used for similarity, but other similarity calculation formulas are also feasible. The embodiments of this application will not be elaborated here.

[0128] 602, set the labels other than the real labels in the preset labels as non-real labels, and calculate the non-label similarity between the label features corresponding to the non-real labels and the training fusion features.

[0129] In this embodiment, labels other than the real labels in the preset labels can be understood as non-real labels of the training text. Specifically, the label similarity between the label features corresponding to the non-real labels and the training fusion features can also be obtained using the formula for calculating cosine similarity.

[0130] 603, set the maximum value of the unlabeled similarity as the second similarity.

[0131] In this embodiment of the application, for these non-real labels, considering that the similarity between their corresponding label features and the training fusion features should be as low as possible, the maximum value of the non-label similarity can be selected as the representative value of the label similarity between the label features corresponding to the non-real labels and the training fusion features. Obviously, this maximum value should be as small as possible compared to the label similarity between the remaining label features and the training fusion features.

[0132] 604. Based on the first similarity and the second similarity, the second loss value is obtained.

[0133] In this embodiment of the application, after obtaining the first similarity and the second similarity, that is, the minimum similarity T between the label features corresponding to the real label and the training fusion features, min The maximum similarity F between the label features corresponding to the non-real labels and the training fusion features. max Then, the following loss function can be constructed to obtain the second loss value, Loss2:

[0134] Loss2=-(T min -F max -threadhold)

[0135] Here, threadhold is a preset constant threshold, which means that the minimum similarity in the real labels is still greater than the maximum similarity in the non-real labels by a threshold.

[0136] like Figure 7 As shown, Figure 7 A flowchart illustrating the iterative training steps for a classification model and label features, as provided in this application embodiment, is described in detail below.

[0137] In this embodiment of the application, steps 701 to 705 are specifically included.

[0138] 701. Update the initial classification model and the initial label features based on the loss value to obtain the updated training classification model and training label features.

[0139] In this embodiment of the application, after obtaining the loss value, the parameters in the initial classification model and initial label features are usually updated based on the backpropagation algorithm to obtain the updated training classification model and training label features.

[0140] 702. Determine the loss value of the training classification model based on the training classification model, the training label features, the training text, and the real label.

[0141] In this embodiment of the application, after obtaining the updated training classification model and training label features, the loss value of the training classification model can be determined again based on the training text and its corresponding real label.

[0142] 703. Determine whether the loss value of the trained classification model meets the preset training completion conditions. If yes, proceed to step 704; otherwise, proceed to step 705.

[0143] In this embodiment, the preset training completion condition typically refers to the loss value being consistently less than a certain preset threshold. Specifically, when the loss value is determined to be consistently less than the preset threshold, it indicates that both the first and second loss values ​​are sufficiently small. This means that the trained label features can effectively capture the semantic information of the labels themselves, and the trained classification model can accurately predict the classification of the training text. Therefore, the classification model and label features can be considered to have been successfully trained. Conversely, if the loss value is not consistently less than the preset threshold, it indicates that the first and / or second loss values ​​have not yet met the requirements. Therefore, further updates to the trained label features and the trained classification model are still needed.

[0144] Furthermore, the larger the loss threshold, the higher the efficiency of model training, but the relatively poorer the application effect of the model. On the other hand, the smaller the loss threshold, the better the application effect of the model, but the lower the efficiency of model training. Specifically, the loss threshold can be set based on the user's actual needs.

[0145] 704, Set the training classification model to a trained classification model, and set the training label features to trained label features.

[0146] In this embodiment of the application, after determining that the training completion condition is met, the training label features at this time are set as trained label features, and the training classification model at this time is set as trained classification model. In subsequent applications of multi-label classification, the trained label features and classification model can be directly used to complete the multi-label classification of the target.

[0147] 705. Update the training classification model and the training label features according to the loss value to obtain the updated training classification model and training label features, and return to step 702.

[0148] In this embodiment of the application, if it is determined that the training completion condition is not met, the training classification model and training label features need to be updated further based on the loss value. Then, the aforementioned steps are repeated, that is, using the training text and its real labels, the loss value of the updated training classification model and training label features is calculated again, and it is determined whether the loss value meets the preset training completion condition. Training can be ended when the loss value meets the preset training completion condition after a certain update, and the current classification model and label features are set as the trained classification model and label features.

[0149] like Figure 8 As shown, Figure 8 A flowchart illustrating the steps for calculating fusion features provided in this application embodiment is described in detail below.

[0150] This application embodiment provides a specific implementation scheme for calculating the fusion features between text features and label features based on an attention mechanism, specifically including steps 801-804:

[0151] 801. Calculate the vector product between the text features and the trained label features to obtain the attention matrix.

[0152] In this embodiment, the attention matrix obtained by calculating the vector product between text features and label features, where the value of each row represents the weight of each label to each word in the target text. Specifically, taking text features F0 and label features E as an example, the attention matrix A0 = E * F0.

[0153] Furthermore, considering that the dimensions of text features F0 and label features E0 may be unequal in actual processing, for example, the dimension of text feature F0 might be [seq_len, Ht], where seq_len is the length of the target text and Ht is the vector dimension of each character in the target text. The label features E of all labels can be represented by an N*H matrix, i.e., E = N*H, where N is the total number of labels and H is the dimension of a single label feature. In this case, it is necessary to first use a pre-defined matrix W of dimension [H, Ht] to make the dimension Ht of the text vector equal to the H of the label feature E, and then calculate the attention matrix, i.e., F1 = W * F0. T A0 = E * F1, where the dimension of F1 is [H, seq_len] and the dimension of A0 is [N, seq_len].

[0154] 802. Normalize the attention matrix to obtain the weight matrix.

[0155] In this embodiment of the application, the specific formula for calculating the weight matrix A1 is as follows:

[0156] A1 = softmax(A0), where softmax indicates that matrix A0 is subjected to softmax normalization. A1 and A0 have the same dimension, which is [N, seq_len].

[0157] 803. Calculate the vector product between the weight matrix and the text features to obtain the target matrix.

[0158] In this embodiment of the application, the target matrix F2 calculated based on the vector product of the weight matrix and the text features can be understood as the weight matrix of each label for each sentence, i.e., F2 = A1 * F0, where the dimension of F2 is [N, Ht].

[0159] 804, extract the fusion features from the target matrix.

[0160] In this embodiment of the application, by taking the average value of the first dimension of the target matrix, the text vector representation incorporating the label information can be obtained, that is, the dimension of the final output fusion feature F is Ht.

[0161] To better implement the multi-label classification method provided in the embodiments of this application, this application also provides a multi-label classification device based on the multi-label classification method. For example... Figure 9 As shown, Figure 9 This is a schematic diagram of a multi-label classification device provided in an embodiment of this application. Specifically, the multi-label classification device includes:

[0162] The acquisition module 901 is used to acquire the target text to be classified.

[0163] Extraction module 902 is used to extract text features of the target text.

[0164] The fusion module 903 is used to obtain fused features based on the text features and the trained label features.

[0165] The classification module 904 is used to determine the target classification label of the target text from the preset labels based on the fusion features.

[0166] In some embodiments of this application, the above-described extraction module is used to input the target text into the feature extraction layer of a trained classification model to obtain the text features of the target text;

[0167] The aforementioned classification module is used to input the fused features into the prediction layer of the classification model to obtain the classification probability of the target text corresponding to the preset label, and to determine the target classification label of the target text from the preset labels based on the classification probability.

[0168] In some embodiments of this application, the classification device further includes a training module; the training module includes:

[0169] The sample acquisition sub-module is used to acquire the initial classification model, initial label features, training text, and the real labels corresponding to the training text.

[0170] The prediction submodule is used to determine the prediction probability of the training text corresponding to the preset label based on the initial classification model and the initial label features.

[0171] The loss value calculation module is used to determine the loss value of the initial classification model based on the predicted probability and the true label;

[0172] The training submodule is used to train the initial classification model and the initial label features based on the loss value, so as to obtain the trained classification model and the trained label features.

[0173] In some embodiments of this application, the prediction sub-module includes:

[0174] The feature extraction unit is used to input the training text into the initial feature extraction layer in the initial classification model to obtain the training text features of the training text;

[0175] A feature fusion unit is used to obtain trained fusion features based on the training text features and the initial label features;

[0176] The probability prediction unit is used to input the training fusion features into the initial prediction layer of the initial classification model to obtain the prediction probability of the training text corresponding to the preset label.

[0177] In some embodiments of this application, the above-mentioned loss value calculation sub-module includes:

[0178] The first loss value calculation unit is used to calculate the cross-entropy between the prediction vector corresponding to the prediction probability and the training vector corresponding to the real label, and obtain the first loss value.

[0179] The second loss value calculation unit is used to obtain a second loss value based on the similarity between the training fusion features and the initial label features;

[0180] The summation unit is used to calculate the sum of the first loss value and the second loss value to obtain the loss value of the initial classification model.

[0181] In some embodiments of this application, the second loss value calculation unit includes:

[0182] The first similarity calculation subunit is used to calculate the label similarity between the label features corresponding to the real label and the training fusion features, and set the minimum value of the label similarity as the first similarity.

[0183] The second similarity calculation subunit is used to set the labels other than the real labels in the preset labels as non-real labels, and to calculate the non-label similarity between the label features corresponding to the non-real labels and the training fusion features.

[0184] The similarity setting subunit is used to set the maximum value among the non-label similarities as the second similarity;

[0185] The second loss value calculation subunit is used to obtain the second loss value based on the first similarity and the second similarity.

[0186] In some embodiments of this application, the above-mentioned training sub-module includes:

[0187] An update unit is used to update the initial classification model and the initial label features according to the loss value, so as to obtain the updated training classification model and training label features;

[0188] The loss value reset unit is used to determine the loss value of the training classification model based on the training classification model, the training label features, the training text, and the real label.

[0189] The setting unit is used to set the training classification model as a trained classification model and the training label features as trained label features when the loss value of the training classification model meets the preset training completion conditions.

[0190] In some embodiments of this application, the fusion module includes:

[0191] The attention matrix calculation submodule is used to calculate the vector product between the text features and the trained label features to obtain the attention matrix;

[0192] The weight matrix calculation submodule is used to normalize the attention matrix to obtain the weight matrix;

[0193] The target matrix calculation submodule is used to calculate the vector product between the weight matrix and the text features to obtain the target matrix;

[0194] The fusion feature extraction submodule is used to extract fusion features from the target matrix.

[0195] This invention also provides a sorting device, such as... Figure 10 As shown, Figure 10 This is a schematic diagram of the structure of a multi-label classification device provided in an embodiment of this application.

[0196] The multi-label classification device includes a memory, a processor, and a multi-label classification program stored in the memory and executable on the processor. When the processor executes the multi-label classification program, it implements the steps of the multi-label classification method in any embodiment.

[0197] Specifically, a multi-tag sorting device may include components such as a processor 1001 with one or more processing cores, a memory 1002 with one or more storage media, a power supply 1003, and an input unit 1004. Those skilled in the art will understand that... Figure 10 The multi-label classification device structure shown does not constitute a limitation on the multi-label classification device. It may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

[0198] The processor 1001 is the control center of the multi-tag sorting device. It connects various parts of the device via various interfaces and lines, and performs various functions and processes data by running or executing software programs and / or modules stored in the memory 1002, and by calling data stored in the memory 1002, thereby providing overall monitoring of the multi-tag sorting device. Optionally, the processor 1001 may include one or more processing cores; preferably, the processor 1001 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 1001.

[0199] The memory 1002 can be used to store software programs and modules. The processor 1001 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002. The memory 1002 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created based on the use of the multi-tag classification device, etc. In addition, the memory 1002 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 1002 may also include a memory controller to provide the processor 1001 with access to the memory 1002.

[0200] The multi-tag sorting device also includes a power supply 1003 that supplies power to the various components. Preferably, the power supply 1003 can be logically connected to the processor 1001 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 1003 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0201] The multi-label classification device may also include an input unit 1004, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0202] Although not shown, the multi-label classification device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 1001 in the multi-label classification device loads the executable files corresponding to the processes of one or more applications into the memory 1002 according to the following instructions, and the processor 1001 runs the applications stored in the memory 1002, thereby implementing the steps in any of the multi-label classification methods provided in the embodiments of the present invention.

[0203] To this end, embodiments of the present invention provide a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk, etc. A multi-label classification program is stored on the computer-readable storage medium, and when executed by a processor, the multi-label classification program implements the steps of any of the multi-label classification methods provided in the embodiments of the present invention.

[0204] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the detailed descriptions of other embodiments above, which will not be repeated here.

[0205] In practice, each of the above units or structures can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units or structures, please refer to the previous method embodiments, which will not be repeated here.

[0206] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0207] The above provides a detailed description of a multi-label classification method provided by the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A multi-label classification method, characterized in that, include: Obtain the target text to be classified; Extract the text features of the target text; The fused features are obtained based on the text features and the trained label features; The target classification label of the target text is determined from the preset labels based on the fusion features; The trained label features are obtained through the following steps: Obtain the initial classification model, initial label features, training text, and the real labels corresponding to the training text; Based on the initial classification model and the initial label features, determine the predicted probability of the training text corresponding to the preset label; The loss value of the initial classification model is determined based on the predicted probability and the true label; The initial classification model and the initial label features are trained based on the loss value to obtain the trained classification model and trained label features. The loss value of the initial classification model includes a second loss value determined based on the similarity between the training fusion features and the initial label features; the training fusion features are obtained based on the training text features and the initial label features. The similarity between the trained fusion features and the initial label features includes: The first similarity is determined based on the label similarity between the label features corresponding to the real label and the training fusion features, and the second similarity is determined based on the non-label similarity between the label features corresponding to the non-real label and the training fusion features, wherein the non-real label is a label other than the real label in the preset labels.

2. The multi-label classification method according to claim 1, characterized in that, The step of extracting text features from the target text includes: The target text is input into the feature extraction layer of a trained classification model to obtain the text features of the target text; The step of determining the target classification label of the target text from the preset labels based on the fusion features includes: The fused features are input into the prediction layer of the classification model to obtain the classification probability of the target text corresponding to the preset label; The target classification label of the target text is determined from the preset labels based on the classification probability.

3. The multi-label classification method according to claim 1, characterized in that, The step of calculating the predicted probability of the training text corresponding to the preset label based on the initial classification model and the initial label features includes: The training text is input into the initial feature extraction layer of the initial classification model to obtain the training text features of the training text; The training fusion features are obtained based on the training text features and the initial label features; The training fusion features are input into the initial prediction layer of the initial classification model to obtain the predicted probability of the training text corresponding to the preset label.

4. The multi-label classification method according to claim 3, characterized in that, The step of determining the loss value of the initial classification model based on the predicted probability and the true label includes: Calculate the cross-entropy between the prediction vector corresponding to the predicted probability and the training vector corresponding to the true label to obtain the first loss value; The second loss value is obtained based on the similarity between the trained fusion features and the initial label features; The sum of the first loss value and the second loss value is calculated to obtain the loss value of the initial classification model.

5. The multi-label classification method according to claim 4, characterized in that, The step of obtaining the second loss value based on the similarity between the trained fusion features and the initial label features includes: Calculate the label similarity between the label features corresponding to the real label and the training fusion features, and set the minimum value of the label similarity as the first similarity; The labels other than the real labels in the preset labels are set as non-real labels, and the non-label similarity between the label features corresponding to the non-real labels and the training fusion features is calculated; The maximum value among the unlabeled similarities is set as the second similarity; The second loss value is obtained based on the first similarity and the second similarity.

6. The multi-label classification method according to claim 1, characterized in that, The step of training the initial classification model and the initial label features based on the loss value to obtain the trained classification model and trained label features includes: The initial classification model and the initial label features are updated based on the loss value to obtain the updated training classification model and training label features; The loss value of the training classification model is determined based on the training classification model, the training label features, the training text, and the real label. When the loss value of the training classification model meets the preset training completion condition, the training classification model is set as a trained classification model, and the training label features are set as trained label features.

7. The multi-label classification method according to any one of claims 1 to 6, characterized in that, The step of obtaining the fused features based on the text features and the trained label features includes: Calculate the vector product between the text features and the trained label features to obtain the attention matrix; The attention matrix is ​​normalized to obtain the weight matrix; Calculate the vector product between the weight matrix and the text features to obtain the target matrix; The fusion features are extracted from the target matrix.

8. A multi-label classification device, characterized in that, include: The acquisition module is used to acquire the target text to be classified. An extraction module is used to extract text features from the target text; The fusion module is used to obtain fused features based on the text features and the trained label features; The classification module is used to determine the target classification label of the target text from the preset labels based on the fusion features; The trained label features are obtained through the following steps: Obtain the initial classification model, initial label features, training text, and the real labels corresponding to the training text; Based on the initial classification model and the initial label features, determine the predicted probability of the training text corresponding to the preset label; The loss value of the initial classification model is determined based on the predicted probability and the true label; The initial classification model and the initial label features are trained based on the loss value to obtain the trained classification model and trained label features. The loss value of the initial classification model includes a second loss value determined based on the similarity between the training fusion features and the initial label features; the training fusion features are obtained based on the training text features and the initial label features. The similarity between the trained fusion features and the initial label features includes: The first similarity is determined based on the label similarity between the label features corresponding to the real label and the training fusion features, and the second similarity is determined based on the non-label similarity between the label features corresponding to the non-real label and the training fusion features, wherein the non-real label is a label other than the real label in the preset labels.

9. A multi-label sorting device, characterized in that, The multi-label classification device includes a processor, a memory, and a multi-label classification program stored in the memory and executable on the processor. The processor executes the multi-label classification program to implement the steps of the multi-label classification method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a multi-label classification program, which is executed by a processor to implement the steps of the multi-label classification method according to any one of claims 1 to 7.