A method for electricity consumption prediction based on Time-LLM

Through the Time-LLM-based power consumption prediction method, the problem of weak generalization ability of traditional methods in residential power consumption prediction is solved, and high accuracy prediction is achieved in the scenario of few samples and zero samples, supporting grid scheduling and efficient utilization of renewable energy.

CN120448714BActive Publication Date: 2025-09-02CHANGCHUN UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510948133.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-10
Publication Date
2025-09-02
Estimated Expiration
2045-07-10

AI Technical Summary

Technical Problem

When facing complex residential electricity consumption behaviors, traditional time series prediction methods are difficult to effectively deal with the problems of weak generalization capabilities of the model and high data demand, especially in the case of small samples and zero samples, which makes it difficult for the model to capture long-term dependencies, overfitting and instability.

Method used

The power consumption prediction method based on Time-LLM is adopted, and the historical power consumption data is obtained for preprocessing and standardization, and the semantic prototype is extracted using a full connection layer, the time series data blocks are encoded into natural language input, and linear projected through the multi-head attention mechanism, and natural language prompt prefix is ​​added to enhance the input information. Finally, the trained Time-LLM model is used for power consumption prediction.

Benefits of technology

It improves the accuracy and generalization ability of power consumption prediction, especially in small sample and zero sample scenarios, which can support the intelligent power grid scheduling and the efficient utilization of renewable energy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120448714B_ABST
    Figure CN120448714B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for predicting electricity consumption based on Time-LLM, which relates to the technical field of electricity consumption prediction for power systems. The method comprises the following steps: constructing a sample data set and performing preprocessing; dividing the input sequence into time series data blocks with the same scale and distribution characteristics through reversible instance normalization; extracting semantic prototypes using a fully connected layer, encoding the time series data blocks into natural language input, and performing linear projection through a multi-head attention mechanism; adding a hint prefix before each reprogrammed patch; inputting the patch with the hint prefix into the LLM, flattening the output to obtain the prediction result of each data block, and then splicing them in the original order after inverse transformation to obtain a continuous prediction sequence; and using experimental indicators to judge the prediction results of the continuous prediction sequence. If the results are qualified, they are applied to actual electricity consumption prediction work. The present invention realizes electricity consumption prediction and improves the accuracy and generalization ability of the prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of power consumption prediction of power systems, and in particular to a power consumption prediction method based on Time-LLM. Background Art

[0002] In today's rapidly developing society, the dramatic increase in electricity demand has made short-term residential electricity consumption forecasting crucial in power system management. Accurate electricity consumption forecasting is crucial for intelligent grid dispatching, reducing energy consumption, and promoting the efficient use of renewable energy. However, residential electricity consumption is influenced by a variety of complex factors, such as weather conditions, time of year, and user habits. These factors combine to make electricity consumption highly nonlinear and spatiotemporally dependent, making traditional forecasting methods difficult to effectively address this challenge.

[0003] Traditional time series prediction methods such as ARIMA and LSTM, although effective in specific fields, generally have problems such as weak model generalization ability and large data requirements.

[0004] Fortunately, the rapid development of Large Language Model (LLM) technology offers hope for addressing this challenge. LLMs, with their powerful text understanding and generation capabilities, offer significant advantages in processing natural language data. Importantly, Time-LLM (time series forecasting based on a Large Language Model) consistently outperforms the best existing models in mainstream forecasting tasks, particularly in few-shot and zero-shot scenarios. Furthermore, Time-LLM achieves even higher performance while maintaining excellent model reprogramming efficiency. Summary of the Invention

[0005] The present invention provides a power consumption prediction method based on Time-LLM to solve the problems existing in the prior art, such as the difficulty of the model to capture long-term dependencies, overfitting, instability, etc. caused by few samples and zero samples.

