A lifelong scenario learning method based on attractor dynamic memory generation network

By using a lifelong contextual learning method based on attractor dynamic memory generation networks, contextual memory representation attractor vectors are generated. Combined with sparse experience replay, the catastrophic forgetting and negative transfer problems of large language models in dynamic environments are solved, achieving efficient and generalized lifelong learning.

CN121683939BActive Publication Date: 2026-07-14BEIJING SCI & TECH PATENT OFFICE

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING SCI & TECH PATENT OFFICE
Filing Date
2025-12-11
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing large language models suffer from catastrophic forgetting and negative transfer problems in the face of dynamic and changing real-world environments, making it difficult to effectively utilize prior knowledge to quickly adapt to new tasks and maintain the ability to perform old tasks.

Method used

We employ an attractor-based dynamic memory generation network, which generates contextual memory representation attractor vectors through LSTM and Attractor layers. Combined with a sparse experience replay mechanism, we achieve contextual meta-learning, avoiding the high computational overhead and parameter collisions of traditional methods.

Benefits of technology

It significantly improves computational efficiency, mitigates catastrophic forgetting and negative transfer, enhances the model's learning ability and generalization performance in dynamic environments, and enables rapid adaptation and knowledge accumulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121683939B_ABST
    Figure CN121683939B_ABST
Patent Text Reader

Abstract

The application discloses a lifelong scene learning method based on an attractor dynamic memory generation network and belongs to the technical field of artificial intelligence. The method comprises the following steps: obtaining a batch of training samples from a training data set or a storage memory bank based on a sparse experience replay strategy, and sampling one training sample from the storage memory bank for each training sample in the batch of training samples; generating a retrieval memory feature vector based on the task sample; passing the vectorized task sample through a memory generation network to obtain a scene memory feature attractor vector; constructing a training total target based on the retrieval memory feature vector, the scene memory feature attractor vector and the training sample, and performing back propagation and optimization on a large language model based on the training total target to obtain the large language model after training. The application can improve the lifelong learning potential of the large model in a dynamic real environment and provides a feasible solution to the problems of catastrophic forgetting and negative transfer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a lifelong contextual learning method based on attractor dynamic memory generation networks. Background Technology

[0002] Large Language Models (LLMs) have demonstrated powerful versatility and contextual learning capabilities, enabling them to adapt to and solve a wide range of tasks. State-of-the-art AI algorithms have achieved remarkable results in various fields such as visual recognition and natural language processing, but their performance is highly dependent on the stability and consistency of the data distribution. With sufficient training samples, algorithms perform exceptionally well on independent and identically distributed test samples, but their performance drops significantly for out-of-distribution data. Therefore, in practical applications, task-specific data is still needed to fine-tune the model and improve its capabilities for specific tasks. However, when faced with new tasks, these models cannot fully utilize the knowledge acquired through previous training to better learn and adapt to new data and tasks—a phenomenon known as negative transfer. Furthermore, when the model is trained again using data from new scenarios and distributions, its performance on previous tasks and data drops drastically—a phenomenon known as catastrophic forgetting. Catastrophic forgetting and negative transfer problems limit the application potential of existing models in dynamically evolving real-world environments.

[0003] In contrast, humans can quickly adapt to new environments and rapidly learn new skills using past experiences, while retaining learned skills and continuously accumulating knowledge. This reflects the continuous learning ability of humans throughout their lifespan, which is the most prominent feature of general intelligence. Unlike multi-task learning settings, lifelong learning, as a realistic lifelong learning setting, typically assumes that the model only traverses the training samples for each task once, and that neither training nor testing samples should contain dataset identification information such as dataset descriptors or task identifiers. The model will face a sample stream whose data distribution may change at any time, and the model cannot know any explicit identifier about which distribution these samples come from. Since fine-tuning instructions can lead to the forgetting of general knowledge in large models, continuous learning is also crucial for LLMs to adapt to new tasks and has significant implications.

