A method for continuous relation extraction combining wake-sleep memory cycles and experience iteration

By combining wake-sleep memory cycles and experience iteration, the problems of catastrophic forgetting and overfitting in continuous relation extraction are solved, and the model achieves efficient generalization and accuracy when learning new relations.

CN119558311BActive Publication Date: 2025-12-26ANHUI UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411652732.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-12-26
Estimated Expiration
2044-11-19

AI Technical Summary

Technical Problem

Existing methods for continuous relation extraction are prone to catastrophic forgetting and overfitting when learning new relation types, and they also suffer from representation bias, which affects the generalization ability and accuracy of the model.

Method used

By combining wake-sleep memory cycles and experience iteration, and using techniques such as data augmentation, K-Means clustering, linear classification, and knowledge distillation, the distribution of relational samples is dynamically adjusted to prioritize the retention of high-quality experiences, correct representational biases in the model, and optimize the model using dream data during the sleep stage.

Benefits of technology

It effectively alleviated overfitting, enhanced the model's generalization ability, corrected representation bias, and improved the model's accuracy and stability in handling new relationships.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119558311B_ABST
    Figure CN119558311B_ABST
Patent Text Reader

Abstract

The application discloses a kind of to combine wake sleep memory cycle and experience iteration's continuous relationship extraction method, belong to information extraction technical field. Including: input a new task into model, using data enhancement technology to expand new relationship instance, and with task jointly build synthetic short-term memory;Using K-Means algorithm to filter instance and store it in long-term memory;In the wake stage, model updates its processing capacity by quickly adapting new relationship samples, and these samples are included in the experience pool;Using experience iteration framework, dynamically adjust the distribution of relationship samples in the process of model learning;In sleep stage, model experiences non-rapid eye movement and rapid eye movement two sub-stages. In NREM stage, neural network replay hippocampus long-term memory. In REM stage, model through simulating dream data of new relationship, strong model robustness, effectively alleviate the catastrophic forgetting problem in continuous relationship extraction, to improve the stability and performance of model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the field of information extraction, and particularly relates to a continuous relation extraction method combining wake-sleep memory cycle and experience iteration. BACKGROUND

[0002] The core goal of the relation extraction task is to identify the specific relationship between two given entities from text data. Traditional relation extraction tasks usually assume that all relationship types are known, without considering the emergence of new relationship types in the real world. In the face of these emerging relationships, existing work usually adopts the strategy of retraining the model. However, in the case of limited storage and computing resources, this retraining method has become no longer feasible, which prompts researchers to explore more efficient solutions. Therefore, the concept of continuous relation extraction (CRE) emerges as the times require, aiming to solve this challenge.

[0003] The core of CRE is to enable the model to learn new relationships while maintaining the processing ability of learned relationships unaffected. Unlike the supervised learning paradigm where all relationship types are known during model training, in the process of continuous relation extraction, the model does not know all relationship types, but continuously obtains new relationship types and training data. While learning new relationship types, due to the change of key parameters, the model's classification ability for existing relationships decreases significantly while learning to classify new relationships, which is called "catastrophic forgetting".

[0004] Memory-based continuous relation extraction methods have been widely applied in the CRE task, and the core of which is to retrain the model by storing and using a small number of typical samples to reduce the forgetting phenomenon. However, this method has some problems:

[0005] On the one hand, with the increase of training times, the model may overfit to a small number of typical samples, thereby damaging its generalization ability to handle new tasks;

[0006] On the other hand, this method may introduce representation bias, i.e., the overlap of new and old relationships in the feature representation space, resulting in the previous learned knowledge being covered by new knowledge.

[0007] Therefore, the present application provides a continuous relation extraction method combining wake-sleep memory cycle and experience iteration. SUMMARY

[0008] The present application aims to provide a continuous relationship extraction method combining wake-sleep memory cycle and experience iteration, which solves the existing problems, effectively alleviates the overfitting phenomenon and corrects the representation bias of the model by combining the playback of experience memory and the generation of diversified dream data, and designing an experience iteration framework that preferentially retains high-quality experience, eliminates low-quality experience and dynamically adjusts the distribution of relationship samples.

[0009] To achieve the above-mentioned purpose, the present application provides a continuous relationship extraction method combining wake-sleep memory cycle and experience iteration, comprising the following steps:

[0010] S1: a new task T k is input into the model;

[0011] S2: use data augmentation technology to expand new relationship instances, and construct a synthetic short-term memory together with T k task;

[0012] S3: use K-Means algorithm to filter out representative instances from , and store these instances in long-term memory for subsequent training;