[0006] According to one aspect of the present invention, a method for predicting electricity consumption based on Time-LLM is provided, comprising: obtaining historical electricity consumption data to construct a sample data set, preprocessing the sample data set, and dividing the preprocessed sample data set into a training set, a validation set, and a test set; normalizing the input sequence through reversible instance normalization to divide the input sequence into time series data blocks with the same scale and distribution characteristics; extracting semantic prototypes using a fully connected layer, encoding the time series data blocks into natural language input, and performing linear projection through a multi-head attention mechanism to connect the reprogrammed patches with the dimensions of the LLM backbone. The proposed method is to align the time series data blocks, wherein the patch refers to the time series data block and the LLM refers to the large language model; a prompt prefix is ​​added before each reprogrammed patch to enhance the input information, wherein the prompt prefix includes the general background of the data set, the task description and the input statistics; the patch with the prompt prefix is ​​input into the LLM, the output is flattened and the prediction result of each data block is obtained, the prediction results of each block are inversely transformed and spliced ​​in the original order to obtain a continuous prediction sequence; the prediction results of the continuous prediction sequence are judged by experimental indicators, and those that are qualified are applied to the actual power consumption forecasting work, and the trained Time-LLM model is used to predict future power consumption based on the actual power consumption.

[0007] Optionally, preprocessing includes data cleaning and processing, identifying and filling missing data, and removing and correcting abnormal data. The preprocessing of the sample data set includes:

[0008] Use the Z-score method to detect outliers in the data and define the data The Z-score is:

[0009] ;

[0010] Where, µ and are the mean and standard deviation of the data, is the index of the data point in the dataset;

[0011] when >α, is considered as an outlier, and α is the preset threshold;

[0012] For the detected outliers, we first use the K-nearest neighbor algorithm to perform interpolation repair and find the outliers that are close to it in the time series. Normal data points { 、 、 、…、 }, calculate the weighted average of these adjacent data points to replace the outlier. The formula is as follows:

[0013] ;

[0014] Where, represents the outlier value after repair, Represents The approaching Normal data points, ;

[0015] Then use the moving average method to smooth the abnormal data, set the window size to 5, calculate the average value of the data points in the window around the abnormal point, and replace the abnormal data point with the calculated average value;

[0016] The mean square error method was used to quantify data differences.

[0017] Optionally, the normalizing the input sequence by reversible instance normalization to divide the input sequence into time series data blocks having the same scale and distribution characteristics includes:

[0018] The input sequence is divided into blocks of the same length. The total number of blocks is:

[0019] ;

[0020] in, Indicates the total number of time series data blocks; Indicates the stride of horizontal sliding; Indicates the lookback time step length of historical load data electricity consumption; Indicates the length of the time series data block with overlapping or non-overlapping data blocks; Number 2 handles the boundary problem by adding extra blocks at the start and end points, so that the time series data of the power historical load is fully covered;

[0021] Normalize each divided data block.

[0022] Optionally, a fully connected layer is used to extract semantic prototypes and encode time series data blocks into natural language input, including:

[0023] Use the fully connected layer Linear Layer to map each patch to a new semantic space. The input data of each patch is ∈ ,in, is the length of the patch, express dimensional real vector space; the weight matrix of LinerLayer is ∈ , represents the real matrix space, used for linear transformation, where is the output dimension, that is, the dimension of the semantic space; the bias vector is ∈ , express dimensional real vector space, used to represent bias or semantic coding; the output of Linear Layer is expressed as:

[0024] ;

[0025] in, ∈ It is the semantic representation of patch.

[0026] Optionally, linear projection is performed via a multi-head attention mechanism to align the reprogrammed patch with the dimensions of the LLM backbone including:

[0027] Use Linear Layer to represent the semantics of the patch Mapping to query matrix , key matrix Sum Matrix , the formula is as follows:

[0028] ;

[0029] ;

[0030] ;

[0031] in, 、 、 They are used to generate the query matrix , key matrix Sum Matrix The weight matrix, 、 、 They are used to generate the query matrix , key matrix Sum Matrix The bias vector of

[0032] Using the query matrix , key matrix Sum Matrix Calculate the attention score:

[0033] ;

[0034] in, is the dimension of the key vector; represents transpose; Indicates that the data in the brackets behind Function Compute;

[0035] After the multi-head attention calculation is completed, the output dimension of the spliced , output projection is performed through a Liner Layer to map the spliced ​​output back to the target dimension , the formula is as follows:

[0036] ;

[0037] in, ∈ is the final multi-head attention output, is the sequence length;

[0038] It is the concatenated output of multi-head attention; ∈ is the weight matrix of the output projection.

[0039] Optionally, add a hint prefix before each reprogramming patch to enhance the input information including:

[0040] Generate natural language prompt prefixes based on the context of time series data and task objectives;

[0041] The generated hint prefix is ​​concatenated with the reprogrammed patch, and the semantic representation of the time series data is: ∈ , the embedding of the hint prefix is ​​represented as ∈ , then the input of LLM is expressed as:

[0042] ;

[0043] in, It is the dimension of semantic representation; is the length of the prompt prefix; ∈ It is the input of LLM; Represents a concatenation operation on the sequence dimension.

[0044] Optionally, the patch with the splicing hint prefix is ​​input into the LLM, the output is flattened, and the prediction results for each data block are obtained including:

[0045] Use a linear layer to map the LLM output from the high-dimensional semantic space to the target dimension:

[0046] ;

[0047] in, It will Input to the output of LLM; and is the weight matrix and bias variable of the output projection; is the predicted output of the final time series data block.

[0048] Optionally, the experimental indicators include mean square error , mean absolute error and the judgment coefficient ,in,

[0049] ;

[0050] ;

[0051] ;

[0052] Where, and Respectively represent The actual and predicted values ​​of each instance; is the arithmetic mean of all actual values; is the total number of data; Indicates the first data points.

[0053] This paper proposes a Time-LLM-based electricity consumption prediction method that applies LLM (Large Language Model) to time series prediction. By introducing LLM technology and leveraging LLM's powerful semantic understanding capabilities, it can improve the accuracy and generalization of electricity consumption prediction, especially in few-sample and zero-sample scenarios.

[0054] By introducing the multi-head attention mechanism, it can better capture the long-term dependencies in time series data and improve the accuracy of prediction;

[0055] The natural language prompt prefix (background + task description + statistical information) enables a clearer understanding of the context of the input data. Compared to directly inputting time series data, the prompt prefix provides additional semantic information, reducing the model's guesswork about the data context and improving prediction accuracy. Furthermore, the prompt prefix clarifies the task description, allowing the model to focus more on the task objective when generating output, avoiding the generation of task-irrelevant output due to unclear objectives and improving the targeted nature of predictions.

[0056] The present invention undergoes a series of operations such as data standardization, semantic coding, dimensional alignment, and prompt enhancement, and the final generated electricity consumption forecast result is suitable for short-term forecasting of residential electricity consumption. It can effectively support the intelligent scheduling of power grids, reduce energy consumption, and promote the efficient use of renewable energy. It has high practical value and promotion prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0058] Figure 1 This is a flow chart of a method for predicting power consumption based on Time-LLM according to an embodiment of the present invention. DETAILED DESCRIPTION

[0059] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of this application. It should be noted that, in the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.

[0060] Secondly, the term "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in various places throughout this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive of other embodiments.

[0061] The terms "comprises" and "having" and any variations thereof in the specification and claims of this application are intended to cover non-exclusive inclusions. For example, a process, method, product or apparatus that includes a series of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, product or apparatus.

[0062] Reference Figure 1 , Figure 1 FIG. 1 is a flow chart of a method for predicting power consumption based on Time-LLM according to an embodiment of the present invention. Figure 1 As shown, the method includes:

[0063] S1, obtain historical electricity consumption data to build a sample data set, preprocess the sample data set, and divide the preprocessed sample data set into a training set, a validation set, and a test set;

[0064] The sample data set is data related to electricity consumption. The data source can be the historical records of the power company, data collected by smart meters, etc. This data contains electricity consumption information in different time periods.

[0065] In one example of the present invention, a public dataset provided by the OpenEI official website was used to select historical electricity consumption data for 15 residences in Louisiana (LA), USA. The data included hourly historical electricity consumption data for each household in 2012, recording the electricity consumption of various electrical devices every hour, for a total of 8,760 data points.

[0066] Clean the data to remove outliers and missing values. For missing values, methods such as mean filling, median filling, and interpolation can be used to fill them. For outliers, statistical methods (such as Z-score) or machine learning methods (such as isolation forest) can be used to detect and correct them.

[0067] In one embodiment of the present invention, preprocessing of a sample data set includes: first, detecting and marking outliers using the Z-score method; second, repairing and replacing using the K-nearest neighbor algorithm (rapidly repairing local anomalies and preserving short-term trends); and third, smoothing the data using the moving average method (making the overall curve smoother and reflecting the overall trend). Specifically:

[0068] First, use the Z-score method to detect outliers on the data, identify outliers that differ greatly from the mean, and define the data The Z-score is , where µ and are the mean and standard deviation of the data, is the index of the data point in the dataset, which means the samples (data points), when >α (in this embodiment, α=3), Considered as outliers;

[0069] For the detected outliers, the K-nearest neighbor (KNN) algorithm is used for interpolation repair to find the outliers that are closest to it in the time series. Normal data points { 、 、 、…、 }, replace the outliers by calculating the weighted average of these nearby data points, that is, , where represents the outlier value after repair, Represents The approaching Normal data points, ,This method effectively utilizes the information of neighboring normal values ​​in the time series ,data, and ensures the smoothness and accuracy of the interpolation results;

[0070] Then, the moving average method is used to smooth the abnormal data. First, the window size is set to 5. For each abnormal point, two data points before and after it are considered, for a total of five data points (near the start and end points of the sequence that may not completely contain the five data points before and after, the window can be expanded by mirror filling or shifting the window backward and forward). The average value of the data points in the window around the abnormal point is calculated, and the calculated average value is used to replace the abnormal value that has been repaired by the K nearest neighbor algorithm (that is, the above ) to smooth the data to reduce noise and fluctuations, and finally use the mean square error (MSE) method to quantify the data differences and evaluate the error between the smoothed data and the original data.

[0071] The preprocessed dataset is divided into training set, validation set and test set in a certain ratio (such as 7:1.5:1.5). The training set is used to train the large language model, the validation set is used to adjust the model's hyperparameters and evaluate the model's capabilities, and the test set is used to test the model's accuracy and feasibility after model training is completed.

[0072] S2, normalizes the input sequence through reversible instance normalization, dividing the input sequence into time series data blocks with the same scale and distribution characteristics;

[0073] Reversible instance normalization (RevIN) is a data normalization method primarily used in time series prediction models. It consists of two main steps: normalization and inverse normalization. Before the input data enters the model, it is first normalized to fix its distribution; after the model output, it is inverse normalized to restore the distribution of the original data. In this embodiment of the present invention, the time series electricity consumption data is broken down into data blocks of equal length. Each data block is then normalized to standardize them and have the same scale and distribution characteristics. The normalized data blocks are input into the model, and the model outputs the prediction results for each block. Finally, the prediction results of each block are inversely transformed and spliced ​​in the original order to restore the continuity of the time series. This method can effectively address the distribution changes in time series data and improve the stability and generalization ability of the model.

[0074] Specifically, in the embodiment of the present invention, S2 includes:

[0075] S21, performing block processing on the input sequence, dividing the input sequence into data blocks of the same length, wherein the total number of divided data blocks is: ;

[0076] in, Indicates the total number of time series data blocks, that is, the number of data blocks into which the entire time series is divided; Indicates the stride of horizontal sliding; Indicates the lookback time step length of historical load data electricity consumption; Indicates the length of the time series data block for overlapping or non-overlapping data blocks; the number 2 handles the boundary problem by adding extra blocks at the starting point and the end point, so that the time series data of the historical power load is completely covered. For example, at the starting point, if a complete data block cannot be formed according to the normal sliding step and the long step length of the backtracking time, an extra data block can be formed by extending the data forward (such as using the mean of the historical data or other filling methods); at the end point, if the remaining data is not enough to form a complete data block, an extra data block can be formed by extending the data backward (such as using the predicted value or other filling methods). In this way, by adding an extra data block at the starting point and the end point (a total of 2 data blocks), it can be ensured that the entire time series data is completely divided into multiple data blocks for standardization.

[0077] S22, performing normalization processing on each divided data block.

[0078] Normalization methods include Z-score normalization, Min-Max normalization, etc.

[0079] S3, uses a fully connected layer to extract semantic prototypes and encode time series data blocks into natural language input;

[0080] The normalized time series data block is fed into a fully connected layer. This layer learns the data's characteristics and encodes it into natural language input, adapting it to the representation of the Large Language Model (LLM). The weight matrix and bias vector of the fully connected layer are continuously adjusted during training to extract the most representative semantic information from the data. Specifically, S3 includes:

[0081] S31, linear transformation: Through step S2, the time series data is divided into multiple patches. Each patch is a data block, representing a local segment of the data. A fully connected layer (Linear Layer) is used to map each patch to a new semantic space. This new semantic space can better represent the characteristics of the patch.

[0082] The input data for each patch is ∈ ,in, is the length of the patch, express dimensional real vector space; the weight matrix of Liner Layer is ∈ , used to map patch data into semantic space, represents the real matrix space for linear transformation (weight matrix), where is the output dimension, that is, the dimension of the semantic space; the bias vector is ∈ , express dimensional real vector space, used to represent bias or semantic encoding; the output of LinearLayer can be expressed as:

[0083] ;

[0084] in, ∈ It is the semantic representation of patch.

[0085] S4, linear projection via a multi-head attention mechanism to align the reprogrammed patch with the dimensions of the LLM backbone;

[0086] In order to align with the LLM input dimension, the semantic representation of the patch needs to be further transformed. The input is fed into the multi-head attention mechanism, which can simultaneously focus on multiple different aspects of the data and capture long-term dependencies in the data. Specifically, S4 includes:

[0087] S41, generation of query, key, and value:

[0088] Use Linear Layer to represent the semantics of the patch Mapping to query matrix , key matrix Sum Matrix , the formula is as follows:

[0089] ;

[0090] ;

[0091] ;

[0092] in, 、 、 They are used to generate the query matrix , key matrix Sum Matrix The weight matrix, 、 、 They are used to generate the query matrix , key matrix Sum Matrix The bias vector of

[0093] S42, attention calculation:

[0094] Using the query matrix , key matrix Sum Matrix Calculate the attention score:

[0095] ;

[0096] in, is the dimension of the key vector; represents transpose; Indicates that the data in the brackets behind Function Compute;

[0097] The multi-head attention mechanism captures different contextual information by computing multiple attention heads in parallel. Each attention head calculates the attention score independently, and then concatenates the results. After the multi-head attention calculation is completed, the concatenated output dimension is , output projection is performed through a Liner Layer to map the spliced ​​output back to the target dimension , the formula is as follows:

[0098] ;

[0099] in, ∈ is the final multi-head attention output, is the sequence length;

[0100] It is the concatenated output of multi-head attention; ∈ is the weight matrix of the output projection.

[0101] The main functions of output projection include:

[0102] Dimension alignment: Align the output dimension of the multi-head attention from Mapping back , so that it is consistent with the input dimension of subsequent layers.

[0103] Feature fusion: Through linear transformation, the output features of multiple attention heads are fused to enhance the expressiveness of the model.

[0104] Parameter optimization: output projection weight matrix are learnable parameters that are optimized through the training process.

[0105] S5, adds a hint prefix before each reprogrammed patch to enhance the input information;

[0106] Among them, the prompt prefix includes the general background of the dataset, the task description, and the input statistics;

[0107] General background of the dataset: Describe the source, domain, and characteristics of the time series data. For example: "This is a time series dataset of electricity consumption from residential households."

[0108] Task description: Clearly state the objectives and requirements of the task. For example: "The task is to predict the electricity consumption for the next 24 hours."

[0109] Input Statistics: Provides statistical information about the input data, such as mean, variance, etc. For example: "The average electricity consumption in the past week was 50 kWh per day."

[0110] Specifically, S5 includes:

[0111] S51, generates natural language prompt prefixes based on the context of time series data and task objectives;

[0112] As shown above, the generated natural language prompt prefix includes: "This is a time series dataset of residential electricity consumption in a certain area. The task is to predict electricity consumption for the next 24 hours. The input data includes electricity consumption over the past week, with an average electricity consumption of 50 kWh / day." These parts are combined into a complete prompt prefix and input into the LLM.

[0113] S52, splicing of prompt words and patches;

[0114] The generated natural language prompt prefix is ​​spliced ​​with the reprogrammed patch to enhance the input information. The spliced ​​input can provide more contextual information for LLM, helping LLM to better understand the task and data, thereby improving the accuracy of prediction.

[0115] The semantic representation of time series data is ∈ , the embedding of the hint prefix is ​​represented as ∈ , then the input of LLM can be expressed as:

[0116] ;

