Artificial intelligence memory two-stage consolidation method and system based on slow wave and desynchronized sleep simulation

CN123014018APending Publication Date: 2026-10-30NANJING PENGCHEN QIZHI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202611518544.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-29
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0007]因此,本发明解决的技术问题是:现有记忆管理缺乏睡眠启发的双阶段巩固与知识图谱动态演化相融合的系统架构,无法实现情景记忆向语义知识的高效转化与长期巩固

Benefits of technology

[0018]本发明的有益效果在于,与现有技术相比,本发明的技术效果如下:本发明通过模拟慢波睡眠与异相睡眠的双阶段巩固机制,构建了从情景记忆优先级筛选、多模式提取、知识图谱更新到推断建边与摘要压缩的完整技术闭环。与现有技术相比,本发明首次将睡眠启发的双阶段巩固架构与知识图谱动态演化深度融合,在多维度优先级评估中引入情绪强度、未来有用性等前瞻性指标,解决了传统方案仅依赖单一维度评估的局限性;同时通过知识图谱的远距离推断建边机制实现了知识关联的主动挖掘与动态扩展,配合长文本摘要压缩与冷热存储分层归档,显著提升了系统的长期可扩展性与知识表征效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123014018A_ABST
    Figure CN123014018A_ABST
Patent Text Reader

Abstract

The application provides a slow wave and heterophase sleep simulation-based artificial intelligence memory two-stage consolidation method and system, and belongs to the technical field of knowledge graphs. The two-stage consolidation mechanism of slow wave sleep and heterophase sleep is simulated, a complete technical closed loop from scene memory priority screening, multi-mode extraction, knowledge graph updating to inference edge construction and abstract compression is constructed, and the limitation that a traditional scheme only depends on single dimension evaluation is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of knowledge graph technology, specifically relating to an artificial intelligence memory two-stage consolidation method and system based on slow wave and REM sleep simulation. Background Technology

[0002] In recent years, one of the core challenges faced by artificial intelligence systems in continuous interactive scenarios has been how to effectively manage the ever-accumulating episodic memory, ensuring that it maintains stable representations of historical experiences while reserving sufficient representational space for the integration of new knowledge over long-term operation. Inspired by the memory consolidation theory in neuroscience, which reveals that the gradual migration of memory representations from the hippocampus to the neocortex mainly occurs during sleep, especially during slow-wave sleep, the collaborative dialogue between the hippocampus and neocortex is crucial for long-term memory retention. Existing research revolves around the sleep paradigm, allowing models to extract short-term, fragile memories into stable long-term knowledge; some works have further proposed the REM-Sleep protocol, utilizing noise replay and synaptic homeostasis mechanisms during offline sleep to stabilize memory representations. In terms of technical implementation, knowledge graphs, due to their structured representation capabilities, have been widely used as the basic carrier for memory storage and reasoning; priority evaluation mechanisms based on cognitive features have also been introduced into memory scheduling and consolidation processes to achieve optimal allocation of storage resources over time. However, how to organically integrate sleep-inspired two-stage consolidation mechanisms, dynamic evolution of knowledge graphs, and multi-dimensional memory priority assessment within a unified system architecture remains a pressing technical challenge.

[0003] For example, patent application CN122509260A discloses a continuous learning method and system based on two-stage sleep-inspired consolidation. This method sequentially executes a slow-wave sleep (SWS) consolidation stage and a rapid eye-tracking (REM) consolidation stage between consecutive tasks. In the SWS stage, the priority playback probability is calculated based on the predicted loss and sampled, and the network parameters are updated using joint anchoring regularization. In the REM stage, the mixed importance score of the parameters is calculated, and synaptic global scaling and soft parameter pruning are performed. While this technical solution effectively mitigates catastrophic forgetting, the consolidation object is limited to neural network parameters and does not involve the structured processing and semantic transformation of the episodic memory content itself, thus failing to achieve a substantial leap from episodic memory to semantic knowledge.

[0004] Furthermore, patent application CN121957921A discloses a memory consolidation method and system based on knowledge graphs and cognitive features. This method constructs an initial knowledge graph by acquiring a set of learned knowledge, obtains basic cognitive resistance based on interaction time and error correction frequency, and obtains dynamic cognitive resistance by integrating blank time and consolidation frequency. It then calculates the urgency of consolidation and generates a scheduling queue. While this technical solution achieves precise and balanced resource scheduling, the knowledge graph construction is a one-time extraction, lacking a support mechanism for continuous evolution and associative inference after the injection of new knowledge; moreover, the priority evaluation does not incorporate the emotional intensity dimension or forward-looking prediction of future usefulness. Summary of the Invention

[0005] The purpose of this section is to outline some aspects of the embodiments of the present invention and to briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section, as well as in the abstract and title of the present application, to avoid obscuring the purpose of this section, the abstract and title of the invention. Such simplifications or omissions shall not be used to limit the scope of the present invention.

[0006] In view of the aforementioned existing problems, the present invention is proposed.

[0007] Therefore, the technical problem solved by this invention is that the existing memory management system architecture, which lacks the integration of sleep-inspired two-stage consolidation and dynamic evolution of knowledge graphs, cannot achieve efficient conversion and long-term consolidation of contextual memory into semantic knowledge.

[0008] To address the aforementioned technical problems, the present invention provides the following technical solution: A two-stage consolidation method for AI memory based on slow wave and REM sleep simulation includes: during periods of low system load, acquiring contextual memories that have not been converted into semantic knowledge; calculating consolidation priority scores based on a weighted sum of normalized emotional intensity, future usefulness, reward value, and retrieval frequency; and selecting the contextual memories whose scores meet preset conditions as a candidate set to be consolidated. The candidate set to be consolidated is processed in batches. Multiple types of patterns are extracted from each of the context memories to obtain a pattern set. The pattern set is updated to the memory storage, which includes at least a knowledge graph. In the updated knowledge graph, recently added nodes are selected as seed nodes. Long-distance node pairs with a distance within a preset range are searched. The connection value is calculated based on a weighted sum of the number of common neighbors, co-occurrence Jaccard similarity, co-occurrence frequency, and path diversity. New edges marked as inference are created between long-distance node pairs with a connection value exceeding a preset value threshold. Compact summaries are generated for context memories in the candidate set to be consolidated that have a length exceeding a preset length. The original dialogue content is archived to cold storage. The original content in the context memory is replaced with the compact summaries. The emotional intensity metadata and named entity tags are retained in the replaced context memories.

[0009] In a preferred embodiment of the present invention, the following weights are specified: the weight of the emotional intensity is greater than the weight of the future usefulness, the weight of the future usefulness is greater than the weight of the reward value, and the weight of the reward value is greater than the weight of the retrieval frequency; the preset condition is to select memories in the memory set to be evaluated whose consolidation priority score is within a preset ranking ratio range as the candidate set to be consolidated; the future usefulness is obtained through a prediction model, which predicts the probability of future retrieval based on multiple feature dimensions of the contextual memory and multiplies it by a time decay factor; the input features of the prediction model are encoded and converted into numerical vectors; the reward value is obtained by accumulating the scores of the contextual memory on multiple utility dimensions and truncating them to a preset upper limit; the retrieval frequency is normalized using the maximum number of retrievals in the current memory set to be evaluated as the denominator.

[0010] In a preferred embodiment of the present invention, the various types of patterns include entity-relationship patterns, temporal patterns, causal patterns, and user preference patterns; when extracting the entity-relationship patterns, named entities are identified from the contextual memory, entity pairs are classified according to their relationships, and filtered based on confidence levels; when extracting the temporal patterns, action units are extracted from the contextual memory and action sequences are generated in chronological order; when extracting the causal patterns, causal relationships between events are identified from the contextual memory through dependency parsing, and causal pairs are extracted; when extracting the user preference patterns, preference expressions are identified from the contextual memory, and preference objects, preference polarity, and intensity values ​​are extracted.