[0004] Luo et al. used a probing method to analyze the generalization and forgetting problems of pre-trained large models during continuous fine-tuning. Research shows that forgetting is prevalent in LLMs, and the larger the model parameter scale, the more severe the forgetting. General instructions and diversified instruction fine-tuning can help alleviate the forgetting problem in LLMs. There are generally three types of methods to address catastrophic forgetting: replay-based methods alleviate forgetting by adding extra learning stages such as knowledge distillation and experience replay; regularization-based methods prevent deviations between parameters learned on new datasets and those learned on previous datasets by adding extra terms to the loss function during training; and architecture-based methods enhance the model by adding contextual memory modules. Due to the massive parameter scale of LLMs, the computational requirements of these three methods increase significantly when applied to large models. Therefore, drawing inspiration from parameter efficient fine-tuning (PEFT) methods such as LoRA, a small number of trainable parameters are introduced while keeping the pre-trained large model parameters fixed to further optimize the lifelong learning ability of large models and alleviate their forgetting problem. Research shows that parameter collisions affect the continuous learning ability of large models. To resolve collisions between task-specific parameters, orthogonal gradient descent is used to decouple parameter dependencies between different tasks. O-LoRA ensures the independence of LoRA parameters between subspaces by constraining task-specific parameters to orthogonal subspaces of previous tasks, and further N-LoRA constructs a collision-free LoRA parameter subspace. However, the above methods are difficult to effectively learn diverse tasks in the real-world lifelong learning settings described in this paper, and therefore cannot better address the catastrophic forgetting and negative transfer problems of large language models. Summary of the Invention

[0005] This invention discloses a lifelong contextual learning method based on attractor dynamic memory generation networks. It leverages the contextual learning capabilities of large models to achieve contextual meta-learning based on contextual representation attractor vectors, avoiding the additional computational overhead of local adaptation in traditional meta-learning methods during training and inference. On one hand, it enables the model to learn new tasks using generated contextual representation vectors of similar tasks; on the other hand, it enables the model to activate old task capabilities using task contextual representation vectors. By integrating attractor dynamic memory generation networks, contextual meta-learning, and sparse experience replay, it outperforms existing technologies in terms of computational efficiency, forgetting resistance, generalization ability, and adaptation speed. These advantages collectively enhance the lifelong learning potential of large models in dynamic real-world environments, providing a practical solution to address catastrophic forgetting and negative transfer problems.

[0006] To achieve the above objectives, the technical solution of the present invention includes the following:

[0007] A lifelong contextual learning method based on attractor dynamic memory generation networks, the method comprising:

[0008] When training a large language model, a batch of training samples is obtained from the training dataset or from the storage memory based on a sparse experience replay strategy, and each training sample in the batch is processed... Sampling from storage memory bank training samples ;in, Indicates a task sample. This indicates the task sample. The true label, Indicates the number of samples taken from the storage memory bank One task sample, Represents task samples The real labels, the large language model includes a base model and a memory generation network;

[0009] based on Task Samples Generate a retrieval memory representation vector;

[0010] Vectorized task samples The memory generation network generates contextual memory representation attractor vectors; the memory generation network includes an LSTM layer and an Attractor layer, wherein the LSTM layer is used to generate contextual memory representation attractor vectors based on the vectorized task samples. Noisy context memory representations are generated, and the Attractor layer is used to generate context memory representation attractor vectors based on the noisy context memory representations.

[0011] Based on retrieval memory representation vectors, episodic memory representation attractor vectors, and training samples Construct a general training objective, and backpropagate and optimize the large language model based on this objective to obtain the trained large language model.

[0012] Furthermore, for each training sample in this batch of training samples Sampling from storage memory bank training samples ,include:

[0013] Task Sample Vectorized into a length of vector sequence ;

[0014] For vector sequences Average pooling is performed, and the result of average pooling is used as the key to perform Faisal nearest neighbor retrieval in the storage memory to obtain the results with the training samples. Most similar training samples .

[0015] Furthermore, based on Task Samples Generate a retrieval memory representation vector, including:

[0016] For each task sample After word segmentation and vectorization, a length of [length missing] is obtained. vector sequence ;in, , Word vectors The dimension;

[0017] Based on vector sequence Generate a vectorized matrix ;

[0018] Along the dimension Perform average pooling to obtain the retrieval memory representation vector. ;in, Represents the retrieval memory representation vector The first in Each component.

[0019] Furthermore, based on the vectorized task samples Generate noisy episodic memory representations, including:

[0020] Initialize the LSTM layer to obtain the initial hidden state. and initial cell state ;

[0021] Computational forget gate , Represents the vectorized task sample The One portion, This represents the Sigmoid activation function. The weight matrix represents the forget gate. Indicates the bias of the forget gate;

[0022] Calculate input gate , This represents the weight matrix of the input gate. Indicates the bias of the input gate;

[0023] Calculate candidate cell state , The weight matrix representing the cell state. Bias indicating cell state;

[0024] Calculate cell state ;

[0025] Calculate the outputs , This represents the weight matrix of the output gate. Indicates the bias of the output gate;

[0026] Calculate hidden states ;

[0027] Generate noisy episodic memory representations , Represents the vectorized task sample The length.

