Text classification method and system based on label information enhancement

By introducing attention mechanism and contrastive learning into the text classification method, combined with cross-entropy and contrastive loss functions, the problem of neglecting the mutual influence between labels and texts in the existing technology is solved, and the accurate representation and semantics of natural language text are achieved. Improved accuracy of text classification.

CN113836934BActive Publication Date: 2024-09-06HEFEI UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110894290.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-05
Publication Date
2024-09-06
Estimated Expiration
2041-08-05

AI Technical Summary

Technical Problem

Existing text classification methods based on label information ignore the mutual influence and complex interactions between labels and input text, resulting in the inability to accurately represent the semantics of natural language text.

Method used

By obtaining the global semantic representation vector and local semantic representation matrix of the text, combined with the label semantic representation, the attention mechanism and the multi-layer perceptron are used to map the labels and texts to the contrastive learning space, and the cross-entropy and contrastive loss functions are combined to optimize the parameters to achieve label recognition. and modeling of interactions between texts.

Benefits of technology

It achieves accurate representation of the semantics of natural language text, improves the accuracy of text classification, and makes up for the shortcomings of existing methods in modeling the interaction between tags and text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113836934B
    Figure CN113836934B
Patent Text Reader

Abstract

The present invention provides a text classification method and system based on label information enhancement, which relates to the technical field of deep learning and natural language understanding. The present invention realizes accurate representation of the mutual influence between input text and labels through contrastive learning, makes up for the deficiencies of existing methods in label representation and modeling of the mutual influence between text and labels, realizes accurate representation of the semantics of natural language text, and improves the accuracy of text classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of deep learning and natural language understanding, and in particular to a text classification method and system based on label information enhancement. Background Art

[0002] Text classification is a very important part of the field of natural language processing and is a common method for evaluating whether the semantic representation of a sentence is accurate. It is mainly used to classify a given single or multiple sentences. Depending on the specific task, text classification also has different classification criteria. For example, sentiment classification is mainly used to determine the sentiment category or polarity of a given sentence; paraphrase recognition is mainly used to determine whether two given sentences express the same semantics. Therefore, the basic technology that this task focuses on is how to accurately represent the input text semantically. The semantic representation of natural language sentences is a basic but extremely important research topic in the field of natural language processing and even artificial intelligence. Whether it is basic information retrieval, semantic extraction, or complex question-answering systems and dialogue systems, a comprehensive and accurate representation of the semantics of the input sentences is required to ensure that the machine understands the complex language system of humans.

[0003] According to different methods of utilizing label information, existing work can be roughly divided into two categories: one-hot encoding method, which focuses on the encoding of input text, and label information is mainly used as a supervisory signal for model training. Label encoding method, on the one hand, focuses on the modeling of input text, and on the other hand, by mapping each label to the same semantic space as the text representation, using low-dimensional dense vectors to represent the semantic information of the label, which helps to model the complex semantic interaction relationship between input text and label. Both methods have made amazing progress in text classification tasks, and the latter method has attracted more and more attention because it can make full use of the semantic information contained in the label to achieve more accurate modeling.

[0004] However, there are still some problems with the existing text classification methods based on label information. The existing encoding-based methods focus more on the representation of the input text. The label semantics are generally used as guiding information for text semantic modeling, while the mutual influence and complex interaction between the label and the input text are ignored. As a result, the existing text classification methods based on label information cannot accurately represent the semantics of natural language text. Summary of the invention

[0005] 1. Technical issues to be solved

[0006] In view of the deficiencies of the prior art, the present invention provides a text classification method and system based on label information enhancement, which solves the technical problem that the prior methods ignore the mutual influence and complex interaction between labels and input text.

[0007] (II) Technical solution

[0008] To achieve the above objectives, the present invention is implemented through the following technical solutions:

[0009] In a first aspect, the present invention provides a text classification method based on label information enhancement, the method comprising:

[0010] S1. Obtain the text global semantic representation vector and text local semantic representation matrix of the input text;

[0011] S2. Obtaining a label semantic representation of a label corresponding to the input text;

[0012] S3, based on the text global semantic representation vector, the text local semantic representation matrix and the label semantic representation, using the attention mechanism to obtain the text-supervised label semantic representation vector and the label-supervised text semantic representation vector, and mapping the text-supervised label semantic representation vector and the label-supervised text semantic representation vector to the contrastive learning space through a first multi-layer perceptron to obtain a mapping vector;