[0011] In a preferred embodiment of the present invention, when updating the pattern set to the memory storage: the entity-relationship pattern is converted into nodes and edges of the knowledge graph, and the weights of existing edges are updated according to time decay and current evidence strength; the temporal pattern is registered to the program memory; the causal pattern is written into the knowledge graph in the form of causal relationship edges, and single-step transitive reasoning is performed on the newly written causal edges in the knowledge graph in the current round, and the newly generated causal edges are stored in the knowledge graph; the depth of the single-step transitive reasoning is limited to 1 level, and the newly generated inferred causal edges do not participate in the next round of reasoning; the user preference pattern is written into the user profile, and multiple records of the same preference object are merged.

[0012] As a preferred embodiment of the present invention, the compact summary performs factual compression on the contextual memory using a language model; key entities and user intent are retained after compression; the summary length does not exceed a preset word count threshold; and the original dialogue content is archived to the cold storage using timestamps as indexes.

[0013] In a preferred embodiment of the present invention, the seed node is a node whose creation time is within a preset number of days prior to the start date of the current consolidation cycle and whose degree is not less than a preset degree threshold, wherein the preset degree threshold is a positive integer; the preset range is a pair of nodes whose graph distance is equal to two hops; and each component of the connection value is normalized and then weighted and summed.

[0014] In a preferred embodiment of the present invention, when creating a new edge marked as inference, it is checked whether a direct edge already exists between the seed node and the distant node; if so, it is skipped. Based on the combination of relation types connected by their common neighbors, the inferred relation type is determined according to a preset mapping rule. If multiple candidate relation types with the highest concurrent frequencies appear, the sum of the total connection weights of the common neighbors corresponding to each candidate pair is compared, and the pair corresponding to the largest sum of connection weights is selected as the final mapping basis. The new edge is created using the inferred relation type, and the inference confidence of the new edge is stored as a weight attribute. After creation, the new edge is upgraded or eliminated based on the verification feedback in subsequent user interactions. The verification feedback includes positive and negative feedback. Positive feedback is when the standard names or normalized equivalent references of the nodes at both ends of the new edge appear simultaneously in the user's subsequent input dialogue content. The negative feedback is detected by performing dependency parsing on the user's subsequent input dialogue content; when the user input simultaneously detects the standard names or normalized equivalent references of the nodes at both ends of the new edge and any negative word from a preset set of negative trigger words, it is determined to be negative feedback.

[0015] As a preferred embodiment of the present invention, after creating a new edge marked as inference, a post-processing step is further included: screening the context memory entries carrying emotion intensity metadata in the candidate set to be consolidated, adjusting the original amplitude stored in the emotion intensity metadata by attenuation, and storing the attenuated original amplitude in the memory record for use in the next consolidation priority score calculation, until a preset termination condition is met.

[0016] In a preferred embodiment of the present invention, the inference confidence level is the product of the weights of each edge on the path between the seed node and the distant node.

[0017] The present invention also provides an artificial intelligence memory two-stage consolidation system based on slow wave and REM sleep simulation, including: a priority calculation module, used to acquire situational memories that have not been converted into semantic knowledge during low system load periods, calculate consolidation priority scores based on the weighted sum of normalized emotional intensity, future usefulness, reward value and retrieval frequency, and select the situational memories whose scores meet preset conditions as a candidate set to be consolidated; The pattern extraction module is used to process the candidate set to be consolidated in batches, extract multiple types of patterns from each of the contextual memories, and obtain a pattern set. A memory update module is used to update the pattern set to the memory storage, wherein the memory storage includes at least a knowledge graph; The edge inference module is used to select recently added nodes as seed nodes in the updated knowledge graph, find long-distance node pairs within a preset range, calculate the connection value based on the weighted sum of the number of common neighbors, co-occurrence Jaccard similarity, co-occurrence frequency and path diversity, and create new edges marked as inference between long-distance node pairs whose connection value exceeds a preset value threshold. The summary compression module is used to generate compact summaries for the context memories in the candidate set to be consolidated that exceed a preset length, archive the original dialogue content to cold storage, replace the original content in the context memory with the compact summary, and retain the emotion intensity metadata and named entity tags in the replaced context memory.

[0018] The beneficial effects of this invention are as follows, compared with the prior art: This invention constructs a complete technical closed loop from episodic memory priority screening, multi-pattern extraction, knowledge graph updating to inference edge building and summary compression by simulating a two-stage consolidation mechanism of slow-wave sleep and REM sleep. Compared with the prior art, this invention is the first to deeply integrate the sleep-inspired two-stage consolidation architecture with the dynamic evolution of the knowledge graph, introducing forward-looking indicators such as emotional intensity and future usefulness into the multi-dimensional priority evaluation, solving the limitation of traditional solutions that rely only on single-dimensional evaluation; at the same time, it realizes the active mining and dynamic expansion of knowledge associations through the long-distance inference edge building mechanism of the knowledge graph, and with the long text summary compression and cold and hot storage hierarchical archiving, it significantly improves the long-term scalability and knowledge representation efficiency of the system. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of the priority screening stage process in this invention.

[0020] Figure 2 This is a schematic diagram of the multi-mode extraction and memory update stage in this invention.

[0021] Figure 3 This is a schematic diagram of the edge construction and summary compression stages in this invention. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this invention. The embodiments described in this application are merely some embodiments of this invention, and not all embodiments. Based on the spirit of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of this invention.

[0023] like Figures 1-3 As shown, the two-stage artificial intelligence memory consolidation method based on slow-wave and REM sleep simulation of the present invention includes: S1: During periods of low system load, acquire contextual memories that have not yet been converted into semantic knowledge. Calculate a consolidation priority score based on a weighted sum of normalized emotion intensity, future usefulness, reward value, and retrieval frequency. Select contextual memories that meet preset criteria as a candidate set for consolidation. S2: Process the candidate set in batches, extracting multiple types of patterns from each contextual memory to obtain a pattern set. S3: Update the pattern set to the memory storage, which includes at least a knowledge graph. S4: In the updated knowledge graph, select recently added nodes as seed nodes. Find distant node pairs within a preset distance range. Calculate the connection value based on a weighted sum of common neighbor count, co-occurrence Jaccard similarity, co-occurrence frequency, and path diversity. Create new edges marked as inference between distant node pairs whose connection value exceeds a preset value threshold. S5: Generate compact summaries for contextual memories in the candidate set for consolidation that exceed a preset length. Archive the original dialogue content to cold storage. Replace the original content in the contextual memory with the compact summaries, retaining emotion intensity metadata and named entity tags in the replaced contextual memories.

[0024] In some embodiments, the two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation provided by the present invention includes the following steps in step S1: Step S111: Obtain the current CPU utilization, memory usage, and disk I / O queue depth of the system. When the CPU utilization is lower than a first preset threshold (e.g., 40%), the memory usage is lower than a second preset threshold (e.g., 60%), and the disk I / O queue depth is less than a third preset threshold (e.g., 8), it is determined that the current time has entered a low-load period.

[0025] During periods of low load, entries whose status flag field value is to be consolidated are read from the contextual memory database. The status flag is initialized to be consolidated when the memory is first generated, and changes to solidified or abandoned after the memory is successfully converted into semantic knowledge or undergoes a preset round of consolidation processing.

[0026] The retrieved entries constitute a set of memories to be evaluated. Each contextual memory is associated with at least its generation timestamp, dialogue context field, emotion intensity metadata, and historical retrieval count.

[0027] Step S112: For each episodic memory in the memory set to be evaluated, perform quantitative processing in the following four dimensions: A: The pre-stored emotion intensity metadata in the context memory is read. The sentiment analysis module uses a sentiment regression model based on a pre-trained language model fine-tuning, specifically the RoBERTa-wwm-ext-large model, fine-tuned on a Chinese sentiment analysis dataset. The dataset can be a public dataset (such as ASAP-Sentiment) or a dialogue sentiment corpus constructed according to industry-standard annotation specifications. The output is the effect value (range -1 to 1) and arousal level (range -1 to 1). The original amplitude is defined as the square root of the sum of the squares of the effect value and arousal level, with a value range of [0, √2].

[0028] The model employs the MSE loss function, the Adam optimizer, a learning rate of 3e-5, and a maximum training epoch of 20. An early stopping strategy is introduced, terminating training prematurely if the loss value on the validation set does not decrease for five consecutive epochs. In practice, convergence occurs around epochs 12-15. The Pearson correlation coefficient of the effectiveness value on the validation set is no less than 0.85. This model requires a GPU with at least 16GB of VRAM for deployment.

