Electric energy metering risk monitoring method, system and equipment based on time sequence model retrieval and medium
By constructing a multimodal data sample library and performing adaptive fusion based on a time-series model retrieval method, the problems of domain dependence and high adaptive cost in the risk monitoring of power metering terminals are solved, and cross-domain adaptation and accurate risk warning are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-18
- Publication Date
- 2026-03-27
AI Technical Summary
Existing technologies for risk monitoring in electricity metering terminals suffer from several problems, including strong domain dependence, insufficient generalization ability, high adaptive costs, difficulty in large-scale deployment, lack of effective adaptive mechanisms during testing, and crude anomaly scoring mechanisms.
A time-series model-based retrieval method is adopted. By collecting multi-dimensional time-series data, a multi-modal time-series data sample library is constructed. A pre-trained time-series basic model is used for encoding and prediction. Historical normal samples are dynamically searched for similarity. Combined with an adaptive fusion mechanism, a fusion feature representation is generated to conduct multi-dimensional risk assessment. Finally, a dynamic decision mechanism is used to output the monitoring results.
It achieves cross-domain adaptation, reduces false alarms and missed alarms, improves monitoring accuracy and robustness, has strong adaptive and generalization capabilities, and provides accurate risk warning capabilities.
Smart Images

Figure CN121745683A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of risk monitoring, in particular to an electric energy metering risk monitoring method, system, device and medium based on time series model retrieval. BACKGROUND
[0002] As a key node of the smart grid, the operation reliability of the electric energy metering terminal is crucial. The current risk monitoring technology is facing severe challenges. Traditional statistical and machine learning methods have poor generalization ability when dealing with massive, high-dimensional and complex time series data, and have high false alarm and missed alarm rates. In recent years, although deep learning models based on Transformer have shown advantages, they are strongly dependent on the domain, and it is costly to train a model for each terminal, making it difficult to scale. Although the time series basic model has the potential for cross-domain generalization, when applied directly to new terminals under the zero-sample setting, the model has difficulty understanding the normal mode of the time series data due to the lack of explicit semantics, resulting in a "domain gap" and high false alarm rate. To bridge this gap, model fine-tuning is not feasible due to the high computational cost.
[0003] In addition, existing technologies generally lack effective test-time adaptation mechanisms, and cannot dynamically calibrate predictions using the terminal's own historical normal data. At the same time, the abnormal scoring mechanism is usually rough, directly using prediction errors, and is highly sensitive to normal fluctuations such as periodic peaks, which can easily cause false alarms. Existing technologies generally face core challenges such as strong domain dependence, insufficient cross-domain generalization ability, high adaptation cost, and inaccurate scoring mechanism when dealing with the widespread, heterogeneous, and dynamic deployment environment of electric energy metering terminals. A new monitoring technology is needed to overcome these limitations. SUMMARY
[0004] In view of the above existing problems, the present application provides an electric energy metering risk monitoring method, system, device and medium based on time series model retrieval, to solve the problems of strong domain dependence, insufficient generalization ability, high domain adaptation cost, difficulty in large-scale deployment, lack of effective test-time adaptation mechanism, inability to use terminal's own historical data, and rough abnormal scoring mechanism.
[0005] To solve the above technical problems, an electric energy metering risk monitoring method based on time series model retrieval is proposed, which includes, The multi-dimensional time sequence operation data of the target electric energy metering terminal is collected, preprocessed, multi-modal time sequence data sample library is obtained, and the pre-trained time sequence basic model is used to process the data, encode and predict the time sequence data; for the current time sequence data to be evaluated, the similar historical normal samples are dynamically searched from the sample library through the similarity-based retrieval mechanism, and the adaptive fusion mechanism is used to integrate the retrieved context information into the prediction logic of the basic model to generate the integrated feature representation; based on the integrated feature representation, multi-dimensional risk assessment is performed, the integrated risk score is calculated, and the dynamic decision mechanism is used to process and judge the risk score, and the monitoring result is output.
[0006] As a preferred scheme of the electric energy metering risk monitoring method based on the time sequence model retrieval, the multi-modal time sequence data sample library is obtained by collecting multi-dimensional time sequence operation data of the electric energy metering terminal and preprocessing, using the overlapping sliding window method to divide the continuous time sequence into data blocks, attaching a context feature vector to each data block, and storing the structured samples in the behavior sample library together with the original time sequence data block.
[0007] As a preferred scheme of the electric energy metering risk monitoring method based on the time sequence model retrieval, the similarity-based retrieval mechanism includes using the encoded current time sequence data as a query basis, searching for historical behavior samples in a hierarchical memory storage structure in parallel by calculating the correlation between features, and according to the correlation, weighting the importance of the search results at each time granularity and aggregating them into a retrieval reference feature.
[0008] As a preferred scheme of the electric energy metering risk monitoring method based on the time sequence model retrieval, the adaptive fusion mechanism includes joint analysis of the retrieval reference feature and the observation feature extracted by the basic model from the current data. Through the learnable weight regulation unit, the contribution ratio of the current observation and the historical reference is dynamically generated according to the joint analysis result. According to the contribution ratio, the observation feature and the retrieval reference feature are adjusted and synthesized to output the fusion feature representation.
[0009] As a preferred scheme of the electric energy metering risk monitoring method based on the time sequence model retrieval, the pre-trained time sequence basic model processing data includes constructing a time sequence basic model based on the Transformer encoder-decoder architecture, using the mask reconstruction task and the contrast learning task for two-stage pre-training on the time sequence data set, establishing a hierarchical memory bank composed of short-term, medium-term and long-term memory banks, using the FAISS index to store the feature representation of the historical time sequence segment and the corresponding future sequence and context information, and dynamically retrieving information from the memory bank according to the input query sequence. The two-stage pre-training formula is expressed as: wherein, is a mask reconstruction loss function, is a set of masked time points, is a time index, is a true observation value, i.e., original time series data, at time step t, is a predicted value of the masking value at time step t by the model, is a contrastive learning loss function, is a similarity function, is a feature representation of an anchor sample generated from the original sample through data augmentation, is a feature representation of a positive sample generated from the original sample through different augmentation methods, is a feature representation of a positive sample generated from the original sample through different augmentation methods, is a feature representation of K samples other than the positive sample is a feature representation of K samples other than the positive sample is a temperature parameter, is the total number of samples in the denominator for calculating the loss, is a sample index, is an exponential function, is a natural logarithm.
[0010] As a preferred scheme of the electric energy metering risk monitoring method based on the time series model retrieval, the parallel search of the historical behavior sample includes calculating the cosine similarity between the query feature and the sample key vector in each memory bank, selecting the Top-K samples with the highest cosine similarity in each memory bank to form the retrieval result set of the current layer, and using a preset weight to weight and fuse the retrieval result similarity under different time scales to obtain the final similarity score of each historical sample. The formula for calculating the final similarity score is: wherein, is a cosine similarity score, is a query vector, is a key vector, is a vector dot product operation, is a norm of the query vector, is a norm of the key vector, is a final similarity score, is the cosine similarity calculated for sample j in the short-term memory bank, is the cosine similarity calculated for sample j in the medium-term memory bank, is the cosine similarity of sample j in the long-term memory bank, is the weight coefficient assigned to the short-term scale similarity, is the weight coefficient assigned to the medium-term scale similarity, is the weight coefficient assigned to the long-term scale similarity, is the sample index in the retrieval result set; The hierarchical memory storage structure includes a short-term memory bank storing data of the last 7 days, a medium-term memory bank storing data of 30 days, and a long-term memory bank storing data of 90 days; The learnable weight regulation unit includes a gated fusion unit receiving the spliced vector of the observation feature and the retrieval reference feature as input, calculating a gating value through a learnable weight matrix and a Sigmoid activation function, using the gating value as a weight to scale the observation feature, using the complement of the gating value as a weight to scale the retrieval reference feature, adding the scaled two parts of features, and outputting the final fused feature; The formula of the gated fusion unit is represented as: wherein, is the gating value, is the Sigmoid activation function, is the learnable weight matrix, is the vector splicing operation, is the observation feature, is the retrieval context vector, is the fused feature representation, is the element-wise multiplication, is the retrieval result set, is the sample index in the retrieval result set, is the Softmax function, is the learnable linear transformation matrix.
[0011] As a preferred scheme of the electric energy metering risk monitoring method based on the time series model retrieval, the multi-dimensional risk assessment includes using the prediction function of the basic model to infer the future time series state based on the fused feature representation, obtaining a prediction sequence, quantifying the deviation degree between the prediction sequence and the actual observation sequence as a core risk indicator, combining an uncertainty indicator reflecting the reliability of the prediction result, and a representation difference indicator reflecting the integration degree of the current data and historical experience, and comprehensively weighting the indicators to obtain a final risk quantification score; The formula for calculating the risk quantification score is represented as: in, For the prediction error term, For the actual observation at time step t+1, The model prediction at time step t+1 The square of the L2 norm. For the distribution deviation term, For Kullback-Leibler divergence, Let be the distribution of the model's predicted future states at time step t. This is a reference distribution learned from historical normal data. For the characteristic drift term, For observational features, As a feature of fusion, It is an L1 norm. The final comprehensive risk score is calculated at time step t. These are the weighting coefficients assigned to the prediction error term. The weighting coefficients assigned to the distribution deviation term, These are the weighting coefficients assigned to the feature drift term; The dynamic judgment mechanism includes smoothing the comprehensive risk score sequence using a moving average algorithm, setting the smoothing window length to the estimated period length of the terminal data, calculating the mean and standard deviation of the smoothed risk scores over the past M time points, updating the dynamic judgment threshold in real time using an exponential moving average method, comparing the smoothed risk score at the current time with the dynamic judgment threshold, and determining a risk event and generating an early warning when the threshold is exceeded. The smoothing formula is expressed as: in, The risk score after smoothing at time step t. To smooth the length of the window, For smooth window indexing; The formula for updating the dynamic threshold is expressed as follows: in, To dynamically determine the threshold at time step t, This represents the mean of the smoothed risk scores over the past M time points. The standard deviation of the risk score after smoothing over the past M time points. This is the sensitivity coefficient.
[0012] The beneficial effects of this preferred technical solution are as follows: by integrating prediction error, distribution deviation and feature drift to construct a multi-dimensional risk assessment, a three-dimensional risk profile is formed, which significantly reduces false alarms and missed alarms. The dynamic decision mechanism uses smoothing processing and adaptive thresholds to filter out instantaneous noise and keep up with the long-term drift of equipment operating conditions, ensuring the sensitivity and adaptability of early warning and providing a reliable basis for intelligent operation and maintenance.
[0013] As a preferred embodiment of the energy metering risk monitoring system based on time-series model retrieval described in this invention, it is characterized by including a multimodal data preprocessing and sample library construction module, a retrieval enhancement time-series basic model module, a dynamic retrieval and context fusion module, a multi-dimensional risk assessment and calculation module, and a dynamic decision and early warning generation module.
[0014] The multimodal data preprocessing and sample library construction module is used to perform two-level data cleaning and outlier removal through rule filtering and isolated forest algorithm, use cross-correlation function to synchronize and align the time of multi-channel data, and use instance normalization and polynomial fitting to decompose data trends and fluctuations. By overlapping blocks and attaching contextual features such as time period, date, temperature and load category to each data block, a hierarchical structured behavioral sample library is constructed.
[0015] The retrieval enhancement temporal basic model module is used to pre-train the model using a Transformer encoder-decoder architecture through a two-stage task of mask reconstruction and contrastive learning.
[0016] The dynamic retrieval and context fusion module is used to calculate the multi-scale cosine similarity between the current data features and the samples in the memory, and to weight and fuse the retrieval results. Through a learnable gating fusion unit, the retrieved context information is dynamically combined with the model's original understanding of the current observation to generate a fused feature representation.
[0017] The multi-dimensional risk assessment and calculation module is used to generate predictions of future states using the decoding function of the basic model, comprehensively calculate three indicators, and perform a weighted summation of the three indicators to obtain the final comprehensive risk score.
[0018] The dynamic judgment and early warning generation module is used to smooth the original risk score sequence to filter out instantaneous spikes caused by normal periodic peaks. Based on the historical statistics of the scores, the exponential moving average is used to dynamically update the anomaly judgment threshold. The smoothed score is compared with the dynamic threshold. If it exceeds the threshold, it is judged as an abnormal event and a graded early warning is triggered. The module provides preliminary anomaly analysis by combining the scores of each sub-item.
[0019] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of a method for monitoring electricity metering risks based on time-series model retrieval.
[0020] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a method for monitoring energy metering risks based on time-series model retrieval.
[0021] The beneficial effects of this invention are as follows: By constructing a structured sample library and conducting two-stage pre-training, this invention lays a solid foundation for accurate analysis. Utilizing hierarchical multi-time granularity retrieval, it dynamically matches personalized historical normal baselines for each current moment, improving the accuracy and robustness of the matching. Furthermore, through an adaptive gating fusion mechanism, it intelligently integrates current observations and historical experience, overcoming the limitations of a single information source and generating features with stronger discriminative power. Based on the fused features, multi-dimensional risk assessment and dynamic threshold decision-making construct a comprehensive risk profile to reduce false alarms and missed alarms. It can adapt to the long-term drift of equipment status, achieving a leap from anomaly detection to risk quantification. This gives the monitoring method extremely high accuracy, strong adaptability and generalization capabilities, and forward-looking and interpretable risk warning capabilities, effectively promoting the upgrade of power metering operation and maintenance towards intelligent and refined management. Attached Figure Description
[0022] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 The above is a flowchart of the overall process of a time-series model-based energy metering risk monitoring method provided in one embodiment of the present invention.
[0024] Figure 2 The flowchart shows a system scheme for an energy metering risk monitoring system based on time-series model retrieval, as provided in one embodiment of the present invention. Detailed Implementation
[0025] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.
[0026] Example 1, referring to Figure 1 As an embodiment of the present invention, a method for monitoring electricity metering risks based on time-series model retrieval is provided, comprising: S100: Collects multi-dimensional time-series operation data of the target power metering terminal, performs preprocessing, obtains a multi-modal time-series data sample library, and uses a pre-trained time-series basic model to process the data, encodes and predicts the time-series data.
[0027] S200: For the current time series data to be evaluated, a similarity-based retrieval mechanism is used to dynamically search for matching historical normal samples from the sample library, and an adaptive fusion mechanism is used to integrate the retrieved contextual information into the prediction logic of the basic model to generate a fused comprehensive feature representation.
[0028] S300: Performs multi-dimensional risk assessment based on comprehensive feature representation, calculates comprehensive risk score, and uses dynamic decision-making mechanism to process and determine the risk score, outputting monitoring results.
[0029] It should be noted that by using a structured sample library and pre-trained models as a foundation, and through multi-scale retrieval and adaptive fusion mechanisms, the model can dynamically refer to historical patterns, achieving zero-cost cross-domain adaptation. Combined with multi-dimensional risk assessment and dynamic threshold decision-making, the monitoring accuracy and robustness are significantly improved, and false alarms are effectively reduced.
[0030] Example 2, refer to Figure 1 This is a second embodiment of the present invention, which provides a method for monitoring electricity metering risks based on time-series model retrieval, including: In step S100, the acquisition of multidimensional time-series runtime data includes steps S101 to S103: S101: Construct a holographic data acquisition system from the on-site power metering terminals to continuously and synchronously collect time-series operational data covering four dimensions: electrical, hardware, communication, and system.
[0031] S102: Electrical measurement characteristics include voltage, current, active / reactive power, power factor, and harmonic distortion rate; hardware operation characteristics include CPU utilization, memory usage, storage read / write speed, and chip temperature; communication network characteristics include heartbeat interval, message retransmission rate, communication delay, packet loss rate, received signal strength, and channel noise; system log characteristics record remote upgrade events, parameter configuration changes, communication anomaly counts, and security audit events.
[0032] S103: All data channels are synchronously acquired at a preset frequency, ultimately forming a unified multi-channel timing matrix.
[0033] Furthermore, in this embodiment of the application, in step S100, the preprocessing includes steps S111~S113: S111: The two-stage cleaning process includes automatically removing obviously invalid data through rule-based filtering (removing out-of-range values) and identifying and removing potential outliers using a sliding window-based median filter combined with the isolated forest algorithm.
[0034] S112: Missing value handling includes, for missing data segments, performing a nearest neighbor (KNN) interpolation algorithm based on multivariate regression, and using highly correlated remaining channel data to reconstruct the missing values with high precision.
[0035] S113: Time synchronization and alignment includes establishing a unified time reference based on the high-precision network time protocol (PTP), automatically estimating the time offset by calculating the window cross-correlation function for the inherent delay of different acquisition channels, and completing the delay compensation in the data preprocessing stage.
[0036] In an optional implementation, in step S100, the preprocessing further includes applying wavelet decomposition to each data channel to decompose the signal into sub-bands of different frequencies, adaptively setting thresholds by calculating the statistical characteristics of each sub-band, and performing soft thresholding on the wavelet coefficients to remove noise and outliers; for missing data, a prediction interpolation method based on a time series autoregressive model is used to fill in the missing data using historical data from the same channel; for time alignment, a dynamic time warping algorithm based on least squares is used to align the data from different channels in the time domain through nonlinear time warping; data normalization uses global normalization instead of instance normalization, and standardizes the data using historical statistics of the entire dataset.
[0037] In another optional implementation, in step S100, the preprocessing may further include: using an empirical mode decomposition method to decompose the time-series data of each channel into multiple intrinsic mode functions and a residual term; identifying and removing IMF components representing abnormal behavior by analyzing the statistical characteristics and instantaneous frequency of each IMF component; reconstructing the signal; handling missing values using an interpolation method based on similar day patterns to find contemporaneous data with similar dates from historical data as a basis for filling; time synchronization using an alignment method based on maximizing mutual information to determine the optimal time delay parameter by maximizing the mutual information between data from different channels; and data decomposition using a seasonal-trend decomposition method to decompose the data into three parts: trend, seasonality, and residual.
[0038] It should be noted that, in the embodiments of this application, in step S100, obtaining the multimodal time series data sample library includes steps S121~S124: S121: Perform a reversible instance normalization operation on each data channel within each sliding window to eliminate dimensional differences between different windows; The formula for instance normalization is expressed as: in, For the o-th data channel at time step t, after instance normalization, This represents the observation value of the o-th data channel at time step t in the original time series data. This represents the arithmetic mean of all data from the o-th data channel within the current sliding window at time step t. Let be the standard deviation of all data from the o-th data channel within the current sliding window at time step t. It is a very small positive number.
[0039] S122: The sliding window polynomial fitting algorithm is used to decompose the original time series data into long-term trend terms and short-term fluctuation residual terms, respectively capturing the slow degradation trend and potential sudden anomalies of the equipment. The sliding window polynomial fitting algorithm is expressed as follows: in, For long-term trend items, This represents the short-term fluctuation residual term.
[0040] S123: The processed continuous time series data is divided into fixed-length data blocks using the overlapping sliding window method, and a context feature vector containing time period code, date type, temperature level and load category is generated for each data block.
[0041] S124: Store all structured samples consisting of data blocks and corresponding context feature vectors into the behavior sample library as the basis for subsequent model retrieval.
[0042] In an optional implementation, in step S100, obtaining the multimodal time series data sample library further includes extracting a set of manually designed time series features for each data block, including statistical features, frequency domain features, and time domain features; using a clustering algorithm to cluster the feature vectors; storing the center of each cluster as a typical pattern in the sample library; the context information includes time tags and working condition tags; the sample library adopts an inverted index structure; samples are organized according to context tags; during retrieval, samples are first filtered according to the context; and similarity is calculated among the filtered samples.
[0043] In another optional implementation, in step S100, obtaining the multimodal time series data sample library may further include collecting normal operating time series data, training a conditional generative adversarial network (GAN), whose generator takes random noise and contextual conditions as input to generate synthetic time series data that conforms to normal behavior patterns, mixing real data with high-quality synthetic data to form an expanded sample library, and storing the generation probability and authenticity score as metadata for each sample in the sample library in addition to the original time series data, and using a ball tree index structure to store the feature vector of the sample, supporting range query and nearest neighbor search, and the sample update adopts an importance sampling strategy, giving priority to retaining samples with high generation probability and good diversity.
[0044] Furthermore, in this embodiment of the application, in step S100, the encoding and prediction of the time-series data includes steps S131 to S133: S131: Design a Transformer-based encoder-decoder architecture. The encoder is responsible for mapping the input temporal data into high-dimensional features, while the decoder uses causal attention masks to ensure that predictions are made only based on historical information and integrates a module for receiving external retrieval context.
[0045] S132: A two-stage strategy is adopted to pre-train the model: the first stage involves randomly masking some time points on large-scale data and training the model to reconstruct the model and learn the inherent laws of time series. The mask reconstruction formula is expressed as: in, For mask reconstruction loss function, The set of time points that were obscured. For time-series indexes, The actual observations at time step t, i.e., the original time series data, This is the model's predicted value for the occlusion at time step t; The second stage utilizes data augmentation to generate positive and negative sample pairs, and improves the discriminative power of the model's feature representation through comparative learning tasks; The contrastive learning formula is expressed as: in, To compare the learning loss function, For similarity function, To enhance the feature representation of anchor samples generated from the original samples through data augmentation, To and Feature representations of positive samples generated from the same original sample using different enhancement methods. To exclude positive samples The feature representation of the K samples outside, For temperature parameters, The total number of samples in the denominator used to calculate the loss. For sample index, It is an exponential function. It is the natural logarithm.
[0046] S133: Establish a three-level FAISS index memory for the target terminal, including a short-term memory that stores normal behavior samples from the last 7 days, a medium-term memory that stores normal behavior samples from the last 30 days, and a long-term memory that stores normal behavior samples from the last 90 days. In each memory, the key of the index is the feature vector extracted by the pre-trained model encoder from the historical normal time-series data block, and the corresponding value includes the future real sequence segment corresponding to the abandoned data block and the context feature vector.
[0047] In an optional implementation, in step S100, the encoding and prediction of the time-series data further includes an encoder consisting of multiple one-dimensional convolutional layers and pooling layers stacked alternately. Each convolutional layer uses a convolutional kernel of a different size to capture multi-scale time-series features. Residual connections are added after the convolutional layers to alleviate the gradient vanishing problem. A global average pooling layer is used to convert the feature map into a fixed-dimensional feature vector. To enhance the ability to capture long-term dependencies, a lightweight recurrent neural network layer is added after the CNN encoder. An attention mechanism is introduced during feature extraction to assign different weights to features at different time steps, highlighting information at important moments.
[0048] In another optional implementation, in step S100, the encoding and prediction of time series data may further include treating different variables at each time step as graph nodes, using the correlation between variables as edge weights, constructing a dynamic graph structure, and the encoder consisting of multiple graph attention network layers. Each layer aggregates neighborhood node information through a message passing mechanism and updates the node representation. In addition to the graph neural network layers, a temporal convolution module is also introduced to extract patterns in the time dimension and interacts with the feature vectors of the entire time series through graph pooling operations.
[0049] In step S200, the dynamic search for matching historical normal samples includes steps S201-S203: S201: Convert the current time window to be detected into a query feature vector through the encoder of the pre-trained model.
[0050] S202: Multi-scale similarity retrieval includes calculating the cosine similarity between the query vector and all key vectors in the short-term, medium-term, and long-term memory banks, and selecting the top K samples with the highest similarity in each bank to form the retrieval result set for each scale. The formula for calculating the cosine similarity score is expressed as follows: in, Scoring the cosine similarity. For query vector, For key vectors, For vector dot product operation, To query the norm of the vector, Let be the norm of the key vector.
[0051] S203: The similarity scores at different time scales are weighted and fused using preset weighting coefficients to calculate a comprehensive final similarity score for each candidate sample, so as to fully evaluate its relevance to the current query. The formula for calculating the final similarity score is expressed as follows: in, For the final similarity score, The cosine similarity of sample j calculated in the short-term memory. The cosine similarity of sample j calculated in the intermediate memory. The cosine similarity of sample j calculated in the long-term memory. The weighting coefficients assigned to short-term similarity The weighting coefficients assigned to the intermediate-scale similarity The weighting coefficients assigned to long-term scale similarity This is a sample index for the search results set.
[0052] Furthermore, in this embodiment of the application, in step S200, the generation of the fused integrated feature representation includes steps S211 to S214: S211: For the K samples with the highest final scores, the Softmax function is used to calculate the weights and aggregate the weighted values to generate a unified retrieval context vector, expressed by the formula: in, To retrieve the context vector, For the search result set, For the sample index in the retrieval results set, For temperature parameters, For the final similarity score, It is a learnable linear transformation matrix. This is the key vector.
[0053] S212: Through a gated fusion unit, the context vector and the observation feature vector obtained by the model encoding the current query are adaptively fused. The gating mechanism dynamically determines the degree of dependence on the current observation and past experience, and outputs the final fused feature representation. The formula for the gated fusion unit is expressed as: in, This is the gate value. It is the Sigmoid activation function. The weight matrix is a learnable matrix. This is a vector concatenation operation. For observational features, For the fused feature representation, For element-wise multiplication, This refers to the Softmax function.
[0054] S213: In the dynamic memory update process, a sliding window mechanism is adopted. When new data is judged to be normal and has a high degree of difference from the samples in the library, it is added as a new sample, and the oldest sample is deleted to maintain the library capacity.
[0055] S214: To ensure the diversity and representativeness of the memory, the system introduces an information value coefficient to evaluate the retention priority of samples. This coefficient comprehensively measures the sample's own information entropy and its difference from the current search result set; high-value samples will be retained first. The formula for calculating the information value coefficient is as follows: in, Information value coefficient For the candidate samples to be evaluated, For information entropy, For similarity function, This is the set of search results.
[0056] In an optional implementation, in step S200, generating the fused comprehensive feature representation further includes modifying the model output layer to simultaneously predict multiple quantiles (10%, 50%, and 90% quantiles). For each prediction time step, prediction intervals at different confidence levels are obtained. The uncertainty index is quantified by the width of the prediction interval (the difference between the 90% quantile and the 10% quantile). The larger the width, the higher the uncertainty. In order to obtain a more robust uncertainty estimate, quantile cross-validation is used to ensure that the predicted values of different quantiles maintain a reasonable order relationship. The degree of calibration of the prediction interval is evaluated by combining the quantile scores.
[0057] In another optional implementation, in step S200, generating the fused comprehensive feature representation may further include assigning a probability distribution to each weight parameter, sampling specific weight values from the weight distribution during forward propagation to obtain a prediction distribution, quantifying the uncertainty by the standard deviation of the prediction distribution, or by calculating the prediction entropy. To reduce computational complexity, a variational inference method is used to approximate the posterior distribution. For multi-step prediction, considering the cumulative effect of prediction error over time, a time-dependent uncertainty propagation model is used.
[0058] In step S300, the multi-dimensional risk assessment includes steps S301 to S303: S301: Input the fused features into the model decoder to generate future state predictions.
[0059] S302: The risk score for the current moment is calculated based on three dimensions, including: first, the prediction error term, which measures the deviation between the predicted value and the actual observed value; second, the distribution deviation term, which uses KL divergence to assess the difference between the current predicted distribution and the historical normal reference distribution; and third, the feature drift term, which quantifies the feature changes introduced by the retrieval enhancement mechanism by calculating the distance between the original observed features and the fused features. The formula for calculating the risk score at the current moment based on three dimensions is as follows: in, For the prediction error term, For the actual observation at time step t+1, The model prediction at time step t+1 The square of the L2 norm. For the distribution deviation term, For Kullback-Leibler divergence, Let be the distribution of the model's predicted future states at time step t. This is a reference distribution learned from historical normal data. For the characteristic drift term, For observational features, As a feature of fusion, It is an L1 norm.
[0060] S303: The scores of these three dimensions are weighted and summed using configurable weighting coefficients to obtain the final comprehensive risk score, thereby achieving a comprehensive quantitative assessment of risk. The formula for calculating the risk quantification score is expressed as follows: in, The final comprehensive risk score is calculated at time step t. These are the weighting coefficients assigned to the prediction error term. The weighting coefficients assigned to the distribution deviation term, These are the weighting coefficients assigned to the feature drift term.
[0061] Furthermore, in step S300, the dynamic decision mechanism includes steps S311 to S313: S311: Apply a simple moving average to smooth the original risk score sequence to suppress instantaneous spikes in false alarms caused by normal periodic fluctuations. The smoothing formula is expressed as: in, The risk score after smoothing at time step t. To smooth the length of the window, For smooth window indexing.
[0062] S312: Based on the statistics of smoothed scores over a period of time, the dynamic judgment threshold is calculated in real time using the exponential moving average method. The threshold is composed of the mean and standard deviation of recent scores, which can smoothly adapt to the slow changes in working conditions. The formula for calculating the dynamic threshold is expressed as follows: in, To dynamically determine the threshold at time step t, This represents the mean of the smoothed risk scores over the past M time points. The standard deviation of the risk score after smoothing over the past M time points. This is the sensitivity coefficient.
[0063] S313: Compare the current smoothed score with the dynamic threshold. When the score exceeds the threshold, it is determined to be a risk event and triggers an abnormal warning of the corresponding level. At the same time, it can combine the analysis of the contribution of various risks to generate an interpretable warning report.
[0064] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
[0065] Example 3, referring to Figure 2The third embodiment of the present invention provides an energy metering risk monitoring system based on time series model retrieval, including a multimodal data preprocessing and sample library construction module, a retrieval enhancement time series basic model module, a dynamic retrieval and context fusion module, a multi-dimensional risk assessment and calculation module, and a dynamic decision and early warning generation module.
[0066] The multimodal data preprocessing and sample library construction module is used to perform two-level data cleaning and outlier removal through rule filtering and isolated forest algorithm, use cross-correlation function to synchronize and align the time of multi-channel data, and use instance normalization and polynomial fitting to decompose data trends and fluctuations. By overlapping blocks and attaching contextual features such as time period, date, temperature and load category to each data block, a hierarchical structured behavioral sample library is constructed.
[0067] The retrieval enhancement temporal basic model module is used to pre-train the model using a Transformer encoder-decoder architecture through a two-stage task of mask reconstruction and contrastive learning.
[0068] The dynamic retrieval and context fusion module is used to calculate the multi-scale cosine similarity between the current data features and the samples in the memory, and to weight and fuse the retrieval results. Through a learnable gating fusion unit, the retrieved context information is dynamically combined with the model's original understanding of the current observation to generate a fused feature representation.
[0069] The multi-dimensional risk assessment and calculation module is used to generate predictions of future states using the decoding function of the basic model, comprehensively calculate three indicators, and perform a weighted summation of the three indicators to obtain the final comprehensive risk score.
[0070] The dynamic judgment and early warning generation module is used to smooth the original risk score sequence to filter out instantaneous spikes caused by normal periodic peaks. Based on the historical statistics of the scores, the exponential moving average is used to dynamically update the anomaly judgment threshold. The smoothed score is compared with the dynamic threshold. If it exceeds the threshold, it is judged as an abnormal event and a graded early warning is triggered. The module provides preliminary anomaly analysis by combining the scores of each sub-item.
[0071] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
[0072] Example 4, the fourth embodiment of the present invention, differs from the previous three embodiments in that: If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0073] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.
[0074] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0075] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
Claims
1. A method for monitoring electricity metering risks based on time-series model retrieval, characterized in that: include, Collect multi-dimensional time-series operation data of the target power metering terminal, preprocess it to obtain a multi-modal time-series data sample library, and use a pre-trained time-series basic model to process the data, encode and predict the time-series data. For the current time series data to be evaluated, a similarity-based retrieval mechanism is used to dynamically search for matching historical normal samples from the sample library, and an adaptive fusion mechanism is used to integrate the retrieved contextual information into the prediction logic of the basic model to generate a fused comprehensive feature representation. Multi-dimensional risk assessment is performed based on comprehensive feature representation, a comprehensive risk score is calculated, and a dynamic decision mechanism is used to process and determine the risk score, outputting monitoring results.
2. The method for monitoring electricity metering risks based on time-series model retrieval as described in claim 1, characterized in that: The process of obtaining a multimodal time series data sample library includes collecting multi-dimensional time series operation data from power metering terminals, preprocessing the data, dividing the continuous time series into data blocks using the overlapping sliding window method, attaching a context feature vector to each data block, and using these data blocks together with the original time series data blocks to form a structured sample, which is then stored in the behavior sample library.
3. The method for monitoring electricity metering risks based on time-series model retrieval as described in claim 2, characterized in that: The similarity-based retrieval mechanism includes using the encoded current time-series data as the query basis, calculating the correlation between features, searching historical behavior samples in parallel in a hierarchical memory storage structure, weighting the search results at each time granularity according to the correlation, and aggregating them into retrieval reference features.
4. The energy metering risk monitoring method based on time-series model retrieval as described in claim 3, characterized in that: The adaptive fusion mechanism includes jointly analyzing the retrieved reference features and the observation features extracted from the current data by the base model; The contribution ratios of current observations and historical references are dynamically generated based on the joint analysis results through learnable weighting units. Based on the contribution ratio, the observed features and the retrieval reference features are adjusted and synthesized to output a fused feature representation.
5. The method for monitoring electricity metering risks based on time-series model retrieval as described in claim 4, characterized in that: The pre-trained temporal base model processing data includes: constructing a temporal base model based on the Transformer encoder-decoder architecture; performing two-stage pre-training on the temporal dataset using mask reconstruction and contrastive learning tasks; establishing a hierarchical memory bank consisting of short-term, medium-term, and long-term memories; using the FAISS index to store the feature representations of historical time series segments and their corresponding future sequences and contextual information; and dynamically retrieving information from the memory bank based on the input query sequence. The two-stage pre-training formula is expressed as: in, For mask reconstruction loss function, The set of time points that were obscured. For time-series indexes, The actual observations at time step t, i.e., the original time series data, This represents the model's predicted occlusion value at time step t. To compare the learning loss function, For similarity function, To enhance the feature representation of anchor samples generated from the original samples through data augmentation, To and Feature representations of positive samples generated from the same original sample using different enhancement methods. To exclude positive samples The feature representation of the K samples outside, For temperature parameters, The total number of samples in the denominator used to calculate the loss. For sample index, It is an exponential function. It is the natural logarithm.
6. The method for monitoring electricity metering risks based on time-series model retrieval as described in claim 5, characterized in that: The parallel search for historical behavior samples includes calculating the cosine similarity between the query features and the sample key vectors in each memory bank, selecting the Top-K samples with the highest cosine similarity in each memory bank to form the retrieval result set of the current layer, and using preset weights to perform weighted fusion of the retrieval result similarity at different time scales to obtain the final similarity score of each historical sample. The formula for calculating the final similarity score is expressed as follows: in, Scoring the cosine similarity. For query vector, For key vectors, For vector dot product operation, To query the norm of the vector, Let be the norm of the key vector. For the final similarity score, The cosine similarity of sample j calculated in the short-term memory. The cosine similarity of sample j calculated in the intermediate memory. The cosine similarity of sample j calculated in the long-term memory. The weighting coefficients assigned to short-term similarity The weighting coefficients assigned to the intermediate-scale similarity The weighting coefficients assigned to long-term scale similarity For the sample index of the search results set; The hierarchical memory storage structure includes a short-term memory bank storing data from the most recent 7 days, a medium-term memory bank storing data from the last 30 days, and a long-term memory bank storing data from the last 90 days. The learnable weight control unit includes a gated fusion unit that receives a concatenated vector of observed features and retrieved reference features as input, calculates a gate value using a learnable weight matrix and a Sigmoid activation function, uses the gate value as a weight to scale the observed features, uses the complement of the gate value as a weight to scale the retrieved reference features, adds the scaled features together, and outputs the final fused features. The formula for the gated fusion unit is expressed as: in, This is the gate value. It is the Sigmoid activation function. The weight matrix is a learnable matrix. This is a vector concatenation operation. For observational features, To retrieve the context vector, For the fused feature representation, For element-wise multiplication, For the search result set, For the sample index in the retrieval results set, For the Softmax function, It is a learnable linear transformation matrix.
7. The method for monitoring electricity metering risks based on time-series model retrieval as described in claim 6, characterized in that: The multi-dimensional risk assessment includes using the predictive function of the basic model to infer the future time series state based on the fusion feature representation, obtaining the predicted sequence, quantifying the degree of deviation between the predicted sequence and the actual observed sequence as the core risk indicator, and combining the uncertainty indicator that reflects the reliability of the prediction results and the characterization difference indicator that reflects the degree of integration between the current data and historical experience, and comprehensively weighting the indicators to obtain the final risk quantification score. The formula for calculating the risk quantification score is expressed as follows: in, For the prediction error term, For the actual observation at time step t+1, The model prediction at time step t+1 The square of the L2 norm, For the distribution deviation term, For Kullback-Leibler divergence, Let be the distribution of the model's predicted future states at time step t. This is a reference distribution learned from historical normal data. For the characteristic drift term, For observational features, As a feature of fusion, It is an L1 norm. The final comprehensive risk score is calculated at time step t. These are the weighting coefficients assigned to the prediction error term. The weighting coefficients assigned to the distribution deviation term, These are the weighting coefficients assigned to the feature drift term; The dynamic judgment mechanism includes smoothing the comprehensive risk score sequence using a moving average algorithm, setting the smoothing window length to the estimated period length of the terminal data, calculating the mean and standard deviation of the smoothed risk scores over the past M time points, updating the dynamic judgment threshold in real time using an exponential moving average method, comparing the smoothed risk score at the current time with the dynamic judgment threshold, and determining a risk event and generating an early warning when the threshold is exceeded. The smoothing formula is expressed as: in, The risk score after smoothing at time step t. To smooth the length of the window, For smooth window indexing; The formula for updating the dynamic threshold is expressed as follows: in, To dynamically determine the threshold at time step t, This represents the mean of the smoothed risk scores over the past M time points. The standard deviation of the risk score after smoothing over the past M time points. This is the sensitivity coefficient.
8. A power metering risk monitoring system based on time-series model retrieval, employing the power metering risk monitoring method based on time-series model retrieval as described in any one of claims 1 to 7, characterized in that, It includes modules for multimodal data preprocessing and sample library construction, retrieval enhancement time series basic model, dynamic retrieval and context fusion, multidimensional risk assessment and calculation, and dynamic decision and early warning generation. The multimodal data preprocessing and sample library construction module is used to perform two-level data cleaning and outlier removal through rule filtering and isolated forest algorithm, use cross-correlation function to synchronize and align the time of multi-channel data, and use instance normalization and polynomial fitting to decompose data trends and fluctuations. By overlapping blocks and attaching contextual features such as time period, date, temperature and load category to each data block, a hierarchical structured behavior sample library is constructed. The retrieval enhancement temporal basic model module is used to pre-train the model using a Transformer encoder-decoder architecture through a two-stage task of mask reconstruction and contrastive learning. The dynamic retrieval and context fusion module is used to calculate the multi-scale cosine similarity between the current data features and the samples in the memory bank, and to weight and fuse the retrieval results. Through a learnable gating fusion unit, the retrieved context information is dynamically combined with the model's original understanding of the current observation to generate a fused feature representation. The multi-dimensional risk assessment and calculation module is used to generate predictions of future states using the decoding function of the basic model, comprehensively calculate three indicators, and perform a weighted summation of the three indicators to obtain the final comprehensive risk score. The dynamic judgment and early warning generation module is used to smooth the original risk score sequence to filter out instantaneous spikes caused by normal periodic peaks. Based on the historical statistics of the scores, the exponential moving average is used to dynamically update the anomaly judgment threshold. The smoothed score is compared with the dynamic threshold. If it exceeds the threshold, it is judged as an abnormal event and a graded early warning is triggered. The module provides preliminary anomaly analysis by combining the scores of each sub-item.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the energy metering risk monitoring method based on time-series model retrieval as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the energy metering risk monitoring method based on time-series model retrieval as described in any one of claims 1 to 7.
Citation Information
Cited By
Pantograph life prediction method and system combined with wear time sequence analysis
CN121958884A
Pantograph life prediction method and system combined with wear time series analysis
CN121958884B
Grain yield prediction method and device based on large model and time sequence retrieval and medium
CN122019798A
Electric power measurement data security risk assessment method and device
CN122022503A
Air blowing seed disturbing type air suction type peanut seed metering method
CN122162564A