[0028] Furthermore, an attractor vector for the context memory representation is generated based on the noisy context memory representation, including:

[0029] Calculate the attractor fusion weight coefficients ;in, These are the trainable parameters for the gating network;

[0030] Calculate the denoised attractor memory representation vector ;in, Indicates the weighting coefficient. Represents the attractor memory matrix;

[0031] Generate contextual memory representation attractor vectors .

[0032] Furthermore, the overall training objective ,in, The parameters representing the large language model. This indicates the number of tasks to be learned. Indicates task The distribution of sample data, This indicates that the input is ,forward The output is The next word under the condition Output probability, loss function , The first element in the attractor vector representing episodic memory representation One portion, Represents the retrieval memory representation vector of the th element. Each component.

[0033] Furthermore, after backpropagation and optimization of the large language model based on this overall training objective, the following steps are also included:

[0034] For task samples After word segmentation and vectorization encoding, a length of [length missing] is obtained. vector sequence ;

[0035] vector sequence With real labels The data is concatenated, and the concatenated result is stored as a value in the storage memory.

[0036] Furthermore, the process of inference based on the trained large model includes:

[0037] For test tasks Perform word segmentation and vectorization encoding to obtain a length of vector sequence ;

[0038] Based on vector sequences Get test tasks The corresponding contextual memory representation attractor vector;

[0039] Characterizing episodic memory as attractor vectors and vector sequences After being assembled, the data is fed into the backbone network of the base model to complete the forward inference process.

[0040] A lifelong contextual learning system based on an attractor dynamic memory generation network, the system comprising:

[0041] The sample sampling module is used to obtain a batch of training samples from the training dataset or from the storage memory based on a sparse experience replay strategy when training a large language model, and to process each training sample in the batch. Sampling from storage memory bank training samples ;in, Indicates a task sample. This indicates the task sample. The true label, Indicates the number of samples taken from the storage memory bank One task sample, Represents task samples The real labels, the large language model includes a base model and a memory generation network;

[0042] The retrieval memory representation vector generation module is used for... Task Samples Generate a retrieval memory representation vector;

[0043] The contextual memory representation attractor vector generation module is used to generate vectorized task samples. The memory generation network generates contextual memory representation attractor vectors; the memory generation network includes an LSTM layer and an Attractor layer, wherein the LSTM layer is used to generate contextual memory representation attractor vectors based on the vectorized task samples. Noisy context memory representations are generated, and the Attractor layer is used to generate context memory representation attractor vectors based on the noisy context memory representations.

[0044] The backpropagation and optimization module is used to perform backpropagation based on the retrieval memory representation vector, the episodic memory representation attractor vector, and the training samples. Construct a general training objective, and backpropagate and optimize the large language model based on this objective to obtain the trained large language model.

[0045] An electronic device includes: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the lifelong contextual learning method based on attractor dynamic memory generation network as described above.

[0046] Compared with the prior art, the present invention has at least the following beneficial effects.

[0047] 1. Significantly improved computational efficiency, avoiding high-cost retrieval.

[0048] The drawbacks of existing technologies: Traditional continuous learning methods (such as those based on playback, regularization, or architecture) face significantly increased computational demands when applied to large language models (LLMs) due to the massive scale of model parameters. Furthermore, the external memory units introduced by architecture-based methods increase retrieval-related overhead during the inference phase.

[0049] Advantages of this invention: This invention introduces an attractor-based dynamic LSTM memory generation network to generate fixed-length context memory representation vectors during the training phase, aligning them with memory representations retrieved from external memory. These vectors are then used directly during the inference phase, avoiding the computational overhead of traditional external memory retrieval (such as Faiss retrieval). This not only reduces inference latency but also decreases the resources required for retrieval, making the method more suitable for resource-constrained real-world environments.

[0050] 2. Effectively alleviates catastrophic forgetting and negative transfer problems.

[0051] Disadvantages of existing technologies: Existing methods such as Parameter Efficient Fine-Tuning (PEFT) methods (such as LoRA) can alleviate forgetting by introducing a small number of trainable parameters, but they still have parameter collision problems, which cause the model to forget old tasks when learning new tasks, or negative transfer (i.e. old knowledge interferes with the learning of new tasks).

[0052] Advantages of this invention: This invention combines a sparse experience replay mechanism (randomly selecting old samples at a rate of 1% for retraining) with an episodic memory generation network. Sparse experience replay periodically reinforces old task skills, while episodic memory attractor vectors ensure the coordination of knowledge between old and new tasks through alignment optimization, thereby systematically mitigating catastrophic forgetting and negative transfer. This method can maintain the model's performance on old tasks without relying on task labels, while quickly adapting to new tasks.