[0013] S4: in the wake-up stage, the model updates its processing ability by quickly adapting to new relationship samples, and incorporates these samples into the experience pool;

[0014] S5: use the experience iteration framework to dynamically adjust the distribution of relationship samples during model learning, so as to better correct the representation bias of the model;

[0015] S6: in the sleep stage, the model goes through two sub-stages of non-rapid eye movement (NREM) and rapid eye movement (REM); in the NREM stage, the neural network replays the long-term memory in the hippocampus. In the REM stage, the model simulates dream data of new relationships to prepare for the ability to handle future new relationships.

[0016] Further, the new task in step S1 is equipped with its independent data set D k and relationship set R k , which respectively contains training set , validation set and test set , and each R k covers at least one relationship type; the relationship sets R k of different tasks do not overlap.

[0017] Further, the specific process of step S2 is as follows:

[0018] S2-1: The enhanced dataset D is obtained by adopting the two data enhancement strategies of mixed enhancement and reverse enhancement aug ;

[0019] S2-1-1: Mixed enhancement is based on the existing relationship R of task T k k = {r1, r2,..., r N}, by randomly pairing these relationships, generating relationship pairs. Based on these relationship pairs, mixed synthetic categories can be constructed, and the dataset D Hybrid ;

[0020] S2-1-2: Reverse enhancement creates an additional reverse category by interchanging the positions of the head and tail entities in the corresponding instances, obtaining the dataset D Reversed ;

[0021] S2-1-3: Combine the dataset D Hybrid and the dataset D Reversed to obtain the enhanced dataset D aug , which is calculated as follows:

[0022] D aug = D Hybird + D Reversed ;

[0023] S2-2: Combine the original training dataset D k of the current task T k with the enhanced dataset D aug to form short-term memory The calculation formula is as follows:

[0024]

[0025] Further, the specific process of step S3 is as follows:

[0026] S3-1: For the kth task T k , encode all instances in into a set of embedding vectors

[0027] S3-2: Apply the K-Means clustering algorithm twice to the encoded instances to obtain some instances closest to the centroids stored in long-term memory .

[0028] S3-2-1: First, cluster these embedding vectors once, dividing them into B clusters. In each cluster, select the instance closest to the cluster center to form a representative instance set, denoted as C k . ​

[0029] S3-2-2: Statistics C k The number of instances in each relation is used to evaluate the importance of the relation. For these more important relations, at least instances are stored to long-term memory ; for relatively unimportant relations, at most instances are selected. If the number of instances of a certain relation is insufficient to fill its allocated memory, the unused memory capacity is reallocated to other relations.

[0030] S3-2-3: The selected instances of each relation are clustered again, and the instances closest to the centroid are selected to be stored to long-term memory .

[0031] Further, the specific process of the step S4 is as follows:

[0032] S4-1: Process the instances x in short-term memory using the pre-trained language model BERT to obtain the result represented as h x . The calculation formula is as follows:

[0033]

[0034] Where and are the hidden representations of the head entity and the tail entity, and are two training parameters.

[0035] S4-2: Use a linear Softmax classifier to calculate the classification probability of the input instance x, define the classification loss function L new to optimize the model parameters. The classification probability and loss function calculation formula is as follows:

[0036] P(x; θ k ) = softmax(W2h x )

[0037]

[0038] Where θ k is the parameter set of the model during the current task T k , W2 j is the trainable weight matrix of the classifier, P(r i |x k ; θ i ) is the probability that the model predicts that the input instance x j belongs to the relation r i , y i is the actual label of the instance x i , if yi =r j Then the indicator function The value is 1 if it is 1, otherwise it is 0.

[0039] S4-3: The generated short-term memory representation h x The corresponding classification loss values ​​are stored in the experience pool.

[0040] Furthermore, the specific process of step S5 is as follows:

[0041] S5-1: During the experience propagation phase, the model continuously expands its experience pool by learning from previous tasks. When task batch T is executed... i At that time, the model can utilize all previously accumulated experience {E1, E2, ..., E...} i-1} to execute the current task T i And, according to a specific experience propagation strategy, newly acquired experience is added to the experience pool. This process can be described as follows:

[0042]

[0043] Where E k It is the accumulated experience pool. μ(E;T) represents the experience utilization rate on task batch T.

[0044] S5-2: In the experience elimination phase, to effectively optimize the structure of the experience pool, it is filtered based on the frequency of experience use f(e) and the importance of the experience. After each task batch, the retained set of experiences is filtered using the following formula.

[0045]

[0046] in It is the set of experiences filtered from the current task batch k. rank(E) k The expression rankes experiences according to the order of their loss values. The function f(e) represents the frequency of use of each experience e. θ is a threshold for retaining an experience.