[0029] The original amplitude is mapped to the closed interval [0,1] using the min-maximum linear normalization method to obtain the normalized sentiment intensity value.

[0030] B: The contextual memory is input into a pre-trained future usefulness prediction model. This model employs a sequence encoding structure based on a Transformer encoder, with 4 encoder layers, 256 hidden layers, and 4 attention heads. The model uses a pre-trained BERT-base-chinese as the bottom-level feature extractor and a binary classification feedforward network at the top level to output the probability that the memory will be actively retrieved by the system within the next 7 natural days. Training data consists of 100,000 contextual memory samples from the system's historical dialogue logs, annotated with subsequent retrieval behaviors, divided into training, validation, and test sets in an 8:1:1 ratio. The training phase uses a binary cross-entropy loss function, an AdamW optimizer, a learning rate of 2e-5, and a batch size of 32. An early stopping strategy terminates training when the validation set loss value does not decrease for three consecutive rounds. The F1 score on the test set is no less than 0.82. In the input features, all numerical dimensions (interaction rounds, proportion of interrogative sentences, and number of implicit citations) are standardized using Z-score, and the latent information density is the ratio of proper nouns (obtained through part-of-speech tagging) to the total number of words in the memorized text.

[0031] The input features are numerically encoded and concatenated into a fixed-length feature vector, which is then input into the model. The model outputs a predicted probability that the memory will be actively retrieved by the system within a preset time period (e.g., 7 calendar days). This predicted probability is then multiplied by a time decay factor, the expression for which is: ,in, The preset retrieval attenuation coefficient (with a value range of 0.01 to 0.1, and a unit of 1 / hour) is used. The product of the time interval (in hours) between the current moment and the moment the memory was generated is used as a normalized future usefulness value.

[0032] C: Accumulate the contribution scores of contextual memory across multiple utility dimensions. Utility dimensions include, but are not limited to: the contribution of the dialogue to the user's final task completion (based on task success rate statistics after dialogue interruption), the intensity score of the user's positive emotional feedback during the interaction, and the improvement in subsequent question-and-answer coverage due to new entities introduced in the dialogue. The task completion contribution score is: if the interaction session containing the dialogue is ultimately marked as a task success, this dimension is assigned a value of 1; if it is marked as a task failure, it is assigned a value of 0; if the task status is unclear, it is assigned a value of 0.5. The positive emotional feedback intensity score is: the positive parts of the sentiment scores of each user statement in the dialogue are accumulated, where the sentiment scores are output by a pre-trained sentiment analysis model, and the value range is [-1, 1]. The improvement in new entity coverage is: the proportion of the number of new named entities introduced in the dialogue that do not yet exist in the knowledge graph divided by the total number of entities in the knowledge graph at the end of the previous consolidation cycle; if the total number of entities is 0, the score for this dimension is 0.

[0033] The scores of each dimension are summed up, and the sum is compared with a preset upper limit (e.g., 10). If it exceeds the preset upper limit, it is truncated to the upper limit. The truncated result is then divided by the preset upper limit to obtain the normalized reward value.

[0034] D: Count the total number of times the scene memory has been retrieved in the system's global operation log. Divide the total number of historical retrievals by the maximum number of historical retrievals in the current set of memories to be evaluated, and use the resulting ratio as the normalized retrieval frequency.

[0035] If the total number of historical retrievals of all episodic memories in the current memory set to be evaluated is 0, that is, the maximum number of historical retrievals is 0, then the normalized retrieval frequency of all episodic memories is 0.

[0036] Step S113: Assign a first weight to the normalized emotion intensity, future usefulness, reward value, and retrieval frequency. Second weight Third weight Fourth weight Each weight satisfies The magnitude relationship. As an optional implementation, the first weight is 0.40, the second weight is 0.30, the third weight is 0.20, and the fourth weight is 0.10, with the sum of the four being 1.

[0037] The consolidation priority score is obtained by multiplying each of the above normalized scores by its corresponding weight and then summing the results. The calculation formula is as follows: ; in, To normalize the intensity of emotion, To normalize future usefulness, To normalize reward value, This represents the normalized search frequency.

[0038] It should be noted that, under the weighted ranking, memories with high emotional intensity are prioritized during low-load consolidation periods, which is conducive to the timely accumulation of interactive experiences that have a significant impact on user experience; future usefulness is secondary, ensuring that the system can proactively retain information carriers that have the potential to support complex question-and-answer scenarios in the long term; reward value is secondary, taking into account the reinforcement of memories of historically high-reward behaviors; retrieval frequency has the lowest weight, to prevent the system from ignoring sparse but potentially valuable long-tail information by overly catering to high-frequency access data, thereby achieving the optimal allocation of limited computing resources across different value dimensions as a whole.

[0039] Step S114: Sort all scene memories in the current memory set to be evaluated in descending order according to their consolidation priority scores. Using the beginning of the sorting sequence as a reference, select scene memories whose ranking falls within a preset ranking ratio range as the final output candidate set to be consolidated. The preset ranking ratio is determined by the ratio parameter P in the system configuration file, and the value of P is set to be between the top 10% and the top 30%. For example, the top 20% of memory entries are selected by default in a single consolidation cycle.

[0040] The specific value of the proportional parameter is dynamically adjusted based on the system's preset duration of low-load periods. For example, if the estimated duration of a low-load period is greater than 60 minutes, the proportional parameter is increased to improve the throughput of a single consolidation; if it is less than 30 minutes, the proportional parameter is decreased accordingly to prevent processing timeouts.

[0041] In some embodiments, the two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation provided by the present invention includes the following steps in step S2: Step S211: Load all scenario memory entries from the output candidate set to be consolidated into the memory buffer at once to construct a processing queue. For each scenario memory in the processing queue, perform text cleaning first. Text cleaning includes at least removing redundant spaces, standardizing punctuation, and standardizing dialogue character tags. The cleaned text serves as the input source for subsequent multi-type pattern extraction.

[0042] Step S212 involves performing named entity recognition on the cleaned contextual memory text. Named entity recognition employs a sequence labeling model based on a bidirectional long short-term memory network combined with a conditional random field (BiLSTM-CRF). The identified entity types include at least person names, organization names, place names, time expressions, and domain-specific concepts. After recognition, entities appearing in the same sentence or adjacent sentences are paired to form candidate entity pairs.

[0043] For each candidate entity pair, a pre-trained relation classification model is used to determine the relation type. The model uses BERT-base-chinese as its backbone network and is fine-tuned on a custom dialogue relation classification corpus containing 50 relation types and 200,000 manually annotated entity pairs. The model input format is: [CLS]sentence text[SEP]head entity[SEP]tail entity[SEP]. The output vector at the [CLS] position is passed through a fully connected layer and a Softmax layer to output the probability distribution of each relation type. The confidence threshold of 0.70 is determined based on the precision-recall curve on the validation set. The model uses a cross-entropy loss function, a learning rate of 2e-5, a batch size of 16, and a maximum training epoch of 10.

[0044] Select the relation type with a probability value exceeding the preset confidence threshold (e.g., 0.70) as the legitimate relation of the entity pair, filter out candidate results with low confidence, and retain entity-relation triples (head entity, relation type, tail entity) with high confidence.

[0045] The confidence threshold can be adjusted during system operation based on the precision-recall balance requirements on the validation set.

[0046] Step S213: Segment the contextual memory text according to dialogue turns or sentence boundaries, and extract the action units contained therein.

[0047] Specifically, action units are identified as follows: Dependency parsing is performed on the text, and clause structures centered on the predicate verb and containing at least one subject or object argument are identified as action units. Each action unit contains at least three semantic slots: the action initiator, the action itself, and the action receiver.

[0048] All action units retrieved from the same episodic memory are arranged in chronological order of their appearance in the dialogue to generate the action sequence of that episodic memory. This action sequence serves as the final expression of the temporal pattern. For cases where multiple action units are involved in the same round of dialogue, their relative order is determined based on their linear position within the sentence.

[0049] Step S214 involves performing dependency parsing on the contextual memory text to identify explicitly expressed causal relationships. Specifically, after constructing a dependency parsing tree, each dependency pair in the tree is traversed. When the core word of any relationship pair is detected to belong to a preset set of causal trigger words, the clause or phrase segment governed by that relationship pair is marked as a causal unit. The set of causal trigger words includes at least: because, therefore, due to, thus, leading to, causing, resulting in, and variations of the above words.