[0053] 3. An attractor-based dynamic memory generation network is proposed to enhance the generalization ability and noise resistance of memory representations.

[0054] Disadvantages of existing technologies: Traditional external memory retrieval mechanisms rely on precise similarity matching, are sensitive to data noise, and may overfit the retrieved memory samples, leading to a decrease in generalization ability.

[0055] Advantages of this invention: This invention uses an attractor dynamic memory generation network to denoise and aggregate noisy LSTM hidden states, generating generalized contextual memory representation vectors. These vectors are aligned with retrieval memories during the training phase but used directly during the inference phase, avoiding noise interference during the retrieval process, thereby improving the model's robustness to out-of-distribution data or noisy environments.

[0056] 4. Enables efficient contextual meta-learning without the need for gradient updates.

[0057] Disadvantages of existing technologies: Traditional meta-learning usually requires local adaptation (such as gradient updates) to quickly adapt to new tasks, which increases the computational burden and is difficult to implement efficiently on large-scale models.

[0058] Advantages of this invention: This invention generates task-related contextual memory attractor vectors and leverages the contextual learning capabilities of large models to achieve contextual meta-learning without gradient updates. When encountering new tasks, the model can quickly learn from similar past task experiences, and when facing old tasks, it can effectively recall corresponding skills, thereby significantly reducing computational burden and improving adaptation speed. This method is closer to human learning patterns, achieving highly efficient "learn-as-you-go" adaptation.

[0059] 5. More in line with the realities of lifelong learning.

[0060] Disadvantages of existing technologies: Existing methods typically rely on task identification information or multiple traversals of training data, which is inconsistent with real-world scenarios where data flow distribution changes constantly and there are no explicit task identifiers.

[0061] Advantages of this invention: This invention assumes that the model performs only a single traversal of the training samples for each task and does not rely on any task identification information, thus more closely resembling the dynamically evolving real-world environment. Through contextual memory generation and sparse experience replay, the model can continuously learn from data from different distributions, gradually accumulating knowledge and enhancing its lifelong learning ability in dynamic environments. Attached Figure Description

[0062] Figure 1 Attractor-based dynamic memory generation network.

[0063] Figure 2 A lifelong contextual learning method based on dynamic memory generative networks. Detailed Implementation

[0064] The system will now be described in further detail with reference to the accompanying drawings. The examples given are for illustrative purposes only and are not intended to limit the scope of the system.

[0065] This invention proposes a lifelong contextual learning method based on an attractor-based dynamic memory generation network. The aim is to enable large models to rapidly adapt to new environments, effectively utilize historical experience to continuously learn new skills, and avoid forgetting already acquired abilities, thereby gradually accumulating knowledge to support lifelong learning. To align with human learning patterns, this method sets the model to perform a single traversal of the training samples for each task, without relying on any task identification information. This invention introduces an attractor-based dynamic LSTM memory generation network. During the training phase, it uses external memory units to retrieve similar task examples, which are then aggregated into fixed-length memory representations. The network is optimized by aligning dynamically generated contextual memory representation attractors with these representations. During the inference phase, the generated contextual memory representation attractors are directly used, avoiding the computational overhead of retrieval and enhancing the model's generalization ability and noise resistance. By generating task-related contextual memory attractor vectors, this method encourages the model to recall existing knowledge in old tasks and draw upon similar experiences in new tasks. This, combined with the contextual learning capabilities of large models, achieves efficient contextual meta-learning, significantly reducing the computational burden of local adaptation in traditional meta-learning. Furthermore, by incorporating a sparse experience replay mechanism, the learning outcomes from previous tasks are further consolidated, mitigating catastrophic forgetting and negative transfer problems in continuous learning. This method significantly enhances the adaptability and learning potential of large models in dynamic real-world environments. Figure 1 This invention provides a complete overview of the overall framework, detailing its architectural design and operational mechanism. The final model demonstrates outstanding comprehensive performance in continuous learning across multiple tasks.

[0066] This method aims to facilitate large-scale models to rapidly adapt to new environments and quickly learn new skills using past experience, while preserving learned skills and continuously accumulating knowledge to achieve lifelong learning capabilities. To ensure consistency with real-world human lifelong learning, this method also assumes that the model only traverses the training samples for each task once, and that the samples do not contain any task-specific information. The proposed method helps alleviate catastrophic forgetting and negative transfer problems, enhances the continuous and lifelong learning capabilities of large-scale models, and strengthens the application potential of existing models in dynamically evolving real-world environments.