[0047] S5-3: Improve the quality and operational efficiency of the experience pool using linear classification loss and knowledge distillation loss. The linear classification loss function measures the difference between the model's predicted distribution and the true distribution, and adjusts the model parameters by minimizing this difference to make the predictions closer to the true distribution. Distillation loss aims to transfer knowledge from previous models to the current model, improving its performance and generalization ability while reducing representation bias.

[0048] L reply_e =α·L lin +(1+α)L kd

[0049] Where L lin and L kd These represent the linear classification loss and the knowledge distillation loss, respectively. α is a weighting coefficient used to balance the contributions of these two losses to the total loss.

[0050] S5-3-1: In the calculation of linear classification loss, the model is first used to evaluate the empirical instance x. i By making predictions, we can obtain empirical instances x. i The probability of belonging to a certain category:

[0051]

[0052] Where θ k It is the current task T k Model parameters; It is the trainable parameter matrix of a linear classifier; Represents the experience pool Input example x i The hidden feature representation;

[0053] S5-3-2: Using cross-entropy loss to calculate the linear classification loss function:

[0054]

[0055] in It is an experience pool The total number of samples in R; k It is the current task T k A set of relationships. It is an indicator function, when the true label y i Equals the predicted label r j The value is 1 if it is true, and 0 otherwise.

[0056] S5-3-3: In the calculation of knowledge distillation loss, the current model and previous models are first used to predict the input samples, generating corresponding soft-label probability distributions. The soft-label generation process utilizes a temperature parameter τ to smooth the predicted probabilities, enabling the model to better capture the relative relationships between different categories. The soft-label probability distributions P of the current model and previous models are shown below. s (x i ) and P t (x i )as follows:

[0057]

[0058] Where z s (x i ) and z t (xi ) is the comparison between the current model and the previous model on sample x. i The unnormalized output. τ1 is the temperature parameter.

