A continuous learning relation extraction method based on hypernetwork

By introducing hypernetwork and continuous learning mechanisms into the relationship extraction model, a specific projection head is generated for each new task, and through mixed data augmentation and multi-task replay mechanisms, the catastrophic forgetting problem that traditional models are prone to occur in continuous learning scenarios is solved, improving the accuracy of relationship extraction and the robustness of the model.

CN119539067BActive Publication Date: 2025-04-11XIAMEN UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510102277.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-04-11
Estimated Expiration
2045-01-22

AI Technical Summary

Technical Problem

When facing continuous learning scenarios, traditional relationship extraction models are prone to catastrophic forgetting problems and are not effective when dealing with continuous relationships. When the model has a relationship similar to the old task in the new task, the classification accuracy will significantly decrease.

Method used

Using a hypernetwork-based continuous learning relationship extraction method, a specific projection head is generated for each new task by introducing hypernetwork and continuous learning mechanisms, and through a hybrid data augmentation and multi-task replay mechanism, the conflict between similar relationships in the model representation space is reduced, and the robustness of the model is enhanced.

Benefits of technology

It effectively reduces conflicts between similar relationships in the model representation space, improves the accuracy of relationship extraction, ensures that the model maintains accurate classification of old tasks while learning new tasks, and achieves true continuous learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119539067B_ABST
    Figure CN119539067B_ABST
Patent Text Reader

Abstract

A method for continuous learning relation extraction based on a hypernetwork, involving the fields of natural language processing and machine learning. The model contains a sample encoder, a network generator based on a hypernetwork, and a task-specific projection head; the sample encoder is used to obtain the embedding representation of each instance; the network generator generates a specific projection head for the current task, and the projection head is used to perform the classification of the specific task. In order to reduce the conflict between similar relations in the model representation space, a specific projection head is created. For a new task, a series of task-specific embeddings are initialized. These embeddings are input into the network generator to create a dedicated projection head for the current task relation classification. Each task has its own specific representation space. The conflict of similar relations in the model representation space is effectively reduced. In the process of training the model, new task training, sample selection and multi-task replay are adopted, and the catastrophic forgetting problem is effectively alleviated through strategies such as cross-task loss and contrastive learning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of natural language processing and machine learning, and in particular to a continuous learning relation extraction method based on a hypernetwork and based on hybrid data enhancement and a hypernetwork for solving the catastrophic forgetting problem and model robustness improvement problem in continuous relation extraction tasks. Background Art

[0002] In the field of machine learning, especially relation extraction tasks in natural language processing, it is often necessary to deal with new tasks and new data that are constantly emerging. Relation Extraction (RE) aims to detect the semantic relationship between two given entities in a text, and plays a key role in many downstream natural language processing tasks including question-answering systems and information retrieval. Traditional RE methods assume that all relations are encountered in one training, but in reality, new relations will continue to appear. Traditional relation extraction models face many challenges when facing continuous learning scenarios. When a new task arrives, the model often forgets the old tasks it has learned before while learning the new task, which is a catastrophic forgetting problem.

[0003] In traditional scenarios, continuous relation extraction (CRE) is formulated as a class-incremental problem, which requires the model to sequentially learn a series of tasks involving new relations. At the same time, it is hoped that the CRE model can maintain accurate classification of old tasks while learning new tasks. Specifically, in the context of CRE, the model needs to sequentially learn a series of tasks, expressed as , each task Represents a traditional relation extraction task, formalized as a triple ,in Represents a set of relationship tags, is the original dataset of the kth task, is the k-th task test set. The k-th task original data set With the k-th task test set Each instance in is represented as ,in In the kth task After training, the model needs to be tested on all the seen test sets The main goal of CRE is to solve the problem of catastrophic forgetting, which refers to the phenomenon that the model forgets the knowledge related to the old tasks in the process of learning new tasks.

[0004] Existing studies use store and replay strategies to address the catastrophic forgetting problem. Specifically, they select representative samples from old tasks and store these samples in external memory. After learning the new task, the model retrains the model using the samples stored in the memory module. However, since the stored typical samples only represent a small part of the original training set, the replay process is prone to overfitting. In addition, some recent studies not only focus on the overfitting problem, but also find that when a relationship similar to that in the old task appears in the new task, the classification accuracy of the old task relationship will drop significantly. In order to better distinguish similar relationships, existing works have improved the robustness of the model by data augmentation at the discrete text level. However, this discrete data augmentation provides limited diversity, which limits the improvement of model robustness. More importantly, existing methods use the same model parameters throughout the continuous learning process. This approach significantly increases the risk of conflict between similar relationships in the unified representation space, making catastrophic forgetting more likely to occur.

[0005] How to make the model better adapt to the data distribution of new tasks while maintaining the ability to accurately distinguish similar relationships is an urgent problem to be solved. Summary of the invention

[0006] The purpose of the present invention is to provide a hypernetwork-based continuous learning relationship extraction method to address the problem that traditional relationship extraction methods are seriously interfered by similar relationships, resulting in poor performance of the model when processing continuous relationships. The method introduces the hypernetwork and continuous learning mechanisms to reduce conflicts between similar relationships in the model representation space, which helps the model to more accurately distinguish different relationship types and improve the accuracy of relationship extraction.

[0007] In order to achieve the above-mentioned object of the invention, the present invention provides the following technical solutions.

[0008] A hypernetwork-based continuous learning relationship extraction method, the model includes: a sample encoder, a hypernetwork-based network generator HNG and a task-specific projection head; the sample encoder is used to obtain the embedding representation of each instance; the network generator HNG generates a specific projection head for the current task; the projection head is used to perform classification of the specific task.

[0009] The method comprises the following steps:

[0010] 1) Model initialization and input processing: As the front-end part of the model, BERT is used as a sample encoder to encode the input sample. The semantic embedding of the sample is calculated through the hidden representation of the starting position of the head and tail entities in the sample and the trainable parameters. The sample encoder captures the semantic information of the sample and represents it as an embedding vector. BERT is a powerful pre-trained language model that can deeply encode the semantic information of the sample when processing the input sample.

[0011] 2) Hypernetwork generates specific projection heads: For each new task, a series of task-specific embeddings are initialized and input into a network generator HNG consisting of four two-layer neural network hypernetworks; the network generator HNG consists of multiple specific hypernetworks and is able to generate a specific projection head for each task; the projection head is used to project the sample embedding into a task-specific representation space to perform classification for that specific task;