[0067] (1) Attractor-based dynamic memory generation network.

[0068] This paper first proposes an attractor-based dynamic memory generation network, such as... Figure 1 As shown. Task samples are input into this network, and the network outputs attractor vectors representing contextual memories relevant to the task. This memory generation network consists of LSTM layers and attractor layers. The vectorized length is... The input sample is denoted as , ,in This represents the dimension of the word vector.

[0069] First, the input samples pass through an LSTM layer to obtain the output hidden state sequence. , , The dimension of the LSTM hidden state is consistent with the dimension of the word vector. The LSTM hidden state sequence is obtained by inputting the sample through formulas (1)-(6). The LSTM hidden state realizes the preliminary representation of the state of the input vector. By encoding the input sample, without introducing richer and longer relevant contextual information, this invention interprets the LSTM hidden state as a noisy contextual memory representation.

[0070] (1)

[0071] (2)

[0072] (3)

[0073] (4)

[0074] (5)

[0075] (6)

[0076] in, Represents the Gate of Oblivion Indicates the input gate. Indicates the state of candidate cells. Indicates cell state, Indicates the output gate. , , , Let represent the weight matrices for the forget gate, input gate, cell state, and output gate, respectively. , , , These represent the biases of the forget gate, input gate, cell state, and output gate, respectively. This represents the Sigmoid activation function.

[0077] Furthermore, noisy episodic memory representation It is fed into the Attractor layer to output the denoised context memory representation attractor vector.

[0078] like Figure 1 As shown, let Represents the attractor memory matrix, This represents the dimension of the attractor memory unit. This represents the number of attractor memory units. The attractor memory matrix is ​​a trainable parameter; the memory storage process is completed through training. The input contains noisy locations. Episodic memory representation First, the attractor fusion weight coefficients are obtained through the attractor gating unit, as shown in Formula 7:

[0079] (7)

[0080] in, These are the trainable parameters for the gated network. .

[0081] Then, as shown in Formula 8, the attractor memory is obtained by using the attractor fusion weight coefficient and the attractor memory matrix to retrieve the attractor memory, and then fused with the original noisy context memory representation proportionally to obtain the final denoised attractor memory representation vector.

[0082] (8)

[0083] in, This represents the weighting coefficient.

[0084] The final denoised attractor representation will be obtained:

[0085] (9)

[0086] (2) Lifelong contextual learning method based on dynamic memory generation network.

[0087] 2.1 Training phase.

[0088] This invention first introduces external memory units during the training phase. Faiss is used to construct these external memory units for memory storage and retrieval. Through similar memory retrieval, memory sample examples similar to the task to which the sample belongs can be obtained. For training samples... The training process is as follows, such as Figure 2 As shown on the left:

[0089] Step 1: External memory retrieval.

[0090] 1) For training samples ,Will Perform word segmentation and encode using the same word vector model as the storage stage;

[0091] 2) Using the encoded key, the most similar key is obtained based on the Faisal nearest neighbor retrieval method. A length of The sample sequence.

[0092] for The retrieved Each sample is denoted as .

[0093] Step 2: Retrieval and Memory Representation Vector Generation: First, generate the retrieved memory representation vector... Perform word segmentation and vectorization separately to obtain the vectorized matrix. Then, average pooling is performed along the first dimension to obtain the retrieval memory representation vector.

[0094] (10)

[0095] Step 3: Generation of episodic memory representation attractor vectors: The data is fed into an attractor dynamic memory generation network to obtain a denoised episodic memory attractor representation. (As shown in Formula 9).

[0096] Step 4: Calculate the loss function.

[0097] The distribution of MSE-Loss optimized alignment retrieval memory representation vector and contextual memory representation vector is constructed according to Formula 11.

[0098] (11)

[0099] The overall goal of model training is as follows:

[0100]

[0101] in, This indicates the number of tasks to be learned. Indicates task The distribution of sample data, This indicates that the input is ,forward The output is The next word under the condition The probability of the output. These are the parameters to be trained in the model. The model indicates that by optimizing parameters In order to minimize the aforementioned losses.

[0102] Step 5: Perform backpropagation and optimization on the model.

[0103] Step 6: External memory storage.

[0104] 1) For training samples The input part of the sample Perform word segmentation and vectorization encoding;

[0105] 2) Use vectorized encoding as the key to... According to length Truncated input With tags The concatenated result is a value, which is stored in the faiss storage module.

[0106] Step 7: Sparse experience replay.