[0050] For each identified causal unit, it is divided into a causal event part and an effect event part: the event description preceding and governed by the causal trigger word is marked as a causal event, or the causal clause introduced by the causal trigger word is marked as a causal event, and the result clause is marked as an effect event. The core predicates and their main arguments of the causal event and effect event are extracted to form a causal pair (causal event, effect event), which serves as the output form of the causal pattern.

[0051] Step S215: Identify the preference expressions of statements generated by user roles in the contextual memory text. For example, the preference lexicon includes, but is not limited to, the following sentiment words and their intensity values: like (0.8), prefer (0.7), tend to (0.6), love (0.9), dislike (-0.7), hate (-0.9), dislike (-0.8), and aversion (-0.85), with the intensity value range consistent with the sentiment intensity normalization interval [-1,1]. The syntactic template is defined based on dependency syntactic relations and includes at least the following two templates: (1) Subject (preference subject) → nsubj → sentiment word → dobj → preference object; (2) Preference object → topi → sentiment word → nsubj → preference subject. When matching any template, the subject, object, and sentiment word are extracted according to the dependency relations, and the preference intensity is assigned according to the intensity value corresponding to the sentiment word.

[0052] When a statement matching the preference expression template is identified, the preference object, preference polarity, and intensity value are extracted from the statement. The preference object is a noun phrase or event description in the statement that has a direct dependency on the sentiment word; the preference polarity is determined as positive or negative based on the semantic direction of the sentiment word; the intensity value is determined based on the extreme value amplitude corresponding to the sentiment word in the preset sentiment dictionary, and the value range is consistent with the normalized interval of the sentiment intensity metadata.

[0053] Step S216 involves encapsulating the extracted entity-relationship patterns, temporal patterns, causal patterns, and user preference patterns into a unified pattern record format according to a preset data structure. Each pattern record must contain at least a pattern type label, a pattern content carrier, and a unique identifier for the source context memory. All pattern records are then aggregated and output as the pattern set corresponding to that context memory for subsequent steps to update the memory storage.

[0054] In some embodiments, the two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation provided by the present invention includes the following steps in step S3: Step S311: For each entity-relation schema in the output schema set, parse its triples (head entity, relation type, tail entity). Perform the following operations in the knowledge graph: check if nodes indexed by the head entity name and tail entity name exist; if not, create new nodes and assign globally unique identifiers to each node; if they already exist, reuse the existing nodes.

[0055] Check if the directed edge corresponding to the triple already exists in the knowledge graph. If it does not exist, create a new edge with the relation type as the edge label, pointing from the head entity to the tail entity, and initialize the weight of the edge to 1. If it already exists, decay the current weight of the existing edge according to a preset time decay function. The expression for the time decay function is: ; in, The preset attenuation coefficient (value range 0.01 to 0.05, unit is 1 / day) This represents the time interval (in days) between the current moment and the last update time of this edge. After decay, the edge weights are cumulatively updated using the current evidence strength (valued at 1) as the increment. .in, The function ensures that the updated edge weights do not exceed a preset upper limit of 1.0, in order to prevent the weights from accumulating indefinitely and causing a decrease in inference confidence and discriminative power. The preset increment constant has a value range of 0.05 to 0.2, and in this embodiment, it is set to 0.1 by default.

[0056] The above update mechanism allows frequently verified knowledge associations to gain higher weight in the long term, while occasional or outdated associations naturally fade away over time, thus maintaining the reasonableness of knowledge density in the knowledge graph and avoiding retrieval noise caused by knowledge expansion.

[0057] Step S312: The extracted action sequence is converted into program memory entries according to a preset executable strategy template. The program memory is implemented using a relational database (such as MySQL) and includes a `procedural_memory` table with fields including: memory ID (BIGINT primary key), trigger condition (TEXT type, storing a JSON description of the context features), action sequence (JSON type, storing action units as an ordered list), creation timestamp (DATETIME), and domain label (VARCHAR). Each action unit in the action sequence includes action type (VARCHAR), action parameters (JSON), and execution order (INT). During system calls, the program memory entry with the highest similarity is selected for execution by performing cosine similarity matching between the feature vector of the current dialogue context and the text embedding vector of the trigger condition.

[0058] Each program memory entry contains at least a trigger condition field and an action sequence field. The trigger condition field records the contextual features in which the action sequence takes effect (e.g., dialogue domain or user intent category), and the action sequence field stores action units arranged chronologically in a list structure. During registration, the trigger conditions of existing program memory entries in the program memory bank are compared with the trigger conditions of the current entry. The similarity comparison uses a pre-trained language model to encode the text description of the trigger conditions into a fixed-length vector and then calculates the cosine similarity, or uses edit distance to calculate text similarity. If the similarity is greater than a preset duplicate detection threshold (e.g., 0.85), the two action sequences are merged; if it is less than the threshold, it is directly stored in the program memory bank as a new entry. One method can be selected according to configuration or requirements.

[0059] It should be noted that the invocation of the program memory is performed independently of the consolidation cycle. During the normal dialogue interaction phase of the system, when responding to user requests in real time, the program memory entry with the highest similarity is selected based on the cosine similarity between the current dialogue context feature vector and the trigger condition embedding vector of each entry in the library. The program memory adopts a read-write separation architecture, and the registration operation in the consolidation cycle is an asynchronous write that does not block online queries.

[0060] Step S313: The extracted causal pairs (cause event, effect event) are parsed into directed causal relationship edges between two event nodes in the knowledge graph. The core predicate and its main arguments of the cause event are used as the identifiers for the cause event nodes, and the core predicate and its main arguments of the effect event are used as the identifiers for the effect event nodes. Nodes are created (if a node does not exist, it is created). A directed edge is created using a preset causal subtype label (such as directly causing, indirectly causing, promoting, or inhibiting) as the edge label, with the edge direction pointing from the cause event node to the effect event node. The initial weight of this causal edge is set to 1. The edge label is determined based on the semantic category of the causal trigger word: when the trigger word belongs to positive causal categories such as "cause" or "make," the label is "direct cause"; when it belongs to "promote" or "drive," the label is "promote"; and when it belongs to "inhibit" or "hinder," the label is "inhibit."

[0061] After writing all empirical causal edges (i.e., causal edges directly extracted from episodic memory, hereinafter referred to as new empirical edges), single-step transitive reasoning is performed using all new empirical edges in this round as the starting set S for reasoning. The formal definition of the reasoning rules is as follows: (1) For each new empirical edge A→B in S, if any causal edge B→C already exists in the knowledge graph (including other empirical edges newly written in this round and old edges that existed before this round, but excluding other inferred causal edges that have been generated in this round), then the transitive causal edge A→C is inferred; (2) For each new empirical edge B→C in S, if any causal edge A→B already exists in the knowledge graph (including other empirical edges newly written in this round and old edges that existed before this round, but excluding other inferred causal edges that have been generated in this round), then the transitive causal edge A→C is inferred. (3) The newly generated inference causal edge (i.e., the above A→C) shall not be used as the intermediate edge (i.e., the position of B→C or A→B) in rule (1) or rule (2) to participate in the re-inference of this round. That is, the propagation depth of the inference is strictly limited to 1 hop, and the extension from the new empirical edge to the adjacent node shall terminate at most; (4) If the same pair of nodes (A, C) can be inferred through multiple different paths, the final confidence shall be determined according to the multi-path confidence value rule specified below.

[0062] For example, if two new empirical edges, A→B and B→C, are added in this round, then A→C is inferred. If C→D is also added in this round, then A→C (the inferred edge) cannot be combined with C→D (the empirical edge) to infer A→D. A→D must wait for the next consolidation cycle. Only after A→C becomes an existing edge can it participate in subsequent inferences. When the total number of new edges generated by transitive inference in a round exceeds a preset limit (e.g., 1000), they are truncated in descending order of inference confidence.