[0012] 3) New task training: When a new task appears, a negative sample set is generated through discrete-negative data augmentation. A network generator HNG is used to create a specific projection head for the new task. The original data and the augmented dataset are mixed to form a new mixed data augmented training set. The mixed data augmented dataset is used to train the projection head of the new task. The encoder is used to encode the training set samples. The encoded relational representation is subjected to continuous-negative data augmentation. Contrastive learning is performed on the augmented feature representation. The contrastive loss is calculated. The model is optimized by maximizing the similarity between samples of the same type and minimizing the similarity between samples of different types.

[0013] 4) Typical sample selection: After training the new task, the samples are re-encoded using the trained encoder and projection head, and the K-means clustering method is used to cluster each type of data for the new task. The samples closest to each cluster center are selected as typical samples and stored in the memory bank.

[0014] 5) Multi-task replay: replay the samples stored in the memory bank and review all the samples in the memory bank, including generating new samples using discrete-forward data augmentation, encoding enhanced samples with task projection head, representing mixed sample features into a new training set and performing continuous-forward data augmentation, introducing a cross-task loss strategy, and calculating multi-task loss; ensure that the knowledge of new and old tasks supports each other through contrastive learning to reduce forgetting of old task knowledge;

[0015] 6) Model inference: Use the nearest class mean-based method for prediction, calculate the prototype of each relationship class, project the test sample into the corresponding relationship space, and compare it with the pre-calculated prototypes of each relationship class. By calculating the similarity between the test sample and each relationship prototype, assign the test sample to the relationship class that is most similar to it.

[0016] In step 1), the sample encoding uses BERT as the sample encoder. For a given sample As input, the given sample The starting and ending positions of the head entity are represented as , given sample The position of the middle tail entity is represented by For a given sample After word segmentation, the given sample The starting position of the head entity (the subject in the sentence) and samples The starting position of the middle tail entity The hidden representation of is used to calculate the current given sample Semantic embedding of

[0017] (1)

[0018] in, Represents a given sample After BERT, semantic embedding and Respectively represent the samples corresponding to the given The starting position of the middle head entity And the given sample The starting position of the middle tail entity Hidden representation of ; and All parameters are randomly generated and trainable.

[0019] In step 2), the hypernetwork generates a specific projection head, and the specific steps include:

[0020] After obtaining the sample embeddings, four k-th task-specific embeddings , , and are randomly initialized with trainable parameters and are subsequently fed into the network generator HNG, which consists of four specific hypernetworks:

[0021] (2)

[0022] (3)

[0023] (4)

[0024] (5)

[0025] in, , , and These are the four super networks in the network generator HNG, and each consists of a two-layer neural network; , , and are four k-th task-specific embeddings that are randomly initialized and trainable, HyperNetwork Output, for Output, for , for Output; Next, the output of these four hypernetworks is used as the projection head for the kth task Parameters for the kth task Build a specific projection head; then, the projection head of the kth task Used to obtain a given sample The relationship is expressed as:

[0026] (6)

[0027] in, For a given sample Semantic embedding after BERT; is the projection head of the kth task; is a given sample The relationship between the two is expressed by comparing the given samples The relationship between The distance between each relation prototype is used to complete the classification.

[0028] In step 3), the new task training may include the following specific steps:

[0029] When the kth task When it appears, the original dataset of the kth task is first expanded by discrete-negative data augmentation Get the kth task enhanced dataset , and use the network generator HNG with the task embedding to create a projection head for the kth task ; Use the encoder to encode the training set samples, generate embedded representations and store them in the embedding library Middle; Augment the dataset from the kth task Select a batch of samples and calculate their representation, and then extract them from the embedding library Select more samples from the task subspace and map them to the task subspace; finally, perform continuous negative data enhancement on the samples, generate negative samples and merge them with positive samples, and calculate the contrast loss ;

[0030] (7)

[0031] in, Indicates a negative sign, Represents the current training set batch relationship representation The i-th element, Represents the current embedding library batch relationship representation The jth element in c Indicates that the current training set batch relationship is traversed in sequence and the current embedding library batch relationship representation And add up the results; and Relational representation and relationship representation Labels; is the indicator function, when the label and The value is 1 if they are equal, otherwise it is 0; represents the logarithmic function with base 2; Indicates The exponential function with base ; “·” represents the dot product operation; Indicates traversing the current embedding library batch relationship representation Those tags do not belong to The relationship between them is expressed and the results are accumulated; in order to maintain the embedded library Updated with batches after each training step Refresh the newly generated representation.

[0032] In step 4), the specific steps of selecting typical samples include:

[0033] After the new task training phase is completed, Select typical samples from the training data and store them in the memory bank Specifically, we use the trained encoder and the projection head of the kth task Recode each sample, group the samples using K-Means clustering, and then select the sample closest to each cluster center as the kth task Representative samples of .

[0034] In step 5), the multitasking is replayed using the data stored in the memory bank. Retrain the model with all samples in order to prevent the model from forgetting the knowledge of old tasks. Since there are multiple representation spaces, comparative learning needs to be performed in each representation space. The specific steps include:

[0035] Step 5.1: Discrete-Forward Data Augmentation: Store in memory The sample set data in the discrete-forward data augmentation; this usually involves a slight transformation of the sample, such as fine-tuning the color, brightness, etc., because the memory library The samples in the training set only account for a small part of the original training set. Positive data augmentation can alleviate the overfitting problem in the training process; it can generate new samples that are similar to but slightly different from the original samples.

[0036] The discrete-positive data augmentation generates a new sample of the same relation by merging two different samples from the same relation. Specifically, for any relation The Samples and Samples , using the relationship The Samples The head entity (subject in the sample) and the tail entity (object in the sample) replacement relationship The Samples The head entity (subject in the sample) and the tail entity (object in the sample) in the relationship Generate a new positive sample .

[0037] Step 5.2: Encoder and Projection Head Application: Encode the augmented samples using the specific projection head corresponding to each task to obtain their feature representation in the relational representation space.

[0038] Step 5.3: Mixed dataset and contrastive learning: Mix the enhanced sample feature representations of all tasks into a new training set; perform continuous-positive data augmentation on this mixed training set to further increase the number of positive samples in the continuous semantic space, such as adding slight Gaussian noise or performing feature smoothing; perform contrastive learning on the enhanced feature representation to consolidate the knowledge of new and old tasks.

