Label enhancement method and system for few-shot multi-label demand classification
By enhancing label semantics through BERT encoding and graph neural networks, and combining weak graph residual propagation mechanism, the problems of insufficient samples and complex label structure in multi-label requirement classification are solved, achieving efficient and interpretable multi-label prediction, which is suitable for requirement analysis and automatic classification in software engineering.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HARBIN INST OF TECH
- Filing Date
- 2026-03-12
- Publication Date
- 2026-06-12
AI Technical Summary
In software engineering, multi-label classification tasks face challenges such as a small number of samples, high semantic abstraction of labels, structural relationships between labels, and high costs associated with manual annotation. This results in existing methods having poor prediction accuracy and recall in scenarios with few samples, and is also unfair to different labels.
The pre-trained language model BERT is used to encode the requirement text and label text, a label graph is constructed and the label semantic vector is enhanced by graph neural network propagation, multi-label classification is performed by combining cosine similarity and domain expert knowledge, and label matching is performed by weak graph residual propagation mechanism to achieve efficient and interpretable multi-label prediction.
It improves the accuracy and recall of multi-label classification under limited sample conditions, maintains label discriminativeness while explicitly modeling the structural dependencies between labels, reduces manual annotation costs, and enhances the stability and interpretability of the model.
Smart Images