[0013] S4, processing the semantic representation vector supervised by the label through a second multi-layer perceptron with a classification layer to obtain a classification result of the text;

[0014] S5. Learning and optimizing the parameters in steps S1 to S3 by selecting a cross entropy loss function and a contrast loss function obtained based on the mapping vector as optimization targets.

[0015] Preferably, the S1 specifically includes:

[0016] Use a unified form to represent the input text, and represent the input text as a word sequence: X = {x1, x2, ..., x n}, where n represents the length of the text sequence, x i Represent the vector representation of the i-th word in the word sequence in the dictionary V, add the symbol CLS to the front and back of the word sequence, and then input the obtained representation into the first pre-trained model. The process can be expressed as:

[0017]

[0018]

[0019]

[0020] Where: α l is the weight parameter; BERT l Indicates the result of taking the first pre-trained model BERT layer l; The vector representation corresponding to the first [CLS] of the lth layer, Hl Represents the matrix representation corresponding to the word sequence of the input text corresponding to the lth layer; [CLS; X; CLS] means splicing two [CLS] to the front and back of the word sequence X respectively; H is the text local semantic representation matrix, which represents the semantic representation output of all words in the word sequence of the target text after the first pre-training model; v is the text global semantic representation vector of the target text after the first pre-training model, which represents the semantic representation of the sentence obtained after weighting.

[0021] Preferably, at S2, before executing the step of obtaining the tag semantic representation of the tag corresponding to the input text, the method further includes:

[0022] An external knowledge base is introduced, and the corresponding sentence description is retrieved from the external knowledge base for each tag.

[0023] Preferably, the S2 specifically includes:

[0024] Using a unified form to represent label text, the entire text set can be represented as y = {y1, y2, ..., y m}, where m represents the size of the entire label set, y j represents the one-hot encoding representation of the j-th label;

[0025] Use E f The semantic vector representation of the label learned by the entire model is represented to obtain a domain-based encoding representation; WordNet is selected as the external knowledge base, and the corresponding sentence description s is retrieved from WordNet for each label. The sentence description is input into the second pre-trained model to obtain a knowledge-based encoding representation;

[0026] By integrating the domain-based encoding representation and the knowledge-based encoding representation, the final label semantic representation is obtained; this process can be expressed as follows:

[0027]

[0028]

[0029]

[0030] Among them: BERT L Indicates the result of taking the last layer of the second pre-trained model BERT; s j Indicates that the corresponding sentence is retrieved from WordNet for the jth tag; and They represent the domain-based encoding representation and knowledge-based encoding representation corresponding to the j-th label respectively; e j Represents the label semantic representation of the jth label.

[0031] Preferably, the S3 specifically includes:

[0032] S301, based on the text global semantic representation vector and the label semantic representation, obtain the label semantic representation vector of the text supervision;

[0033] S302, based on the text local semantic representation matrix and the label semantic representation, obtaining a label-supervised text semantic representation vector;

[0034] S303 , mapping the text-supervised label semantic representation vector and the label-supervised text semantic representation vector to the contrastive learning space through a first multi-layer perceptron to obtain a mapping vector.

[0035] Preferably, the S301 specifically includes:

[0036] Using the attention mechanism, under the guidance of text semantics, the most relevant part is selected from the label semantic representation to generate a text-supervised label semantic representation vector. The process can be expressed as follows:

[0037] E=[e1,e2,…,e m ]

[0038]

[0039]

[0040] Where: E represents the matrix formed by stacking the label semantic representations of all labels; {ω l ,W l ,U l} are the parameters that require model training; I l is a column vector of length m containing all 1s; Indicates that U l The result of v is repeated l times; β l The probability distribution vector representing the importance of all label semantics considering the text semantics; Indicates the degree of influence of the jth label semantics on the final semantics when the text semantics are considered; Represents the semantic representation vector of text supervision; tanh() is a nonlinear activation function.

[0041] Preferably, the S302 specifically includes:

[0042] The attention mechanism is selected to model the influence of label semantics on text semantics. The word information most relevant to each label is selected from the text word sequence, and it is integrated together to obtain the label-supervised text semantic representation vector. The process can be expressed as follows:

[0043]

[0044]

[0045]