[0039] Step 5.4: Multi-task loss optimization: Introduce a cross-task loss strategy to optimize the model, minimize the knowledge forgotten between new and old tasks, and improve the generalization ability of the model on new tasks;

[0040] After calculating the contrast loss for all tasks separately, these losses are averaged to obtain the multi-task loss :

[0041] (8)

[0042] Among them, the fraction are the number of tasks that have been learned so far, is the contrastive loss computed using each task-specific projection head, is the multi-task loss.

[0043] In step 6), the specific steps of the model inference include:

[0044] Step 6.1: Relationship class prototype calculation: Generate relationship class prototypes using the task-specific projection head; these prototypes are representative feature representations of each category and are used to compare with test samples during the testing phase;

[0045] Step 6.2: Test sample projection: Project the test sample into the same relational representation space through the encoder and the projection head of the current task to obtain its feature representation;

[0046] Step 6.3: Similarity calculation and classification: Calculate the similarity between the test sample feature representation and each relationship class prototype, such as Euclidean distance, cosine similarity, etc.; assign the test sample to the relationship class that is most similar to it to complete the classification task; specifically, according to the similarity with the test sample The most similar prototype is assigned a class label:

[0047] (9)

[0048] in, Represents the test sample The corresponding classification results; Functions represent collections The subscript corresponding to the minimum value in ; Representing a collection The cth element in ; The table represents the th element in the set; ; is the number of relation categories contained in each task; Indicates the number of tasks that have been learned so far; Representing relationships ; It's a relationship Corresponding specific projection head; It is a test sample Embedded representation of ; It's a memory bank China Relations The average value of all relations represented.

[0049] A hypernetwork-based continuous learning relationship extraction system, including the following modules:

[0050] The sample encoding module is used to encode the input sample into a semantic embedding vector through BERT to provide semantic information for subsequent processing;

[0051] The hypernetwork projection head generation module is used to generate a specific projection head for each new task, projecting the sample embedding into a task-specific representation space to assist classification;

[0052] New task training module, used to perform data augmentation, encoding and contrastive learning for new tasks, and to train and optimize models;

[0053] Typical sample selection module, used to select typical samples from new task data and store them in the memory bank to provide support for subsequent replay;

[0054] Multi-task replay module, which is used to replay memory bank samples, consolidate knowledge through data augmentation and contrastive learning, and optimize cross-task performance;

[0055] The model inference module is used to generate relationship class prototypes, project and classify test samples, and complete the relationship extraction task.

[0056] An electronic device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned method for continuous learning relationship extraction based on a hypernetwork when executing the computer program.

[0057] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for extracting continuous learning relationships based on a hypernetwork is implemented.

[0058] Compared with the prior art, the advantages and outstanding technical effects of the present invention are:

[0059] 1. In order to reduce the conflict between similar relations in the model representation space, the present invention introduces a hypernetwork-based network generator (HNG) to create a specific projection head for each task. For a new task, a series of task-specific embeddings are initialized. These embeddings are input into the network generator to create a dedicated projection head for the current task relationship classification. Each task has its own specific representation space. Effectively isolate the influence of different tasks in the model representation space, reduce the conflict of similar relations in the model representation space, and significantly reduce the problem of catastrophic forgetting. Use the memory module to store typical samples, and revisit these samples in the multi-task replay phase to further consolidate the memory of old task knowledge.

[0060] 2. In order to further enhance the robustness of the model and better distinguish similar relationships, the present invention introduces a hybrid data enhancement method. Through the hybrid data enhancement method, data enhancement is performed in discrete text space and continuous semantic space respectively to generate positive and negative samples, thereby improving the model's ability to distinguish similar relationships. Discrete data enhancement increases the model's ability to handle text diversity, while continuous data enhancement enhances the model's generalization ability at the semantic level.

[0061] 3. The model structure and method proposed in this invention can sequentially learn a series of tasks and maintain accurate classification of old tasks while learning new tasks, thus achieving true continuous learning. Through multi-task training strategy, the knowledge consistency between new and old tasks is ensured, thus improving the continuous learning ability of the model.

[0062] 4. The present invention adopts a prediction method based on the nearest class mean, and performs classification by calculating the similarity between the test sample and the relationship class prototype, thereby improving the efficiency and accuracy of the model in the reasoning stage.

[0063] 5. The present invention realizes effective processing of continuous relation extraction tasks by combining hypernetwork, hybrid data enhancement and multi-task learning strategies. Semantic information is obtained through sample encoding, specific projection heads are generated by hypernetwork for task-specific representation learning, the generalization ability of the model is improved through hybrid data enhancement, and knowledge forgetting is reduced through multi-task replay and cross-task loss strategies. Finally, accurate classification of test samples is achieved through model inference and classification steps.

[0064] 6. The present invention has achieved excellent performance on multiple data sets, proving the effectiveness of the present invention in practical applications. The present invention can be widely used in scenarios related to natural language processing and information retrieval. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 It is a schematic diagram of the overall framework flow.

[0066] Figure 2 This is an example of the training process for a new task.

[0067] Figure 3 is an example of a sample selection process.

[0068] Figure 4 This is an example of the process flow of the multi-task replay learning process.

[0069] Figure 5 This is an example of the model inference process. DETAILED DESCRIPTION

[0070] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the following embodiments will further illustrate the present invention in conjunction with the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. On the contrary, the present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention as defined by the claims.

[0071] The embodiment of the present invention aims to solve the balance problem between training new tasks and forgetting old tasks in continuous learning, by introducing a variety of data enhancement techniques, task-specific projection head generation, effective sample selection strategies and multi-task replay mechanisms, to ensure that the model maintains high generalization ability and robustness in the process of continuous learning. In the new task training stage, the goal of the present invention is to learn new tasks. In the sample selection stage, the present invention selects representative samples from the current task. In the multi-task playback stage, the goal of the present invention is to retrain the model using samples from M.

[0072] 1. Model Structure

[0073] The model consists of three key components: a sample encoder, a hypernetwork-based network generator (HNG), and a task-specific projection head. The sample encoder is used to obtain an embedding representation for each instance. Subsequently, the network generator HNG generates a specific projection head for the current task, which is then used to perform classification for that specific task.