[0059] S5-3-4: Use Kullback-Leibler divergence (KL divergence) to measure the soft label distribution P of the current model. s (x i ) and the soft label distribution P of the previous model t (x i Differences between:

[0060]

[0061] Furthermore, the specific process of step S6 is as follows:

[0062] S6-1: First, summarize the long-term memories from each task batch and integrate them into a long-term memory set;

[0063]

[0064] Then, a prototype set is generated for each known relationship. By examining the prototype set Feature extraction is performed on all instances to compute the prototype embedding of the relation.

[0065]

[0066] in It is a relationship Prototype embedding. It is an example The feature extraction function.

[0067] S6-2: In the NREM phase, first start with the long-term memory set. Samples are extracted to consolidate and reinforce the model's existing knowledge partially frozen during the sobering phase. Contrastive learning loss and knowledge distillation loss are used to optimize the model parameters. The total loss for this phase can be expressed as:

[0068] L NREM =L cos +L kd

[0069] Where L cos and L kd These represent contrastive learning loss and knowledge distillation loss, respectively.

[0070] In contrastive learning loss, a contrastive learning network is used to strengthen the model's consolidation of previous memories. Specifically, the loss function is defined as follows:

[0071]

[0072] where represents the input instance x i 's hidden representation and the similarity between the relationship prototype embedding . τ3 is the temperature parameter.

[0073] The calculation of the knowledge distillation loss function is as follows:

[0074]

[0075] S6-3: In the REM phase, dream data containing randomness and variability is first introduced. Then, the model parameters are optimized using the adversarial linear loss, adversarial compound and p-margin loss, and smooth adversarial compound loss.

[0076] S6-3-1: First, add random noise to the data in the short-term memory and long-term memory set. The generated noise has the same shape as the memory data.

[0077] S6-3-2: Use techniques such as normalization and scaling to control the amplitude of the noise and adjust the influence of the noise.

[0078] S6-3-3: Combine the processed noise with the original memory data to generate dream data containing memory data and random noise. The obtained dream data set can be represented as:

[0079]

[0080] where represents generating standard normal distribution noise with the same shape as . γ is a scaling parameter that controls the influence of the noise.

[0081] S6-3-4: Define the total loss function L REM , which combines three key components: adversarial linear loss L lin , adversarial compound and p-margin loss , and smooth adversarial compound loss

[0082]

[0083] where ω1, ω2 and ω3 are weight hyperparameters of L lin , and , respectively, used to balance the contributions of each loss term.

[0084] Linear loss L linThe model is optimized by minimizing the cross-entropy between the true label and the predicted probability, ensuring that it can still maintain high-precision classification performance when facing adversarial samples. The specific loss function is defined as follows:

[0085]

[0086] where P(r j |x i ; θ k ) represents the probability of predicting that the input x i belongs to the relationship r j . y i is the true label of x i .

[0087] The adversarial composite and p-margin loss further considers the marginal effect of model output (i.e., the difference in confidence between different classes), aiming to improve the overall robustness of the model by optimizing the marginal performance in an adversarial environment. The specific loss function is defined as follows:

[0088]

[0089] where represents finding the worst perturbation x′ i within the perturbation range ||x i -x′ p ||p i ≤ γ under the p-norm constraint. The function Φ τ is a smoothing function. The symbol represents the sum over all incorrect labels y′ i ≠ y i , which reflects the overall loss of the model on incorrect labels. The function Φ ρ is used to measure the score difference between the correct label y i and the incorrect label y′ i . θ(x′ i ,y′ i ) and θ(x′ i ,y i ) represent the predicted scores for the incorrect label y′ i and the correct label y i under the input x′ i .

[0090] Smooth adversarial composite loss Based on the adversarial composite and p-margin loss, a smoothing term is introduced to reduce the instability in optimization, thereby improving the stability and optimizability of training. Its loss function form is as follows:

[0091]

[0092] where the parameter v is used to control the smoothing degree to reduce the instability in training. denotes the perturbation neighborhood B(x i ,γ) of the input x i in the dream dataset. i The maximum adversarial perturbation x′ i is found in the perturbation neighborhood B(x i ,γ) of the input x i . i The L2 norm of the difference in prediction scores for the correct label y i and the wrong label y′ i before and after the perturbation is represented by ||Δθ(x′ i ,y i )-Δθ(x i ,y i )||2.

[0093] The present application has the following beneficial effects:

[0094] Compared with the prior art, the technical scheme provided by the present application has the following significant effects:

[0095] 1. The wake-sleep memory cycle method is proposed to solve the problem that the existing method may cause overfitting of a small number of typical samples as the number of training increases, thereby damaging the generalization ability of the model in processing new tasks. The method combines the playback of experience memory and the generation of diversified dream data, effectively reduces the risk of overfitting and enhances the generalization ability of the model.

[0096] 2. The experience iteration framework is designed to solve the problem that the existing method may introduce representation bias, i.e., the overlap of new and old relationships in the feature representation space, resulting in the previous learned knowledge being covered by new knowledge. The framework preferentially retains high-quality experiences, eliminates low-quality experiences, and dynamically adjusts the distribution of relationship samples, thereby correcting the representation error of the model. BRIEF DESCRIPTION OF DRAWINGS

[0097] Fig. 1 is the flowchart of the continuous relationship extraction method combining wake-sleep memory cycle and experience iteration of the present application.

[0098] Fig. 2 is the overall framework diagram of the present application.

[0099] Fig. 3 is the experience iteration framework diagram of the present application. DETAILED DESCRIPTION

[0100] In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular architectures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known methods, devices, circuits, and

[0101] It is to be understood that the terminology "includes", "has", "holds", "contains" and / or "comprising", "including", "having" and their conjugates, as used herein, means "including but not limited to", and not to the exclusion of any other term or aspect.

[0102] It is also to be understood that the terminology "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items, as well as to the possibility that one or more of the listed items alone can be present.

[0103] As used in the description of the application and the appended claims, the term "if' can be interpreted to mean "when" or "upon" or "in response to determining" or "in response to detecting" depending on the context. Similarly, the phrase "if it is determined" or "if [a described condition or event] is detected" can be interpreted to mean "upon determining" or "in response to determining" or "upon [the described condition or event] being detected" or "in response to [the described condition or event] being detected", depending on the context.

[0104] In addition, the terms "first", "second", "third", etc. as used in the description of embodiments herein and in the claims, are used for distinguishing between similar elements and not necessarily for describing a sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein are, for example, capable of use in either order.

[0105] Reference throughout this specification to "one embodiment", "an embodiment", or "a specific embodiment", means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the application. Thus, appearances of the phrases "in one embodiment", "in an embodiment", "in some embodiments", "in other embodiments", "in additional embodiments", and so on, do not necessarily all refer to the same embodiment, unless otherwise indicated. The terms "including", "containing", "comprising", "having" and variations thereof, mean "including but not limited to", unless expressly specified otherwise.

[0106] With reference to Figs. 1-3 The present application provides a method for extracting persistent relationships combining wake-sleep memory cycle and experience iteration, comprising the following steps:

[0107] S1: a new task T k is input into the continuous relation extraction model of the application;

[0108] S2: using data augmentation techniques to expand new relation instances, and jointly constructing a short-term memory with T k

[0109] S2-1: two data augmentation strategies, mixed augmentation and reverse augmentation, are adopted to obtain the augmented dataset;

[0110] S2-2: the original training dataset D k of the current task T k is combined with the augmented dataset D aug to form a short-term memory The specific formula is as follows:

[0111]

[0112] S3: using K-Means algorithm to filter out representative instances from and store these instances in long-term memory for use in subsequent training;

[0113] S4: in the wake-up stage, the model updates its processing ability by quickly adapting to new relation samples, and these samples are included in the experience pool;

[0114] S5: using the experience iteration framework, dynamically adjusting the distribution of relation samples in the process of model learning to correct the representation bias of the model;

[0115] S6: in the sleep stage, the model goes through two sub-stages of non-rapid eye movement and rapid eye movement.

[0116] As an embodiment provided by the application, preferably, the method of S2: using data augmentation techniques to expand new relation instances, and jointly constructing a short-term memory with T k is as follows:

[0117] S2-1-1: mixed augmentation is based on the existing relations R k of the task T k ={r1, r2,..., r N}, which generates relation pairs by randomly pairing these relations. Based on these relation pairs, mixed synthetic categories can be constructed to obtain the dataset D Hybrid This process includes the following steps: first, extract the head entity e i1 but does not contain the tail entity e i2 ​​the span s i , and contains tail entity e j2 but does not contain head entity e j1 the span s j ; then s i and s j are concatenated to form a hybrid instance x hybrid = [s i ; s j ]. With this hybrid augmentation, one additional synthetic category is constructed for the new task.

[0118] S2-1-2: Reverse augmentation creates one additional reverse category by interchanging the positions of head and tail entities in the corresponding instance. The augmented dataset D Reversed is obtained. For each asymmetric relation r i , one additional reverse category is created by interchanging the positions of head and tail entities in the corresponding instance.

[0119] S2-1-3: The augmented dataset D aug is obtained by combining dataset D Hybrid and dataset D Reversed , which is calculated as follows:

[0120] D aug = D Hybird + D Reversed .

[0121] As an embodiment provided by the present application, preferably, the method for selecting representative instances from D and storing these instances in long-term memory using K-Means algorithm is as follows:

[0122] S3-1: For the kth task T k , encode all instances in D into a set of embedding vectors

[0123] S3-2: Apply the K-Means clustering algorithm twice to the encoded instances to obtain some instances closest to the centroids stored in long-term memory .

[0124] S3-2-1: Apply the K-Means clustering algorithm to divide these embedding vectors into B clusters. In each cluster, select the instance closest to the cluster center to form a representative instance set, denoted as C k .

[0125] S3-2-2: Count C k ​The number of instances in each relation is used to evaluate the importance of the relation. Relations containing instances exceeding the threshold set by the administrator are considered more important; for these more important relations, at least instances are stored into long-term memory ; for relatively unimportant relations, at most instances are selected. If the number of instances of a certain relation is insufficient to fill its allocated memory, the unused memory capacity is reallocated to other relations.

[0126] S3-2-3: The selected instances of each relation are clustered again and the instances closest to the centroid are selected to be stored into long-term memory .

[0127] As an embodiment provided by the present application, preferably, in the wakeful phase, the model updates its processing capacity by quickly adapting to new relation samples and incorporates these samples into the experience pool, specifically:

[0128] S4-1: Process the instances x in short-term memory using the pre-trained language model BERT to obtain the result represented as h x . The specific formula is as follows:

[0129]

[0130] S4-2: Use a linear Softmax classifier to calculate the classification probability of the input instance x, define the classification loss function L new to optimize the model parameters. The classification probability and loss function are calculated as follows:

[0131] P(x; θ k ) = softmax(W2h x )

[0132]

[0133] where θ k is the parameter set of the model during the current task T k . W2 j is the trainable weight matrix of the classifier. P(r i | x k ; θ i ) is the probability that the model predicts that the input instance x j belongs to the relation r i . y i is the actual label of the instance x i . If y j = r x , the value of the indicator function is 1, otherwise it is 0.

[0134] S4-3: The generated short-term memory representation h x and the corresponding classification loss value is stored in the experience pool. S5: Using the experience iteration framework, the distribution of relationship samples is dynamically adjusted during model learning to better correct the representation bias of the model.

[0135] As an embodiment provided by the present application, preferably, the experience iteration framework is used to dynamically adjust the distribution of relationship samples during model learning to correct the representation bias of the model, specifically:

[0136] S5-1: Refer to Fig. 3 During the experience propagation phase, the model continuously expands its experience pool by learning from previous tasks. When performing task batch T i , the model can utilize all previously accumulated experiences {E1, E2,..., E i-1} to perform the current task T i , and according to a specific experience propagation strategy, the newly obtained experience is added to the experience pool. The process can be described as:

[0137]

[0138] where E k is the accumulated experience pool. μ(E;T) represents the experience utilization rate on task batch T.

[0139] S5-2: In the experience elimination phase, in order to effectively optimize the structure of the experience pool, the experiences are screened according to their usage frequency f(e) and importance. After each task batch ends, the retained experience set is screened by the following formula

[0140]

[0141] where is the experience set screened in the current task batch k. rank(E k ) represents ranking the experiences according to the loss value size sorting criteria. The function f(e) represents the usage frequency of each experience e. θ is a threshold value for experience retention.

[0142] S5-3: Use linear classification loss function and knowledge distillation loss function to improve the quality and operation efficiency of the experience pool. The linear classification loss function is used to measure the difference between the model prediction distribution and the true distribution, and by minimizing the difference, the model parameters are adjusted to make the prediction closer to the true distribution. Distillation loss aims to transfer the knowledge of the previous model to the current model to improve its performance and generalization ability, while reducing the representation bias.

[0143] L reply_e = α·Llin + (1 + a)L kd

[0144] where L lin and L kd represent linear classification loss and knowledge distillation loss, respectively. a is a weight coefficient to balance the contribution of these two losses to the total loss.

[0145] S5-3-1: In the process of calculating the linear classification loss, first, the model makes a prediction on the experience instance x i , and the probability that the experience instance x i belongs to a certain class can be obtained:

[0146]

[0147] where θ k is the model parameter of the current task T k . is the trainable parameter matrix of the linear classifier. represents the hidden feature representation of the input instance x i in the experience pool .

[0148] S5-3-2: Use cross-entropy loss to calculate the linear classification loss function:

[0149]

[0150] where N is the total number of samples in the experience pool . R k is the relationship set of the current task T k . is an indicator function, which is 1 when the real label y i is equal to the predicted label r j , otherwise 0.

[0151] S5-3-3: In the process of calculating the knowledge distillation loss, first, use the current model and the previous model to make predictions on the input sample, and generate the corresponding soft label probability distribution. The generation process of the soft label uses a temperature parameter τ, which is used to smooth the prediction probability, so that the model can better capture the relative relationship between different classes. The soft label probability distribution P s (x i ) and P t (x i ) of the current model and the previous model are as follows:

[0152]

[0153]

[0154] where z s (x i ) and z t (x i ) are the unnormalized outputs of the current model and the previous model on sample x i . τ1 is a temperature parameter.

[0155] S5-3-4: Use Kullback-Leibler divergence (KL divergence) to measure the difference between the soft label distribution P s (x i ) of the current model and the soft label distribution P t (x i ) of the previous model:

[0156]

[0157] As an embodiment provided by the present application, preferably, in the sleep stage, the model goes through two sub-stages of non-rapid eye movement (NREM) and rapid eye movement (REM). In the NREM stage, the neural network replays the long-term memory in the hippocampus. In the REM stage, the model prepares for the ability to handle future new relationships by simulating dream data of new relationships. Specifically:

[0158] S6-1: First, the long-term memories in each task batch are summarized and integrated into a long-term memory set;

[0159]

[0160] Then, a prototype set is generated for each known relationship. The prototype embedding of the relationship is calculated by performing feature extraction operations on all instances in the prototype set

[0161]

[0162] where is the prototype embedding of the relationship . f represents the feature extraction function on instance .

[0163] S6-2: In the NREM stage, samples are extracted from the long-term memory set to consolidate and strengthen the existing knowledge of the model that is partially frozen in the wake stage, which refers to the memory or knowledge that has been formed in the wake state, is relatively stable but has not yet been completely consolidated; use contrastive learning loss and knowledge distillation loss to optimize model parameters. The total loss in this stage can be represented as:

[0164] L NREM=L cos +L kd

[0165] Where L cos and L kd These represent contrastive learning loss and knowledge distillation loss, respectively.

[0166] In contrastive learning loss, a contrastive learning network is used to strengthen the model's consolidation of previous memories. Specifically, the loss function is defined as follows:

[0167]

[0168] in Representative input instance x i Hidden representation With relational prototype embedding The similarity between them. τ3 is a temperature parameter.

[0169] The calculation of the knowledge distillation loss function is as follows:

[0170]

[0171] S6-3: In the REM stage, dream data containing randomness and variability is first introduced. Then, adversarial linear loss, adversarial composite and ρ-margin loss, and smooth adversarial composite and loss are used to optimize the model parameters.

[0172] S6-3-1: First, add random noise to the data in the short-term and long-term memory sets. The generated noise has the same shape as the memory data.

[0173] S6-3-2: Use techniques such as normalization and scaling to control noise amplitude and adjust noise influence.

[0174] S6-3-3: Combine the processed noise with the original memory data to generate dream data containing both memory data and random noise. The resulting dream dataset can be represented as:

[0175]

[0176] in Represents generation and The noise is a standard normal distribution with the same shape. γ is a scaling parameter that controls the influence of the noise.

[0177] S6-3-4: Defines the total loss function L REM This function combines three key components: adversarial linear loss L lin , antagonistic compounding and p-margin loss And smooth antagonistic compounding and loss

[0178]

[0179] Where ω1, ω2, and ω3 are respectively L lin , as well as The weight hyperparameters are used to balance the contributions of each loss term.

[0180] Linear loss L lin The model is optimized by minimizing the cross-entropy between the true labels and predicted probabilities, ensuring high classification accuracy even when facing adversarial examples. The specific loss function is defined as follows:

[0181]

[0182] Where P(r) j |x i ;θ k ) represents the predicted input x i Belongs to relation r j The probability of y. i For x i The true label.