[0046] Where: {ω, W, U} represent the parameters that need to be trained; I is a column vector of length n with all values ​​being 1; e t is the semantic representation of the t-th label in the matrix E; γ t It represents the weight distribution vector corresponding to the word sequence of the input text under the condition of considering the semantics of the t-th label; It represents the weight corresponding to the i-th word of the input text under the condition of considering the semantics of the t-th label; It represents the semantic representation vector of the input text under the condition of considering the semantics of the t-th label; Represents the semantic representation vector of label supervision; maxpooling() represents the maximum pooling operation.

[0047] Preferably, the S4 specifically includes:

[0048] The label-supervised semantic representation vector is input into the second multi-layer perceptron with classification layer to obtain the classification result of the input text. The process can be expressed as:

[0049]

[0050] y * = argmax {y∈y} P(y|X,y)

[0051] Where: P(y|X,y) represents the probability of the predicted result being y, y * Represents the final prediction result of the model.

[0052] Preferably, the S5 specifically includes:

[0053] 1) Cross entropy loss function:

[0054]

[0055] Where: log() is the log-likelihood function, K represents the number of samples in a training batch, y i The one-hot vector representation of the true label corresponding to the i-th sample, that is, only the index position corresponding to the true label has a value of 1, and the other positions are all 0, and the vector length is the number of all labels;

[0056] 3) Contrastive loss function:

[0057]

[0058] Where: z1 and z2 represent mapping vectors respectively; τ is a hyperparameter used to control the strength of contrastive learning; sim() represents the similarity calculation function; 1 [k≠j] is an indicator value, which means that if and only if k≠j, its corresponding value is 1, otherwise it is 0;

[0059] 3) Based on the two loss functions, the final optimization goal of the embodiment of the present invention is obtained by weighting and integrating the two functions:

[0060] Loss = Loss1 + λLoss2

[0061] Among them: λ is a hyperparameter.

[0062] In a second aspect, the present invention provides a text classification system based on label information enhancement, the system comprising:

[0063] A text semantic representation acquisition module is used to obtain a text global semantic representation vector and a text local semantic representation matrix of an input text;

[0064] A label semantic representation acquisition model, used to acquire the label semantic representation of the label corresponding to the input text;

[0065] An attention mechanism module is used to obtain a text-supervised label semantic representation vector and a label-supervised text semantic representation vector based on the text global semantic representation vector, the text local semantic representation matrix and the label semantic representation by using an attention mechanism, and map the text-supervised label semantic representation vector and the label-supervised text semantic representation vector to a contrastive learning space through a first multi-layer perceptron to obtain a mapping vector;

[0066] A classification result acquisition module, used to process the semantic representation vector supervised by the label through a second multi-layer perceptron with a classification layer to obtain a classification result of the text;

[0067] A parameter optimization module is used to learn and optimize the parameters in the text semantic representation acquisition module, the label semantic representation acquisition model and the attention mechanism module by selecting a cross entropy loss function and a contrast loss function obtained based on the mapping vector as optimization targets.

[0068] (III) Beneficial effects

[0069] The present invention provides a text classification method and system based on label information enhancement. Compared with the prior art, it has the following beneficial effects:

[0070] The present invention realizes accurate representation of the mutual influence between input text and labels through contrastive learning, makes up for the deficiencies of existing methods in label representation and modeling of the mutual influence between text and labels, realizes accurate representation of the semantics of natural language text, and improves the accuracy of text classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0072] Figure 1 A block diagram of a text classification method based on label information enhancement. DETAILED DESCRIPTION

[0073] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention are clearly and completely described. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0074] The embodiments of the present application provide a text classification method and system based on label information enhancement, which solves the technical problem that the existing methods ignore the mutual influence and complex interaction between labels and input texts, achieves accurate representation of the semantics of natural language text, and improves the accuracy of text classification.

[0075] The technical solution in the embodiment of the present application is to solve the above technical problems, and the overall idea is as follows:

[0076] There are still some problems in the existing label-based text classification methods. First, most of these methods use a low-dimensional dense vector to represent the semantics of the label. The vector is learned during the model training process and cannot accurately represent the rich semantic information contained in the label. The same label may focus on different aspects of semantics when facing different input sentences, so a more accurate label representation is needed; secondly, the existing encoding-based methods still focus more on the representation of the input text, and the label semantics are more of a guiding information for text semantic modeling. The mutual influence and complex interaction between the label and the input text, as well as the mutual dependence between the labels, are ignored and not given enough attention. In order to solve the above problems, the embodiments of the present invention, on the one hand, use human prior knowledge (such as knowledge graphs, semantic webs) to achieve more comprehensive and accurate modeling of label semantics; on the other hand, contrastive learning is introduced into text categories, and the entire input information is more comprehensively modeled from the perspectives of input text and label semantics, respectively, to achieve modeling of the mutual influence relationship between the input text and the label, thereby achieving accurate representation of the semantics of natural language text and accuracy of text classification.