[0074] 1.1 Use BERT as the sample encoder. For a given sample As input, the given sample The starting and ending positions of the head entity are represented as , given sample The position of the middle tail entity is represented by For a given sample After word segmentation, the given sample The starting position of the head entity (the subject in the sentence) and samples The starting position of the middle tail entity The hidden representation of is used to calculate the current given sample Semantic embedding of

[0075] (1)

[0076] in, Represents a given sample After BERT, semantic embedding and Respectively represent the samples corresponding to the given The starting position of the middle head entity And the given sample The starting position of the middle tail entity Hidden representation of ; and All parameters are randomly generated and trainable.

[0077] 1.2 Supernet-based Network Generator with Task-Specific Projection Head: After obtaining sample embeddings, four k-th task-specific embeddings , , and are randomly initialized with trainable parameters and are subsequently fed into the network generator HNG, which consists of four specific hypernetworks:

[0078] (2)

[0079] (3)

[0080] (4)

[0081] (5)

[0082] in, , , and These are the four super networks in the network generator HNG, and each consists of a two-layer neural network; , , and are four k-th task-specific embeddings that are randomly initialized and trainable, HyperNetwork Output, for Output, for , for Output; Next, the output of these four hypernetworks is used as the projection head for the kth task Parameters for the kth task Build a specific projection head; then, the projection head of the kth task Used to obtain a given sample The relationship is expressed as:

[0083] (6)

[0084] in, For a given sample Semantic embedding after BERT; is the projection head of the kth task; is a given sample The relationship between the two is expressed by comparing the given samples The relationship between The distance between each relation prototype is used to complete the classification.

[0085] 2. Hybrid Data Augmentation

[0086] In order to further enhance the robustness of the model in distinguishing similar relations, a hybrid data augmentation method is introduced, which performs data augmentation in both discrete text space and continuous semantic space. At the same time, data augmentation is performed from two directions: one for generating positive examples and the other for generating negative examples. Therefore, the hybrid data augmentation method includes four augmentation strategies, namely discrete-positive data augmentation, discrete-negative data augmentation, continuous-positive data augmentation, and continuous-negative data augmentation.

[0087] Discrete-Negative Data Augmentation: By combining samples from two different relations, diverse negative samples (NOTA, meaning "not any of the above") are constructed. Specifically, for the relation Middle Samples , another relationship Middle Samples , using the relationship Middle Samples The head entity and tail entity replacement relationship Middle Samples The head entity and the tail entity in , thereby generating a new negative sample , new negative samples The label is set to NOTA.

[0088] Continuous-Negative Data Augmentation: Continuous-Negative Data Augmentation: Perform data augmentation in the semantic space to further enhance the diversity of negative samples. Specifically, for any relation Middle The relationship between samples , with another relationship Middle The relationship between samples , perform an average operation on these two relationship representations to obtain a new negative relationship representation , this averaging operation ensures that the generated negative samples are sufficiently far from the original samples: ;in, It's a relationship Middle The relationship between samples is represented by It's a relationship Middle The relationship between samples is expressed as follows: It is a new negative relationship representation.

[0089] Discrete-positive data augmentation: Generate new samples of the same relation by merging two different samples from the same relation. Specifically, for any relation The Samples and Samples , using the relationship The Samples The head entity (subject in the sample) and the tail entity (object in the sample) replacement relationship The Samples The head entity (subject in the sample) and the tail entity (object in the sample) in the relationship Generate a new positive sample .

[0090] Continuous-Positive Data Augmentation: Aims to generate more diverse positive samples. Specifically, for any relationship , where the relationship Middle Samples and, Samples By mixing the relational representations of two different samples after passing through the encoder, a new positive relational representation is generated : ;in, and It's a relationship Middle Samples and The relationship between samples is represented by From a uniform distribution The mixing coefficients sampled in , New positive relationship representation; continuous-positive data augmentation adds randomness to the generation process, thereby further enhancing the diversity of samples.

[0091] 3. Model training

[0092] like Figure 1 As shown in the figure, the overall framework of the present invention includes three main steps: new task training, sample selection and multi-task replay. The goal of new task training is to learn new tasks; sample selection mainly involves selecting a small number of typical samples and storing them in the memory bank. Medium; Multi-task replay is designed to review memory bank The model first learns the new task, then selects representative samples from the current task and stores them in the memory bank. , and finally the stored samples in all tasks are used to retrain the model.

[0093] 3.1 New task training and typical sample selection

[0094] First, the new task training set is enhanced with discrete-negative data to increase the number of data sets. Then, all samples are encoded by the encoder and stored in the front-end library. At the same time, the task embedding and network generator are used to generate the current task-specific projection head. Finally, the relation representation is enhanced with continuous-negative data for contrastive learning.

[0095] 3.1.1 New Task Training: When a new task appears, a set of negative samples is generated through discrete-negative data augmentation, and a specific projection head is created for the new task. Then, the original data and the augmented dataset are mixed to form a new training set to support the training of the new task.

[0096] (1) New task reception and data preparation: When a new task is received, the original training dataset of the task is first obtained.

[0097] (2) Discrete-negative data augmentation: Discrete-negative data augmentation is performed on the original training dataset of the new task. This usually involves transforming the original samples, such as rotating, scaling, flipping, etc., to generate negative samples that are different from the original samples but have similar characteristics. These negative samples are used to increase the diversity and quantity of the dataset, which helps the model better learn the characteristics of the new task.

[0098] (3) Encoder and projection head generation: A pre-trained encoder is used to encode all samples and convert the original data into a high-dimensional feature representation. At the same time, a specific projection head is generated for the new task using task embedding and network generator. This projection head is used to map the encoded features into a relational representation space that is more suitable for the current task.

[0099] (4) Mixed dataset and training: The original data and the enhanced dataset are mixed to form a new training set. The model is trained using this mixed training set to support learning of new tasks.

[0100] (5) Continuous-negative data augmentation and contrastive learning: During the training process, continuous-negative data augmentation is performed on the encoded relational representation, such as adding noise, fine-tuning features, etc. Then, contrastive learning is performed on the enhanced feature representation to optimize the model by maximizing the similarity between samples of the same type and minimizing the similarity between samples of different types.

[0101] like Figure 2 As shown, when the kth task When it appears, the original dataset of the kth task is first enhanced by discrete-negative data Enhance to get the kth task enhanced data set . The four k-th task-specific embeddings are then , , and Input to the network generator HNG to generate the projection head for the kth task . Then from the embedding library and the kth task augmented dataset Select a part of the data to get the relationship representation, then use continuous-negative data enhancement, and finally compare the loss . Figure 2 In the example, label ① represents the discrete-negative data enhancement module; label ② represents the continuous-negative data enhancement and contrastive learning module; label ③ represents the embedding library .