[0107] This invention employs sparse experience replay at a rate of 1%. Through sparse experience replay, it continuously reinforces the learning of old tasks and skills, thereby further mitigating the catastrophic forgetting problem during continuous learning. Throughout the training process, this invention randomly samples from the memory bank at fixed intervals and updates the model synchronously based on the sampling results. This paper uses a sparse experience replay strategy, that is, after processing every 10,000 new samples, 100 memory samples (i.e., 1%) are randomly selected for replay training.

[0108] 1) Randomly select 1% of the experience playback samples from the external memory module. .

[0109] 2) Repeat steps 1-5 for the experience playback sample to complete the experience playback.

[0110] 2.2 Reasoning stage.

[0111] During the inference phase, this invention uses contextual memory representation attractor vectors instead of retrieval memory representation vectors, avoiding the additional performance overhead of external memory retrieval. Furthermore, by utilizing contextual memory network representations instead of memory retrieval, the representations exhibit stronger generalization and noise resistance. Figure 2 As shown on the right.

[0112] (1) Samples for each task By using an attractor-based dynamic memory generation network, contextual representation attractor vectors related to the task to which the sample belongs are generated. As shown in Formula 9.

[0113] For old tasks, the generated contextual representation attractor vectors can prompt large models to recall contextual memories of related tasks, ensuring that learned tasks and skills are not lost or forgotten, so as to achieve continuous accumulation of capabilities.

[0114] For new tasks, the generated context representation attractor vector represents the old context expression that is most similar to the new task. This context vector enables the large model to quickly adapt to new tasks and new environments and learn new skills by utilizing old contexts and existing experience.

[0115] (2) Combine the context representation attractor vector with the input sample After word segmentation and vectorization, the vectorized representations are concatenated and fed into the backbone network of the base model to complete the forward inference process.

[0116] For example:

[0117] For the sample input: "University of A Hires Coach X, University of A's CoachX is hired as University of B's ​​football coach and vows to take Team B to the Championship Bowl for the first time since 1968.", the sample label is... "Sports";

[0118] The sample input was segmented into words to obtain: [“University”, “of”, …, “1968”];

[0119] Then, the word segmentation results are vectorized through the model's embedding layer to obtain a vectorized representation. An example after matrix transposition is shown below:

[0120] = [[0.1, 0.7, …, 0.2], / / Example of word vectors from University, with dimensions of

[0121] [0.3, 0.2, …, 0.9], / / Example of word vectors of

[0122]

[0123] [0.1, 0.7, …, 0.2],] / / Example word vectors from 1968

[0124] Will The input is fed into an attractor-based dynamic memory generation network, as shown in Equation 9, to obtain the context representation attractor vector. ,Will The representation after word segmentation and vectorization of the sample input The data is then spliced ​​together and fed into the input part of the multi-head attention module of the backbone network to complete the forward inference process of the base model.

[0125] In summary, by replacing traditional external memory retrieval with attractor dynamic memory networks, efficient and generalized contextual memory is achieved. Combined with alignment optimization and sparse replay, catastrophic forgetting and negative transfer problems are solved with low computational cost, ultimately enhancing the lifelong learning capability of large models in dynamic real-world environments. The key points of this invention are mainly reflected in the following aspects.

[0126] 1. A dynamic memory generation network based on attractors is proposed. A dynamic memory generation network consisting of LSTM layers and attractor layers is designed to generate denoised contextual memory representation attractor vectors. The input sample sequence is processed by LSTM layers to generate a hidden state sequence, which is considered a "noisy contextual memory representation." This sequence is initially encoded using standard LSTM gating mechanisms (input gate, forget gate, output gate, etc.). A trainable attractor memory matrix and gating network parameters are introduced. By fusing the attractor weights, the noisy representation is optimized into a denoised attractor representation vector. This process enhances the generalization ability and noise resistance of the memory representation.

[0127] 2. A method for aligning external retrieval memory with generated memory representations is proposed. An external memory storage and retrieval system is constructed using Faiss, retrieving sample examples similar to the current task. The retrieved samples are vectorized and average-pooled to generate retrieval memory representation vectors. The generated attractor representation vectors are then forced to align with the retrieval memory representation vectors using the MSE loss function, ensuring that the contextual memory representations accurately capture task-related information. The total loss combines language model loss and alignment loss to achieve end-to-end optimization.