[0077] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0078] The embodiment of the present invention provides a text classification method based on label information enhancement, such as Figure 1 As shown, the method includes steps S1 to S4:

[0079] S1. Obtain the text global semantic representation vector and text local semantic representation matrix of the input text;

[0080] S2, obtaining the label semantic representation of the label corresponding to the input text;

[0081] S3, based on the text global semantic representation vector, the text local semantic representation matrix and the label semantic representation, using the attention mechanism to obtain the text-supervised label semantic representation vector and the label-supervised text semantic representation vector, and mapping the text-supervised label semantic representation vector and the label-supervised text semantic representation vector to the contrastive learning space through the first multi-layer perceptron to obtain a mapping vector;

[0082] S4, processing the semantic representation vector of label supervision through the second multi-layer perceptron with classification layer to obtain the classification result of the text;

[0083] S5. Using the selected cross entropy loss function and the contrast loss function obtained based on the mapping vector as the optimization target, learn and optimize the parameters in steps S1 to S3.

[0084] The embodiment of the present invention achieves accurate representation of the mutual influence between input text and labels through contrastive learning, makes up for the deficiencies of existing methods in label representation and modeling of the mutual influence between text and labels, achieves accurate representation of the semantics of natural language text, and improves the accuracy of text classification.

[0085] The following is a detailed description of each step:

[0086] In step S1, the global text semantic representation vector and the local text semantic representation matrix of the input text are obtained. The specific implementation process is as follows:

[0087] Use a unified mathematical form to represent the input text, and represent the input text as a word sequence: X = {x1, x2, ..., x n}, where n represents the length of the text sequence, x i The vector representation corresponding to the i-th word in the word sequence in the dictionary V is represented. The dictionary V already exists (for example, the pre-trained language model BERT will provide the corresponding dictionary). Then, the special symbol "[CLS]" is added to the front and back of the word sequence, and then the obtained representation is input into the first pre-trained model (BERT is used as the representative of the pre-trained model in the embodiment of the present invention). Assuming that the embodiment of the present invention selects the output of the last L layers in the pre-trained model, the vector representation of the final input text can be obtained by weighted summing the output results of these L layers, and its weight parameters {α1, α2,…, α L} needs to be trained along with the entire model. The process can be expressed as:

[0088]

[0089]

[0090]

[0091] in: The vector representation corresponding to the first [CLS] of the lth layer, H l Represents the matrix representation corresponding to the word sequence of the input text corresponding to the lth layer; [CLS; X; CLS] means splicing two [CLS] to the front and back of the word sequence X respectively; H is the text local semantic representation matrix, which represents the semantic representation output of all words in the word sequence of the target text after the first pre-training model; v is the text global semantic representation vector of the target text after the first pre-training model, which represents the semantic representation of the sentence obtained after weighting.

[0092] In step S2, the label semantic representation of the label corresponding to the input text is obtained, and the specific implementation process is as follows:

[0093] Using a unified mathematical form to represent label text, the entire text set can be represented as y = {y1, y2, ..., y m}, where m represents the size of the entire label set, y j represents the unique hot encoding representation of the jth label. The embodiment of the present invention first uses E f It represents the semantic vector representation of the label learned by the entire model, which is referred to as the domain-based encoding representation here; at the same time, the embodiment of the present invention selects WordNet as the external knowledge base (it should be noted that the external knowledge base can also select knowledge graphs and other semantic networks, etc.), retrieves the corresponding sentence description s for each label from WordNet, and then inputs the sentence description into the second pre-trained model (such as BERT), and uses the representation of [CLS] in the output of the last layer as the semantic representation describing the sentence, which is referred to as the knowledge-based encoding representation here; finally, the domain-based encoding representation and the knowledge-based encoding representation are integrated to obtain the final label semantic representation. Taking the jth label as an example, the process can be expressed as follows:

[0094]

[0095]

[0096]