[0183] Adversarial composite and ρ-margin loss further consider the edge effects of the model output (i.e., the difference in confidence between different classes), aiming to improve the overall robustness of the model by optimizing edge performance in adversarial environments. The specific loss function is defined as follows:

[0184]

[0185] in This refers to finding the range of perturbations ||x under the p-norm constraint. i -x′ i || p Worst perturbation x′ within ≤γ i Function Φ τ It is a smooth function. (Symbol) This indicates that for all error labels y′ i ≠y i Summing is performed, which reflects the model's overall loss on mislabeled data. The function Φ ρ Used to measure the model's performance on the correct label y i and error label y′ i The difference in scores between them. θ(x′) i ,y′ i ) and θ(x′ i ,y i ) represent the input x′ respectively i Below is the error label y′i and correct label y i the prediction score.

[0186] Smoothed adversarial composite loss A smoothing term is introduced on the basis of adversarial composite and p-margin loss to reduce the instability in optimization, so as to improve the stability and optimizability of training. The loss function form is:

[0187]

[0188] Wherein, the parameter v is used to control the smoothing degree to reduce the instability in training. The symbol represents that in the perturbation neighborhood B(x i , γ) of the input x i of the dream data set, the maximum adversarial perturbation x′ i is searched. The ||Δθ(x′ i , y i )-Δθ(x i , y i )||2 represents the L2 norm of the difference in prediction score of the model before and after perturbation, correct label y i and error label y′ i .