[0102] When the kth task When it appears, the initial step consists of augmenting the original dataset of the kth task by discrete-negative data Enhance to get the kth task enhanced data set And generate the projection head of the kth task ; Next, use the encoder to encode all samples in the training set, generate semantic embeddings for the samples, and store these semantic embeddings in the embedding library This process does not involve gradient calculation and is embedded in the library will be removed after training; then, the dataset is augmented from the kth task Take a batch of samples ,in, , , Represent the first, second and samples; and use formula (1) to obtain the current training set batch representation ,in, , , Respectively represent the first sample, the second sample and the The relationship between samples; at the same time, from the embedding library Sampling a larger batch ,in, , , Respectively represent the first sample, the second sample and the The semantic embedding of samples is obtained, and these samples are mapped to the specific subspace of the current task through formula (6), and the batch relation representation of the current embedding library is obtained. ,in , , Respectively represent the first sample, the second sample and the The relationship between samples; the relationship between the current training set batch and the current embedding library batch relationship representation Apply continuous negative sample data augmentation to generate negative samples and integrate them into the current training set batch relation representation and the current embedding library batch relationship representation are enhanced respectively; finally, the contrast loss is calculated , the formula is as follows:

[0103] (7)

[0104] in, Indicates a negative sign, Represents the current training set batch relationship representation The i-th element, Represents the current embedding library batch relationship representation The jth element in is Indicates that the current training set batch relationship is traversed in sequence and the current embedding library batch relationship representation And add up the results; and Relational representation and relationship representation Labels; is the indicator function, when the label and The value is 1 if they are equal, otherwise it is 0; represents the logarithmic function with base 2; Indicates The exponential function with base ; “·” represents the dot product operation; Indicates traversing the current embedding library batch relationship representation Those tags do not belong to In order to maintain the embedding library Updated with batches after each training step Refresh the newly generated representation.

[0105] 3.1.2 Sample selection

[0106] After encoding all the data of the current task based on the encoder and projection head, cluster each type of data of the new task using the K-means clustering method, and then select the sample closest to each cluster center and store it in the memory bank. These samples represent typical features in new tasks and can be used in subsequent task replay to reduce forgetting and enhance the model’s continuous learning ability.

[0107] The sample selection process can refer to Figure 3 The training process shown in Figure 3 After learning the kth task After that, four k-th task-specific embeddings , , and Input to the network generator HNG to generate the projection head for the kth task . The encoder is then used with the projection head of the kth task Get the original dataset of the kth task Then, the relationship representation is clustered using the K-means clustering method, and the samples closest to the sample center of each category are selected and stored in the memory library. middle.

[0108] (1) Projection head and encoder application: Use the projection head and encoder of the current task to encode the training set and obtain the feature representation of each sample.

[0109] (2) K-means clustering: K-means clustering is performed on the encoded feature representation. The clustering algorithm divides samples into different categories based on their similarities. The number of clusters is usually determined by the specific requirements of the task or prior knowledge.

[0110] (3) Typical sample selection: Select the samples closest to the cluster center from each cluster as typical samples. These samples represent the key features in the kth task and are important resources for subsequent task replay.

[0111] (4) Sample storage: Store the selected typical samples in the memory bank This memory is used to save key samples in all tasks for use in subsequent task replay.

[0112] 3.2 Multi-task Training

[0113] To reduce the forgetting of old task knowledge, the system Specifically, the samples stored in the memory The sample set in is subjected to discrete-positive data augmentation to generate a new training set, which is encoded using a specific projection head corresponding to each task. Subsequently, continuous-positive data augmentation and comparative learning are performed in the relational representation space to ensure that the knowledge of new and old tasks can support each other, thereby improving the generalization ability of the model. In order to alleviate the overfitting problem caused by the limited number of samples, a hybrid data augmentation strategy is used in this embodiment to generate positive and negative samples. The system performs continuous-positive and discrete-positive data augmentation on the stored samples, and the generated samples are used as additional input data of the model to enhance the robustness of the model.

[0114] like Figure 4 As shown in the figure, multi-task replay is used to prevent the model from forgetting old tasks. First, all memory banks are The samples in are first discrete-forward data augmented to obtain an augmented memory bank , and then put it into the embedding library through the encoder In the embedding library here is recreated from scratch and is not the same as the new task learning phase, and then uses the four first task-specific embeddings , , and Input to the network generator HNG to generate the projection head for the first task , and so on, using four k-th task-specific embeddings , , and Input to the network generator HNG to generate the projection head for the kth task . Then use all generated projection heads to get the augmented memory The relationship representation of each sample in , then continuous-positive data enhancement is performed on these relationship representations, and finally the replay loss is calculated .

[0115] Step 3.2.1: Discrete-positive data augmentation: Perform discrete-positive data augmentation on the set of samples stored in the memory bank. This usually involves making slight transformations to the samples, such as fine-tuning color, brightness, etc., to generate new samples that are similar to the original samples but slightly different.

[0116] Step 3.2.2: Encoder and Projection Head Application: Encode the augmented samples using the specific projection head corresponding to each task to obtain their feature representation in the relational representation space.

[0117] Step 3.2.3: Mixed dataset and contrastive learning: Mix the enhanced sample feature representations of all tasks into a new training set. Then, perform continuous-forward data augmentation on this mixed training set, such as adding slight Gaussian noise or performing feature smoothing, to increase the diversity of the data. Finally, perform contrastive learning on the enhanced feature representation to consolidate the knowledge of the new and old tasks; the goal of contrastive learning is to make the sample feature representations of the same task closer, while the sample feature representations of different tasks farther apart.

[0118] Step 3.2.4: Multi-task loss optimization: During the multi-task replay process, a cross-task loss strategy is introduced to optimize the model. This strategy aims to minimize the knowledge forgetting between new and old tasks while improving the generalization ability of the model on new tasks.

[0119] Specifically, after learning the kth task Then, use the stored Retrain the model with all samples in the memory to prevent the model from forgetting the knowledge of old tasks. In addition, since there are multiple representation spaces, it is necessary to perform contrastive learning in each representation space. Specifically, the memory library is first enhanced using the discrete positive sample data enhancement method. Enhanced memory , because the memory The samples in only account for a small part of the original training set. Positive data augmentation can alleviate the overfitting problem during training. Then, the contrast loss in each task space is calculated. The difference is that here the continuous-positive data augmentation method is used to further increase the number of positive samples in the continuous semantic space. After calculating the contrast loss for all tasks separately, these losses are averaged to obtain the replay loss:

[0120] (8)

[0121] Among them, the fraction are the number of tasks that have been learned so far, is the contrastive loss computed using each task-specific projection head, is the multi-task loss.

[0122] This implementation method can refer to Figure 4 The replay process in , where label ④ represents the discrete-positive data enhancement module, and label ⑤ represents the continuous-positive data enhancement and contrastive learning module. Through this process, technicians can understand how to introduce a hybrid data enhancement strategy in multi-task replay to improve the generalization performance of the model on multiple tasks. Figure 4All samples in the memory bank are first subjected to discrete-positive data augmentation, and then put into the embedding bank through the encoder. Then, the task embeddings of all tasks are used with the network generator to generate multiple projection heads, and these projection heads are used to obtain relational representations. Finally, these relational representations are subjected to continuous-positive data augmentation and contrastive learning.

[0123] 4. Model Inference

[0124] In order to improve the classification accuracy of the model in continuous learning, a prediction method based on the nearest class mean is designed for prediction. The core of this method is to calculate the prototype (or class center) of each relationship class, which represents the central position of each relationship class in the feature space. The mean of the samples within the class is used as the representative of the class to simplify the classification decision process. In addition, since it is classified based on the position of the sample in the feature space, it is also robust to nonlinearly separable data sets.

[0125] like Figure 5 As shown, before testing begins, four first task-specific embeddings are used , , and Input to the network generator HNG to generate the projection head for the first task , and so on, using four k-th task-specific embeddings , , and Input to the network generator HNG to generate the projection head for the kth task ; Then use the above projection head to calculate the average of all samples of each relationship and store them. At the beginning of the test, the test sample , first use the encoder to obtain the test sample The embedding representation of , and then compares the similarity between it and the average value of all samples of each relationship. It should be noted that for any relationship , calculate the sample The relationship between the relationship c and all samples represents the average value When measuring the similarity between the two, we need to use the specific projection head corresponding to the relationship c. Calculate the relationship representation. Finally, according to the principle of highest similarity, assign it to the most similar class to achieve classification prediction.

[0126] Step 4.1: Relationship class prototype calculation: For each relationship class, a relationship class prototype is generated by using a specific projection head corresponding to the task for its training samples. These prototypes are a representative feature representation of each relationship class in the feature space, which are used to compare with the test samples in the testing phase.

[0127] Step 4.2: Test sample projection: Project the test sample into the same relational representation space as the training data through the encoder and the projection head of the current task, and pass the test sample through the same feature extraction process to obtain its representation in the feature space.

[0128] Step 4.3: Similarity calculation and classification: Calculate the similarity between the test sample feature representation and each pre-calculated relationship class prototype. The similarity can usually be obtained by calculating the Euclidean distance, cosine similarity and other indicators between them. Then, assign the test sample to the relationship class that is most similar to it, that is, the relationship class with the highest similarity or the smallest distance, to complete the classification task.

[0129] Specifically, by calculating the similarity between the test sample and each relation prototype, the test sample is assigned to the relation class that is most similar to it. More specifically, the prototype of each relation is first calculated. Subsequently, the test sample is projected into the same representation space as each prototype and compared with each prototype. Finally, according to the similarity with the test sample, The most similar prototype is assigned a class label:

[0130] (9)

[0131] in, Represents the test sample The corresponding classification results; Functions represent collections The subscript corresponding to the minimum value in ; Representing a collection The cth element in ; The table represents the th element in the set; ; is the number of relation categories contained in each task; Indicates the number of tasks that have been learned so far; Representing relationships ; It's a relationship Corresponding specific projection head; It is a test sample Embedded representation of ; It's a memory bank China Relations The average value of all relations represented.

[0132] The embodiments of the present invention solve the balance problem between training new tasks and forgetting old tasks according to the technical solution of the invention, and through different data enhancement methods and cross-task loss strategies, the model maintains high generalization ability and robustness in the continuous learning process. These specific implementation methods not only support the understanding and implementation of the claims, but also provide effective technical details to help those skilled in the art fully understand the innovation and scope of application of the present invention.

[0133] The present invention introduces a hypernetwork-based network generator (HNG) to create a specific projection head for each new task, thereby effectively distinguishing the relationship representations in different tasks and enhancing the model's adaptability to new tasks. The present invention uses a hybrid data enhancement strategy to perform data enhancement in discrete text space and continuous semantic space respectively to generate positive and negative samples to enrich training data. At the same time, multi-task replay is performed using representative samples stored in the memory module, combined with cross-task loss and knowledge distillation methods, to effectively alleviate the phenomenon that the model forgets the knowledge of old tasks when learning new tasks. The present invention introduces a hybrid data enhancement method. The present invention considers the similarity of relationships when generating positive and negative samples, and increases the robustness of the model in distinguishing similar relationships. In addition, contrastive learning is performed separately in each representation space to further enhance the model's perception of subtle differences. The present invention designs a prediction method based on the nearest class mean, which achieves more accurate classification by calculating the similarity between the test sample and the relationship class prototype, and improves the classification accuracy of the model in continuous learning.

[0134] In order to verify the performance of the continuous learning relation extraction method based on hybrid data augmentation and hypernetwork (Hy²CRE for short) in relation extraction tasks, especially in dealing with two challenging datasets: complex relation extraction (FewRel) and long-tail scene relation extraction (TACRED). By comparing with a series of benchmark methods, including CML, RP-CRE, EMAR+ACA, DAS, CD-CRE, RationaleCL, DP-CRE and CRL, the effectiveness and advancement of the Hy²CRE method are fully verified.

[0135] The task accuracy of each model on the FewRel dataset is shown in Table 1.

[0136] Table 1

[0137]

[0138] As can be seen from Table 1, on the FewRel dataset, the accuracy of Hy²CRE on all tasks is significantly higher than that of other compared benchmark methods. In particular, on task T1, the accuracy of Hy²CRE of the present invention is as high as 99.0%, showing its excellent performance in dealing with complex relation extraction tasks. As the number of tasks increases, although the accuracy of other models gradually decreases, Hy²CRE still maintains a relatively high accuracy, which shows that the present invention has strong generalization ability and robustness.

