Power time sequence prediction method based on retrieval enhancement generation and memory mechanism
By constructing a frozen and dynamic memory set combined with the Sundial model, the problem of existing time series forecasting models ignoring recent patterns and distribution shifts in long series processing is solved, achieving high-precision and low-overhead power time series forecasting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-18
- Publication Date
- 2026-03-31
AI Technical Summary
Existing time series forecasting models tend to ignore recent key patterns when dealing with long series, are sensitive to distribution shifts, and lack structured memory mechanisms, leading to decreased prediction accuracy and unreliability.
We employ a retrieval-enhanced generation and memory mechanism approach, which constructs frozen memory sets and dynamic memory sets, combines them with the Sundial model for prediction, and utilizes frozen memory to calibrate the generator output, thereby achieving collaborative capture of long-term and short-term dependencies.
It significantly improves prediction accuracy, reduces computational overhead, enhances the model's adaptability and scalability, and adapts to non-stationary environments.
Smart Images

Figure CN121766518A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of time series forecasting technology, specifically, it relates to a power time series forecasting method based on retrieval-enhanced generation and memory mechanisms. Background Technology
[0002] Time series data is widely used in energy management, financial markets, industrial operations, and healthcare monitoring. High-accuracy time series forecasting is crucial for system performance optimization, resource allocation, risk mitigation, and strategic planning. Retrieval-enhanced generation (RAG) architectures have demonstrated significant effectiveness in large-scale language models (LLMs), improving the accuracy of generated responses by integrating external knowledge. Recent advancements in basic time series models (such as Chronos and Sundial) have further improved general forecasting performance through large-scale pre-training. In recent years, two main approaches have emerged in the field of time series forecasting: While Transformer-based deep learning models (such as Informer, PatchTST, and Timemixer++) can capture complex temporal dependencies, they tend to overlook recent key patterns when processing long sequences and are sensitive to distribution shifts. Basic time series models (such as Chronos and Sundial), while possessing strong generalization capabilities, are prone to "illusion" phenomena on specialized datasets, leading to decreased prediction accuracy. Furthermore, existing retrieval augmentation methods such as RAF, although incorporating historical sequence retrieval, lack structured memory mechanisms and cannot effectively distinguish between long-term and short-term patterns. While Memformer introduces external memory modules, its design is primarily geared towards natural language processing tasks and does not fully consider the dynamic evolutionary characteristics of time series. Therefore, existing technologies suffer from the following shortcomings: Limitations of Transformer-based models: While traditional Transformer-based models strive to capture complex temporal dependencies, they often assign uniform attention weights to all historical time steps. This may overemphasize irrelevant long-range information while underestimating recent key patterns.
[0003] Limitations of the base model: Although the base model with large-scale pre-training is highly general, it is susceptible to data bias and domain drift when applied to highly specialized and constantly updated datasets, resulting in unreliable prediction results and difficulty in maintaining prediction accuracy.
[0004] The shortcomings of existing retrieval methods: Other retrieval enhancement methods, although they retrieve historical sequences, lack a structured memory mechanism to extract different time patterns; while Memformer includes an external dynamic memory module, its original design was for NLP tasks and it has not fully adapted to the unique needs of time series prediction. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention proposes a power time series prediction method based on retrieval-enhanced generation and memory mechanisms; it achieves collaborative capture of long and short time dependencies and has high prediction accuracy.
[0006] This invention is achieved through the following technical solution: a time series prediction method based on retrieval enhancement generation and memory mechanism, the method specifically including the following steps: Step 1, Warm-up Phase: Key operating pattern motifs are obtained from a subset of the historical training dataset of power information through time pattern extraction and memory embedding, and a frozen memory set is constructed as a warm-up phase. Step 2, the memory retrieval enhancement stage, uses a dual-tower embedding layer to construct a dynamic memory set and a query set, performs similarity-based retrieval of the top-K most relevant historical patterns, and updates the dynamic memory set through a forgetting-enhancement mechanism; Step 3, Prediction Stage: The retrieved dynamic memory is aggregated with the current input and fed into the prediction model based on Sundial architecture to generate several candidate prediction sequences. The frozen memory is then used to calibrate the output of the Sundial generator to produce the final prediction.
[0007] Further, in step 1, The time pattern extraction specifically involves: constructing a cumulative similarity matrix through dynamic programming, aggregating local similarities in the matrix and penalizing misalignment, identifying and extracting the Top-K non-overlapping key operating pattern motifs from the power data, with each pattern corresponding to a typical operating condition, thus forming a structured pattern repository.
[0008] Further, in step 1, The memory embedding specifically involves: using reversible instance normalization and block embedding techniques to map each key operating mode motif into a high-dimensional embedding vector, and using comparative learning to pre-train the embedding module to aggregate the embeddings of similar operating modes in the vector space.
[0009] Furthermore, in step 1, the frozen memory set consists of an embedding vector and the corresponding original sequence, and the embedded motifs constitute the frozen memory set. It consists of tuples Composition, in which E frozen It is a frozen embedding vector. S motif It is the original motif sequence; In step 2, the dynamic memory set As the recent input sequence is continuously updated; each memory is stored as a tuple: ,E dynamic For embedding vectors, S dynamic For the original sequence, v For the vitality of memory, t This is the last access time.
[0010] Furthermore, in step 2, The memory embedding matrices of the frozen memory set and the dynamic memory set are combined, and the cosine similarity between the query embedding and the memory embedding is calculated. Top-K retrieval is performed based on the similarity score, and the retrieval results from different memory sources are merged and reordered by inverse sorting fusion.
[0011] Furthermore, in step 2, the forgetting-enhancement mechanism specifically involves: increasing the vitality value of retrieved memory entries by a constant enhancement value and updating the access timestamp; decaying the vitality value of memory entries that have not been retrieved for a long time according to a preset rule; and deleting memory entries with low vitality values or low retention probabilities when the dynamic memory set is full.
[0012] Furthermore, in step 3, For candidate predictions generated from Sundial, the candidate predictions are calibrated using typical operating modes stored in frozen memory. The final prediction result is output through similarity matching, affine alignment and weighted fusion.
[0013] A power time-series prediction system based on retrieval-enhanced generation and memory mechanisms; The system includes a preheating module, a retrieval enhancement memory module, and a prediction module; The preheating module extracts key operating mode motifs from a subset of the historical training dataset of power information through time pattern extraction and memory embedding, and constructs a frozen memory set as preheating; The retrieval enhancement memory module uses a dual-tower embedding layer to construct a dynamic memory set and a query set, performs similarity-based retrieval of the Top-K most relevant historical patterns, and updates the dynamic memory set through a forgetting-enhancement mechanism; The prediction module aggregates the retrieved dynamic memory with the current input and inputs it into the prediction model based on the Sundial architecture to generate several candidate prediction sequences. It also uses frozen memory to calibrate the output of the Sundial generator, thereby producing the final prediction.
[0014] An electronic device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the above method.
[0015] A computer-readable storage medium for storing computer instructions that, when executed by a processor, implement the steps of the above-described method.
[0016] Compared with the prior art, the present invention has the following significant advantages: 1. Significantly improved prediction accuracy: On multiple public datasets (such as ETTh1, ETTm1, Electricity, etc.), compared with the Sundial base model, the MSE is reduced by 4.8% and the MAE is reduced by 6.4%; in long-term prediction tasks (such as horizon=336), the MSE is reduced by up to 12.8%; 2. Strong adaptability: The dynamic memory set and forgetting mechanism can effectively cope with data distribution shifts and adapt to non-stationary environments; 3. High computational efficiency: The dual-memory system and retrieval mechanism significantly reduce training and inference overhead while ensuring accuracy; 4. Modular design: Supports flexible integration with multiple basic models and has good scalability. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the RAMTime model framework of the present invention; Figure 2 The graph shows the performance analysis of the RAMTime model, including (a) the impact of the latent space dimension on model performance; (b) the impact of the number of encoder layers on model performance; and (c) a comparison of the inference speed and accuracy of this model with other models. Figure 3 The image shows the prediction results of the RAMTime model, where a) ETTh1, b) ETTm1, c) ECL, and d) Traffic. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] Unless otherwise specified, the experimental methods used in the following examples are conventional methods. Unless otherwise specified, the materials, reagents, methods, and instruments used are all conventional materials, reagents, methods, and instruments in the art, and can be obtained commercially by those skilled in the art.
[0020] The method of this invention is mainly aimed at power information time series prediction tasks, such as numerical prediction of the next few hours to days for multi-dimensional time series such as transformer oil temperature, load current, power factor and partial discharge signal in substations, thereby supporting equipment condition assessment, fault early warning and operation and maintenance decision-making.
[0021] The sampling frequency varies from 1 min / 3 min / 15 min / 1 h, and the sampling frequency of each data point in the same dataset is equal.
[0022] Combination Figures 1 to 3 This invention proposes a time series prediction method based on retrieval enhancement generation and memory mechanisms; Step 1, Preheating Phase: Building Frozen Memories In power scenarios, equipment operation often exhibits periodicity and repetitive patterns (such as daily load curves, weekly load characteristics, and seasonal temperature rises). This invention first extracts significant operational pattern motifs from a subset of historical training data (e.g., summer peak-hour data from a substation over the past three years) using time pattern extraction techniques. These motifs include "transformer temperature rise-load correlation curves" and "abnormal oscillation waveforms," and are then constructed into a frozen memory library as a preheating basis for the prediction system.
[0023] Specifically, a cumulative similarity matrix is constructed through dynamic programming to identify a set of non-overlapping Top-K key patterns in power data, forming a structured pattern library P. Each pattern corresponds to a typical operating condition. Subsequently, Reversible Instance Normalization (RevIN) and block embedding techniques are used to map each primitive to a high-dimensional embedding vector. Pre-training the embedding module through contrastive learning allows the embeddings of similar operating patterns to cluster in the vector space. The final frozen memory set contains the embedding vectors and their corresponding original sequences, providing stable and reusable long-term prior knowledge for the prediction system.
[0024] A frozen memory set is constructed from a subset of the training dataset as a warmup by using temporal pattern extraction and memory embedding. This invention establishes a stable frozen memory set from pre-extracted time series patterns, which provides a robust base pattern and significantly improves prediction accuracy by leveraging advanced motif discovery techniques to mine recurring patterns.
[0025] Pattern extraction: Extract salient temporal patterns (motifs) from the training data subset, construct a cumulative similarity matrix through dynamic programming, and identify the non-overlapping top-K motif set.
[0026] RAMTime first starts from a subset of dataset D Extracting important time series patterns. Through dynamic programming, it can be achieved using a cumulative similarity matrix C. ( yes The algorithm identifies the optimal candidate pattern by considering the sequence length. It computes C by aggregating local similarities while penalizing misalignments.
[0027]
[0028] in F i,j Indicates a point in time i and j The similarity between them is penalized. Following the above method, this invention identifies and extracts the Top-K non-overlapping sets from C, and generates a structured pattern repository P. Where K is the number of pattern sets, N is the number of motifs in each set, L is the variable length of each motif, and D is the number of features. This tensor forms the basis for building frozen memories in subsequent frameworks.
[0029] Memory embedding: Using Reversible Instance Normalization (RevIN) and block embedding techniques, motifs are mapped to high-dimensional embedding vectors, and pre-trained embedding modules are learned through contrastive learning. The repository P is embedded through a specific memory embedding module. A transformation is performed to capture salient features while maintaining the consistency of the distribution. Given the input... Each input channel First, independent normalization is performed using Reversible Instance Normalization (RevIN) to make its mean zero and standard deviation one, in order to mitigate the variation in the time series distribution.
[0030]
[0031] Then, the present invention will Divide into several lengths The sliding step size is S The invention uses consecutive overlapping patches. Given these patches, the invention embeds them using both value embedding and positional embedding. The combined embedding is then used to create dimensions using a simple linear layer through a projection head with GeLU activation and layer normalization.
[0032]
[0033] Storage Structure: The frozen memory set consists of embedding vectors and the original motif sequence, providing stable long-term dependencies. The embedded motifs constitute the frozen memory set. It consists of tuples Composition, in which E It is a frozen embedding vector. S It is the original motif sequence. The frozen memory set provides long-term dependencies for subsequent predictions.
[0034] The memory embedding module is pre-trained using a three-layer contrastive learning objective: embeddings from the same pattern set and the same feature constitute strong positive pairs; embeddings from the same pattern set but with different features constitute weak positive pairs; and embeddings from different pattern sets constitute negative pairs. InfoNCE loss is used to encourage the clustering of positive pairs while pushing away negative pairs.
[0035]
[0036] The entire phase can be viewed as a warm-up process, which significantly enhances... It improves the ability to distinguish effective motifs and shortens the training time.
[0037] Step 2, Retrieve Enhanced Memory (RAM): To adapt to real-time changes in power grid operation (such as sudden faults, weather changes, and temporary dispatching), this invention designs a dynamic memory system. This system uses a dual-tower embedding architecture to encode the current input sequence (such as monitoring data from the last few hours) and memory entries respectively, and retrieves the top-K most relevant historical patterns from both frozen and dynamic memories based on cosine similarity.
[0038] The dynamic memory set continuously records the embeddings, raw data, memory vitality values, and last access times of recent input sequences. Inspired by the Ebbinghaus forgetting curve, it is updated through a "forgetting-reinforcement" mechanism: frequently retrieved memories (such as a recurring overload pattern) are reinforced, while long-unused memories are gradually decayed and eliminated. Retrieved memories are fused with the current input through a cross-attention mechanism to form an enhanced contextual representation, thereby organically combining historical experience with the current state.
[0039] The RAM process is executed by using a dual-tower embedding layer to build a dynamic memory set and query set, performing similarity-based Top-K retrieval, and applying cross-attention and aggregation to generate recalled memories. RAMTime uses a dual-tower architecture to dynamically integrate relevant historical patterns with current inputs, enabling the system to dynamically adapt to evolving time series while maintaining computational efficiency through intelligent memory management.
[0040] Dynamic memory set: Stores the embeddings, original sequences, vitality values, and last access times of recently input sequences, supporting continuous updates. To capture evolving temporal patterns, this invention introduces a dynamic memory set. It is continuously updated based on recent input sequences. Each memory is stored as a tuple: , representing the embedding vector, the original sequence, the vitality of the memory, and the last access time, respectively.
[0041] This invention employs a dual-tower architecture: the query embedding tower and the memory embedding tower process the current input and the memory entry respectively, and uses momentum contrastive learning (MoCo) to improve retrieval quality.
[0042] Query Embedded Tower Encode the current input x into a query embedding. And memory embedded in the tower Then the memory embeddings of the frozen and dynamic memory sets are calculated, generating... Although the two towers share the same network architecture, their parameters are not shared, enabling specialized representation learning for queries and memories. This decoupled design, combined with Momentum Comparison (MoCo), ensures stable and high-quality embedding retrieval.
[0043] Contrast loss is defined as follows:
[0044] Here, Representing memory i Based on vitality-based weights, it suppresses noisy negative samples and improves the quality of contrastive learning.
[0045] Enhanced Recall: Upon receiving a new input query, RAMTime performs a comprehensive retrieval by calculating the similarity between the query embedding and all memory embeddings. This invention combines the memory embedding matrix and calculates the cosine similarity between the query and the memory embeddings, reducing overall training and inference overhead while maintaining competitive retrieval quality.
[0046]
[0047] Based on these similarity scores, a Top-K search is performed to select from the frozen and dynamic memory sets. k The most relevant memory entries. To fully integrate the retrieved context with the query, this invention employs a cross-attention mechanism, where the query acts as the query matrix Q. The retrieved memories serve as the key K and the value V.
[0048]
[0049] To further improve retrieval quality, this invention employs Reverse Rank Fusion (RRF) to merge and reorder retrieval results from different memory sources. Ultimately, the aggregated and reordered memory is obtained, denoted as [missing information]. .
[0050] Forgetting-Reinforcement Mechanism: To effectively manage dynamic memory sets under continuous input streams, this invention introduces an adaptive forgetting-reinforcement mechanism inspired by the Ebbinghaus forgetting curve. This strategy enhances memory effectiveness by reinforcing frequently accessed items and removing less relevant items. Whenever a memory item... When retrieved, its vitality increases by a constant enhancement value. And its access time will be updated to the current timestamp. .
[0051]
[0052] For memories that have not been retrieved for a period of time, their activity will effectively decay, preventing long-term unused memory entries from occupying too much capacity. The probability of a memory being retained is modeled as follows:
[0053] in This is the time that has elapsed since the last visit. Control the baseline attenuation rate, while The invention controls the impact of vitality on retention time. When the dynamic memory set is full, memory entries with low vitality or low retention probability are forgotten, ensuring that only the most relevant and useful memories are retained. Ultimately, this invention obtains retrieval results for all memory entries. This provides a foundation for accurate prediction.
[0054] Step 3, Prediction Phase: The retrieved dynamic memory is aggregated with the current input and then fed into a prediction model based on the Sundial architecture to generate several candidate prediction sequences. Simultaneously, the candidate predictions are calibrated using typical operating modes (such as normal operating primitives) stored in the frozen memory. Through similarity matching, affine alignment, and weighted fusion, the final prediction result is output. This process effectively combines long-term regularity with short-term dynamism, significantly improving prediction robustness under complex scenarios such as sudden load changes and equipment anomalies.
[0055] To improve deployment efficiency, this invention uses low-rank adaptation (LoRA) to perform lightweight fine-tuning of the basic prediction model, which significantly reduces the number of trainable parameters and facilitates integration into power edge computing devices.
[0056] The recalled dynamic memory is aggregated with the current input, and the frozen memory is used to calibrate the output of the Sundial generator to produce the final prediction. This design combines long-range prior patterns with instance-specific context, while capturing both long and short-term dependencies to achieve robust and adaptive predictions.
[0057] Using the base model for prediction: Based on the retrieved memory set This invention leverages these memories to enhance the predictive performance of a pre-trained base model. This is achieved through memory-enhanced input construction and memory-guided output selection, which facilitates contextual expansion and structure extraction of predictions. The recalled memory set contains both dynamic and frozen memory entries. This invention normalizes and concatenates the dynamic sequence with the current input. x These are combined to form a rich context that provides extended temporal information. Then, the enhanced input... The data is passed to the base model, which generates multiple candidate predictions.
[0058]
[0059] This invention uses Sundial as the base model because it is capable of generating multiple diverse prediction sequences. This aligns effectively with the retrieval-enhanced memory strategy of this invention: from the candidate predictions generated by Sundial, this invention retrieves the one most similar to the recalled frozen motif using cosine similarity, applies affine alignment, and performs a weighted fusion with the original prediction to produce the final output. The aligned prediction is then weighted based on confidence level. By merging the data, a final prediction can be obtained. .
[0060]
[0061] To efficiently adapt the base model without requiring full fine-tuning, this invention employs Low-Rank Adaptation (LoRA), which utilizes low-rank decomposition... By updating matrices A and B to influence the weights of the entire matrix, the number of trainable parameters is greatly reduced while maintaining adaptability. This allows the model to simultaneously leverage the contextual richness of dynamic memory and the structural regularity of frozen motifs, achieving accurate and robust predictions through memory-enhanced learning.
[0062] like Figure 1 As shown, the RAMTime model of this invention can be divided into three stages: Warmup Phase (Lower Left and Middle): This phase corresponds to the "MotifExtractor" and "Memory Embedding" processes in the diagram. First, basic temporal patterns are extracted from the input data subset D'. Then, through the memory embedding module (including instance normalization, patchify, value / positional embedding, GeLU activation function, layer normalization, and projection head), frozen memory embedding vectors are generated. Construct a frozen memory set called "Frozen Memory Set".
[0063] RAM processing stage (middle and right side): This stage corresponds to the "Dual Tower" and the retrieval process on the right. The current input x is then processed by the query embedding module to generate... And enter the shared memory embedding module to generate This is used to update the dynamic memory. The dynamic memory is updated through a forgetting-reinforcement mechanism. During retrieval, and and Similarity is calculated and the K most similar memories are selected for recall. Then, through cross-attention, feature fusion, ranking-based reordering and aggregation operations, memory fragments are finally generated.
[0064] Forecasting Phase (Top): Retrieved and enhanced memories (dynamic memories for enhancing input, frozen memories for calibrating output) are combined into contextual content, assisting the base model Sundial in making predictions through "LoRA" adaptation. Finally, the final prediction Y is generated through the "Align" step of prediction alignment.
[0065] In the examples, all models were trained using Adam (initial learning rate 0.0001, halved every epoch), with a batch size of 32, a maximum of 10 epochs, and early stopping. The embedding dimension was 256, and the forgetting rate was... and enhancement value The values were set to 0.3 and 0.6 respectively. 10% of the training data was used for frozen memory construction to balance efficiency and representativeness. The input length was fixed at 96, and predictions were evaluated at prediction strides of {96, 192, 336, 720}. All results are averages of 5 runs for each configuration, using MSE and MAE as evaluation metrics. The model was run on an NVIDIA RTX 4090 GPU (24GB RAM).
[0066]
[0067] Table 1: Performance evaluation of the time series basic model based on mean squared error (MSE) and mean absolute error (MAE), and comparison with RAMTime.
[0068]
[0069] Table 2: Performance evaluation of deep learning time series models based on mean squared error (MSE) and mean absolute error (MAE), and comparison with RAMTime.
[0070] As shown in Tables 1 and 2, this invention reduces MSE by 4.8% and MAE by 6.4% compared to the Sundial base model on multiple public datasets (such as ETTh1, ETTm1, Electricity, etc.); in long-term prediction tasks (such as horizon=336), the MSE is reduced by up to 12.8%. A time series prediction system based on retrieval-enhanced generation and memory mechanisms; The system includes a preheating module, a retrieval enhancement memory module, and a prediction module; The preheating module extracts key operating mode motifs from a subset of the historical training dataset of power information through time pattern extraction and memory embedding, and constructs a frozen memory set as a preheating module. The retrieval enhancement memory module uses a dual-tower embedding layer to construct a dynamic memory set and a query set, performs similarity-based retrieval of the top-K most relevant historical patterns, applies cross-attention and aggregation to generate recalled memories, and updates the dynamic memory set through a forgetting-enhancement mechanism; The prediction module aggregates the retrieved dynamic memory with the current input and inputs it into the prediction model based on the Sundial architecture to generate several candidate prediction sequences. It also uses frozen memory to calibrate the output of the Sundial generator, thereby producing the final prediction.
[0071] An electronic device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the above method.
[0072] A computer-readable storage medium for storing computer instructions that, when executed by a processor, implement the steps of the above-described method.
[0073] The memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDRSDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DRRAM). It should be noted that the memory of the methods described in this invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0074] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired means such as coaxial cable, optical fiber, digital subscriber line (DSL), or wireless means such as infrared, wireless, or microwave. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media such as floppy disks, hard disks, magnetic tapes, optical media such as high-density digital video discs (DVDs), or semiconductor media such as solid-state drives (SSDs).
[0075] In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software. The steps of the method disclosed in the embodiments of this application can be directly implemented by a hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, detailed descriptions are omitted here.
[0076] It should be noted that the processor in the embodiments of this application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method embodiments can be completed by the integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied as execution by a hardware decoding processor, or as execution by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above methods.
[0077] The foregoing has provided a detailed description of the time series prediction method based on retrieval enhancement generation and memory mechanisms proposed in this invention. The principles and implementation methods of this invention have been elucidated. The method proposed in this invention fully considers the characteristics of power time series data, and by fusing historical patterns and real-time states through a memory mechanism, it can provide reliable technical support for smart grid operation monitoring, equipment early warning, and dispatch optimization. The above description of the embodiments is only for the purpose of helping to understand the method and core ideas of this invention; at the same time, for those skilled in the art, based on the ideas of this invention, there will be changes in specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this invention.
Claims
1. A power time series forecasting method based on retrieval-augmented generation and memory mechanism, characterized in that: The method specifically comprises the following steps: Step 1, preheating phase: obtain key operating patterns motifs from a subset of the power information historical training dataset through time pattern extraction and memory embedding, and construct a frozen memory set as preheating; Step 2, retrieval-augmented memory phase: use a double-tower embedding layer to construct a dynamic memory set and a query set, retrieve the most relevant Top-K historical patterns based on similarity, and update the dynamic memory set through a forgetting-augmentation mechanism; Step 3, prediction phase: aggregate the retrieved dynamic memory with the current input, input it into a Sundial-based prediction model, generate several candidate prediction sequences, and use the frozen memory to calibrate the output of the Sundial generator to produce the final prediction.
2. The method of claim 1, wherein: In step 1, The time pattern extraction specifically comprises: constructing a cumulative similarity matrix through dynamic programming, aggregating local similarity for the matrix, and penalizing misalignment, identifying and extracting non-overlapping Top-K key operating patterns motifs from the power data, each pattern corresponding to a typical operating condition, and forming a structured pattern repository.
3. The method of claim 2, wherein: In step 1, The memory embedding specifically comprises: using reversible instance normalization and block embedding technology to map each key operating pattern motif to a high-dimensional embedding vector, and pre-training the embedding module through contrastive learning to make similar operating pattern embeddings cluster in the vector space.
4. The method of claim 3, characterized in that: In step 1, the frozen memory set consists of embedded vectors and corresponding original sequences, the embedded base sequences constitute the frozen memory set , which consists of tuples , where E frozen is a frozen embedded vector, S motif is an original base sequence; In step 2, the dynamic memory set , is continuously updated with recent input sequences; each memory is stored as a tuple: , E dynamic is an embedding vector, S dynamic is the original sequence, v is the vitality of the memory, t is the last access time.
5. The method of claim 4, wherein: In step 2, Combine the memory embedding matrix of the frozen memory set and the dynamic memory set, calculate the cosine similarity between the query embedding and the memory embedding, perform Top-K retrieval based on the similarity score, and then merge and reorder the retrieval results of different memory sources through inverse ranking fusion.
6. The method of claim 5, characterized in that: In step 2, the forgetting-augmentation mechanism specifically comprises: increasing the retrieved memory entry's vitality value by a constant augmentation value and updating the access timestamp, and decaying the vitality value of long-term unretrieved memory entries according to a preset rule; when the dynamic memory set is full, delete memory entries with low vitality value or low retention probability.
7. The method of claim 6, wherein: In step 3, For the candidate predictions generated from Sundial, use the typical operating patterns stored in the frozen memory to calibrate the candidate predictions, output the final prediction result through similarity matching, affine alignment and weighted fusion.
8. An electricity timing prediction system based on a retrieval-augmented generation and memory mechanism, characterized by: The system is used to execute the power time series forecasting method based on the retrieval-augmented generation and memory mechanism of any one of claims 1 to 7; The system comprises a preheating module, a retrieval-augmented memory module and a prediction module; The preheating module obtains key operating patterns motifs from a subset of the power information historical training dataset through time pattern extraction and memory embedding, and constructs a frozen memory set as preheating; The search-enhanced memory module uses a dual tower embedding layer to construct a dynamic memory set and a query set, performs similarity-based search on the most relevant Top-K historical patterns, applies cross-attention and aggregation to generate recalled memories, and updates the dynamic memory set through a forgetting-enhancing mechanism; The prediction module aggregates the retrieved dynamic memories with the current input, inputs them into a prediction model based on a Sundial framework, generates a plurality of candidate prediction sequences, and uses frozen memories to calibrate the output of the Sundial generator, thereby producing a final prediction. 9.An electronic device comprising a memory and a processor, the memory storing a computer program, wherein, The processor executes the computer program to implement the steps of the method in any one of claims 1 to 7.
10. A computer readable storage medium for storing computer instructions, characterized in that, The computer instructions are executed by the processor to implement the steps of the method in any one of claims 1 to 7.