[0189] In the description of the present specification, the description of the terms "one embodiment", "an example", "a specific example" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0190] The preferred embodiments of the application disclosed above are only used to help explain the application. The preferred embodiments do not describe all the details, nor limit the application to the specific embodiments described. Obviously, many modifications and variations can be made according to the content of the present specification. The present specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the application, so that those skilled in the art can well understand and utilize the application. The application is limited only by the claims and their full scope and equivalents.

Claims

1. A method for continuous relationship extraction combining wake-sleep memory cycles and experience iteration, characterized in that, The method comprises the following steps: Step S1 : inputting a new task to the persistent relation extraction model; Step S2: Extend new relationship instance using hybrid enrichment and reverse enrichment strategy, with task Co-constructing synthetic short-term memory ; Step S3: Selecting the instance closest to the centroid from the set of instances using the K-Means algorithm and storing the selected instance in the long-term memory ​​ Step S4: in the wakeful stage, the short-term memory is processed by the pre-trained language model BERT, and the generated short-term memory and the corresponding classification loss value are included in the experience pool. Examples x in the short-term memory are processed by the pre-trained language model BERT, and the generated short-term memory and the corresponding classification loss value are included in the experience pool. Step S5: dynamically adjusting the distribution of relationship samples in the process of model learning using an experience iterative framework to correct the representation bias of the model; Step S6: in the sleep stage, the model undergoes two sub-stages of non-rapid eye movement and rapid eye movement; In the non-rapid eye movement stage, the neural network replays long-term memory in the hippocampus; In the rapid eye movement phase, the model optimizes the model parameters using an adversarial linear loss, an adversarial composite, and smooth adversarial composite loss to simulate dream data for new relationship samples; In the step S5, the specific way of dynamically adjusting the distribution of relationship samples using the experience iterative framework is as follows: Step S51: in the experience propagation stage, continuously expand the experience pool of the model by learning previous tasks; Step S52: In the experience elimination phase, experiences in the experience pool are filtered according to the frequency of use of the experience and the importance of the experience. and the importance of the experience. Specifically, the importance of experience is ranked according to the loss value size of the classification loss function, and the smaller the loss value is, the more important the experience is; Step S53: correct the representation bias of the model using a linear classification loss function and a knowledge distillation loss function.