[0139] The task accuracy of each model on the TACRED dataset is shown in Table 2.

[0140] Table 2

[0141]

[0142] As can be seen from Table 2, Hy²CRE of the present invention also shows excellent performance on the TACRED dataset. Although the tasks of this dataset are relatively difficult, the accuracy of Hy²CRE on all tasks is higher than or close to the highest performance of other benchmark methods. In particular, on tasks T1 and T2, the accuracy of Hy²CRE is as high as 98.1% and 95.2%, respectively, which further proves the effectiveness of the method of the present invention in dealing with long-tail relationship extraction tasks. On other tasks, Hy²CRE also maintains a relatively high accuracy, indicating that the present invention can perform well in different scenarios.

[0143] In summary, the experimental results fully demonstrate the excellent performance and advancement of the Hy²CRE model in dealing with relation extraction tasks. Whether in the context of few-sample relation extraction or complex relation extraction, the present invention shows significantly better accuracy than other benchmark methods, providing strong support for its widespread promotion in practical applications.

[0144] CML [Wu et al., 2021]: Propose a curriculum meta-learning method to alleviate the order sensitivity and catastrophic forgetting problems in CRE.

[0145] RP-CRE [Cui et al., 2021]: Enhance model performance by optimizing sample embeddings.

[0146] EMAR+ACA [EMNLP 2022]: Leveraging adversarial category augmentation for more precise and robust representations.

[0147] DAS [ACL 2023]: Addressing the catastrophic forgetting problem of similarity relations using ensemble training and knowledge distillation.

[0148] CD-CRE [Xia et al., 2023]: Introduces a simple yet efficient classifier that encourages the model to learn more robust representations.

[0149] RationaleCL [Xiong et al., 2023]: Use a large-scale language model to improve the robustness of the model.

[0150] DP-CRE [Huang et al., 2024]: Manages model knowledge by analyzing embedding changes of new tasks to solve the overfitting problem during replay.

[0151] CRL [ACL 2022]: Preserving learned knowledge using contrastive learning and knowledge distillation.

[0152] The present invention provides an effective continuous learning solution for relationship extraction tasks in natural language processing through an innovative continuous learning relationship extraction method and device, as well as corresponding electronic devices and storage media, solves a series of problems faced by existing technologies in continuous learning scenarios, and has important application value and promotion prospects.

[0153] The above embodiments are only preferred embodiments of the present invention and cannot be considered to limit the scope of the present invention. All equivalent changes and improvements made within the scope of the present invention should still fall within the scope of the present invention.

Claims

1. A continuous learning relationship extraction method based on hypernetwork, characterized by The following steps are involved: 1) Model initialization and input processing: The front-end part of the model uses BERT as a sample encoder to encode the input sample. The semantic embedding of the sample is calculated through the hidden representation of the starting position of the head and tail entities in the sample and the trainable parameters. The sample encoder captures the semantic information of the sample and represents it as an embedding vector; 2) Hypernetwork generates specific projection heads: For each new task, a series of task-specific embeddings are initialized and input into a network generator HNG consisting of four two-layer neural network hypernetworks; the network generator HNG consists of multiple specific hypernetworks and is able to generate a specific projection head for each task; the projection head is used to project the sample embeddings into a task-specific representation space to perform classification for that specific task; The hypernetwork generates a specific projection head, and the specific steps include: After obtaining the sample embeddings, four k-th task-specific embeddings and are randomly initialized and are trainable parameters, and are then input to the network generator HNG, which consists of four specific hypernetworks: Among them, f hyper1 ,f hyper2 ,f hyper3 and f hyper4 These are the four super networks in the network generator HNG, and each consists of a two-layer neural network; and are four task-specific embeddings that are randomly initialized and trainable, For the hypernetwork hyper1 Output, f hyper3 Output, f hyper2 , f hyper4 Output; The output of these four hypernetworks is used as the projection head P of the kth task k The parameter of the kth task T k Construct a specific projection head; then, the projection head P of the kth task k Used to obtain the relational representation of a given sample x: z x = P k (h x ) (6) Among them, h x is the semantic embedding of a given sample x after BERT; P k is the projection head of the kth task; z x is the relational representation of a given sample x, by comparing the relational representation z of a given sample x k The distance to each relation prototype is used to complete the classification; 3) New task training: When a new task appears, a negative sample set is generated through discrete-negative data augmentation. A network generator HNG is used to create a specific projection head for the new task. The original data and the augmented dataset are mixed to form a new mixed data augmented training set. The mixed data augmented dataset is used to train the projection head of the new task. The encoder is used to encode the training set samples. The encoded relational representation is subjected to continuous-negative data augmentation. Contrastive learning is performed on the augmented feature representation. The contrastive loss is calculated. The model is optimized by maximizing the similarity between samples of the same type and minimizing the similarity between samples of different types. The specific steps of the new task training are as follows: When the kth task T k When it appears, the original dataset D of the kth task is first expanded by discrete-negative data augmentation k Get the kth task enhanced dataset D k ′, and use the network generator HNG and task embedding to create a projection head P for the kth task k ; Use the encoder to encode the training set samples, generate embedded representations and store them in the embedding library EB; Enhance the dataset D from the kth task k ′, and calculate its representation. At the same time, more samples are selected from the embedding library EB and mapped to the task subspace. Finally, the samples are continuously-negatively enhanced, negative samples are generated and merged with positive samples, and the contrast loss L is calculated. c ; Among them, - represents a negative sign, z i Indicates the current training set batch relationship represents the i-th element of Z, Represents the current embedding library batch relationship representation The jth element in Indicates traversing the current training set batch relationship representation Z and the current embedding library batch relationship representation in sequence And add up the results; y i and j They are the relational representations z i and relationship representation Label; I(y i =y j ) is the indicator function, when the label y i and j The value is 1 when they are equal, otherwise it is 0; log2 represents the logarithmic function with base 2; exp represents the exponential function with base e; "·" represents the dot product operation; Indicates traversing the current embedding library batch relationship representation Those tags do not belong to y i The relationship representation is generated by , and the results are accumulated; in order to keep the embedding library EB updated, it is refreshed with the newly generated representation in batch B after each training step; 4) Typical sample selection: After training the new task, the samples are re-encoded using the trained encoder and projection head, and each type of data for the new task is clustered using the K-means clustering method. The samples closest to each cluster center are selected as typical samples and stored in the memory bank. 5) Multi-task replay: replay the samples stored in the memory bank and review all the samples in the memory bank, including generating new samples using discrete-forward data augmentation, encoding enhanced samples with task projection head, representing mixed sample features into a new training set and performing continuous-forward data augmentation, introducing a cross-task loss strategy, and calculating multi-task loss; ensure that the knowledge of new and old tasks supports each other through contrastive learning to reduce forgetting of old task knowledge; 6) Model inference: Use the nearest class mean-based method for prediction, calculate the prototype of each relationship class, project the test sample into the corresponding relationship space, and compare it with the pre-calculated prototypes of each relationship class. By calculating the similarity between the test sample and each relationship prototype, assign the test sample to the relationship class that is most similar to it.