[0128] 3. A contextual meta-learning mechanism is designed, which directly utilizes the contextual learning capabilities of a large model by dynamically generated contextual memory attractor vectors, achieving rapid adaptation and contextual meta-learning without gradient updates. For new tasks, the attractor vectors represent experience from similar old tasks, prompting the model to adapt quickly; for old tasks, the attractor vectors effectively recall existing skills, preventing forgetting. Unlike traditional meta-learning that requires local adaptation (such as gradient updates), this method achieves task switching simply by prefix concatenation (concatenating the attractor vector with the input sample), significantly reducing computational overhead during inference.

[0129] 4. Efficient Inference and Generalized Memory Generation: Direct Use of Attractor Vectors: During the inference phase, external memory retrieval is unnecessary; the contextual memory attractor vectors output by the dynamic memory generation network are directly used for forward inference. This avoids the computational latency caused by retrieval, and the denoising and generalization properties of attractor vectors improve the model's robustness in noisy environments. Knowledge Accumulation and Recall: Attractor vectors can automatically recall old knowledge or draw on similar experiences based on task type, achieving continuous knowledge accumulation and enhancing the model's adaptability in dynamic environments.

[0130] 5. A sparse experience replay mechanism is introduced to systematically alleviate catastrophic forgetting and negative transfer problems in continuous learning. The sparse experience replay strategy is incorporated into the overall framework to periodically strengthen the training of skills for old tasks, further mitigating catastrophic forgetting without relying on task labels. Simultaneously, contextual memory is used to guide and reduce negative transfer effects between tasks, enhancing the stability and scalability of the model in lifelong learning in dynamic real-world environments.

[0131] Although specific embodiments of the system have been disclosed for illustrative purposes to aid in understanding and implementing the system, those skilled in the art will understand that various substitutions, variations, and modifications are possible without departing from the spirit and scope of the system and the appended claims. Therefore, the system should not be limited to the content disclosed in the preferred embodiments, and the scope of protection claimed by the system is determined by the scope defined in the claims.

Claims

1. A lifelong contextual learning method based on attractor dynamic memory generation networks, characterized in that, The method includes: When training a large language model, a batch of training samples is obtained from the training dataset or from the storage memory based on a sparse experience replay strategy, and each training sample in the batch is processed... Sampling from storage memory bank training samples ;in, Indicates a task sample. This indicates the task sample. The true label, Indicates the number of samples taken from the storage memory bank One task sample, Represents task samples The real labels, the large language model includes a base model and a memory generation network; based on Task Samples Generate a retrieval memory representation vector; Vectorized task samples The memory generation network generates contextual memory representation attractor vectors; the memory generation network includes an LSTM layer and an Attractor layer, wherein the LSTM layer is used to generate contextual memory representation attractor vectors based on the vectorized task samples. Noisy context memory representations are generated, and the Attractor layer is used to generate context memory representation attractor vectors based on the noisy context memory representations. Based on retrieval memory representation vectors, episodic memory representation attractor vectors, and training samples Construct a general training objective, and backpropagate and optimize the large language model based on this general training objective to obtain the trained large language model; Inference is performed based on the trained large model to obtain the labels of the test text; The step of performing text reasoning based on the trained large model to obtain the label of the test text includes: For test text Perform word segmentation and vectorization encoding to obtain a length of vector sequence ; Based on vector sequences Get the test text The corresponding contextual memory representation attractor vector; Characterizing episodic memory as attractor vectors and vector sequences After being concatenated, the data is fed into the backbone network of the base model to complete forward inference, thus obtaining the test text. Tags; Among them, based on the vectorized task samples Generate noisy episodic memory representations, including: Initialize the LSTM layer to obtain the initial hidden state. and initial cell state ; Computational forget gate , Represents the vectorized task sample The One portion, This represents the Sigmoid activation function. The weight matrix represents the forget gate. Indicates the bias of the forget gate; Calculate input gate , This represents the weight matrix of the input gate. Indicates the bias of the input gate; Calculate candidate cell state , The weight matrix representing the cell state. Bias indicating cell state; Calculate cell state ; Calculate the output gate , This represents the weight matrix of the output gate. Indicates the bias of the output gate; Calculate hidden states ; Generate noisy episodic memory representations , Represents the vectorized task sample Length; The generation of context memory representation attractor vectors based on noisy context memory representations includes: Calculate the attractor fusion weight coefficients ;in, These are the trainable parameters for the gating network; Calculate the denoised attractor memory representation vector ;in, Indicates the weighting coefficient. Represents the attractor memory matrix; Generate contextual memory representation attractor vectors ; Among them, the overall training objective , The parameters representing the large language model. This indicates the number of tasks to be learned. Indicates task The distribution of sample data, This indicates that the input is ,forward The output is The next word under the condition Output probability, loss function , The first element in the attractor vector representing episodic memory representation One portion, Represents the retrieval memory representation vector of the th element. One portion, This represents the dimension of the attractor memory unit.