2. The method of claim 1, wherein the method is characterized by, In the step S1, the task equipped with independent data sets and relationship sets ; The dataset includes a training set , a validation set , and a test set ; Each relation set At least one relation type; relation sets between different tasks Do not overlap.

3. The method of claim 1, wherein the method is characterized by, In the step S2, the short-term memory is constructed The step is specifically as follows: Step S21: Adopting mixed enhancement and reverse enhancement strategy to obtain enhanced dataset D aug ; Step S22: combine the task original training dataset with the enhanced dataset D aug to form short-term memory ; wherein .

4. The method of claim 3, wherein the method is a method of persistent relationship extraction that combines wake-sleep memory cycles and experience iteration. The data set D aug of step S21 is generated as follows: Step S211: based on the existing relationship of the task , the mixed reinforcement strategy generates a pair of relationships by randomly pairing the existing relationship of the task ; a pair of relationships ; Based on the relation pairs, a hybrid synthetic class is constructed to obtain a dataset ; Step S212: Reverse the enhanced strategy by interchanging the positions of the head and tail entities in the corresponding instance, create an additional reversed class, and obtain the dataset ; Step S213: Combine datasets and dataset resulting in an enhanced dataset in the following way: 。 5. The method of claim 1, wherein the method is characterized by, In the step S3, the specific steps of screening the instance closest to the centroid are as follows: Step S31: For the kth task T k , encode all instances in into a set of embedding vectors ; Step S32: Apply twice K-Means clustering algorithm to the encoded embedded vector set to get the instance closest to the centroid and store to long-term memory In the middle.