2. A method for extracting relations based on continuous learning of a hypernetwork as claimed in claim 1, characterized in that In step 1), the sample encoding uses BERT as a sample encoder; for a given sample x as input, the starting and ending positions of the head entity in the given sample x are represented as E11 and E12 respectively, and the position of the tail entity in the given sample x is represented as E21 and E22; after the given sample x is segmented, the hidden representations of the starting position E11 of the head entity in the given sample x and the starting position E21 of the tail entity in the given sample x are used to calculate the semantic embedding of the current given sample x; Among them, h x Represents the semantic embedding of a given sample x after BERT. and They respectively represent the hidden representations corresponding to the starting position E11 of the head entity in the given sample x and the starting position E21 of the tail entity in the given sample x; W and b are both randomly generated and trainable parameters.

3. A method for extracting relations based on continuous learning of a hypernetwork as claimed in claim 1, characterized in that In step 4), the specific steps of selecting typical samples include: After the new task training phase is completed, from the kth task T k Select typical samples from the training data and store them in the memory bank M; specifically, use the trained encoder and the projection head P of the kth task k Recode each sample, group the samples using K-Means clustering, and then select the sample closest to each cluster center as the kth task T k Representative samples of .

4. A method for extracting relations based on continuous learning of a hypernetwork as claimed in claim 1, characterized in that In step 5), the multi-task replay uses all samples stored in the memory bank M to retrain the model to prevent the model from forgetting the knowledge of old tasks. Since there are multiple representation spaces, comparative learning needs to be performed in each representation space. The specific steps include: Step 5.1: Discrete-positive data enhancement: Perform discrete-positive data enhancement on the sample set data stored in the memory bank M; this involves slight transformation of the samples, including fine-tuning of color and brightness, because the samples in the memory bank M only account for a small part of the original training set, and positive data enhancement can alleviate the overfitting problem in the training process; to generate new samples similar to the original samples; Discrete-positive data augmentation generates new samples of the same relation by merging two different samples from the same relation; specifically, for any relation r i The i1th sample x in i1 and i2 samples x i2 , using the relation r i The i1th sample x in i1 The head entity and tail entity replacement relationship r i The i2th sample x in i2 The head entity and the tail entity in the relationship r i Generate a new positive sample x i12 ; Step 5.2: Encoder and projection head application: Encode the enhanced samples using the specific projection head corresponding to each task to obtain their feature representation in the relational representation space; Step 5.3: Mixed dataset and contrastive learning: Mix the enhanced sample feature representations of all tasks into a new training set; perform continuous-positive data augmentation on this mixed training set to further increase the number of positive samples in the continuous semantic space, including adding slight Gaussian noise or performing feature smoothing; perform contrastive learning on the enhanced feature representation to consolidate the knowledge of new and old tasks; Step 5.4: Multi-task loss optimization: Introduce a cross-task loss strategy to optimize the model, minimize the knowledge forgotten between new and old tasks, and improve the generalization ability of the model on new tasks; After calculating the contrast loss for all tasks separately, these losses are averaged to obtain the multi-task loss L R : Among them, the upper and lower k in the fraction are the number of tasks that have been learned so far, L Cv (v=1,...,k) is the contrast loss calculated using each task-specific projection head, L R is the multi-task loss.

5. A method for extracting relations based on continuous learning of a hypernetwork as claimed in claim 1, characterized in that In step 6), the specific steps of the model inference include: Step 6.1: Relationship class prototype calculation: Generate relationship class prototypes using the task-specific projection head; these prototypes are representative feature representations of each category and are used to compare with test samples during the testing phase; Step 6.2: Test sample projection: Project the test sample into the same relational representation space through the encoder and the projection head of the current task to obtain its feature representation; Step 6.3: Similarity calculation and classification: Calculate the similarity between the test sample feature representation and each relationship class prototype, including Euclidean distance and cosine similarity; assign the test sample to the relationship class that is most similar to it to complete the classification task; specifically, according to the relationship with the test sample x t The most similar prototype is assigned a class label: Among them, y t Represents the test sample x t The corresponding classification result; the argmin function represents the subscript corresponding to the minimum value in the set {1,2,...,km}; q represents the qth element in the set {1,2,...,km}; x t represents the tth element in the set; m is the number of relation categories contained in each task; k represents the number of tasks currently learned; t c Represents the relationship c; P tc is the specific projection head corresponding to relation c; h t is the test sample x t Embedding representation of c is the average of all relational representations of relation c in the memory M.

6. A continuous learning relationship extraction system based on a hypernetwork, characterized by According to any one of claims 1 to 5, a method for extracting relations based on continuous learning of a hypernetwork is adopted, wherein the system comprises the following modules: The sample encoding module is used to encode the input sample into a semantic embedding vector through BERT to provide semantic information for subsequent processing; The hypernetwork projection head generation module is used to generate a specific projection head for each new task, projecting the sample embedding into a task-specific representation space to assist classification; New task training module, used to perform data augmentation, encoding and contrastive learning for new tasks, and to train and optimize models; Typical sample selection module, used to select typical samples from new task data and store them in the memory bank to provide support for subsequent replay; Multi-task replay module, which is used to replay memory bank samples, consolidate knowledge through data augmentation and contrastive learning, and optimize cross-task performance; The model inference module is used to generate relationship class prototypes, project and classify test samples, and complete the relationship extraction task.

7. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the hypernetwork-based continuous learning relationship extraction method as described in any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, it implements a hypernetwork-based continuous learning relationship extraction method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Unsupervised sentence representation learning method based on synthetic data

    CN116611422A

  • Prompt-based adversarial data enhanced continuous learning relation extraction method

    CN116882400A