Hierarchical text classification method and system for ensuring node label consistency
By using text encoder and multi-label classifier in hierarchical text classification and combining the message delivery mechanism, the problem of label inconsistency is solved, the accuracy of classification results and the integrity of hierarchical structure are achieved, and the model performance is improved.
Patent Information
- Application Number
- CN202411340697.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-14
AI Technical Summary
The prior art fails to fully utilize the label structure in hierarchical text classification, resulting in label inconsistency problems and is difficult to meet practical application needs.
The context features are extracted through the text encoder, and the multi-label classifier is input. The initial classification probability is reconstructed into confidence using the reconstruction function, and the message passing between the child node and the parent node is transmitted until the message propagation converges and the node status is updated. Ensure consistency of classification results.
It achieves label consistency, reduces classification errors, and improves the model's adaptability and overall performance to complex structures.
Smart Images

Figure CN119311872A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and more particularly to a hierarchical text classification method and system for ensuring consistency of node labels. Background Art
[0002] At present, multi-label text classification refers to classifying an instance into multiple labels at the same time, but there is no hierarchical relationship between the labels, and they are parallel to each other. Hierarchical text classification (HTC) is a special multi-label classification task, in which there is a clear hierarchical relationship between the labels, usually presented as a tree or graph structure. In this case, an instance not only needs to be classified into multiple levels, but also must follow the parent-child dependency relationship between these levels.
[0003] like Fig. 9 As shown in , given an input text: "Beckham's new book is about to be released...", we can classify its labels as: "News-Sports-Football" or "Features-Books", which shows that hierarchical text classification can be a single-path problem or a multi-path problem. Due to the characteristics of hierarchical text classification, the prediction result of each node should be consistent with the prediction results of all ancestor nodes in its path, that is, the classification result must ensure that the association relationship between parent and child nodes is in the same path. Fig. 9 As shown, the correct classification results are represented by green nodes, forming a complete path, for example: "News-Sports-Football". This consistency of parent-child node relationship is called label consistency.
[0004] However, most classification methods tend to treat hierarchical text classification as a flat multi-label classification task, failing to fully utilize the hierarchical label structure, leading to label inconsistency. Fig.10 As shown in the figure, traditional methods may produce isolated breakpoints (red nodes), such as "sports" and "features" are not correctly predicted, resulting in incomplete or inconsistent parent-child node relationships in the path. This inconsistent label result is inconsistent with reality and is difficult to meet the needs of actual application scenarios.
[0005] Therefore, how to restore an inconsistent overall node structure to a consistent structure is a problem that technical personnel in this field need to solve urgently. Summary of the invention
[0006] In view of this, the present invention provides a hierarchical text classification method and system for ensuring the consistency of node labels, eliminating isolated breakpoints by ensuring logical rule constraints, and restoring the inconsistency of the overall node structure to a consistent structure.
[0007] In order to achieve the above object, the present invention adopts the following technical solution:
[0008] A hierarchical text classification method for ensuring node label consistency, comprising:
[0009] Extract contextual features of each news article through a text encoder;
[0010] Input the context features into a multi-label classifier, and output a preliminary classification probability corresponding to the label of each context feature;
[0011] Each label is regarded as a node, and the preliminary classification probability of each node is reconstructed into the confidence of the node through a reconstruction function;
[0012] Messages are generated based on child nodes, parent nodes and confidence levels, and the generated messages are aggregated until the message propagation converges. The node status is then updated through the converged aggregated messages, and the final multi-label classification results of the news articles are output.
[0013] Preferably, the extracting context features of each news article specifically comprises: extracting context features from each news article X through a BERT text encoder;
[0014] H = BERT(X);
[0015] Where H is the contextual feature extracted by the BERT text encoder.
[0016] Preferably, the inputting the context feature into the multi-label classifier specifically includes:
[0017] p=W·H+b;
[0018] Among them, W is the weight matrix, b is the bias, and p is the preliminary classification score for each label.
[0019] Preferably, reconstructing the preliminary classification probability of each node into the confidence of the node through a reconstruction function specifically includes:
[0020] V c =σ(p c );
[0021] Among them, V c is the initial confidence of node c, σ(·) is the probability reconstruction function, p c is the initial score of the news text pair classified into node c.
[0022] Preferably, the message generation based on the child node, the parent node and the confidence level specifically includes:
[0023] Method 1: The classification probability of the parent node is adjusted according to the initial confidence of the child node corresponding to the parent node, and the parent node receives the message from the child node;
[0024] Method 2: adjusting the classification probability of the child node according to the initial confidence of the parent node, and the child node receives the message from the parent node;
[0025] Method three, or adjusting the classification probability of the parent node according to the initial confidence of the child node corresponding to the parent node, the parent node receives the message from the child node, and at the same time adjusting the classification probability of the child node according to the initial confidence of the parent node, the child node receives the message from the parent node.
[0026] Preferably, in the method 1, updating the node status specifically includes:
[0027] Aggregate the generated messages, V c ′=V c +M a +M b ;
[0028] Among them, V c ′The state of the parent node after aggregation, V c is the initial confidence of node c, M a and M b Represent the messages from child nodes a and b respectively, and continuously update the classification probability between nodes until the message propagation converges;
[0029] Update the node status and convert it into probability value: p c =Sigmod(V c ′(2)-V c ′(1)), V c ′(2) and V c ′(1) represents two different state confidences of node c.
[0030] Preferably, in the second method, updating the node status specifically includes:
[0031] Aggregate the generated messages, V a ′=V a +M d ;
[0032] Among them, V a ′The state of the child node after aggregation, V a is the initial confidence of node a, M d Represents the message from the parent node d, which continuously updates the classification probability between nodes until the message propagation converges;
[0033] Update the node status and convert it into probability value: p a=Sigmod(V a ′(2)-V a ′(1)), V a ′(2) and V a ′(1) represents two different state confidences of node a.
[0034] Preferably, in the third method, updating the node status specifically includes:
[0035] Aggregate the generated messages, V c ′=V c +M s2f +M f2s ;
[0036] Among them, M s2f Indicates messages from different child nodes, M f2s Represents the message from the parent node, continuously updating the probability between nodes until the message propagation converges;
[0037] Update the node status and convert it into probability value: p c =Sigmod(V c ′(2)-V c ′(1));
[0038] Among them, V c ′(2) and V c ′(1) represents two different state confidences of node c.
[0039] A hierarchical text classification system that ensures node label consistency, comprising:
[0040] Feature extraction module, which extracts contextual features of each news article through a text encoder;
[0041] A classification probability calculation module inputs the context features into a multi-label classifier and outputs a preliminary classification probability corresponding to the label of each context feature;
[0042] A confidence reconstruction module takes each label as a node and reconstructs the preliminary classification probability of each node into the confidence of the node through a reconstruction function;
[0043] The classification module generates messages based on child nodes, parent nodes and confidence levels, aggregates the generated messages until the message propagation converges, and then updates the node status through the converged aggregated messages to output the final multi-label classification results of the news article.
[0044] It can be seen from the above technical solutions that, compared with the prior art, the present invention discloses a hierarchical text classification method and system that ensures the consistency of node labels. Through the message passing mechanism constrained by logical rules, the label consistency in the classification task is achieved, while ensuring the accuracy of the classification results and the integrity of the hierarchical structure. The present invention can effectively cope with multi-level label systems, and by passing label information between parent nodes and child nodes, the adaptability of the classification model to complex structures is improved. It not only reduces the error in label classification, but also improves the overall performance of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] 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 embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0046] Figure 1 A schematic diagram of the method steps provided by the present invention;
[0047] Figure 2 A hierarchical text multi-label classification diagram in news classification provided by the present invention;
[0048] Figure 3 Node transformation process diagram of algorithm case 1 provided by the present invention;
[0049] Figure 4 The flowchart of Algorithm 1 provided by the present invention;
[0050] Figure 5 Node transformation process diagram of algorithm case 2 provided by the present invention;
[0051] Figure 6 A flowchart of Algorithm 2 provided by the present invention;
[0052] Figure 7 Node transformation process diagram of algorithm case 3 provided by the present invention;
[0053] Figure 8 Flowchart of Algorithm 3 provided by the present invention;
[0054] Fig. 9 A correct graph of the classification results provided by the present invention;
[0055] Fig.10 This is an error diagram of the classification results provided by the present invention. DETAILED DESCRIPTION
[0056] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.
[0057] The embodiment of the present invention discloses a hierarchical text classification method for ensuring the consistency of node labels. Figure 1 As shown, including:
[0058] Extract contextual features of each news article through a text encoder;
[0059] Input the context features into the multi-label classifier and output the preliminary classification probability corresponding to the label of each context feature;
[0060] Take each label as a node, and reconstruct the preliminary classification probability of each node into the node confidence through the reconstruction function;
[0061] Messages are generated based on child nodes, parent nodes and confidence levels, and the generated messages are aggregated until the message propagation converges. The node status is then updated through the converged aggregated messages, and the final multi-label classification results of the news articles are output.
[0062] In a specific embodiment, extracting context features of each news article specifically includes: extracting context features from each news article X through a BERT text encoder;
[0063] H = BERT(X);
[0064] Where H is the contextual feature extracted by the BERT text encoder.
[0065] In a specific embodiment, inputting context features into a multi-label classifier specifically includes:
[0066] p=W·H+b;
[0067] Among them, W is the weight matrix, b is the bias, and p is the preliminary classification score for each label.
[0068] In a specific embodiment, reconstructing the preliminary classification probability of each node into the confidence of the node through the reconstruction function specifically includes:
[0069] V c =σ(p c );
[0070] Among them, V c is the initial confidence of node c, where Vc is the initial confidence of node c, σ(·) is the probability reconstruction function, which can convert the initial probability into a two-dimensional confidence expression, namely V c =[V c (1),V c (2)],V c (1) and V c (2) represents the two different state confidences of the current node c, p c is the initial score of the news text pair classified into node c.
[0071] In a specific embodiment, generating a message based on a child node, a parent node, and a confidence level specifically includes:
[0072] Method 1: The classification probability of the parent node is adjusted according to the initial confidence of the child node corresponding to the parent node, and the parent node receives the message from the child node;
[0073] Method 2: Adjust the classification probability of the child node according to the initial confidence of the parent node, and the child node receives the message from the parent node;
[0074] Method three, or adjust the classification probability of the parent node according to the initial confidence of the child node corresponding to the parent node, the parent node receives the message from the child node, and adjusts the classification probability of the child node according to the initial confidence of the parent node, and the child node receives the message from the parent node.
[0075] In a specific embodiment, in method 1, updating the node status specifically includes:
[0076] Aggregate the generated messages, V c ′=V c +M a +M b ;
[0077] Among them, V c ′The state of the parent node after aggregation, V c is the initial confidence of node c, M a and M b Represent the messages from child nodes a and b respectively, and continuously update the classification probability between nodes until the message propagation converges;
[0078] Update the node status and convert it into probability value: p c =Sigmod(V c ′(2)-V c ′(1)), V c ′(2) and V c ′(1) represents two different state confidences of node c.
[0079] In a specific embodiment, in method 2, updating the node status specifically includes:
[0080] Aggregate the generated messages, V a ′=V a +M d ;
[0081] Among them, V a ′The state of the child node after aggregation, V a is the initial confidence of node a, M d Represents the message from the parent node d, which continuously updates the classification probability between nodes until the message propagation converges;
[0082] Update the node status and convert it into probability value: p a =Sigmod(V a ′(2)-V a ′(1)), V a ′(2) and V a ′(1) represents two different state confidences of node a.
[0083] In a specific embodiment, in method three, updating the node status specifically includes:
[0084] Aggregate the generated messages, V c ′=V c +M s2f +M f2s ;
[0085] Among them, M s2f Indicates messages from different child nodes, M f2s Represents the message from the parent node, continuously updating the probability between nodes until the message propagation converges;
[0086] Update the node status and convert it into probability value: p c =Sigmod(V c ′(2)-V c ′(1));
[0087] Among them, V c ′(2) and V c ′(1) represents two different state confidences of node c
[0088] A hierarchical text classification system that ensures node label consistency, comprising:
[0089] Feature extraction module, which extracts contextual features of each news article through a text encoder;
[0090] The classification probability calculation module inputs the context features into the multi-label classifier and outputs the preliminary classification probability corresponding to the label of each context feature;
[0091] The confidence reconstruction module treats each label as a node and reconstructs the preliminary classification probability of each node into the confidence of the node through the reconstruction function;
[0092] The classification module generates messages based on child nodes, parent nodes and confidence levels, aggregates the generated messages until the message propagation converges, and then updates the node status through the converged aggregated messages to output the final multi-label classification results of the news article.
[0093] In a specific embodiment, hierarchical text multi-label classification in news classification is used as an application scenario. In a news portal or news aggregation platform, news articles need to be automatically classified, and each article may belong to multiple categories at the same time. Figure 2 As shown in the figure, an article may belong to three categories: "Technology", "Artificial Intelligence" and "Natural Language Processing", and "Artificial Intelligence" is a subcategory under the big category of "Technology", and "Natural Language Processing" is a subcategory of "Artificial Intelligence". For more accurate classification, the algorithm not only needs to identify multiple labels for each article, but also needs to consider the hierarchical structure between these labels.
[0094] like Figure 3 As shown, the method 1 proposed by the present invention can constrain the parent node through the child node, that is, the state of the parent node is dynamically updated by passing messages through the child node. If the probability of a child node (such as "natural language processing") exceeds a certain threshold (such as 0.5), the probability of the parent node ("artificial intelligence") is also corrected to be greater than 0.5. That is, when the child node is a label and the parent node is not a label, the parent node is modified to be a label.
[0095] Specific applications:
[0096] Step 1: Data input and feature extraction
[0097] In multi-label classification tasks, text needs to be preprocessed by a text encoder to extract high-dimensional semantic features. In this model, the present invention selects BERT as the text encoder to generate rich context vector representations for each news article.
[0098] After each news article X passes through the BERT model, a vectorized representation H=BERT(X) is obtained, where H is the contextual features extracted by BERT, which represent the semantic information of the news article.
[0099] Step 2: Multi-label classification
[0100] After obtaining the feature representation H of the news text, the next step is to perform a preliminary classification of the text through a multi-label classifier. Each label is regarded as a node in the classification process, and the features extracted by BERT will be used as the input of these nodes for node initialization and classification probability calculation.
[0101] The feature H extracted by each text encoder is input into the multi-label classifier, which outputs the preliminary classification probability of each label:
[0102] p=W·H+b
[0103] Among them, W is the weight matrix, b is the bias, and p is the preliminary classification score of each label. At this point, the classifier will give a preliminary classification status for each label.
[0104] Step 3: Node initialization
[0105] Each classification label (such as "technology" or "artificial intelligence") is represented as a node, and the algorithm reconstructs the probability distribution of each label node into the node's confidence V through a reconstruction function. Take node C ("artificial intelligence") as an example.
[0106] V c =σ(p c )
[0107] Where V c is the activation value of node c, indicating the initial confidence of classification to this node, p c It is the initial score of news text pair classification to artificial intelligence.
[0108] Step 4: Message Generation
[0109] The text information of the article In this algorithm, child nodes (such as node A "natural language processing" and node B "computer vision") can affect their parent node (node C "artificial intelligence"). The algorithm can adjust the probability of the parent node according to the activation status of its child nodes. At this time, the parent node will receive the message M from its child nodes. a and M b .
[0110] M a =w×V a ×T1
[0111] M b =w×V b ×T1
[0112] Where w is a learnable weight used to control the importance of the message, V a represents the initial confidence of node a, V b represents the initial confidence of node b, where T1 represents the message passed from the child node to the parent node.
[0113] Step 5: Message Aggregation
[0114] The activation status of a child node will affect the parent node. For example, if the probability of a news item on the child node "Natural Language Processing" (node A) is high, the message will be passed upward through the algorithm to increase the probability of its parent node "Artificial Intelligence" (node C). The state of the aggregated parent node is:
[0115] V c ′=V c +M a +M b
[0116] Among them, M a and M b They represent messages from different child nodes respectively, and the algorithm will continuously update the probabilities between nodes until the message propagation converges.
[0117] Step 6: Probability Update
[0118] After getting the aggregated message, update the node status and convert it into a probability value:
[0119] p c =Sigmod(V c ′(2)-V c ′(1)).
[0120] The process of message transmission and probability adjustment is iterative until the messages transmitted by the nodes converge and are no longer updated (the probabilities of certain label nodes no longer change significantly). At this point, the algorithm outputs the final multi-label classification results of the news articles. For each news article, multiple labels may be assigned, and the hierarchical relationship between these labels will be retained. Taking node c as an example, the overall flow chart of Algorithm 1 is as follows: Figure 4 shown.
[0121] like Figure 5 As shown, the second method proposed in the present invention can constrain the child node through the parent node, that is, the state of the child node is dynamically updated by passing messages through the parent node. If the probability of a parent node (such as "artificial intelligence") does not exceed a certain threshold (such as 0.5), the probability of the child node ("natural language processing") is also corrected to be less than 0.5. That is, when the child node is a label and the parent node is not a label, the child node is modified to not be a label.
[0122] Specific applications:
[0123] Step 1: Data input and feature extraction
[0124] In multi-label classification tasks, text needs to be preprocessed by a text encoder to extract high-dimensional semantic features. In this model, the present invention selects BERT as the text encoder to generate rich context vector representations for each news article.
[0125] After each news article X passes through the BERT model, a vectorized representation H=BERT(X) is obtained, where H is the contextual features extracted by BERT, which represent the semantic information of the news article.
[0126] Step 2: Multi-label classification
[0127] After obtaining the feature representation H of the news text, the next step is to perform a preliminary classification of the text through a multi-label classifier. Each label is regarded as a node in the classification process, and the features extracted by BERT will be used as the input of these nodes for node initialization and classification probability calculation.
[0128] The feature H extracted by each text encoder is input into the multi-label classifier, which outputs the preliminary classification probability of each label:
[0129] p=W·H+b
[0130] Among them, W is the weight matrix, b is the bias, and p is the preliminary classification score of each label. At this point, the classifier will give a preliminary classification status for each label.
[0131] Step 3: Node initialization
[0132] Each classification label (such as "technology" or "artificial intelligence") is represented as a node, and the algorithm reconstructs the probability distribution of each label node into the node's confidence V through a reconstruction function. Take node C ("artificial intelligence") as an example.
[0133] V c =σ(p c )
[0134] Where V c is the activation value of node c, indicating the initial confidence of classification to this node, p c It is the initial score of news text pair classification to artificial intelligence.
[0135] Step 4: Message Generation
[0136] In this algorithm, the parent node (for example, node C "artificial intelligence") can affect its subordinate child node (node A "natural language processing"). The algorithm can adjust the probability of the child node according to the activation state of its parent node. At this time, the child node will receive the message M from its parent node. c .
[0137] M c=w×V c ×T2
[0138] Where w is a learnable weight used to control the importance of the message, and T1 indicates that the message is passed from the child node to the parent node.
[0139] Step 5: Message Aggregation
[0140] The activation state of the parent node will affect the child nodes. For example, if the probability of news classification on the parent node "artificial intelligence" (node C) is low, the message will be passed down through the algorithm to reduce the probability of its child node "natural language processing" (node A). The state of the child nodes after aggregation is:
[0141] V a ′=V a +M d
[0142] Among them, M d Represents the message from the parent node D. The algorithm will continuously update the probability between nodes until the message propagation converges.
[0143] Step 6: Probability Update
[0144] After getting the aggregated message, update the node status and convert it into a probability value:
[0145] p a =Sigmod(V a ′(2)-V a ′(1)).
[0146] The process of message transmission and probability adjustment is iterative until the message transmitted by the node converges and is no longer updated (the probability of certain label nodes no longer changes significantly). At this point, the algorithm will output the final multi-label classification result of the news article. For each news article, multiple labels may be assigned, and the hierarchical relationship between these labels will be retained. Taking node C as an example, the overall flow chart of Algorithm 2 is as follows: Figure 6 shown.
[0147] like Figure 7 As shown, the method three proposed in the present invention can constrain the target node through the parent node and the child node at the same time. The whole process is comprehensively considered, and the probability update of the node is affected by adjusting different weights w1 and w2, and finally it plays a role in correcting the inconsistent labels.
[0148] Step 1: Data input and feature extraction
[0149] In multi-label classification tasks, text needs to be preprocessed by a text encoder to extract high-dimensional semantic features. In this model, the present invention selects BERT as the text encoder to generate rich context vector representations for each news article.
[0150] After each news article X passes through the BERT model, a vectorized representation H=BERT(X) is obtained, where H is the contextual features extracted by BERT, which represent the semantic information of the news article.
[0151] Step 2: Multi-label classification
[0152] After obtaining the feature representation H of the news text, the next step is to perform a preliminary classification of the text through a multi-label classifier. Each label is regarded as a node in the classification process, and the features extracted by BERT will be used as the input of these nodes for node initialization and classification probability calculation.
[0153] The feature H extracted by each text encoder is input into the multi-label classifier, which outputs the preliminary classification probability of each label:
[0154] p=W·H+b
[0155] Among them, W is the weight matrix, b is the bias, and p is the preliminary classification score of each label. At this point, the classifier will give a preliminary classification status for each label.
[0156] Step 3: Node initialization
[0157] Each classification label (such as "technology" or "artificial intelligence") is represented as a node, and the algorithm reconstructs the probability distribution of each label node into the node's confidence V through a reconstruction function. Take node C ("artificial intelligence") as an example.
[0158] V c =σ(p c )
[0159] Where V c is the activation value of node c, indicating the initial confidence of classification to this node, p c It is the initial score of news text pair classification to artificial intelligence.
[0160] Step 4: Message Generation
[0161] In this algorithm, child nodes (such as node A "natural language processing" and node B "computer vision") can affect their parent node (node C "artificial intelligence"). The algorithm can adjust the probability of the parent node according to the activation status of its child nodes. At this time, node C as the parent node will receive the message M from its child nodes. a and M b .
[0162] M a =w1×V a ×T1
[0163] Mb =w2×V b ×T1
[0164] M s2f =M a +M b
[0165] At the same time, the parent node (for example, node D "technology") can affect its subordinate child node (node C "artificial intelligence"). The algorithm can adjust the probability of the child node according to the activation state of its parent node. At this time, node C as a child node will receive the message M from its parent node. d .
[0166] M d =w2×V d ×T2
[0167] M f2s =M d
[0168] where w i (i=1,2) is a learnable weight used to control the importance of the message. The weights of message transmission under different rules are different. i It is the state transition matrix, which controls the message transmission direction, where T1 represents the message transmission from the child node to the parent node, and T2 represents the message transmission from the parent node to the child node.
[0169] Step 5: Message Aggregation
[0170] The activation state of the child node will affect the parent node, and the activation state of the parent node will also affect the child node with a certain probability. The degree of influence on the node varies according to the importance of the message it transmits. The state of the C node after aggregation is:
[0171] V c ′=V c +M s2f +M f2s
[0172] Among them, M s2f Indicates messages from different child nodes, M f2s Represents the message from the parent node, and the algorithm will continuously update the probability between nodes until the message propagation converges.
[0173] Step 6: Probability Update
[0174] After getting the aggregated message, update the node status and convert it into a probability value:
[0175] p c =Sigmod(V c ′(2)-V c ′(1)).
[0176] The process of message transmission and probability adjustment is iterative until the message transmitted by the node converges and is no longer updated (the probability of certain label nodes no longer changes significantly). At this point, the algorithm will output the final multi-label classification result of the news article. For each news article, multiple labels may be assigned, and the hierarchical relationship between these labels will be retained. Taking node C as an example, the entire algorithm process flow chart is as follows: Figure 8 shown.
[0177] In order to verify the effectiveness of this algorithm, the three data sets used in the experiment are introduced; secondly, the evaluation indicators and comparison models are described in detail. Finally, the experimental results of the method of the present invention are analyzed. It can be seen that the problem of label inconsistency can be effectively solved, and the scores in the comprehensive evaluation are greatly improved.
[0178] All experimental methods are basically conducted on the following three classic HTC datasets, including a scientific literature dataset Web of Science (WOS) and two large news datasets Reuters Corpus Volume I (RCV1) and New York Times (NYT).
[0179] WOS is a scientific literature database that contains a large number of academic articles and is often used for hierarchical text classification (HTC) tasks. Its data comes from a wide range of fields, including science, technology, and social sciences, and the text is mainly document abstracts. The labels are based on subject classification and have a hierarchical structure.
[0180] RCV1 is a large news corpus released by Reuters, containing more than 800,000 news articles. The label structure includes 4 top-level categories and 103 subcategories. These articles cover multiple fields such as finance, economy, sports, and politics, providing rich news texts for research and development of classification models. RCV1's hierarchical labeling system makes it particularly suitable for studying multi-label classification and hierarchical text classification tasks, and is the largest of the three datasets.
[0181] NYT is a large news dataset published by The New York Times, containing news reports from many years, covering multiple topics such as politics, international affairs, and economy. This dataset is widely used in news classification, sentiment analysis, and topic modeling tasks. Table 1 provides statistics on the training and test set splits for each of the three datasets.
[0182] Table 1 Statistics of WOS, NYT, and RCV1 datasets
[0183] Dataset Training set Test Set Layer Depth Classification Type WOS 30070 9397 2 141 NYT 23345 7292 8 166 RCV1-V2 20833 781265 4 103
[0184] The unified evaluation index of the algorithm on the standard data set, the present invention uses Micro-F1 and Macro-F1 as the evaluation function of the hierarchical text classification effect to evaluate the classification effect, and uniformly measures the effect of entity recognition, as follows:
[0185] Macro-F1 takes the arithmetic average of the F1-score of each category without considering the difference in the number of samples in each category.
[0186] First calculate the F1-score for each category i:
[0187]
[0188] Among them, true positive TP (true positive) represents the number of positive samples correctly identified; false positive FP (false positive) represents the number of samples that mistakenly classify negative samples as positive; FN (false negative) represents the number of samples that the model mistakenly classifies positive samples as negative.
[0189] Micro-F1 is calculated based on the global true positives, false positives, and false negatives, considering the total number of samples in all categories.
[0190] First, calculate the global P micro and R micro :
[0191]
[0192] The specific experimental results are shown in Table 2. It is verified that Algorithm 1 has achieved significant performance improvement on Dataset 2 (WOS), with Macro-F1 improved by 1.25% and Micro-F1 improved by 0.92%. This shows that Algorithm 1 has a good improvement effect on the classification task of the WOS dataset.
[0193] Algorithm 2 performs well on Dataset 3 (NYT), with Macro-F1 improving by 1.47% and Micro-F1 improving by 0.44%, significantly outperforming the basic model. This shows that Algorithm 2 is suitable for the characteristics of the NYT dataset and can effectively improve classification performance.
[0194] Algorithm 3 achieved the greatest improvement on dataset 1 (RCV1), with Macro-F1 improved by 1.72% and Micro-F1 improved by 0.98%. This shows that Algorithm 3 has a clear advantage in processing the RCV1 dataset.
[0195] In summary, the three algorithms proposed in this invention have achieved significant performance improvements on different data sets, verifying the effectiveness and pertinence of the algorithms.
[0196] Table 2 Experimental results
[0197]
[0198] As shown in Table 2, the bold values in the table represent the best results, and the method significantly improves the performance of the model on all data sets. In addition, the improvement of Macro-F1 is more significant than that of Micro-F1. This phenomenon may be due to the long-tail label distribution problem, that is, some categories have more samples (mainstream categories), while some categories have fewer samples (tail categories), which makes the tail categories generally difficult to accurately identify. The method of the present invention can effectively identify these tail categories, so the improvement of Macro-F1 is significantly higher than that of Micro-F1. These results effectively confirm the effectiveness of the method of the present invention in solving the problem of HTC label inconsistency, and demonstrate its good scalability and portability.
[0199] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0200] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined in the present invention may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown in the present invention, but will conform to the widest scope consistent with the principles and novel features disclosed in the present invention.
Claims
1. A hierarchical text classification method for ensuring node label consistency, characterized in that: include: Extract contextual features of each news article through a text encoder; Input the context features into a multi-label classifier, and output a preliminary classification probability corresponding to the label of each context feature; Each label is regarded as a node, and the preliminary classification probability of each node is reconstructed into the confidence of the node through a reconstruction function; Messages are generated based on child nodes, parent nodes and confidence levels, and the generated messages are aggregated until the message propagation converges. The node status is then updated through the converged aggregated messages, and the final multi-label classification results of the news articles are output.
2. A hierarchical text classification method for ensuring node label consistency according to claim 1, characterized in that: The extracting context features of each news article specifically includes: extracting context features from each news article X through a BERT text encoder; H = BERT(X); Where H is the contextual feature extracted by the BERT text encoder.
3. A hierarchical text classification method for ensuring node label consistency according to claim 1, characterized in that: The inputting the context feature into the multi-label classifier specifically includes: p=W·H+b; Among them, W is the weight matrix, b is the bias, and p is the preliminary classification score for each label.
4. A hierarchical text classification method for ensuring node label consistency according to claim 1, characterized in that: The reconstructing the preliminary classification probability of each node into the confidence of the node by the reconstruction function specifically includes: V c =σ(p c ); Among them, V c is the initial confidence of node c, σ(·) is the probability reconstruction function, p c is the initial score of the news text pair classified into node c.
5. A hierarchical text classification method for ensuring node label consistency according to claim 4, characterized in that: The message generation based on the child node, the parent node and the confidence level specifically includes: Method 1: The classification probability of the parent node is adjusted according to the initial confidence of the child node corresponding to the parent node, and the parent node receives the message from the child node; Method 2: adjusting the classification probability of the child node according to the initial confidence of the parent node, and the child node receives the message from the parent node; Method three, or adjusting the classification probability of the parent node according to the initial confidence of the child node corresponding to the parent node, the parent node receives the message from the child node, and at the same time adjusting the classification probability of the child node according to the initial confidence of the parent node, the child node receives the message from the parent node.
6. A hierarchical text classification method for ensuring node label consistency according to claim 5, characterized in that: In the method 1, updating the node status specifically includes: Aggregate the generated messages, V c ′=V c +M a +M b ; Among them, V c ′The state of the parent node after aggregation, V c is the initial confidence of node c, M a and M b Represent the messages from child nodes a and b respectively, and continuously update the classification probability between nodes until the message propagation converges; Update the node status and convert it into probability value: p c =Sigmod(V c ′(2)-V c ′(1)), V c ′(2) and V c ′(1) represents two different state confidences of node c.
7. A hierarchical text classification method for ensuring node label consistency according to claim 5, characterized in that: In the second method, updating the node status specifically includes: Aggregate the generated messages, V a ′=V a +M d ; Among them, V a ′The state of the child node after aggregation, V a is the initial confidence of node a, M d Represents the message from the parent node d, which continuously updates the classification probability between nodes until the message propagation converges; Update the node status and convert it into probability value: p a =Sigmod(V a ′(2)-V a ′(1)), V a ′(2) and V a ′(1) represents two different state confidences of node a.
8. A hierarchical text classification method for ensuring node label consistency according to claim 5, characterized in that: In the third method, updating the node status specifically includes: Aggregate the generated messages, V c ′=V c +M s2f +M f2s ; Among them, M s2f Indicates messages from different child nodes, M f2s Represents the message from the parent node, continuously updating the probability between nodes until the message propagation converges; Update the node status and convert it into probability value: p c =Sigmod(V c ′(2)-V c ′(1)); Among them, V c ′(2) and V c ′(1) represents two different state confidences of node c.
9. A hierarchical text classification system for ensuring node label consistency, using a hierarchical text classification method for ensuring node label consistency according to any one of claims 1 to 8, characterized in that: include: Feature extraction module, which extracts contextual features of each news article through a text encoder; A classification probability calculation module inputs the context features into a multi-label classifier and outputs a preliminary classification probability corresponding to the label of each context feature; A confidence reconstruction module takes each label as a node and reconstructs the preliminary classification probability of each node into the confidence of the node through a reconstruction function; The classification module generates messages based on child nodes, parent nodes and confidence levels, aggregates the generated messages until the message propagation converges, and then updates the node status through the converged aggregated messages to output the final multi-label classification results of the news article.