[0097] Among them: BERT L Indicates the result of taking the last layer of BERT, y j represents the one-hot encoding representation of the jth label; s j Indicates that the corresponding sentence is retrieved from WordNet for the jth tag; and They represent the domain-based encoding representation and knowledge-based encoding representation corresponding to the j-th label, respectively, and e j Represents the label semantic representation of the jth label.

[0098] In step S3, based on the text global semantic representation vector, the text local semantic representation matrix and the label semantic representation, the attention mechanism is used to obtain the text-supervised label semantic representation vector and the label-supervised text semantic representation vector, and the text-supervised label semantic representation vector and the label-supervised text semantic representation vector are mapped to the contrastive learning space through the first multi-layer perceptron to obtain a mapping vector. The specific implementation process is as follows:

[0099] S301, based on the text global semantic representation vector and the label semantic representation, obtaining the label semantic representation vector of the text supervision, specifically including:

[0100] The embodiment of the present invention first models the influence of text semantics on the label semantic representation. Specifically, the embodiment of the present invention chooses to use the attention mechanism to select the most relevant part from the label semantic representation under the guidance of text semantics, thereby generating a text-supervised label semantic representation vector. The process can be expressed as follows:

[0101] E=[e1,e2,…,e m ]

[0102]

[0103]

[0104] Where: E represents the matrix formed by stacking the label semantic representations of all labels; {ω l ,W l ,U l} are the parameters that require model training; I l is a column vector of length m containing all 1s; Indicates that U l The result of v is repeated l times; β l The probability distribution vector representing the importance of all label semantics considering the text semantics; Indicates the degree of influence of the jth label semantics on the final semantics when the text semantics are considered; Represents the semantic representation vector of text supervision. tanh() is a nonlinear activation function.

[0105] S302: Based on the text local semantic representation matrix and the label semantic representation, obtain a label-supervised text semantic representation vector.

[0106] At the same time, in order to analyze the selection of label semantics for text semantic representation, the embodiment of the present invention also selects the attention mechanism to model the influence of label semantics on text semantics, selects the word information most relevant to each label from the text word sequence, and then fuses them together to obtain a label-supervised text semantic representation vector. The process can be expressed as follows:

[0107]

[0108]

[0109]

[0110] Where: {ω, W, U} represent the parameters that need to be trained; I is a column vector of length n with all values ​​being 1; e t is the semantic representation of the t-th label in the matrix E; γ tIt represents the weight distribution vector corresponding to the word sequence of the input text under the condition of considering the semantics of the t-th label; It represents the weight corresponding to the i-th word of the input text under the condition of considering the semantics of the t-th label; It represents the semantic representation vector of the input text under the condition of considering the semantics of the t-th label; Represents the semantic representation vector of label supervision; maxpooling() represents the maximum pooling operation.

[0111] S303, mapping the text-supervised label semantic representation vector and the label-supervised text semantic representation vector to the contrastive learning space through a first multi-layer perceptron to obtain a mapping vector;

[0112] After obtaining the semantic representation of text supervision and the semantic representation of label supervision respectively, the embodiment of the present invention maps these two representations to the contrastive learning space through a multi-layer perceptron (MLP). The process can be expressed as follows:

[0113]

[0114]

[0115] Where ReLU() represents a nonlinear activation function, z1 and z2 represent vectors mapped to the contrastive learning space, i.e., mapping vectors, which lay the foundation for contrastive learning in the objective function.

[0116] In step S4, the semantic representation vector of label supervision is processed by the second multi-layer perceptron with classification layer to obtain the classification result of the text. The specific implementation process is as follows:

[0117] In the embodiment of the present invention, the semantic representation vector of label supervision is The input is sent to another multi-layer perceptron (MLP1) with a classification layer to predict the final classification result of the input text. The process can be expressed as:

[0118]

[0119] y * = argmax {y∈y} P(y|X,y)

[0120] Where: P(y|X,y) represents the probability of the predicted result being y, y * Represents the final prediction result of the model.

[0121] In step S5, the parameters in steps S1 to S3 are learned and optimized by selecting the cross entropy loss function and the contrast loss function as the optimization target. The specific implementation process is as follows:

[0122] After obtaining the above results, the embodiment of the present invention selects the cross entropy loss function and the contrast loss function InfoNCE as optimization targets for training the model and learning the parameters in the model, as follows:

[0123] 1) Cross entropy loss function: Considering that the text classification task is a classification task, the cross entropy loss function of the classification task is selected as the optimization target, which can be expressed as:

[0124]

[0125] Where log() is the log-likelihood function, K represents the number of samples in a training batch, and y i The one-hot vector representation of the true label corresponding to the i-th sample, that is, only the index position corresponding to the true label has a value of 1, and the other positions are all 0, and the vector length is the number of all labels.

[0126] 2) Contrastive loss function: In order to ensure that the learned semantic representation of text supervision and the semantic representation of label supervision can be as similar as possible (from the same sample), the embodiment of the present invention selects the InfoNCE loss function as the optimization target of the contrastive learning process, which is specifically expressed as follows:

[0127]

[0128] Where τ is a hyperparameter used to control the strength of contrastive learning; sim() represents a similarity calculation function, such as cosine similarity; 1 [k≠j] It is an indicator value, which means that if and only if k≠j, its corresponding value is 1, otherwise it is 0.

[0129] 3) Based on the two loss functions, the final optimization goal of the embodiment of the present invention is obtained by weighting and integrating the two functions:

[0130] Loss = Loss1 + λLoss2

[0131] Among them: λ is the hyperparameter of the model, which is used to control the impact of the two loss functions on the final result.

[0132] It should be noted that the embodiment of the present invention uses the cross entropy loss function and contrast loss function of step S5 as optimization targets to learn and optimize the parameters in steps S1 to S3, such as the weight parameters {α1, α2, …, α L}、Domain-based encoding representation E f , weight parameter {ω l ,W l ,U l} and {ω, W, U}, etc. When the loss value of the loss function reaches the preset value, the above parameters in the current training process are saved, and the text to be classified is classified through steps S1 to S4 after the parameters are saved. That is, S1 to S5 is the training process of the complete model, and steps S1 to S4 are equivalent to the application process of the model, among which S303 does not need to be executed during the application process of the model.

[0133] The embodiment of the present invention further provides a text classification system based on label information enhancement, the system comprising:

[0134] A text semantic representation acquisition module is used to obtain a text global semantic representation vector and a text local semantic representation matrix of an input text;

[0135] A label semantic representation acquisition model is used to obtain the label semantic representation of the label corresponding to the input text;

[0136] An attention mechanism module is used to obtain a text-supervised label semantic representation vector and a label-supervised text semantic representation vector based on a text global semantic representation vector, a text local semantic representation matrix and a label semantic representation by using an attention mechanism, and map the text-supervised label semantic representation vector and the label-supervised text semantic representation vector to a contrastive learning space through a first multi-layer perceptron to obtain a mapping vector;

[0137] A classification result acquisition module is used to process the semantic representation vector of label supervision through a second multi-layer perceptron with a classification layer to obtain the classification result of the text;

[0138] The parameter optimization module is used to learn and optimize the parameters in the text semantic representation acquisition module, the label semantic representation acquisition model and the attention mechanism module by selecting the cross entropy loss function and the contrast loss function obtained based on the mapping vector as the optimization target.

[0139] It can be understood that the text classification system based on label information enhancement provided in the embodiment of the present invention corresponds to the above-mentioned text classification method based on label information enhancement. The explanations, examples, beneficial effects and other parts of the relevant contents can refer to the corresponding contents in the text classification method based on label information enhancement, and will not be repeated here.

[0140] In summary, compared with the prior art, the present invention has the following beneficial effects:

[0141] 1. The embodiment of the present invention achieves accurate representation of the mutual influence between input text and labels through contrastive learning, which makes up for the deficiencies of existing methods in label representation and modeling of the mutual influence between text and labels, achieves accurate representation of the semantics of natural language text, and improves the accuracy of text classification.

[0142] 2. The embodiment of the present invention achieves a more comprehensive and accurate label semantic representation by introducing additional prior knowledge (ie, introducing an external knowledge base), thereby further improving the accuracy of text classification.

