A method for predicting industry electricity consumption based on retrieval-enhanced generation
By constructing a hidden Markov model and vector database, combining search and generation models, the problem that existing power prediction methods are difficult to capture complex nonlinear timing patterns is solved, and higher prediction accuracy and adaptability are achieved.
Patent Information
- Application Number
- CN202510220062.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2045-02-26
AI Technical Summary
Existing power prediction methods are difficult to capture complex nonlinear timing patterns, have low prediction accuracy, and poor adaptability to mutation points, so they cannot effectively utilize multi-industry correlation characteristics.
The industry electricity consumption prediction method based on search enhancement is adopted. By collecting and preprocessing historical electricity consumption data, a hidden Markov model is constructed for segmentation, low-dimensional feature vectors are extracted and vector database is constructed, and real-time electricity consumption prediction is carried out in combination with the search and generation model.
It improves the accuracy and interpretability of power consumption prediction, enhances the model's sensitivity to historical key features, and can more effectively adapt to mutation points and multi-industry correlation features.
Smart Images

Figure CN119692824B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an industry electricity consumption prediction method based on retrieval enhancement generation, belonging to the technical field of electricity prediction. Background Art
[0002] In the field of power technology, there are many power forecasting methods, which can be generally divided into three categories:
[0003] The first is the electricity forecasting method based on traditional statistical algorithms, such as moving average autoregression, exponential smoothing and prophet models, such as a method and system for forecasting daily electricity fluctuations for non-residential users disclosed in the invention patent application with publication number "CN113627682A"; the electricity forecasting model based on traditional statistical algorithms (such as ARIMA and SARIMA algorithms) relies on linear assumptions and independence assumptions to learn the laws of historical time series, and it is difficult to capture complex nonlinear time series patterns. The electricity forecasting model based on autoregression or cross regression contains a limited number of parameters, has a large prediction granularity, is insufficient in fitting the random distribution of electricity consumption, and has poor adaptability to mutation points (such as policy adjustments and emergencies), cannot effectively utilize multi-industry correlation characteristics, and has a significant accuracy bottleneck.
[0004] The second is the prediction model based on the first generation of artificial intelligence technology, neural network, decision tree and other methods, such as XGBOOST model, LightGBM model, BP neural network model, etc., such as the power consumption prediction method based on the multivariate XGBoost combination model disclosed in the invention patent application with the publication number "CN118297633A"; the prediction model based on the first generation of artificial intelligence technology (such as LSTM, RNN) introduces operators with stronger nonlinear fitting ability such as neural networks, has a larger number of model parameters, and has a certain enhancement in the ability to fit the random distribution of power consumption, but the training of the model needs to rely on feature engineering to build a large amount of high-quality labeled data, and the labor cost required for the optimization and adjustment of the model parameters is extremely high. The model has insufficient generalization ability and poor interpretability for small sample scenarios of industry power consumption. Compared with the power prediction model based on traditional statistical algorithms, the prediction accuracy has been improved, but it also brings a greater workload.
[0005] The third is to introduce solutions of pre-trained models (large models) based on the new generation of artificial intelligence technology, such as the Transformer-based time series prediction large model and the prediction model based on the mixed expert model (MoE), such as the invention patent application with publication number "CN118709870A" that discloses an artificial intelligence agent method and system for electricity prediction based on a large language model; the prediction model based on the second generation of artificial intelligence technology obtains a pre-trained model with certain generalization ability through unsupervised learning, which reduces the workload of technical personnel, but the distribution difference between the pre-training data and the electricity prediction field may lead to low performance of the model, lack of controllability of the generated results, and it is difficult to directly adjust the prediction results in combination with knowledge in the field of electric power, and it cannot be directly applied to electricity prediction tasks. The adaptation of pre-trained large models in electricity prediction tasks is not mature enough. Summary of the invention
[0006] In order to solve the above problems existing in the prior art, the present invention proposes an industry electricity consumption prediction method based on retrieval enhanced generation.
[0007] The technical solution of the present invention is as follows:
[0008] In one aspect, the present invention provides a method for predicting industry electricity consumption based on retrieval enhancement generation, comprising the following steps:
[0009] Collect the industry's historical electricity consumption data and pre-process the industry's historical electricity consumption data to obtain a historical electricity consumption sequence;
[0010] Construct a historical electricity consumption sequence segmentation model to segment the historical electricity consumption sequence according to the change points of the electricity consumption time series pattern;
[0011] Extracting the multi-dimensional feature vector of each historical electronic sequence, performing dimensionality reduction processing on the multi-dimensional feature vector of the historical electronic sequence to obtain the low-dimensional feature vector of the historical electronic sequence, constructing a vector database, and storing all the low-dimensional feature vectors;
[0012] Construct a retrieval enhancement generation model to identify the electricity consumption time series pattern corresponding to the low-dimensional feature vector of each historical electricity consumption sequence in the vector database;
[0013] Collect the real-time electricity consumption data of the industry and construct it into a real-time electricity consumption sequence, extract the real-time electricity consumption sequence as a query vector, query the vector database based on the query vector, and fuse the low-dimensional feature vectors obtained by the query to obtain a fused feature vector;
[0014] An industry electricity consumption forecasting model is constructed, and the fused feature vector is used as a covariate and input into the industry electricity consumption forecasting model simultaneously with the real-time electricity consumption sequence to predict future industry electricity consumption.
[0015] As a preferred embodiment of the present invention, the specific steps of preprocessing the industry historical electricity consumption data are:
[0016] The collected historical electricity consumption data of the industry is constructed into an original data sequence in chronological order, and the original data sequence is denoised and normalized. The normalized original data sequence is:
[0017] ;
[0018] in: Represents the normalized The original data sequence samples at the moment; express The original data sequence samples at the moment; Represents the mean of the original data series; Represents the standard deviation of the original data series;
[0019] The normalized original data sequence samples are used as the historical electricity consumption sequence.
[0020] As a preferred embodiment of the present invention, the historical electricity consumption sequence segmentation model is constructed based on a hidden Markov model.
[0021] As a preferred embodiment of the present invention, the specific steps of segmenting the historical power usage sequence according to the change points of the power usage time sequence pattern are:
[0022] Assume the number of hidden states of the hidden Markov model is , which is the number of power consumption time series patterns, constructs the initial state probability vector , Indicates the initial state The probability of state transfer matrix is , Indicates from the state Transfer to state The probability of
[0023] Assume that the observation value corresponding to each hidden state obeys Gaussian distribution, input the historical electricity consumption sequence into the hidden Markov model and train it based on the Baum-Welch algorithm, and calculate the parameters of the hidden Markov model by maximizing the likelihood function of the observed historical electricity consumption sequence. The likelihood function is specifically shown in the following formula:
[0024] ;
[0025] in: represents the likelihood function; represents the hidden Markov model parameters; represents the hidden state sequence; Represents the historical electricity consumption sequence;
[0026] The hidden state of the historical electricity consumption sequence is inferred through the trained hidden Markov model, and the hidden state sequence of the historical electricity consumption sequence is solved based on the Viterbi algorithm, as shown in the following formula:
[0027] ;
[0028] in: Hidden state sequence representing the historical electricity consumption sequence;
[0029] According to the hidden state sequence of the historical power consumption sequence obtained by solving, the hidden state change points in the historical power consumption sequence are identified as the change points of the power consumption time series pattern. The historical power consumption sequence is segmented according to the change points of the power consumption time series pattern. The segmented subsequences are specifically shown in the following formula:
[0030] ;
[0031] in: Indicates A point where the power usage timing pattern changes; Indicates the total number of change points in the power usage timing pattern.
[0032] As a preferred embodiment of the present invention, a low-dimensional feature vector of a historical electronic sequence is extracted by an autoencoder, and the specific steps are as follows:
[0033] Extracting a multi-dimensional feature vector of each historical electronic sequence, specifically statistical features and shape features;
[0034] The statistical features and shape features are combined into a multi-dimensional feature vector of fixed length, and the multi-dimensional feature vector is compressed into a low-dimensional feature vector using an autoencoder, as shown in the following formula:
[0035] ;
[0036] ;
[0037] in: Indicates The encoding result of a multi-dimensional feature vector; Indicates multidimensional feature vectors; Indicates encoding by the encoder of the autoencoder; represents the activation function; represents the weight matrix of the encoder; Indicates the encoder bias; Indicates The decoding result of a multi-dimensional feature vector is a low-dimensional feature vector; Indicates decoding by the decoder of the autoencoder; represents the weight matrix of the decoder; Represents the bias of the decoder.
[0038] As a preferred embodiment of the present invention, the specific steps of identifying the power usage time sequence pattern corresponding to the low-dimensional feature vector of each historical electronic usage sequence in the vector database are:
[0039] Based on the historical electricity consumption law of the industry, a historical electricity consumption time series pattern library is constructed. The low-dimensional feature vector of any historical electricity consumption sequence in the vector database is assumed to be , suppose any historical electricity consumption time sequence pattern sequence in the historical electricity consumption time sequence pattern library is , based on dynamic time warping, the minimum cumulative distance between the low-dimensional feature vector of the historical electronic sequence and the historical electricity consumption time series pattern sequence is solved, as shown in the following formula:
[0040] ;
[0041] in: The minimum cumulative distance between the low-dimensional feature vector representing the historical electricity consumption sequence and the historical electricity consumption time series pattern sequence is: ; The first low-dimensional feature vector of the historical electronic sequence samples; Indicates the first samples; The sample index of the low-dimensional feature vector representing the historical electronic sequence, , The total number of samples of low-dimensional feature vectors representing the historical electronic sequence; Represents the sample index of the historical power consumption time series pattern sequence, , The total number of samples representing the historical electricity consumption time series pattern sequence;
[0042] based on The similarity score between the low-dimensional feature vector of the historical electricity consumption sequence and all historical electricity consumption time series pattern sequences is calculated as shown in the following formula:
[0043] ;
[0044] in: Low-dimensional feature vector representing the historical electronic sequence With Similarity scores of historical electricity consumption time series patterns; Low-dimensional feature vector representing the historical electronic sequence With The minimum cumulative distance of a historical electricity consumption time series pattern sequence;
[0045] Extract from the historical power consumption time series pattern library according to the similarity score from large to small The historical electricity consumption time series pattern sequence corresponding to the electricity consumption time series pattern is constructed, and the combined optimization function is shown in the following formula:
[0046] ;
[0047] ;
[0048] in: Represents a set of historical electricity consumption time series pattern sequences; A set of historical power consumption time series patterns corresponding to the extracted power consumption time series pattern; represents the penalty coefficient; express The A sequence of power usage timing patterns; express The A sequence of power usage timing patterns; express time window; express time window; express and The overlapping part of Indicates constraints;
[0049] The above combined optimization function is solved based on the greedy algorithm to obtain the final electricity consumption timing pattern corresponding to the low-dimensional feature vector of the historical electronic sequence.
[0050] As a preferred embodiment of the present invention, the steps of constructing the fused feature vector are:
[0051] The real-time power consumption sequence is mapped to a query vector through a pre-trained encoder, as shown in the following formula:
[0052] ;
[0053] in: represents the query vector; represents the encoding operation of the pre-trained encoder; Represents real-time power consumption sequence;
[0054] Based on the query vector, a query is performed in the vector database to obtain low-dimensional feature vectors of multiple historical electronic sequences with the same electricity consumption time series pattern, and the similarity score between the low-dimensional feature vector of each historical electronic sequence obtained by the query and the query vector is calculated, as shown in the following formula:
[0055] ;
[0056] in: express and The similarity score between Indicates The low-dimensional feature vector of the historical electronic sequence obtained by the query;
[0057] The weight of the low-dimensional feature vector of each historical electronic sequence obtained by query is calculated based on the above formula, as shown in the following formula:
[0058] ;
[0059] in: express The weight of Indicates The low-dimensional feature vector of the historical electronic sequence obtained by the query;
[0060] The low-dimensional feature vectors of all historical electronic sequences obtained by query are weighted and fused, as shown in the following formula:
[0061] ;
[0062] ;
[0063] ;
[0064] in: represents the intermediate coefficient; Represents the decoding operation of the decoder; represents the fused feature vector; represents a multi-layer perceptron; represents external characteristic variables; represents the learnable weight matrix; represents the learnable bias vector.
[0065] As a preferred embodiment of the present invention, an industry electricity consumption prediction model is constructed based on a machine learning model. The industry electricity consumption prediction model generates future The predicted value of industry electricity consumption in a time step is shown in the following formula:
[0066] ;
[0067] in: Indicates the future The predicted value of industry electricity consumption at each time step; represents the industry electricity consumption forecasting model; express arrive Real-time power consumption sequence sample value at the moment; Indicates the length of the real-time power consumption sequence;
[0068] A joint loss function is constructed to optimize the industry electricity consumption forecasting model. The joint loss function is specifically shown in the following formula:
[0069] ;
[0070] in: represents the joint loss function; Indicates the future The actual value of industry electricity consumption at each time step; Represents the weight parameter.
[0071] On the other hand, the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in any embodiment of the present invention is implemented.
[0072] In yet another aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any embodiment of the present invention.
[0073] The present invention has the following beneficial effects:
[0074] 1. The present invention combines Bayesian change point detection with Hidden Markov Model (HMM) to achieve multi-scale change point detection and segmentation, effectively reduce noise interference, and facilitate the interpretation of change points in combination with industry knowledge;
[0075] 2. The present invention quantifies the electricity consumption pattern into time series features and stores them as a vector library, and combines the vector database to achieve efficient storage and retrieval. At the same time, a knowledge retrieval enhancement generation (RAG) method for daily electricity consumption patterns is designed, which can find relevant time series patterns from historical electricity consumption patterns and enhance the model's sensitivity to historical key features;
[0076] 3. The present invention introduces the characteristic variables recalled by the vector library as covariates, constructs a multivariate time series prediction model, transforms the time series prediction problem into a retrieval process of similar electricity consumption patterns, and dynamically adjusts the covariate weights in combination with the attention mechanism, which has stronger interpretability and better effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] Figure 1 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0078] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0079] It should be understood that the step numbers used in this document are only for convenience of description and are not intended to limit the order in which the steps are executed.
[0080] It should be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0081] The terms “include” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0082] The term "and / or" means and includes any and all possible combinations of one or more of the associated listed items.
[0083] Embodiment 1:
[0084] See also Figure 1 , a method for predicting industry electricity consumption based on retrieval enhancement generation, comprising the following steps:
[0085] Collect the industry's historical electricity consumption data and pre-process the industry's historical electricity consumption data to obtain a historical electricity consumption sequence;
[0086] Construct a historical electricity consumption sequence segmentation model to segment the historical electricity consumption sequence according to the change points of the electricity consumption time series pattern;
[0087] Extracting the multi-dimensional feature vector of each historical electronic sequence, performing dimensionality reduction processing on the multi-dimensional feature vector of the historical electronic sequence to obtain the low-dimensional feature vector of the historical electronic sequence, constructing a vector database, and storing all the low-dimensional feature vectors;
[0088] Construct a retrieval enhancement generation model to identify the electricity consumption time series pattern corresponding to the low-dimensional feature vector of each historical electricity consumption sequence in the vector database;
[0089] Collect the real-time electricity consumption data of the industry and construct it into a real-time electricity consumption sequence, extract the real-time electricity consumption sequence as a query vector, query the vector database based on the query vector, and fuse the low-dimensional feature vectors obtained by the query to obtain a fused feature vector;
[0090] An industry electricity consumption forecasting model is constructed, and the fused feature vector is used as a covariate and input into the industry electricity consumption forecasting model simultaneously with the real-time electricity consumption sequence to predict future industry electricity consumption.
[0091] As a preferred implementation of this embodiment, the specific steps of preprocessing the industry historical electricity consumption data are:
[0092] The collected historical electricity consumption data of the industry is constructed into an original data sequence in chronological order, and the original data sequence is denoised and normalized to eliminate the influence of noise and dimensional differences. The normalized original data sequence is:
[0093] ;
[0094] in: Represents the normalized The original data sequence samples at the moment; express The original data sequence samples at the moment; Represents the mean of the original data series; Represents the standard deviation of the original data series;
[0095] The normalized original data sequence samples are used as the historical electricity consumption sequence.
[0096] As a preferred implementation of this embodiment, the historical electricity consumption sequence segmentation model is constructed based on a hidden Markov model.
[0097] As a preferred implementation of this embodiment, the specific steps of segmenting the historical power usage sequence according to the change points of the power usage time sequence pattern are:
[0098] Assume the number of hidden states of the hidden Markov model is , which is the number of power consumption time series patterns, constructs the initial state probability vector , Indicates the initial state The probability of state transfer matrix is , Indicates from the state Transfer to state probability;
[0099] Assume that the observation value corresponding to each hidden state obeys Gaussian distribution, input the historical electricity consumption sequence into the hidden Markov model and train it based on the Baum-Welch algorithm, and calculate the parameters of the hidden Markov model by maximizing the likelihood function of the observed historical electricity consumption sequence. The likelihood function is specifically shown in the following formula:
[0100] ;
[0101] in: represents the likelihood function; represents the hidden Markov model parameters; represents the hidden state sequence; Represents the historical electricity consumption sequence;
[0102] The hidden state of the historical electricity consumption sequence is inferred through the trained hidden Markov model, and the hidden state sequence of the historical electricity consumption sequence is solved based on the Viterbi algorithm, as shown in the following formula:
[0103] ;
[0104] in: Hidden state sequence representing the historical electricity consumption sequence;
[0105] The Viterbi algorithm is calculated recursively through dynamic programming:
[0106] ;
[0107] in: Indicates status Always in the state The maximum probability of express The hidden state of the moment;
[0108] According to the hidden state sequence of the historical power consumption sequence obtained by solving, the hidden state change points in the historical power consumption sequence are identified as the change points of the power consumption time series pattern. The historical power consumption sequence is segmented according to the change points of the power consumption time series pattern. The segmented subsequences are specifically shown in the following formula:
[0109] ;
[0110] in: Indicates A point where the power usage timing pattern changes; Indicates the total number of change points of the power usage timing pattern;
[0111] Combine industry background knowledge (such as policy changes, seasonal factors) to explain the change points, and adjust the number of hidden states or model parameters when necessary to improve the accuracy and interpretability of change point detection.
[0112] As a preferred implementation of this embodiment, the low-dimensional feature vector of the historical electronic sequence is extracted by an autoencoder, and the specific steps are as follows:
[0113] Extracting multidimensional feature vectors of each historical electronic sequence, specifically statistical features (such as mean, variance, trend slope) and shape features (such as local extreme points);
[0114] The statistical features and shape features are combined into a multi-dimensional feature vector of fixed length, and the multi-dimensional feature vector is compressed into a low-dimensional feature vector using an autoencoder, as shown in the following formula:
[0115] ;
[0116] ;
[0117] in: Indicates The encoding result of a multi-dimensional feature vector; Indicates multidimensional feature vectors; Indicates encoding by the encoder of the autoencoder; represents the activation function; represents the weight matrix of the encoder; Indicates the encoder bias; Indicates The decoding result of a multi-dimensional feature vector is a low-dimensional feature vector; Indicates decoding by the decoder of the autoencoder; represents the weight matrix of the decoder; represents the bias of the decoder;
[0118] The loss function is:
[0119] ;
[0120] in: express Divergence; represents normal distribution; represents the adjustment coefficient;
[0121] The low-dimensional feature vector metadata (such as timestamps and fragment tags) are stored together in the vector database, and an index structure is built to support efficient similarity search.
[0122] Finally, the vector database can efficiently manage feature vectors through an indexing mechanism; fast retrieval is achieved through the vector index structure, and similarity-based pattern matching is supported.
[0123] As a preferred implementation of this embodiment, the specific steps of identifying the power usage time sequence pattern corresponding to the low-dimensional feature vector of each historical electronic usage sequence in the vector database are:
[0124] Based on the historical electricity consumption law of the industry, a historical electricity consumption time series pattern library is constructed. The low-dimensional feature vector of any historical electricity consumption sequence in the vector database is assumed to be , suppose any historical electricity consumption time sequence pattern sequence in the historical electricity consumption time sequence pattern library is , based on dynamic time warping, the minimum cumulative distance between the low-dimensional feature vector of the historical electronic sequence and the historical electricity consumption time series pattern sequence is solved, as shown in the following formula:
[0125] ;
[0126] in: The minimum cumulative distance between the low-dimensional feature vector representing the historical electricity consumption sequence and the historical electricity consumption time series pattern sequence is: ; The first low-dimensional feature vector of the historical electronic sequence samples; Indicates the first samples; The sample index of the low-dimensional feature vector representing the historical electronic sequence, , The total number of samples of low-dimensional feature vectors representing the historical electronic sequence; Represents the sample index of the historical power consumption time series pattern sequence, , The total number of samples representing the historical electricity consumption time series pattern sequence;
[0127] based on The similarity score between the low-dimensional feature vector of the historical electricity consumption sequence and all historical electricity consumption time series pattern sequences is calculated as shown in the following formula:
[0128] ;
[0129] in: Low-dimensional feature vector representing the historical electronic sequence With Similarity scores of historical electricity consumption time series patterns; Low-dimensional feature vector representing the historical electronic sequence With The minimum cumulative distance of a historical electricity consumption time series pattern sequence;
[0130] Extract from the historical power consumption time series pattern library according to the similarity score from large to small The historical electricity consumption time series pattern sequence corresponding to each electricity consumption time series pattern is constructed to build the most similar and diverse pattern set, and the combined optimization function is constructed as shown in the following formula:
[0131] ;
[0132] ;
[0133] in: Represents a set of historical electricity consumption time series pattern sequences; A set of historical power consumption time series patterns corresponding to the extracted power consumption time series pattern; represents the penalty coefficient; express The A sequence of power usage timing patterns; express The A sequence of power usage timing patterns; express time window; express time window; express and The overlapping part of Indicates constraints;
[0134] The above combined optimization function is solved based on the greedy algorithm to obtain the final electricity consumption timing pattern corresponding to the low-dimensional feature vector of the historical electronic sequence:
[0135] ;
[0136] in: The final electricity consumption time series pattern corresponding to the low-dimensional feature vector representing the historical electron consumption sequence.
[0137] As a preferred implementation of this embodiment, the steps of constructing the fused feature vector are:
[0138] The real-time power consumption sequence is mapped to a query vector through a pre-trained encoder, as shown in the following formula:
[0139] ;
[0140] in: represents the query vector; represents the encoding operation of the pre-trained encoder; Represents real-time power consumption sequence;
[0141] Based on the query vector, a query is performed in the vector database to obtain low-dimensional feature vectors of multiple historical electronic sequences with the same electricity consumption time series pattern, and the similarity score between the low-dimensional feature vector of each historical electronic sequence obtained by the query and the query vector is calculated, as shown in the following formula:
[0142] ;
[0143] in: express and The similarity score between Indicates The low-dimensional feature vector of the historical electronic sequence obtained by the query;
[0144] The weight of the low-dimensional feature vector of each historical electronic sequence obtained by query is calculated based on the above formula, as shown in the following formula:
[0145] ;
[0146] in: express The weight of Indicates The low-dimensional feature vector of the historical electronic sequence obtained by the query;
[0147] The low-dimensional feature vectors of all historical electronic sequences obtained by query are weighted and fused, as shown in the following formula:
[0148] ;
[0149] ;
[0150] ;
[0151] in: represents the intermediate coefficient; Represents the decoding operation of the decoder; represents the fused feature vector; represents a multi-layer perceptron; represents external characteristic variables; represents the learnable weight matrix; represents the learnable bias vector.
[0152] As a preferred implementation of this embodiment, an industry electricity consumption prediction model is constructed based on a machine learning model. The industry electricity consumption prediction model generates future The predicted value of industry electricity consumption in a time step is shown in the following formula:
[0153] ;
[0154] in: Indicates the future The predicted value of industry electricity consumption at each time step; represents the industry electricity consumption forecasting model; express arrive Real-time power consumption sequence sample value at the moment; Indicates the length of the real-time power consumption sequence;
[0155] A joint loss function is constructed to optimize the industry electricity consumption forecasting model. The joint loss function is specifically shown in the following formula:
[0156] ;
[0157] in: represents the joint loss function; Indicates the future The actual value of industry electricity consumption at each time step; Represents the weight parameter.
[0158] Embodiment 2:
[0159] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in any embodiment of the present invention when executing the program.
[0160] Embodiment three:
[0161] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described in any embodiment of the present invention is implemented.
[0162] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.
[0163] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0164] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0165] In several embodiments provided in the present application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), disk or optical disk, and other media that can store program codes.
[0166] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for predicting industry electricity consumption based on retrieval enhancement generation, characterized in that: The following steps are involved: Collect the industry's historical electricity consumption data and pre-process the industry's historical electricity consumption data to obtain a historical electricity consumption sequence; Construct a historical electricity consumption sequence segmentation model to segment the historical electricity consumption sequence according to the change points of the electricity consumption time series pattern; Extracting the multi-dimensional feature vector of each historical electronic sequence, performing dimensionality reduction processing on the multi-dimensional feature vector of the historical electronic sequence to obtain the low-dimensional feature vector of the historical electronic sequence, constructing a vector database, and storing all the low-dimensional feature vectors; Construct a retrieval enhancement generation model to identify the electricity consumption time series pattern corresponding to the low-dimensional feature vector of each historical electronic sequence in the vector database. The specific steps are as follows: Based on the historical electricity consumption law of the industry, a historical electricity consumption time series pattern library is constructed. The low-dimensional feature vector of any historical electricity consumption sequence in the vector database is assumed to be , suppose any historical electricity consumption time sequence pattern sequence in the historical electricity consumption time sequence pattern library is , based on dynamic time warping, the minimum cumulative distance between the low-dimensional feature vector of the historical electronic sequence and the historical electricity consumption time series pattern sequence is solved, as shown in the following formula: ; in: The minimum cumulative distance between the low-dimensional feature vector representing the historical electricity consumption sequence and the historical electricity consumption time series pattern sequence is: ; The first low-dimensional feature vector of the historical electronic sequence samples; Indicates the first samples; The sample index of the low-dimensional feature vector representing the historical electronic sequence, , The total number of samples of low-dimensional feature vectors representing the historical electronic sequence; Represents the sample index of the historical power consumption time series pattern sequence, , The total number of samples representing the historical electricity consumption time series pattern sequence; based on The similarity score between the low-dimensional feature vector of the historical electricity consumption sequence and all historical electricity consumption time series pattern sequences is calculated as shown in the following formula: ; in: Low-dimensional feature vector representing the historical electronic sequence With Similarity scores of historical electricity consumption time series patterns; Low-dimensional feature vector representing the historical electronic sequence With The minimum cumulative distance of a historical electricity consumption time series pattern sequence; Extract from the historical power consumption time series pattern library according to the similarity score from large to small The historical electricity consumption time series pattern sequence corresponding to the electricity consumption time series pattern is constructed, and the combined optimization function is shown in the following formula: ; ; in: Represents a set of historical electricity consumption time series pattern sequences; A set of historical power consumption time series patterns corresponding to the extracted power consumption time series pattern; represents the penalty coefficient; express The A sequence of power usage timing patterns; express The A sequence of power usage timing patterns; express time window; express time window; express and The overlapping part of Indicates constraints; The above combined optimization function is solved based on a greedy algorithm to obtain the final electricity consumption time sequence pattern corresponding to the low-dimensional feature vector of the historical electronic sequence; Collect the real-time electricity consumption data of the industry and construct it into a real-time electricity consumption sequence, extract the real-time electricity consumption sequence as a query vector, query the vector database based on the query vector, and fuse the low-dimensional feature vectors obtained by the query to obtain a fused feature vector; An industry electricity consumption forecasting model is constructed, and the fused feature vector is used as a covariate and input into the industry electricity consumption forecasting model simultaneously with the real-time electricity consumption sequence to predict future industry electricity consumption.
2. According to claim 1, a method for predicting industry electricity consumption based on retrieval enhancement generation is characterized in that: The specific steps of preprocessing the industry historical electricity consumption data are as follows: The collected historical electricity consumption data of the industry is constructed into an original data sequence in chronological order, and the original data sequence is denoised and normalized. The normalized original data sequence is: ; in: Represents the normalized The original data sequence samples at the moment; express The original data sequence samples at the moment; Represents the mean of the original data series; Represents the standard deviation of the original data series; The normalized original data sequence samples are used as the historical electricity consumption sequence.
3. The method for predicting industry electricity consumption based on retrieval enhancement generation according to claim 2 is characterized in that: The historical electricity consumption sequence segmentation model is constructed based on a hidden Markov model.
4. The method for predicting industry electricity consumption based on retrieval enhancement generation according to claim 3 is characterized in that: The specific steps of segmenting the historical power consumption sequence according to the change points of the power consumption time sequence pattern are as follows: Assume the number of hidden states of the hidden Markov model is , which is the number of power consumption time series patterns, constructs the initial state probability vector , Indicates the initial state The probability of state transfer matrix is , Indicates from the state Transfer to state probability; Assume that the observation value corresponding to each hidden state obeys Gaussian distribution, input the historical electricity consumption sequence into the hidden Markov model and train it based on the Baum-Welch algorithm, and calculate the parameters of the hidden Markov model by maximizing the likelihood function of the observed historical electricity consumption sequence. The likelihood function is specifically shown in the following formula: ; in: represents the likelihood function; represents the hidden Markov model parameters; represents the hidden state sequence; Represents the historical electricity consumption sequence; The hidden state of the historical electricity consumption sequence is inferred through the trained hidden Markov model, and the hidden state sequence of the historical electricity consumption sequence is solved based on the Viterbi algorithm, as shown in the following formula: ; in: Hidden state sequence representing the historical electricity consumption sequence; According to the hidden state sequence of the historical power consumption sequence obtained by solving, the hidden state change points in the historical power consumption sequence are identified as the change points of the power consumption time series pattern. The historical power consumption sequence is segmented according to the change points of the power consumption time series pattern. The segmented subsequences are specifically shown in the following formula: ; in: Indicates A point where the power usage timing pattern changes; Indicates the total number of change points in the power usage timing pattern.
5. The method for predicting industry electricity consumption based on retrieval enhancement generation according to claim 1 is characterized in that: The low-dimensional feature vector of the historical electronic sequence is extracted through the autoencoder. The specific steps are as follows: Extracting a multi-dimensional feature vector of each historical electronic sequence, specifically statistical features and shape features; The statistical features and shape features are combined into a multi-dimensional feature vector of fixed length, and the multi-dimensional feature vector is compressed into a low-dimensional feature vector using an autoencoder, as shown in the following formula: ; ; in: Indicates The encoding result of a multi-dimensional feature vector; Indicates multidimensional feature vectors; Indicates encoding by the encoder of the autoencoder; represents the activation function; represents the weight matrix of the encoder; Indicates the encoder bias; Indicates The decoding result of a multi-dimensional feature vector is a low-dimensional feature vector; Indicates decoding by the decoder of the autoencoder; represents the weight matrix of the decoder; Represents the bias of the decoder.
6. The method for predicting industry electricity consumption based on retrieval enhancement generation according to claim 1 is characterized in that: The steps of constructing the fused feature vector are: The real-time power consumption sequence is mapped to a query vector through a pre-trained encoder, as shown in the following formula: ; in: represents the query vector; represents the encoding operation of the pre-trained encoder; Represents real-time power consumption sequence; Based on the query vector, a query is performed in the vector database to obtain low-dimensional feature vectors of multiple historical electronic sequences with the same electricity consumption time series pattern, and the similarity score between the low-dimensional feature vector of each historical electronic sequence obtained by the query and the query vector is calculated, as shown in the following formula: ; in: express and The similarity score between Indicates The low-dimensional feature vector of the historical electronic sequence obtained by the query; The weight of the low-dimensional feature vector of each historical electronic sequence obtained by query is calculated based on the above formula, as shown in the following formula: ; in: express The weight of Indicates The low-dimensional feature vector of the historical electronic sequence obtained by the query; The low-dimensional feature vectors of all historical electronic sequences obtained by query are weighted and fused, as shown in the following formula: ; ; ; in: represents the intermediate coefficient; Represents the decoding operation of the decoder; represents the fused feature vector; represents a multi-layer perceptron; represents external characteristic variables; represents the learnable weight matrix; represents the learnable bias vector.
7. The method for predicting industry electricity consumption based on retrieval enhancement generation according to claim 6 is characterized in that: An industry electricity consumption prediction model is constructed based on a machine learning model. The industry electricity consumption prediction model generates future The predicted value of industry electricity consumption in a time step is shown in the following formula: ; in: Indicates the future The predicted value of industry electricity consumption at each time step; represents the industry electricity consumption forecasting model; express arrive Real-time power consumption sequence sample value at the moment; Indicates the length of the real-time power consumption sequence; A joint loss function is constructed to optimize the industry electricity consumption forecasting model. The joint loss function is specifically shown in the following formula: ; in: represents the joint loss function; Indicates the future The actual value of industry electricity consumption at each time step; Represents the weight parameter.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Non-residential user daily electric quantity fluctuation prediction method and system
CN113627682A
Power abnormal fluctuation detection and prediction calculation method based on integrated algorithm
CN113505935A
Time series data analysis method and device, equipment and storage medium
CN116340796A