6. The method of claim 5, wherein the method is characterized by, In the step S32, the method of obtaining the instance closest to the centroid comprises the following steps: Step S321: one clustering is performed on the embedding vector set, and the embedding vectors are divided into clusters; in each cluster, the instance closest to the cluster center is selected to form a representative instance set, denoted as ​ Step S322: Statistics The number of instances of each relationship is used to assess the importance of the relationship; In particular, relationships comprising an example number exceeding an administrator-set threshold are considered more important; for these more important relationships, at least one instance is stored to long-term memory R k is a task relationship, ;​ For the remaining relatively unimportant relationships, at most one instance is selected; If the number of instances of a certain relationship is insufficient to fill the allocated memory, the unused memory capacity is reallocated to other relationships; Step S323: Cluster the selected instances of each relation again and select the instance closest to the centroid to store in long term memory In the middle.

7. The method of claim 1, wherein the method is characterized by, In the step S4, the method of including the generated short-term memory and the corresponding classification loss value into the experience pool comprises the following steps: Step S41: process the short-term memory using a pre-trained language model BERT, and the result is represented as h x ;​ Step S42: Calculate the classification probability of the input instance x using a linear Softmax classifier, and define the classification loss function L new to optimize the model parameters; Step S43: store the generated short-term memory and the corresponding classification loss value in the experience pool.

8. The method of claim 1, wherein the method is characterized by, In the step S6, the specific way of the model undergoing two sub-stages of non-rapid eye movement and rapid eye movement is as follows: Step S61: aggregate long-term memories in each task batch into a long-term memory set and generate a prototype set for each known relation and compute the prototype embedding for the corresponding relation by performing a feature extraction operation on all instances in the prototype set ​ Step S62: During the non-rapid eye movement (NREM) phase, retrieve data from long-term memory sets. Samples were extracted to consolidate and strengthen the model's existing knowledge that was partially frozen during the waking phase; frozen existing knowledge refers to relatively stable but not yet fully consolidated memories or knowledge that have been formed in the waking state; the model parameters were optimized using contrastive learning loss and knowledge distillation loss. Step S63: In the rapid eye movement phase, dream data containing randomness and variability is introduced to optimize the model parameters using adversarial linear loss, adversarial composite and loss and smooth adversarial composite and loss.

9. The method of claim 8, wherein the method is characterized by, In the step S63, the generation steps of dream data are as follows: Step S631: add random noise to the data in the short-term memory and long-term memory set, and the generated noise has the same shape as the memory data; Step S632: control the noise amplitude using normalization and scaling techniques to adjust the influence of noise; Step S633: combine the processed noise with the original memory data to generate dream data containing memory data and random noise.