[0063] For a new inferred causal edge (e.g., A→C) that is effectively generated in this round according to the above rules (1) to (4), the inference confidence is determined as follows: the product of the weights of each edge on the path from node A to intermediate node B is obtained, and the product of the weights of each edge on the path from intermediate node B to node C is obtained. The minimum of the two is taken as the initial confidence value of the transitive inferred edge; or, the product of the A to B path, the product of the B to C path, and the user-defined transit attenuation factor (within the range of 0.5 to 0.9) are multiplied together to obtain the initial confidence value. The initial confidence value is stored in the knowledge graph as the weight attribute of the inferred causal edge, and further corrected by subsequent user interaction feedback.

[0064] For scenarios where there are multiple different paths that can deduce the causal relationship between the same pair of nodes (i.e. multiple valid paths that simultaneously meet the above rules (1) to (4), such as the simultaneous existence of two paths A→B→C and A→D→C, and the middle edges of these paths do not contain the newly generated inferred causal edges in this round), the maximum value among the confidence values ​​calculated for each path is taken as the final confidence of the inferred causal edge, and the path information corresponding to the maximum value is stored as evidence in the edge attribute for subsequent tracing and verification.

[0065] It is important to emphasize that if the middle edge of a candidate path contains a newly generated inference causal edge in this round, the path will not be considered a valid inference path in this round, and its corresponding confidence calculation will not be performed in this round. It will only participate in inference and confidence calculation after the middle edge is converted into an existing old edge in the subsequent consolidation cycle.

[0066] Step S314: The extracted user preference patterns are written into the user profile database as user profile attribute entries. For multiple preference records with the same preference object but different source contextual memories, a merge operation is performed: if the preference polarity is consistent, the intensity values ​​of each record are updated to the comprehensive intensity value of the preference object by a time-weighted average, where the time weight is proportional to the distance between the record's generation time and the current time, with more recent records having a larger weight; at the same time, the verification count of the preference object is increased. If a preference polarity conflict occurs (the same preference object has both positive and negative records), the total intensity values ​​of the two types of records are compared, and the side with the larger total intensity value is taken as the current dominant polarity of the preference object, while the record on the other side is retained as a historical alternative state instead of being directly deleted, to support subsequent preference drift detection.

[0067] Step S315: Mark all generated pattern records as updated, and change the extracted pattern flag in the corresponding source context memory record from negative to positive to ensure that the same context memory is not extracted repeatedly in subsequent consolidation cycles.

[0068] It should be noted that transactional semantics only apply to the synchronous updates of the knowledge graph, program memory, and user profiles in step S3. For the inference edge creation in step S4 and the digest compression and cold storage archiving in step S5, if any step fails, the system records the failure log and the current progress, and will prioritize retrying in the next low-load cycle. The committed S3 updates are unaffected, and the inference edges created in S4 and the digests generated in S5 will be patched and eventually consistent by independent asynchronous verification tasks in subsequent cycles.

[0069] It should be noted that the knowledge graph update in step S3 (including node creation, edge weight update, and causal reasoning edge generation) and the inference edge building operation in step S4 operate on different subsets of the same knowledge graph: step S3 processes pattern information directly generated from the candidate set to be consolidated in the current round, while step S4 processes recently added nodes in the updated entire knowledge graph. The update operation in step S3 is completed before step S4, allowing step S4 to perform inference on the complete graph state that has incorporated the new knowledge of this round. The order of the two operations is fixed, there is no cross-dependency, and no operational conflict occurs.

[0070] Furthermore, the newly generated inferred causal edge in step S3 can be used as an existing edge in the knowledge graph to participate in the path diversity statistics in step S4, but it is not used as the basis for selecting seed nodes; if the confidence of the inferred causal edge is lower than the preset threshold (0.3 by default in this embodiment), it is excluded from the path statistics in step S413.

[0071] In some embodiments, the two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation provided by the present invention includes the following steps in step S4: Step S411: Read the creation timestamps of all nodes in the knowledge graph and filter out nodes whose creation time is within a preset number of days before the start date of the current consolidation cycle as a candidate seed node set. The preset number of days ranges from 7 to 30 days (e.g., 14 days by default) to limit association mining to recently added knowledge elements, avoid performing invalid long-distance pairing calculations on overly old nodes, and thus control the computational complexity of a single consolidation cycle.

[0072] From the candidate seed node set, nodes with a degree (i.e., the number of edges directly connected to the node) not less than a preset degree threshold are further filtered. The preset degree threshold is a positive integer (e.g., 3). Nodes with a degree less than this threshold are excluded because they lack sufficient topological connectivity information. Among the filtered nodes, they are selected in descending order of importance. Importance is determined by a weighted sum of the node's historical reference frequency and betweenness centrality. As an optional implementation, importance... The formula for calculation is: ; in, The historical reference frequency of this node is normalized to the interval [0,1] using the minimum-maximum normalization method, with the benchmark being the maximum and minimum historical reference frequencies of all nodes in this seed node set. The betweenness centrality of this node is normalized to the interval [0,1] using a minimum-maximum normalization method, with the benchmark being the maximum and minimum betweenness centralities of all nodes in the seed node set. When the maximum and minimum values ​​in the set are equal, the normalization value of this node is 0.5. The preset weighting coefficients (ranging from 0.3 to 0.7, e.g., 0.5) are used. After sorting by importance score from highest to lowest, the top K nodes are selected as the final seed nodes. The value of K is determined by the maximum number of seed nodes per cycle parameter in the system configuration file (e.g., the default value is 50).

[0073] Step S412: Starting from each seed node, a breadth-first search algorithm is used to expand the search outwards in the knowledge graph, selecting nodes whose graph distance hop count is within a preset range as distant candidate nodes. The preset range consists of node pairs with a graph distance of two hops, excluding one-hop direct neighbors (those with existing direct edges). One-hop neighbors are not considered valuable for inference because they are already directly connected to each other.

[0074] During the traversal, the following two types of node pairs are excluded: (1) node pairs where there is already a direct edge between the seed node and the distant candidate node; (2) repeated combinations that have been processed as distant candidate node pairs during the traversal. Node pairs that meet the jump count range and have not been excluded are considered as distant node pairs to be evaluated.

[0075] Step S413: For each pair of distant nodes to be evaluated (node ​​A, node B), perform the calculation of the following four components: (a) The total number of common nodes in the knowledge graph that are directly connected to node A and directly connected to node B is denoted as . Using the hyperbolic tangent function to... Perform normalization processing, that is Mapping to the [0,1) interval to avoid absolute value deviations between different node pairs due to local density differences.

[0076] (ii) Calculate the co-occurrence frequency of nodes A and B in episodic memory. Specifically, count the number of memory entries in the episodic memory database that simultaneously contain the standard names of node A and node B, denoted as . The sum of the number of memory entries containing node A but not node B and the number of memory entries containing node B but not node A is denoted as . .like If it is 0, then The value is 0; otherwise, the formula for calculating co-occurrence Jaccard similarity is: ; The ratio falls directly in the [0,1] interval and does not require additional normalization.

[0077] It should be noted that the snapshot is regenerated at the start of each consolidation cycle (i.e. before S1 is executed), and the summary replacement result submitted in S5 will be incorporated into the new snapshot at the start of the next cycle.

[0078] (iii) The total number of times node A and node B co-occur in the same contextual memory item is denoted as . Normalization is performed using the hyperbolic tangent function: ; in, A preset scaling factor (e.g., a value of 5) is used to map co-occurrence frequencies to the [0,1) interval. The introduction of the scaling factor ensures that node pairs with co-occurrence frequencies of different orders of magnitude maintain reasonable gradient differences after normalization.

[0079] (iv) Count the total number of paths (i.e., simple paths) between node A and node B that have no repeating intermediate nodes, denoted as . And the number of paths with distinct edge types (i.e., the number of deduplicated paths), denoted as The formula for calculating path diversity is: ; This ratio falls directly in the [0,1] interval and is used to quantify the richness of topological connections between nodes. The higher the path diversity, the more semantic paths exist between node A and node B, and the more reliable the confidence of the inferred connection.