Figure CN122196183A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of label classification technology, and in particular relates to a label enhancement method for classification with a small number of samples and multiple labels. Background Technology
[0002] In the fields of software engineering, systems analysis, and requirements engineering, a large number of requirements documents in natural language still rely on manual analysis, organization, and classification. This is especially true in complex software systems, where requirements often originate from diverse sources, are expressed in inconsistent ways, and a single requirement may involve multiple functional modules or quality attributes. This makes the requirements analysis process not only costly but also highly dependent on the experience of the analysts.
[0003] With the development of natural language processing technology, automatic text-based requirement classification has gradually become a research hotspot. Among them, multi-label text classification (MLTC) is the task that best reflects real-world requirement analysis scenarios because a requirement often belongs to multiple categories simultaneously. For example, in functional requirements (FR), a requirement may involve both "input and perception systems" and "processing and decision-making systems"; in non-functional requirements (NFR), a requirement may be associated with both "security" and "maintainability." Therefore, compared with general text classification tasks, requirement text classification faces significant challenges.
[0004] In real-world engineering scenarios, manual annotation of requirement text is extremely costly. Unlike general tasks such as sentiment analysis and news classification, requirement tags typically have strong domain-specific characteristics, requiring experts with backgrounds in requirement engineering or system architecture for accurate annotation. Therefore, the actual amount of annotated data available is usually relatively small.
[0005] In addition, unlike the flat labels such as sports / finance / entertainment in traditional text classification, demand classification labels have the following characteristics:
[0006] 1. High semantic abstraction: For example, tags such as internal coordination system, scalability and evolvability are not specific events or entities, but abstract system attributes;
[0007] 2. There are structural relationships between tags: Different tags are not independent of each other, but have semantic similarity and functional coupling relationships;
[0008] 3. The tags themselves have textual descriptions: Tags can be interpreted by natural language, and are not just discrete IDs;
[0009] These characteristics mean that simply treating labels as one-hot vectors would be a huge waste of prior information at the label level.
[0010] In multi-label classification tasks, models typically output the predicted probability or score for each label. However, converting continuous scores into a final binary prediction is a non-trivial problem. Using a fixed threshold (e.g., 0.5) consistently often leads to: high precision and low recall in few-sample scenarios; unfairness towards different labels; and results that are highly sensitive to training randomness. Therefore, a systematic threshold adaptation method is needed. Summary of the Invention
[0011] The purpose of this invention is to provide a label enhancement method for classification with few samples and many labels, thereby solving the above-mentioned technical problems.
[0012] This invention is implemented as follows: a label enhancement method for classification with few samples and multiple labels, comprising the following steps:
[0013] Obtain the requirement text and encode the requirement text using the pre-trained language model BERT to obtain the requirement text semantic vector;
[0014] Obtain multiple predefined demand category labels and their corresponding descriptive texts, and use the pre-trained language model BERT to encode the descriptive text of each demand category label to obtain a label semantic matrix;
[0015] Based on the label semantic matrix and prior grouping knowledge, a label graph is constructed, and the initial label semantic vectors in the label semantic matrix are propagated through a graph neural network to obtain enhanced label semantic vectors.
[0016] The semantic vector of the required text is matched with the enhanced semantic vector of the label to obtain the multi-label classification result.
[0017] Further, the steps of obtaining the requirement text and encoding it using the pre-trained language model BERT to obtain the requirement text semantic vector specifically include:
[0018] Input the requirement text x, which is first segmented and encoded to obtain the token sequence:
[0019] ;
[0020] The hidden layer representation H is then obtained by inputting it into the BERT encoder:
[0021] ;
[0022] Where n is the length of the token sequence; d is the hidden dimension; BERT(·) is the output of the BERT encoder;
[0023] use The representation of h as the semantic vector of the demand text x :
[0024] .
[0025] Further, the steps of obtaining multiple predefined demand category labels and their corresponding descriptive texts, and encoding the descriptive text of each demand category label using the pre-trained language model BERT to obtain a label semantic matrix, specifically include:
[0026] For the i-th requirement category label, its description text is y. i The corresponding label semantic vector Defined as:
[0027] ;
[0028] Then the label semantic matrix E y for:
[0029] ;
[0030] Where L represents the total number of demand category labels.
[0031] Furthermore, the construction of the label graph specifically includes:
[0032] Based on the aforementioned label semantic matrix, the cosine similarity between any two demand category labels is calculated, and the k most similar demand category labels are selected for each demand category label to construct a semantic similarity graph A. sim ;
[0033] Based on prior grouping knowledge in the field of requirements engineering, requirement category labels are divided into two main categories: functional requirement labels and non-functional requirement labels, and an intra-group prior graph A is constructed. group ;
[0034] Artificial semantic edges are introduced, and prior connection weights are assigned to label pairs with explicit associations based on domain expert knowledge, thus constructing an artificial semantic adjacency matrix A. manual ;
[0035] The semantic similarity graph, within-group prior graph, and artificial semantic adjacency matrix are weighted and fused, and then subjected to standard symmetric normalization and self-loop enhancement to obtain the final label graph adjacency matrix A. norm .
[0036] Furthermore, the graph neural network propagation adopts a weak graph residual propagation mechanism, and its propagation formula is as follows:
[0037] ;
[0038] Where E is the initial label embedding, i.e. the initial label semantic vector; This is the embedded label after propagation, i.e., the enhanced label semantic vector; The graph shows the propagation intensity coefficient.
[0039] Further, the step of matching the semantic vector of the demand text with the enhanced semantic vector of the label to obtain the multi-label classification result specifically includes:
[0040] Calculate the cosine similarity between the semantic vector of the demand text and the semantic vector of the enhanced tag, and introduce a learnable temperature parameter to obtain the matching score of each demand category tag;
[0041] The matching score is converted into a probability value by an activation function, and the predicted probability of each demand category label is obtained as the multi-label classification result.
[0042] Another objective of this invention is to provide a label enhancement system for classification with few samples and multiple labels, used to implement the aforementioned label enhancement method for classification with few samples and multiple labels, specifically including:
[0043] The text encoding module is used to acquire the requirement text and encode the requirement text using the pre-trained language model BERT to obtain the requirement text semantic vector.
[0044] The label encoding module is used to obtain multiple predefined demand category labels and their corresponding descriptive texts, and to encode the descriptive text of each demand category label using the pre-trained language model BERT to obtain a label semantic matrix;
[0045] The label enhancement module is used to construct a label graph based on the label semantic matrix and prior grouping knowledge, and to perform graph neural network propagation on the initial label semantic vectors in the label semantic matrix to obtain the enhanced label semantic vectors.
[0046] The matching and classification module is used to match the semantic vector of the required text with the enhanced semantic vector of the label to obtain a multi-label classification result.
[0047] This invention provides a label augmentation method for classification with few samples and multiple labels. Based on BERT as the encoder, it integrates label semantics and label structural relationships, achieving efficient and interpretable multi-label prediction through a matching classification head. Specifically designed for scenarios with few samples and multiple labels, this invention presents a novel label semantic augmentation paradigm that explicitly models the structural dependencies between labels while maintaining label discriminative power. Attached Figure Description
[0048] Figure 1 This is a flowchart illustrating a label enhancement method for classification with few samples and multiple labels, provided in an embodiment of the present invention.
[0049] Figure 2 This is a schematic diagram of the structure of a label enhancement system for classification with few samples and multiple labels provided in an embodiment of the present invention. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0051] like Figure 1 As shown, in one embodiment of the present invention, a label enhancement method for classification with few samples and multiple labels is provided, comprising the following steps:
[0052] S1. Obtain the requirement text and encode the requirement text using the pre-trained language model BERT to obtain the requirement text semantic vector.
[0053] S2. Obtain multiple predefined demand category labels and their corresponding description texts, and use the pre-trained language model BERT to encode the description text of each demand category label to obtain a label semantic matrix;
[0054] S3. Based on the label semantic matrix and prior grouping knowledge, construct a label graph, and perform graph neural network propagation on the initial label semantic vectors in the label semantic matrix to obtain enhanced label semantic vectors;
[0055] S4. Match the semantic vector of the required text with the enhanced semantic vector of the label to obtain the multi-label classification result.
[0056] In multi-label datasets, labels not only carry rich semantic information, but the co-occurrence information between labels also implies potential relationships between them. Therefore, when constructing label representations, the correlation between labels and the semantic representation of the labels themselves can be fully utilized. Specifically, the label set and the input requirement text need to be initially encoded to obtain their baseline representations in the semantic space. In this embodiment of the invention, a pre-trained BERT encoder (whose parameters are kept frozen) is used and does not participate in the subsequent training process, thereby ensuring the stability and consistency of the encoding results. This embodiment of the invention maps the requirement text representation, label semantic representation, and label structural relationships to the same representation space and completes multi-label discrimination through a matching mechanism.
[0057] Furthermore, this invention introduces a label graph as an intermediate structure. The core idea is to treat labels as nodes, explicitly model the semantic, structural, and prior relationships between labels as a graph structure, and enhance the label representation through a graph propagation mechanism. Essentially, this elevates the label space from a discrete set to a structured semantic space. During label graph construction, based on the basic classification principles of requirements engineering, all labels are explicitly divided into two categories: functional requirements (FR) and non-functional requirements (NFR), and intra-group prior connection rules are introduced. Specifically, weak connections are established only between FR-FR and NFR-NFR labels, and by default, no direct edges are connected between FR and NFR. The core purpose of this design is to inject domain structural priors into the model, thereby constraining the rationality of the graph structure. Simultaneously, this grouping constraint effectively avoids misconnections based solely on semantic similarity, such as incorrectly associating functional labels like input and perception systems with non-functional labels like performance and concurrency capabilities, thus improving the stability and interpretability of the label graph in low-sample, multi-label classification tasks.
[0058] In this embodiment of the invention, the requirement text statement is first encoded into a requirement text semantic vector using a pre-trained language model, and then the label semantic vector is matched with the requirement text semantic vector to obtain logits. At the same time, the label semantic vector is propagated a few times on the label graph. The propagation matrix is not directly the label graph adjacency matrix, but a residual weak graph is used to limit the propagation strength, thereby introducing a small amount of graph information without destroying the label semantic prototype.
[0059] In a preferred embodiment of the present invention, each request text is given in natural language form, for example: the system should support administrators to enter an order number on the page and submit a request; the text length is usually short, but the semantics are highly focused. Specifically, step S1 above includes:
[0060] Given the input text x, it is first segmented and encoded to obtain a token sequence:
[0061] ;
[0062] The hidden layer representation H is then obtained by inputting it into the BERT encoder:
[0063] ;
[0064] Where n is the length of the token sequence; d is the hidden dimension; BERT(·) is the output of the BERT encoder;
[0065] In this embodiment of the invention, using The representation of h as the semantic vector of the demand text x :
[0066] ;
[0067] The semantic vector of the required text serves as the basic text representation for subsequent matching and fusion.
[0068] In a preferred embodiment of the present invention, each requirement category label has a clear natural language description, such as: input and perception system, processing and decision-making system, scalability and evolvability, etc., and these label texts contain important semantic information. A globally unique, fixed-order label list text is defined, in which there are 6 categories of functional requirements (FR) and 11 categories of non-functional requirements (NFR), for a total of 17 labels. Specifically, step S2 above includes:
[0069] The label text is encoded using the same BERT model as the text encoding; for the i-th demand category label, its description text is y. i The corresponding label semantic vector Defined as:
[0070] ;
[0071] Then the label semantic matrix E y for:
[0072] ;
[0073] Where L represents the total number of demand category labels.
[0074] This design is crucial, ensuring strict alignment between label embedding, graph nodes, and classification output. It provides a unified index space for multi-module collaboration, including BERT, Graph Neural Networks (GNN), and threshold search, avoiding the hidden but fatal problem of label misalignment in multiple files and stages.
[0075] In a preferred embodiment of the present invention, based on the label graph-based GNN semantic labeling, a new adjacency matrix is constructed from three aspects: label similarity graph, intra-group prior graph, and artificial semantic edges, to explicitly model the structural dependencies between labels; specifically, step S3 above includes:
[0076] S31. Label Graph Construction: In requirement classification tasks, different labels often have semantic or statistical relationships. Analyzing label semantics assigns each label a high-information-density semantic description text, including: label definition, coverage, exclusion scope, strong semantic cues, and typical sentence structure. This step transforms a label from a discrete ID into a semantic object understandable by a language model, thus supporting label embedding, semantic similarity calculation between labels, and few-shot semantic transfer. The construction of the label graph follows a design philosophy of fusing multi-source semantics into a unified graph structure, and the overall process can be summarized in four stages.
[0077] Phase 1: Based on the label semantic matrix, calculate the cosine similarity between any two demand category labels, and select the k most similar demand category labels for each demand category label to construct a semantic similarity graph A. sim First, the semantic description text of the labels is encoded using a model derived from the text encoder. Then, the cosine similarity between any two labels is calculated. For each label, the top-k most similar labels are selected as neighbors, formally represented as follows:
[0078] ;
[0079] Among them, e i and e j These are the i-th and j-th demand category labels, respectively; TopK(i) are the k most similar neighbors of the i-th demand category label;
[0080] Phase Two: Based on prior grouping knowledge from the requirements engineering field, requirement category labels are divided into two main categories: functional requirement labels and non-functional requirement labels, and an intra-group prior diagram A is constructed. group The label graph's structural design is constrained by prior grouping knowledge from the requirements engineering domain, aiming to mitigate structural noise issues that easily arise in semantic similarity-driven graph construction under small sample conditions. Let the complete label set be... for:
[0081] ;
[0082] ;
[0083] in, This represents a set of functional requirement tags. This represents a set of non-functional requirement labels. Based on this explicit partitioning, this embodiment of the invention introduces intra-group prior connection rules when constructing the label adjacency matrix, allowing only weak connections within the same subset, while prohibiting direct connections across groups by default.
[0084] Specifically, given any two labels Its intra-group prior graph adjacency definition is:
[0085] ;
[0086] in, The weak connection weights are used to characterize the potential semantic relevance of similar demand category labels; this matrix does not rely on data distribution statistics, but comes directly from domain knowledge, thus providing stable structural priors under conditions of few samples.
[0087] Phase 3: Introducing artificial semantic edges, assigning prior connection weights to label pairs with explicit associations based on domain expert knowledge, and constructing an artificial semantic adjacency matrix A. manual In classification scenarios with limited samples and multiple labels, relying solely on data-driven methods, such as constructing label graphs based on the semantic similarity of label text, often fails to reliably learn the true relationships between labels, especially for label pairs that appear infrequently, have scarce co-occurring samples, but are logically highly related. Therefore, this invention introduces artificial semantic edges during the label graph construction stage to explicitly inject domain expert knowledge, forming a knowledge-infused graph structure prior.
[0088] Assume the tag set is:
[0089] ;
[0090] Artificial semantic edges are defined as a weighted set of undirected edges:
[0091] ;
[0092] in, Indicates label and The prior association strength between them, r ij This indicates the semantic type of the association; thus, an artificial semantic adjacency matrix can be constructed:
[0093] ;
[0094] The above artificial semantic adjacency matrix A manualIt is not obtained through statistical learning, but rather derived from explicit encoding of expert knowledge and engineering experience; therefore, it can be considered a strong structural prior. This differs from A, which is based on distribution similarity. sim Or A based on category division group Unlike other semantic edges, artificial semantic edges often depict causal relationships, dependency relationships, or normative constraint relationships.
[0095] The fourth stage involves weighted fusion of the semantic similarity graph, the intra-group prior graph, and the artificial semantic adjacency matrix, followed by standard symmetric normalization and self-loop enhancement to obtain the final label graph adjacency matrix A. norm ;
[0096] The adjacency moment A of the weighted fusion label graph is:
[0097] ;
[0098] in, , , For weighting;
[0099] Standard symmetric normalization and self-loop enhancement are applied to the adjacency moments of the weighted fused label graph:
[0100] ;
[0101] Where D is the degree matrix and I is the identity matrix.
[0102] S32. Graph Neural Network Propagation: This embodiment of the invention employs a weak graph residual propagation mechanism to constrain the update rules of the standard graph convolutional network (GCN); specifically, the update form of the label embedding is designed as follows:
[0103] ;
[0104] Where E is the initial label embedding, i.e. the initial label semantic vector; This is the embedded label after propagation, i.e., the enhanced label semantic vector; The graph shows the propagation intensity coefficient.
[0105] In a preferred embodiment of the present invention, step S4 is a fusion representation and matching multi-label prediction, specifically including:
[0106] S41. Matching-based classification head: Employing a matching mechanism instead of a traditional linear classifier, it calculates the cosine similarity between the semantic vector of the demand text and the enhanced semantic vector of the label, and can introduce a learnable temperature parameter to obtain the matching score s for each demand category label. i:
[0107] ;
[0108] Where sin is the cosine similarity; h is the semantic vector of the demand text; and the enhanced tag semantic vector is... .
[0109] S42. Multi-label probability output: The matching score is converted into a probability value through an activation function (such as the sigmoid function) to obtain the predicted probability p of each demand category label. i As the output of multi-label classification results:
[0110] ;
[0111] in, This is the sigmoid function.
[0112] In another embodiment of the present invention, a practical application scheme of the above method is also provided; specifically, the experimental objects of the embodiments of the present invention are natural language requirement statements in real software engineering scenarios, the sources of which include requirement specifications, system design documents, and functional and quality attribute description texts commonly found in engineering practice. Unlike general text classification tasks, requirement texts usually have the following significant characteristics: short text length, highly concise semantics, dense domain terminology, high level of tag abstraction, and obvious engineering semantic orientation.
[0113] In terms of data distribution, the experimental dataset contains both single-label and multi-label samples, and each requirement statement typically corresponds to only 1 to 2 labels, which aligns with the characteristics of "sparse labels and limited co-occurrence" in real-world engineering. It is worth noting that the dataset used in this method is predominantly positive samples, containing almost no explicitly constructed negative samples. This setting significantly increases the task difficulty compared to traditional multi-label classification scenarios and more closely reflects the reality of actual requirement analysis processes where only relevant attributes are labeled, and irrelevant attributes are not explicitly labeled.
[0114] The experimental results fully verify the effectiveness of the method proposed in the embodiments of this invention. First, the baseline model achieves high levels in both micro-F1 and macro-F1, indicating that the matching classification head, after combining label semantics, has strong generalization ability with few samples.
[0115] Secondly, the model performance significantly declined after introducing the standard label graph GCN, especially in terms of micro-F1 and recall. This phenomenon indicates that, under conditions of limited sample size and sparse label co-occurrence, directly propagating strong graphs can easily amplify noisy relationships and destroy the discriminative power of the original label prototypes.
[0116] Further ablation experiments showed that when the label graph was replaced with an identity matrix (i.e., graph propagation was completely turned off), the model performance quickly recovered and approached or even exceeded the baseline level. This indirectly proves that the main reason for the performance degradation was not the model implementation error, but the mismatch between the graph propagation mechanism itself and the data conditions.
[0117] Building upon this foundation, the introduction of weak graph residual propagation significantly improved model performance once again. Taking ε=0.1 as an example, the model achieved excellent results on the test set with micro-F1≈0.98 and macro-F1≈0.98, maintaining a good balance between precision and recall. This result demonstrates that the weak graph mechanism can introduce a small amount of beneficial structural information without destroying the semantic prototype of the labels, thereby achieving a stable enhancement of the baseline model.
[0118] This invention employs multiple evaluation metrics to comprehensively assess model performance, including loss, micro-F1, macro-F1, micro-precision, and micro-recall. Micro-F1 reflects the model's overall performance in predicting the total label, while macro-F1 emphasizes the model's fairness to a minority of labels. Combining these two metrics provides a more comprehensive characterization of the performance of multi-label classification models under limited sample conditions.
[0119] Experimental results show that the weak graph matching model proposed in this embodiment outperforms the baseline model and the strong graph model on all core metrics, especially the improvement on macro-F1, indicating that the algorithm has significant advantages in alleviating label imbalance and long-tail problems.
[0120] From an application perspective, the method proposed in this invention is highly suitable for deployment in actual software requirements analysis processes. Since the model requires only a small number of labeled samples during the training phase, and the semantic and structural information of the labels can be continuously supplemented by external knowledge, it exhibits good scalability when migrating to new projects or new domains.
[0121] In practical engineering applications, this method can be used for multiple stages such as automatic requirement classification, requirement consistency checking, requirement conflict analysis, and requirement traceability matrix construction, significantly reducing the cost of manual analysis. A representative application case is the automatic analysis and classification of software requirements for large-scale government and enterprise information systems. In actual engineering, requirements typically originate from natural language descriptions, such as functional and quality demands raised by business personnel, product managers, or external users in a conversational and unstructured manner. These requirement texts often have loose semantic expressions, high sample annotation costs, and the same requirement may simultaneously involve functional requirements and multiple non-functional requirement attributes, such as performance, security, or maintainability requirements, typically exhibiting characteristics of few samples, multiple labels, and correlations and exclusions between labels. To address this issue, the method proposed in this paper fully utilizes the semantic information of labels through a matching classification head, maintaining strong generalization ability even with very few labeled samples. Simultaneously, a weak graph residual label propagation mechanism is introduced to integrate domain expert knowledge and structural priors between labels into the model in a controllable manner, thereby avoiding the oversmoothing risk caused by strong graph propagation. In practical applications, this method can be used to automatically tag and structure massive amounts of requirement documents, providing intelligent assistance for requirement review, architecture design, and quality attribute analysis. It significantly reduces the cost of manual analysis and improves the accuracy and consistency of requirement management, demonstrating good engineering implementation value and promising prospects for promotion.
[0122] like Figure 2 As shown, in another preferred embodiment of the present invention, a label enhancement system for classification with few samples and multiple labels is also provided to implement the above method, specifically including:
[0123] The text encoding module 10 is used to acquire the requirement text and encode the requirement text using the pre-trained language model BERT to obtain the requirement text semantic vector.
[0124] The label encoding module 20 is used to obtain multiple predefined demand category labels and their corresponding description texts, and to encode the description text of each demand category label using the pre-trained language model BERT to obtain a label semantic matrix.
[0125] The label enhancement module 30 is used to construct a label graph based on the label semantic matrix and prior grouping knowledge, and to perform graph neural network propagation on the initial label semantic vectors in the label semantic matrix to obtain the enhanced label semantic vectors.
[0126] The matching and classification module 40 is used to match the semantic vector of the requirement text with the enhanced semantic vector of the label to obtain a multi-label classification result.
[0127] It should be noted that each of the above modules can be implemented as a computer program, which can run on a computer device. The computer device's memory can store the computer program consisting of each module, enabling the processor to execute each step of the above method.
[0128] It should be understood that although the steps in the flowcharts of the embodiments of the present invention are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in each embodiment may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.
[0129] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods.
[0130] The above embodiments merely illustrate several implementation methods of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this patent should be determined by the appended claims.
Claims
1. A label enhancement method for classification with few samples and multiple labels, characterized in that, Includes the following steps: Obtain the requirement text and encode the requirement text using the pre-trained language model BERT to obtain the requirement text semantic vector; Obtain multiple predefined demand category labels and their corresponding descriptive texts, and use the pre-trained language model BERT to encode the descriptive text of each demand category label to obtain a label semantic matrix; Based on the label semantic matrix and prior grouping knowledge, a label graph is constructed, and the initial label semantic vectors in the label semantic matrix are propagated through a graph neural network to obtain enhanced label semantic vectors. The semantic vector of the required text is matched with the enhanced semantic vector of the label to obtain the multi-label classification result.
2. The label enhancement method for classification with few samples and multiple labels according to claim 1, characterized in that, The steps of obtaining the requirement text and encoding it using the pre-trained language model BERT to obtain the semantic vector of the requirement text specifically include: Input the requirement text x, which is first segmented and encoded to obtain the token sequence: ; The hidden layer representation H is then obtained by inputting it into the BERT encoder: ; Where n is the length of the token sequence; d is the hidden dimension; BERT(·) is the output of the BERT encoder; use The representation of h as the semantic vector of the demand text x : 。 3. The label enhancement method for classification with few samples and multiple labels according to claim 2, characterized in that, The steps of obtaining multiple predefined demand category labels and their corresponding descriptive texts, and encoding the descriptive text of each demand category label using the pre-trained language model BERT to obtain a label semantic matrix, specifically include: For the i-th requirement category label, its description text is y. i The corresponding label semantic vector Defined as: ; Then the label semantic matrix E y for: ; Where L represents the total number of demand category labels.
4. The label enhancement method for classification with few samples and multiple labels according to claim 1, characterized in that, The construction of the label graph specifically includes: Based on the aforementioned label semantic matrix, the cosine similarity between any two demand category labels is calculated, and the k most similar demand category labels are selected for each demand category label to construct a semantic similarity graph A. sim ; Based on prior grouping knowledge in the field of requirements engineering, requirement category labels are divided into two main categories: functional requirement labels and non-functional requirement labels, and an intra-group prior graph A is constructed. group ; Artificial semantic edges are introduced, and prior connection weights are assigned to label pairs with explicit associations based on domain expert knowledge, thus constructing an artificial semantic adjacency matrix A. manual ; The semantic similarity graph, within-group prior graph, and artificial semantic adjacency matrix are weighted and fused, and then subjected to standard symmetric normalization and self-loop enhancement to obtain the final label graph adjacency matrix A. norm .
5. The label enhancement method for classification with few samples and multiple labels according to claim 4, characterized in that, The graph neural network propagation adopts a weak graph residual propagation mechanism, and its propagation formula is as follows: ; Where E is the initial label embedding, i.e. the initial label semantic vector; This is the embedded label after propagation, i.e., the enhanced label semantic vector; The graph shows the propagation intensity coefficient.
6. The label enhancement method for classification with few samples and multiple labels according to claim 1, characterized in that, The step of matching the semantic vector of the demand text with the enhanced semantic vector of the label to obtain the multi-label classification result specifically includes: Calculate the cosine similarity between the semantic vector of the demand text and the semantic vector of the enhanced tag, and introduce a learnable temperature parameter to obtain the matching score of each demand category tag; The matching score is converted into a probability value by an activation function, and the predicted probability of each demand category label is obtained as the multi-label classification result.
7. A label enhancement system for classification with few samples and multiple labels, used to implement the label enhancement method for classification with few samples and multiple labels as described in any one of claims 1-6, characterized in that, include: The text encoding module is used to acquire the requirement text and encode the requirement text using the pre-trained language model BERT to obtain the requirement text semantic vector. The label encoding module is used to obtain multiple predefined demand category labels and their corresponding descriptive texts, and to encode the descriptive text of each demand category label using the pre-trained language model BERT to obtain a label semantic matrix; The label enhancement module is used to construct a label graph based on the label semantic matrix and prior grouping knowledge, and to perform graph neural network propagation on the initial label semantic vectors in the label semantic matrix to obtain the enhanced label semantic vectors. The matching and classification module is used to match the semantic vector of the required text with the enhanced semantic vector of the label to obtain a multi-label classification result.