[0143] It should be noted that, through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0144] In this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0145] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A text classification method based on label information enhancement, characterized in that: The method comprises: S1. Obtain the text global semantic representation vector and text local semantic representation matrix of the input text; S2. Obtaining a label semantic representation of a label corresponding to the input text; S3, based on the text global semantic representation vector, the text local semantic representation matrix and the label semantic representation, using the attention mechanism to obtain the text-supervised label semantic representation vector and the label-supervised text semantic representation vector, and mapping the text-supervised label semantic representation vector and the label-supervised text semantic representation vector to the contrastive learning space through a first multi-layer perceptron to obtain a mapping vector; S4, processing the semantic representation vector supervised by the label through a second multi-layer perceptron with a classification layer to obtain a classification result of the text; S5, using the selected cross entropy loss function and the contrast loss function obtained based on the mapping vector as the optimization target, learning and optimizing the parameters in steps S1 to S3; Wherein, the S3 specifically includes: S301, based on the text global semantic representation vector and the label semantic representation, obtaining the label semantic representation vector of the text supervision; including: Using the attention mechanism, under the guidance of text semantics, the most relevant part is selected from the label semantic representation to generate a text-supervised label semantic representation vector. The process can be expressed as follows: E=[e1,e2,…,e m ] Where: E represents the matrix formed by stacking the label semantic representations of all labels; {ω l ,W l ,U l } are the parameters that require model training; I l is a column vector of length m containing all 1s; Indicates that U l The result of v is repeated l times; β l The probability distribution vector representing the importance of all label semantics considering the text semantics; Indicates the degree of influence of the jth label semantics on the final semantics when the text semantics are considered; Represents the semantic representation vector of text supervision; tanh() is a nonlinear activation function; S302, based on the text local semantic representation matrix and the label semantic representation, obtaining a label-supervised text semantic representation vector; including: The attention mechanism is selected to model the influence of label semantics on text semantics. The word information most relevant to each label is selected from the text word sequence, and it is integrated together to obtain the label-supervised text semantic representation vector. The process can be expressed as follows: Where: {ω, W, U} represent the parameters that need to be trained; I is a column vector of length n with all values ​​being 1; e t is the semantic representation of the t-th label in the matrix E; γ t It represents the weight distribution vector corresponding to the word sequence of the input text under the condition of considering the semantics of the t-th label; It represents the weight corresponding to the i-th word of the input text under the condition of considering the semantics of the t-th label; It represents the semantic representation vector of the input text under the condition of considering the semantics of the t-th label; Represents the semantic representation vector of label supervision; maxpooling() represents the maximum pooling operation; S303 , mapping the text-supervised label semantic representation vector and the label-supervised text semantic representation vector to the contrastive learning space through a first multi-layer perceptron to obtain a mapping vector.

2. The text classification method based on label information enhancement as claimed in claim 1, characterized in that: The S1 specifically includes: Use a unified form to represent the input text, and represent the input text as a word sequence: X = {x1, x2, ..., x n }, where n represents the length of the text sequence, x i Represent the vector representation of the i-th word in the word sequence in the dictionary V, add the symbol CLS to the front and back of the word sequence, and then input the obtained representation into the first pre-trained model. The process can be expressed as: Where: α l is the weight parameter; BERT l Indicates the result of taking the first pre-trained model BERT layer l; The vector representation corresponding to the first [CLS] of the lth layer, H l Represents the matrix representation corresponding to the word sequence of the input text corresponding to the lth layer; [CLS; X; CLS] means splicing two [CLS] to the front and back of the word sequence X respectively; H is the text local semantic representation matrix, which represents the semantic representation output of all words in the word sequence of the target text after the first pre-training model; v is the text global semantic representation vector of the target text after the first pre-training model, which represents the semantic representation of the sentence obtained after weighting.

3. The text classification method based on label information enhancement as claimed in claim 1, characterized in that: At S2, before obtaining the tag semantic representation of the tag corresponding to the input text, the method further includes: An external knowledge base is introduced, and the corresponding sentence description is retrieved from the external knowledge base for each tag.

4. The text classification method based on label information enhancement as claimed in claim 2, characterized in that: The S2 specifically includes: Using a unified form to represent label text, the entire text collection can be represented as Where m represents the size of the entire label set, y j represents the one-hot encoding representation of the j-th label; Use E f The semantic vector representation of the label learned by the entire model is represented to obtain a domain-based encoding representation; WordNet is selected as the external knowledge base, and the corresponding sentence description s is retrieved from WordNet for each label. The sentence description is input into the second pre-trained model to obtain a knowledge-based encoding representation; By integrating the domain-based encoding representation and the knowledge-based encoding representation, the final label semantic representation is obtained; this process can be expressed as follows: Among them: BERT L Indicates the result of taking the last layer of the second pre-trained model BERT; s j Indicates that the corresponding sentence is retrieved from WordNet for the jth tag; and They represent the domain-based encoding representation and knowledge-based encoding representation corresponding to the j-th label respectively; e j Represents the label semantic representation of the jth label.