[0080] Step S414: Assign weights to the number of common neighbors, co-occurrence Jaccard similarity, co-occurrence frequency, and path diversity, with each weight satisfying a normalization constraint that their sum equals 1. As an optional implementation, the first weight corresponding to the number of common neighbors... The value is 0.25, representing the second weight corresponding to the co-occurrence Jaccard similarity. The value is 0.30, representing the third weight corresponding to the co-occurrence count. The value is 0.20, representing the fourth weight corresponding to path diversity. The value is set to 0.25. Under this weighting configuration, co-occurrence Jaccard similarity has the highest weight, reflecting that semantic co-occurrence is the strongest signal for inferring associations; the number of common neighbors and path diversity are next, taking into account both topological structure and path richness; the weight of co-occurrence frequency is relatively the lowest, to prevent the excessive influence of occasional high-frequency co-occurrence on the connection value.

[0081] Connecting Value The formula for calculation is: ; Step S415 compares the calculated connection value with a preset value threshold. The preset value threshold is a constant predefined in the system configuration file, ranging from 0.4 to 0.7 (e.g., a default value of 0.55), used to control the baseline quality of inferred edge creation. When the connection value is greater than the preset value threshold, the distant node pair is marked as a valid inferred node pair and proceeds to the subsequent edge construction process; when it is less than or equal to the preset value threshold, edge construction for that node pair is abandoned, and no further operations are performed. This threshold mechanism ensures that only relationships between nodes supported by sufficient semantic and topological evidence are inferred as legitimate new edges, thereby maintaining the quality of inferred edges in the knowledge graph.

[0082] Step S416: For each valid node pair (node ​​A, node B) output, extract all common neighbor nodes between node A and node B. For each common neighbor node... Read the type label of the edge connecting node A in the knowledge graph. and the type label of the edge connecting node B. Combine the two into an edge type combination pair Count the frequency of edge type combinations contributed by all common neighbors, and select the combination with the highest frequency as the basis for candidate inference of relation type.

[0083] If the most frequent pair of nodes has a corresponding entry in the preset mapping rule table, the inferred relationship type is determined based on the mapping. If the most frequent pair of nodes does not have a corresponding entry in the mapping rule table, the valid node pair is skipped, no inferred edge is created, and the event is recorded in the system log for subsequent analysis to expand the mapping rule table.

[0084] The preset mapping rule table is stored in the system knowledge base in the form of a rule table and is constructed during the initialization phase of the system's first startup. The construction method of the rule table is as follows: using all empirical edges (edges whose source is marked as empirical) in the knowledge graph as the statistical object, the head entity type, relation type, and tail entity type of each edge are extracted. The edge types corresponding to each pair of common neighbors are then combined... Types of relationships with target inference The mapping relationships between them are counted by frequency, and the mapping relationship with the highest frequency is selected as the initial rule entry and written into the rule table. If the knowledge graph is empty when the system is initialized, the relation triples in the external open knowledge graph (such as CN-DBpedia) are used as the alternative statistical source, and the initial rule table is constructed in the same way. After the system runs and accumulates empirical edges, it will be gradually updated and replaced.

[0085] The incremental update mechanism for the rule table is as follows: An update is triggered every 10 consolidation cycles or every 50 valid inference edges verified by positive user feedback. During the update, the rule table is updated to reflect the validity of the inference edges verified in this round. Combination pairs and their true relationship types As new samples, they are added to the statistical pool to recalculate the frequency of each mapping relationship. If a pair does not yet exist in the rule table and its frequency exceeds a preset frequency threshold (default 5 times), then the entry for that pair → relationship type is expanded to the rule table; if a pair already exists but its frequency statistics change significantly (support change exceeds 20%), then the confidence weight of that entry is updated. The updated rule table takes effect in the inference edge building step of the next consolidation cycle.

[0086] Step S417: For the valid node pair (A, B), search the knowledge graph for all simple paths from A to B with a graph distance of two hops (i.e., paths of the form...). The path, where (For any intermediate node). If there is only one such path. Then read the edge weight. and Calculate the inference confidence level .

[0087] If there exist multiple simple paths in the graph with a distance equal to two hops (e.g.) and If both exist simultaneously, then calculate the path confidence score (i.e., the product of the weights of the two edges on that path) for each path, and take the maximum value among all path confidence scores as the final inference confidence of that inference edge, that is: ; And the path information (intermediate nodes) corresponding to this maximum value The edge weights and their corresponding edge weights are stored together in the edge attributes as evidence.

[0088] If the maximum path confidence score still cannot distinguish between paths (i.e., multiple paths have the same score), then the path with the larger number of common neighbors is selected as the deciding factor. The value is used as the inference confidence of the new inference edge and stored in the knowledge graph as the weight attribute of the new edge.

[0089] In step S418, the newly created edge, marked as inferred, is in a state of pending verification. During subsequent user interactions, the system continuously listens to the user's input dialogue content. When it detects that the user mentions the standard names or normalized equivalent references of the nodes at both ends of the new edge simultaneously in a single or multiple rounds of dialogue, this event is considered a positive verification feedback.

[0090] The normalized equivalent references include at least: synonyms, abbreviations, and alternative names of the node's standard name, as well as pronouns referring to the node (such as it, the company, or the user), which are also considered equivalent references after being linked to the standard name through the coreference resolution model.

[0091] The coreference resolution model is an end-to-end coreference resolution model fine-tuned based on a pre-trained Chinese model (such as RoBERTa-wwm-ext-large). It needs to be fine-tuned on a Chinese coreference resolution corpus, such as CLEU-corpus, or on dialogue coreference resolution samples constructed according to industry-standard annotation specifications to adapt to the coreference resolution task in Chinese dialogue scenarios. This model encodes each span in the dialogue text as a vector and predicts its coreference relationship with other spans. Deployment of this model requires a GPU with at least 24GB of video memory (such as an NVIDIA A100 or equivalent computing power).

[0092] During the observation period, when the cumulative number of positive validation feedbacks reaches a preset validation threshold (e.g., 3 times), the weight attribute increases by a preset increment (e.g., +0.2), but the increased value does not exceed the upper limit of 1.0. When the inference edge has been observed for a preset period (e.g., 30 calendar days) since its creation and the cumulative number of positive feedbacks has not reached the preset validation threshold, the inference edge is marked as eliminated (if subsequent conclusive positive feedback evidence appears after the observation period ends, the system retains the log and the administrator reviews it, but the weight is not automatically restored). That is, the upgrade condition only takes precedence over the elimination condition during the observation period. Or, if negative feedback that explicitly negates the relationship (e.g., A and B are not related) appears in the user interaction content during the observation period, the inference edge is marked as eliminated.

[0093] The negative feedback detection method involves performing dependency parsing on subsequent user input to identify whether it contains negative assertions based on the standard names of the nodes at both ends of the new edge. Specifically, a set of negative trigger words is preset, including at least: no, not, not, irrelevant, not belonging, not equal to, and completely unrelated. When the user input simultaneously contains the standard name or normalized equivalent reference of node A, the standard name or normalized equivalent reference of node B, and any negative trigger word, and all three are within the same clause or adjacent clauses, it is considered a negative feedback event.

[0094] This verification feedback mechanism enables the system to gradually correct inference errors through long-term interaction, preventing erroneous knowledge from accumulating continuously in the knowledge graph.

[0095] In some embodiments, the two-stage consolidation method for artificial intelligence memory based on slow-wave and paradoxical sleep simulation provided by the present invention further includes a post-processing step after creating a new edge labeled as inference: After the summary compression and cold storage archiving of this consolidation cycle are completed, the contextual memory entries carrying emotional intensity metadata in the candidate set to be consolidated are screened. The original amplitude stored in the emotional intensity metadata, that is, the valence-arousal composite amplitude directly output by the sentiment analysis module in step S112-A, is attenuated and adjusted without any normalization processing.

[0096] Specifically, the original amplitude is multiplied by a preset attenuation factor (0.95 by default in this embodiment), and the product is written back to storage, overwriting the original original amplitude; or, the original amplitude is subtracted from a preset fixed attenuation amount (0.05 by default in this embodiment), and the difference is written back to storage, but the lower limit is not lower than 0. Attenuation adjustment is only performed when the absolute value of the original amplitude is greater than a preset termination threshold (e.g., 0.01). Once the absolute value is less than or equal to the termination threshold, or the context memory has been marked as having been converted into semantic knowledge, subsequent attenuation operations on that entry are stopped.

[0097] The above conditions for stopping attenuation are the preset termination conditions.