[0117] in, is the sequence length; It is the dimension of semantic representation; is the length of the prompt prefix; ∈ It is the input of LLM; Represents a concatenation operation on the sequence dimension.

[0118] S6, input the patch with the splicing hint prefix into LLM, flatten the output and obtain the prediction result of each data block;

[0119] Use a linear layer to map the LLM output from the high-dimensional semantic space to the target dimension, that is, the dimension of the prediction result, to obtain the final time series prediction result:

[0120] ;

[0121] in, It will Input to the output of LLM; and is the weight matrix and bias variable of the output projection; is the predicted output of the final time series data block.

[0122] S7, inversely transforming the prediction results of each block and splicing them in the original order to obtain a continuous prediction sequence;

[0123] After the previous steps, the power consumption prediction for each data block corresponding to a certain period of time in the future is obtained. Then, each prediction result is restored to the original dimension (after the model output, the prediction result is inverse normalized by reversible instance normalization to restore the distribution of the original data). Finally, each power consumption prediction result is spliced ​​in the original time order to obtain a continuous prediction sequence.

[0124] S8, using experimental indicators to judge the measurement results of the continuous prediction sequence, and if qualified, applying it to actual power consumption prediction work, using the trained Time-LLM model to predict future power consumption based on actual power consumption.

[0125] The experimental indicators use mean square error (MSE), mean absolute error (MAE) and judgment coefficient (R2) to evaluate the prediction results. If the prediction results meet the preset qualification standards in terms of various indicators, the method is applied to actual electricity consumption forecasting. Based on the input real-time data (such as the current time, user historical electricity consumption data, etc.), the trained Time-LLM model is used to generate corresponding future electricity consumption forecast results (such as hourly electricity consumption forecasts for a period of time in the future). These prediction results can be used for power grid scheduling, energy management, user electricity consumption planning, etc., to provide support for the intelligent operation of the power system.

[0126] Among them, the mean square error (MSE), mean absolute error (MAE) and judgment coefficient (R 2 ) is calculated as follows:

[0127] ;

[0128] ;

[0129] ;

[0130] in, and Respectively represent The actual and predicted values ​​of each instance; is the arithmetic mean of all actual values; is the total number of data; Indicates the first samples (data points).

[0131] By introducing LLM and multi-head attention mechanism, the present invention can better capture the long-term dependencies in time series data and improve the accuracy of prediction. The prediction results can help power grid companies to reasonably arrange power generation plans, optimize the allocation of power resources, and improve the operating efficiency and stability of the power grid.

[0132] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A method for predicting electricity consumption based on Time-LLM, characterized in that: include: Obtain historical electricity consumption data to construct a sample data set, preprocess the sample data set, and divide the preprocessed sample data set into a training set, a validation set, and a test set; Normalize the input sequence through reversible instance normalization, dividing the input sequence into time series data blocks with the same scale and distribution characteristics; Using fully connected layers to extract semantic prototypes, we encode time series data blocks into natural language inputs and perform linear projection via a multi-head attention mechanism to align the reprogrammed patches with the dimensions of the LLM backbone, where patches refer to time series data blocks and LLM refers to large language models. Add a hint prefix before each reprogrammed patch to enhance the input information, where the hint prefix includes the general background of the dataset, task instructions, and input statistics; The patch with the splicing hint prefix is ​​input into LLM, the output is flattened and the prediction result of each data block is obtained. The prediction results of each block are inversely transformed and spliced ​​in the original order to obtain a continuous prediction sequence; The prediction results of the continuous prediction sequence are judged by using experimental indicators. If the results are qualified, they are applied to the actual power consumption forecasting work, and the trained Time-LLM model is used to predict the future power consumption based on the actual power consumption.

2. The power consumption prediction method based on Time-LLM according to claim 1 is characterized in that: Preprocessing includes data cleaning and processing, identifying and filling missing data, and removing and correcting abnormal data. The preprocessing of the sample data set includes: Use the Z-score method to detect outliers in the data and define the data The Z-score is: ; Where, µ and are the mean and standard deviation of the data, is the index of the data point in the dataset; when >α, is considered as an outlier, and α is the preset threshold; For the detected outliers, we first use the K-nearest neighbor algorithm to perform interpolation repair and find the outliers that are close to it in the time series. Normal data points { 、 、 、…、 }, calculate the weighted average of these adjacent data points to replace the outlier. The formula is as follows: ; Where, represents the outlier value after repair, Represents The approaching Normal data points, ; Then use the moving average method to smooth the abnormal data, set the window size to 5, calculate the average value of the data points in the window around the abnormal point, and replace the abnormal data point with the calculated average value; The mean square error method was used to quantify data differences.