2. The method according to claim 1, characterized in that, For each training sample in this batch of training samples Sampling from storage memory bank training samples ,include: Task Sample Vectorized into a length of vector sequence ; For vector sequences Average pooling is performed, and the result of average pooling is used as the key to perform Faisal nearest neighbor retrieval in the storage memory to obtain the results with the training samples. Most similar training samples .

3. The method according to claim 1, characterized in that, based on Task Samples Generate a retrieval memory representation vector, including: For each task sample After word segmentation and vectorization, a length of [length missing] is obtained. vector sequence ;in, , Word vectors The dimension; Based on vector sequence Generate a vectorized matrix ; Along the dimension Perform average pooling to obtain the retrieval memory representation vector. ;in, Represents the retrieval memory representation vector The first in Each component.

4. The method according to claim 1, characterized in that, After backpropagation and optimization of the large language model based on this overall training objective, the following steps are also included: For task samples After word segmentation and vectorization encoding, a length of [length missing] is obtained. vector sequence ; vector sequence With real labels The data is concatenated, and the concatenated result is stored as a value in the storage memory.

5. A lifelong contextual learning system based on an attractor dynamic memory generation network, characterized in that, The system includes: The sample sampling module is used to obtain a batch of training samples from the training dataset or from the storage memory based on a sparse experience replay strategy when training a large language model, and to process each training sample in the batch. Sampling from storage memory bank training samples ;in, Indicates a task sample. This indicates the task sample. The true label, Indicates the number of samples taken from the storage memory bank One task sample, Represents task samples The real labels, the large language model includes a base model and a memory generation network; The retrieval memory representation vector generation module is used for... Task Samples Generate a retrieval memory representation vector; The contextual memory representation attractor vector generation module is used to generate vectorized task samples. The memory generation network generates contextual memory representation attractor vectors; the memory generation network includes an LSTM layer and an Attractor layer, wherein the LSTM layer is used to generate contextual memory representation attractor vectors based on the vectorized task samples. Noisy context memory representations are generated, and the Attractor layer is used to generate context memory representation attractor vectors based on the noisy context memory representations. The backpropagation and optimization module is used to perform backpropagation based on the retrieval memory representation vector, the episodic memory representation attractor vector, and the training samples. Construct a general training objective, and backpropagate and optimize the large language model based on this general training objective to obtain the trained large language model; The inference module performs inference based on the trained large model to obtain the labels of the test text; The step of performing text reasoning based on the trained large model to obtain the label of the test text includes: For test text Perform word segmentation and vectorization encoding to obtain a length of vector sequence ; Based on vector sequences Get the test text The corresponding contextual memory representation attractor vector; Characterizing episodic memory as attractor vectors and vector sequences After being concatenated, the data is fed into the backbone network of the base model to complete forward inference, thus obtaining the test text. Tags; Among them, based on the vectorized task samples Generate noisy episodic memory representations, including: Initialize the LSTM layer to obtain the initial hidden state. and initial cell state ; Computational forget gate , Represents the vectorized task sample The One portion, This represents the Sigmoid activation function. The weight matrix represents the forget gate. Indicates the bias of the forget gate; Calculate input gate , This represents the weight matrix of the input gate. Indicates the bias of the input gate; Calculate candidate cell state , The weight matrix representing the cell state. Bias indicating cell state; Calculate cell state ; Calculate the output gate , This represents the weight matrix of the output gate. Indicates the bias of the output gate; Calculate hidden states ; Generate noisy episodic memory representations , Represents the vectorized task sample Length; The generation of context memory representation attractor vectors based on noisy context memory representations includes: Calculate the attractor fusion weight coefficients ;in, These are the trainable parameters for the gating network; Calculate the denoised attractor memory representation vector ;in, Indicates the weighting coefficient. Represents the attractor memory matrix; Generate contextual memory representation attractor vectors ; Among them, the overall training objective , The parameters representing the large language model. This indicates the number of tasks to be learned. Indicates task The distribution of sample data, This indicates that the input is ,forward The output is The next word under the condition Output probability, loss function , The first element in the attractor vector representing episodic memory representation One portion, Represents the retrieval memory representation vector of the th element. One portion, This represents the dimension of the attractor memory unit.

6. An electronic device, characterized in that, The electronic device includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, it implements the lifelong contextual learning method based on attractor dynamic memory generation network as described in any one of claims 1-4.