[0098] It is important to emphasize that this attenuation operation only applies to the stored original amplitude and does not involve any normalization calculations or normalized values. The attenuated original amplitude is read in step S112-A of the subsequent consolidation cycle and participates in the min-max linear normalization of the current round (based on the statistical benchmark of the set to be evaluated in the current round) along with the original amplitudes of other scene memories. The normalized value is then used to calculate the consolidation priority score.

[0099] As an alternative approach, to eliminate the uncertainty caused by changes in the normalization benchmark as the composition of the set to be evaluated changes, a fixed reference system can be used for normalization: the upper limit of normalization is fixed at 1.0 (corresponding to the maximum possible amplitude output by the sentiment analysis module), and the lower limit of normalization is fixed at 0. That is, in each calculation, the original amplitude after decay is divided by √2 to obtain the normalized sentiment intensity value (because the normalized amplitude falls within the [0,1] interval). This fixed reference system ensures that the normalized sentiment intensity value of each episodic memory depends only on its own decay history and is independent of the sentiment intensity distribution of other memories in the set to be evaluated in the current round, thus ensuring the consistency of the priority ranking results.

[0100] In some embodiments, the two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation provided by the present invention includes the following steps in step S5: Step S511: Read each scene memory in the candidate set to be consolidated output in step S1, and count the number of characters or tokens in the original dialogue content.

[0101] The preset length is a length threshold predefined in the system configuration file, used to distinguish between long and short conversations. As an optional implementation, the preset length threshold is measured in tokens, ranging from 512 to 2048 tokens (e.g., a default of 1024 tokens). When the number of tokens in the original content of a context memory is greater than or equal to the preset length threshold, the context memory is marked as requiring summary processing; when the number of tokens is less than the preset length threshold, the summary generation step is skipped, and the original content is directly retained.

[0102] Step S512: For each context memory marked as requiring summarization, construct a summary generation prompt. The prompt must contain at least the following elements: (1) a task instruction requiring the model to compress the given dialogue content while preserving key entities and user intent; (2) a factual constraint instruction requiring the model not to add any information not present in the original content; and (3) the original dialogue content itself. The prompt is input into a pre-trained large language model. The model uses Qwen-14B-Chat as its base model and is fine-tuned using LoRA on the LCSTS Chinese dialogue summarization dataset and a self-built dataset of 100,000 dialogue summarization pairs (rank 16, learning rate 3e-4, 3 training rounds). The inference temperature parameter T=0.7, top_p=0.9, and the maximum generated length is 256 tokens. On the self-built test set, the ROUGE-1 F1 score of the model is no less than 0.52.

[0103] The model outputs a compact summary text of the context. The compact summary retains key entities from the original dialogue (including at least names of people, organizations, places, and domain-specific concepts) and user intent (including at least the user's request type, target, and constraints), while removing repetitive expressions, small talk, interjections, and redundant information unrelated to the core facts. The summary length does not exceed a preset character threshold, which is an integer (ranging from 100 to 300 Chinese characters, e.g., a default of 150 characters), predefined in the system configuration file.

[0104] As an optional implementation, a fact consistency verification step is introduced in the summary generation process: the generated summary and the original dialogue content are respectively input into a pre-trained semantic similarity model, which is the Sentence-BERT model. The input text is encoded into a fixed-length semantic vector and the cosine similarity between the two is calculated. When the similarity is lower than a preset similarity threshold (e.g., 0.85), the original content is retained and the record is marked for subsequent review, so as to ensure that information is not distorted due to automatic summarization under any circumstances.

[0105] Step S513: Before performing the summary replacement operation, the original dialogue content to be compressed is exported from the hot storage (i.e., the main storage medium on which the system online query depends) and packaged into archive records. Each archive record contains at least the following fields: (1) the complete text of the original dialogue content; (2) a timestamp, which is the time when the scene memory was generated, and the format is a time code accurate to the millisecond level; (3) a unique identifier for the scene memory, which is used to establish a bidirectional mapping relationship with the replaced summary entry.

[0106] Before writing to cold storage, estimate the amount of data to be archived, split the archiving task into multiple batches, each batch containing no more than 50 context memory records or a total data volume of no more than 10MB. After each batch is written, check whether the low-load period is about to end. If it is about to end, pause the archiving task and save the breakpoint, and continue execution in the next low-load period.

[0107] Cold storage is a persistent storage medium independent of hot storage (such as distributed object storage, tape library, or low-frequency access cloud storage service). Its read latency is higher than that of hot storage, but its storage cost is significantly lower. It is used to store historical raw data that is not frequently accessed by the system but needs to be retained for a long time.

[0108] Step S514: To ensure data consistency between cold storage archiving and hot storage digest replacement, a two-phase commit and compensation transaction mechanism is adopted: (1) Pre-commit stage: Package the original dialogue content to be compressed into archive records and write them to the temporary area of ​​cold storage. After each record is written, calculate the checksum (using SHA-256) and compare it with the local checksum. After all records are written, mark the status of the archiving task in the local persistent queue as cold storage has been written and is ready to be submitted, and record the list of record IDs and cold storage path of this archive.

[0109] (2) Formal Submission Phase: After confirming the success of all phase one operations, the digest replacement operations are executed sequentially in the hot storage. For each record that is successfully replaced, the status of the record in the local persistent queue is updated to indicate that it has been replaced in the hot storage, and a commit command is sent to the cold storage to migrate the corresponding record from the temporary area to the formal area.

[0110] If an exception occurs during the formal commit phase (such as hot storage write timeout or cold storage commit command failure), the system immediately initiates a compensation transaction: for records whose status is "hot storage replaced," digest generation and replacement are re-executed based on the original archived data in cold storage in the next consolidation cycle; for records whose status is "cold storage written, awaiting commit, but hot storage replacement has not yet been performed," a rollback command is sent to the corresponding record in the cold storage temporary area to delete it, and the local cache is released. All incomplete task records are stored in a local persistent queue (implemented based on WAL logs) to ensure that after a system restart, the system can automatically recover and continue executing incomplete archiving tasks based on the queue status, thereby ensuring eventual data consistency and preventing the loss of any original data.

[0111] In step S515, when performing the content replacement operation, all metadata fields in the scene memory record, except for the content field, remain unchanged. Specifically, the original amplitude field stored in the emotion intensity metadata maintains its original value. This value was directly output and stored by the emotion analysis module in step S112-A without any normalization processing, and continues to be retained in the record after the replacement operation. In subsequent consolidation cycles, step S112-A reads this original amplitude and directly uses it as a normalized emotion intensity value for priority score calculation based on a fixed reference system (upper limit 1.0, lower limit 0), without performing any further normalization transformation, thereby avoiding the overhead of repeated emotion analysis calculations caused by summary replacement.

[0112] The named entity label field is also fully preserved. The named entity label is the list of entities extracted and stored during named entity recognition in step S212, which includes the entity name, entity type, and the offset of each entity's position in the original dialogue. Since only key entities are retained in the replaced summary text, the complete entity list stored in the entity label field can still be used for subsequent entity linking, co-occurrence statistics, and retrieval matching operations, thereby maximizing the preservation of structured information usable by downstream tasks while compressing the dialogue context.

[0113] Step S516: After completing the above replacement and retention operations, update the status flag field of the scene memory from "Pending Consolidation" to "Summarized," and record the execution time of summary generation, summary length, and corresponding original data archiving path in the system log for subsequent auditing and traceability. The updated status flag ensures that the scene memory will not be repeatedly selected as an object requiring summarization in subsequent consolidation cycles, and does not affect its continued participation in the consolidation priority score calculation in step S1 as a scene memory that has not been converted into semantic knowledge in subsequent cycles. That is, its eligibility to participate depends only on whether the memory has been converted into a semantic knowledge flag, and is independent of whether it has been summarized.

[0114] The present invention also provides an artificial intelligence memory two-stage consolidation system based on slow wave and REM sleep simulation, including: a priority calculation module, used to acquire situational memories that have not been converted into semantic knowledge during low system load periods, calculate consolidation priority scores based on the weighted sum of normalized emotional intensity, future usefulness, reward value and retrieval frequency, and select situational memories that meet preset conditions as a candidate set to be consolidated; The pattern extraction module is used to process the candidate set to be consolidated in batches, extracting multiple types of patterns from each episodic memory to obtain a pattern set; The memory update module is used to update the pattern set to the memory storage, which includes at least the knowledge graph; The edge inference module is used to select recently added nodes as seed nodes in the updated knowledge graph, find long-distance node pairs within a preset range, calculate the connection value based on the weighted sum of the number of common neighbors, co-occurrence Jaccard similarity, co-occurrence frequency and path diversity, and create new edges marked as inference between long-distance node pairs whose connection value exceeds a preset value threshold. The summary compression module is used to generate compact summaries for contextual memories in the candidate set to be consolidated that exceed the preset length. The original dialogue content is archived to cold storage, and the original content in the contextual memory is replaced with the compact summary. The emotional intensity metadata and named entity tags are retained in the replaced contextual memory.

[0115] The AI ​​memory two-stage consolidation system based on slow-wave and REM sleep simulation provided in this embodiment of the invention can execute the AI ​​memory two-stage consolidation method based on slow-wave and REM sleep simulation provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0116] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0117] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. An artificial intelligence-based two-stage memory consolidation method based on slow-wave and REM sleep simulation, characterized in that, include: During periods of low system load, contextual memories that have not been converted into semantic knowledge are acquired. Consolidation priority scores are calculated based on the weighted sum of normalized emotional intensity, future usefulness, reward value, and retrieval frequency. Contextual memories that meet preset conditions are selected as candidate sets to be consolidated. The candidate set to be consolidated is processed in batches, and multiple types of patterns are extracted from each of the episodic memories to obtain a pattern set. The pattern set is updated in the memory storage, which includes at least a knowledge graph; In the updated knowledge graph, recently added nodes are selected as seed nodes, and long-distance node pairs within a preset range are found. The connection value is calculated based on a weighted sum of the number of common neighbors, co-occurrence Jaccard similarity, co-occurrence frequency, and path diversity. New edges marked as inference are created between long-distance node pairs whose connection value exceeds a preset value threshold. For the contextual memories in the candidate set to be consolidated that exceed a preset length, a compact summary is generated, the original dialogue content is archived to cold storage, the original content in the contextual memory is replaced with the compact summary, and the emotional intensity metadata and named entity tags are retained in the replaced contextual memory.