5. The text classification method based on label information enhancement as claimed in claim 1, characterized in that: The S4 specifically includes: The label-supervised semantic representation vector is input into the second multi-layer perceptron with classification layer to obtain the classification result of the input text. The process can be expressed as: in: Indicates the probability that the prediction result is y, y * Represents the final prediction result of the model.

6. The text classification method based on label information enhancement according to any one of claims 1 to 5, characterized in that: The S5 specifically includes: 1) Cross entropy loss function: Where: log() is the log-likelihood function, K represents the number of samples in a training batch, y i The one-hot vector representation of the true label corresponding to the i-th sample, that is, only the index position corresponding to the true label has a value of 1, and the other positions are all 0, and the vector length is the number of all labels; 2) Contrastive loss function: Where: z1 and z2 represent mapping vectors respectively; τ is a hyperparameter used to control the strength of contrastive learning; sim() represents the similarity calculation function; 1 [k≠j] is an indicator value, which means that if and only if k≠j, its corresponding value is 1, otherwise it is 0; 3) Based on the two loss functions, the final optimization goal of the embodiment of the present invention is obtained by weighting and integrating the two functions: Loss = Loss1 + λLoss2 Among them: λ is a hyperparameter.

7. A text classification system based on label information enhancement, characterized in that: The system comprises: A text semantic representation acquisition module is used to obtain a text global semantic representation vector and a text local semantic representation matrix of an input text; A label semantic representation acquisition model, used to acquire the label semantic representation of the label corresponding to the input text; An attention mechanism module is used to obtain a text-supervised label semantic representation vector and a label-supervised text semantic representation vector based on the text global semantic representation vector, the text local semantic representation matrix and the label semantic representation by using an attention mechanism, and map the text-supervised label semantic representation vector and the label-supervised text semantic representation vector to a contrastive learning space through a first multi-layer perceptron to obtain a mapping vector; A classification result acquisition module, used to process the semantic representation vector supervised by the label through a second multi-layer perceptron with a classification layer to obtain a classification result of the text; A parameter optimization module, used to learn and optimize the parameters in the text semantic representation acquisition module, the label semantic representation acquisition model and the attention mechanism module by selecting a cross entropy loss function and a contrast loss function obtained based on the mapping vector as optimization targets; The attention mechanism module is specifically used to perform the following steps: S301, based on the text global semantic representation vector and the label semantic representation, obtaining the label semantic representation vector of the text supervision; including: Using the attention mechanism, under the guidance of text semantics, the most relevant part is selected from the label semantic representation to generate a text-supervised label semantic representation vector. The process can be expressed as follows: E=[e1,e2,…,e m ] Where: E represents the matrix formed by stacking the label semantic representations of all labels; {ω l ,W l ,U l } are the parameters that require model training; I l is a column vector of length m containing all 1s; Indicates that U l The result of v is repeated l times; β l The probability distribution vector representing the importance of all label semantics considering the text semantics; Indicates the degree of influence of the jth label semantics on the final semantics when the text semantics are considered; Represents the semantic representation vector of text supervision; tanh() is a nonlinear activation function; S302, based on the text local semantic representation matrix and the label semantic representation, obtaining a label-supervised text semantic representation vector; including: The attention mechanism is selected to model the influence of label semantics on text semantics. The word information most relevant to each label is selected from the text word sequence, and it is integrated together to obtain the label-supervised text semantic representation vector. The process can be expressed as follows: Where: {ω, W, U} represent the parameters that need to be trained; I is a column vector of length n with all values ​​being 1; e t is the semantic representation of the t-th label in the matrix E; γ t It represents the weight distribution vector corresponding to the word sequence of the input text under the condition of considering the semantics of the t-th label; It represents the weight corresponding to the i-th word of the input text under the condition of considering the semantics of the t-th label; It represents the semantic representation vector of the input text under the condition of considering the semantics of the t-th label; Represents the semantic representation vector of label supervision; maxpooling() represents the maximum pooling operation; S303 , mapping the text-supervised label semantic representation vector and the label-supervised text semantic representation vector to the contrastive learning space through a first multi-layer perceptron to obtain a mapping vector.