3. The power consumption prediction method based on Time-LLM according to claim 1 is characterized in that: The step of normalizing the input sequence by reversible instance normalization to divide the input sequence into time series data blocks with the same scale and distribution characteristics includes: The input sequence is divided into blocks of the same length. The total number of blocks is: ; in, Indicates the total number of time series data blocks; Indicates the stride of horizontal sliding; Indicates the lookback time step length of historical load data electricity consumption; Indicates the length of the time series data block with overlapping or non-overlapping data blocks; Number 2 handles the boundary problem by adding extra blocks at the start and end points, so that the time series data of the power historical load is fully covered; Normalize each divided data block.

4. The power consumption prediction method based on Time-LLM according to claim 1 is characterized in that: Using fully connected layers to extract semantic prototypes, encoding time series data blocks into natural language input includes: Use the fully connected layer Linear Layer to map each patch to a new semantic space. The input data of each patch is ∈ ,in, is the length of the patch, express dimensional real vector space; the weight matrix of Liner Layer is ∈ , represents the real matrix space, used for linear transformation, where is the output dimension, that is, the dimension of the semantic space; the bias vector is ∈ , express dimensional real vector space, used to represent bias or semantic coding; the output of Linear Layer is expressed as: ; in, ∈ It is the semantic representation of patch.

5. The power consumption prediction method based on Time-LLM according to claim 4 is characterized in that: Linear projection via a multi-head attention mechanism is performed to align the reprogrammed patch with the dimensions of the LLM backbone including: Use Linear Layer to represent the semantics of the patch Mapping to query matrix , key matrix Sum Matrix , the formula is as follows: ; ; ; in, 、 、 They are used to generate the query matrix , key matrix Sum Matrix The weight matrix, 、 、 They are used to generate the query matrix , key matrix Sum Matrix The bias vector of Using the query matrix , key matrix Sum Matrix Calculate the attention score: ; in, is the dimension of the key vector; represents transpose; Indicates that the data in the brackets behind are Function Compute; After the multi-head attention calculation is completed, the output dimension of the spliced , output projection is performed through a Liner Layer to map the spliced ​​output back to the target dimension , the formula is as follows: ; in, ∈ is the final multi-head attention output, is the sequence length; It is the concatenated output of multi-head attention; ∈ is the weight matrix of the output projection.

6. The power consumption prediction method based on Time-LLM according to claim 5, characterized in that: Add a prompt prefix before each reprogramming patch, and enhance the input information including: Generate natural language prompt prefixes based on the context of time series data and task objectives; The generated hint prefix is ​​concatenated with the reprogrammed patch, and the semantic representation of the time series data is: ∈ , the embedding of the hint prefix is ​​represented as ∈ , then the input of LLM is expressed as: ; in, It is the dimension of semantic representation; is the length of the prompt prefix; ∈ It is the input of LLM; Represents a concatenation operation on the sequence dimension.

7. The power consumption prediction method based on Time-LLM according to claim 6, characterized in that: The patch with the splicing hint prefix is ​​input into the LLM, the output is flattened, and the prediction results for each data block are obtained, including: Use a linear layer to map the LLM output from the high-dimensional semantic space to the target dimension: ; in, It will Input to the output of LLM; and is the weight matrix and bias variable of the output projection; is the predicted output of the final time series data block.

8. The power consumption prediction method based on Time-LLM according to claim 1, characterized in that: The experimental indicators include mean square error , mean absolute error and the judgment coefficient ,in, ; ; ; Where, and Respectively represent The actual and predicted values ​​of each instance; is the arithmetic mean of all actual values; is the total number of data; Indicates the first data points.

Citation Information

Patent Citations

  • Generative power load prediction method and system based on correlation feature fusion

    CN117458440A

  • Load prediction method and system based on variational auto-encoder and TIME-LLM model

    CN119994901A