2. The two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation as described in claim 1, characterized in that, The weight of the emotional intensity is greater than the weight of the future usefulness, the weight of the future usefulness is greater than the weight of the reward value, and the weight of the reward value is greater than the weight of the search frequency. The preset condition is to select memories whose consolidation priority scores are within a preset ranking ratio range from the memory set to be evaluated as the candidate set to be consolidated. The future usefulness is obtained through a prediction model, which predicts the probability of future retrieval based on multiple feature dimensions of the contextual memory and multiplies it by a time decay factor; the input features of the prediction model are encoded and converted into numerical vectors. The reward value is obtained by accumulating the scores of the contextual memory across multiple utility dimensions and truncating them to a preset upper limit; The retrieval frequency is normalized using the maximum number of retrievals in the current memory set to be evaluated as the denominator.

3. The two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation as described in claim 1, characterized in that, The various types of patterns include entity-relationship pattern, time sequence pattern, causal pattern, and user preference pattern; When extracting the entity-relationship pattern, named entities are identified from the context memory, entity pairs are classified into relationships and filtered based on confidence level; When extracting the temporal pattern, action units are extracted from the contextual memory and action sequences are generated in chronological order; When extracting the causal pattern, the causal relationships between events are identified and causal pairs are extracted from the episodic memory through dependency parsing. When extracting the user preference pattern, the preference expression is identified from the context memory and the preference object, preference polarity and intensity value are extracted.

4. The two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation according to claim 3, characterized in that, When updating the set of patterns to memory storage: The entity-relationship pattern is transformed into nodes and edges of the knowledge graph, and the weights of existing edges are updated based on time decay and current evidence strength. Register the timing pattern to the program memory; The causal pattern is written into the knowledge graph in the form of causal relationship edges, and single-step transitive reasoning is performed on the newly written causal edges in the knowledge graph in the current round. The new causal edges generated by the reasoning are also stored in the knowledge graph. The depth of the single-step transitive reasoning is limited to 1 level, and newly generated inference causal edges do not participate in the next round of reasoning; The user preference pattern is written into the user profile, and multiple records of the same preference object are merged.

5. The two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation according to claim 1, characterized in that, The compact summary uses a language model to factually compress the episodic memory; Key entities and user intents are preserved after compression; The abstract length does not exceed the preset word count threshold; The original dialogue content is archived to the cold storage using timestamps as indexes.

6. The two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation according to claim 1, characterized in that, The seed node is a node whose creation time is within a preset number of days before the start date of the current consolidation cycle and whose degree is not less than a preset degree threshold, wherein the preset degree threshold is a positive integer; The preset range is the node pairs whose graph distance is equal to two hops; The components of the connection value are normalized and then weighted and summed.

7. The two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation according to claim 1, characterized in that, When creating a new edge marked as inference, check if a direct edge already exists between the seed node and the distant node; if it does, skip it. Based on the combination of relationship types connected by the common neighbors of the two, the inferred relationship type is determined according to the preset mapping rules; If multiple candidate relation types with the highest frequency appear, the sum of the total connection weights of the common neighbors corresponding to each candidate pair is compared, and the pair corresponding to the one with the largest sum of connection weights is selected as the final mapping basis. The new edge is created based on the inferred relation type, and the inferred confidence of the new edge is stored as a weight attribute; After creation, the new edge is upgraded or eliminated based on the verification feedback from subsequent user interactions; The verification feedback includes positive feedback and negative feedback; The positive feedback is that the standard names or normalized equivalent designations of the nodes at both ends of the new edge appear simultaneously in the dialogue content subsequently entered by the user. The negative feedback detection method is to perform dependency parsing on the dialogue content subsequently input by the user. When the user input is detected to contain both the standard name or normalized equivalent reference of the two nodes of the new edge and any negative word from the preset set of negative trigger words, it is determined to be negative feedback.

8. The two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation according to claim 1, characterized in that, After creating the new edges labeled as inferences, post-processing steps are also included: Filter the scenario memory entries carrying emotion intensity metadata in the candidate set to be consolidated, and adjust the original amplitude stored in the emotion intensity metadata by attenuation. The attenuated original amplitude is stored in the memory record for the next consolidation priority score calculation until the preset termination condition is met.

9. The two-stage consolidation method for artificial intelligence memory based on slow-wave and REM sleep simulation according to claim 7, characterized in that, The inference confidence is the product of the weights of each edge on the path between the seed node and the distant node.

10. An AI-based two-stage memory consolidation system based on slow-wave and REM sleep simulation, used to implement the AI-based two-stage memory consolidation method based on slow-wave and REM sleep simulation as described in any one of claims 1 to 9, characterized in that: include: The priority calculation module is used to acquire contextual memories that have not been converted into semantic knowledge during periods of low system load, calculate a consolidation priority score based on a weighted sum of normalized emotional intensity, future usefulness, reward value, and retrieval frequency, and select the contextual memories whose scores meet preset conditions as a candidate set to be consolidated. The pattern extraction module is used to process the candidate set to be consolidated in batches, extract multiple types of patterns from each of the contextual memories, and obtain a pattern set. A memory update module is used to update the pattern set to the memory storage, wherein the memory storage includes at least a knowledge graph; The edge inference module is used to select recently added nodes as seed nodes in the updated knowledge graph, find long-distance node pairs within a preset range, calculate the connection value based on the weighted sum of the number of common neighbors, co-occurrence Jaccard similarity, co-occurrence frequency and path diversity, and create new edges marked as inference between long-distance node pairs whose connection value exceeds a preset value threshold. The summary compression module is used to generate compact summaries for the context memories in the candidate set to be consolidated that exceed a preset length, archive the original dialogue content to cold storage, replace the original content in the context memory with the compact summary, and retain the emotion intensity metadata and named entity tags in the replaced context memory.

Citation Information

Patent Citations

  • Memory consolidation method and system based on knowledge graph and cognitive features

    CN121957921A

  • Continuous learning method and system based on two-stage sleep inspiration and consolidation

    CN122509260A