Electricity consumption prediction method and system based on federated learning of fused rag and personalized graph

By integrating RAG and personalized graph federated learning methods, a federated learning framework is constructed and a personalized electricity consumption model is generated, which solves the problems of insufficient accuracy and adaptability in electricity consumption forecasting in urban areas and achieves more efficient electricity consumption forecasting and power resource management.

CN121212472BActive Publication Date: 2026-04-10国网福建省电力有限公司营销服务中心 +1
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-19
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively capture the spatiotemporal connections between urban communities under complex and ever-changing electricity demand conditions. They also cannot provide personalized model parameters for different urban districts, resulting in insufficient prediction accuracy and generalization ability, which affects the allocation of power resources and the stable operation of the power grid.

Method used

We adopt a method that integrates RAG and personalized graph federated learning. By constructing a federated learning framework, we obtain standardized electricity consumption data, adjacency matrix and scene feature vector. We use graph neural network to generate personalized electricity consumption model and aggregate the model through random block model and similarity calculation to improve the model's adaptability and generalization ability.

Benefits of technology

It improves the accuracy and adaptability of electricity consumption forecasting, enabling it to adapt to different electricity consumption patterns in various scenarios, enhancing the robustness and generalization ability of the model, and providing more accurate basis for power management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121212472B_ABST
    Figure CN121212472B_ABST
Patent Text Reader

Abstract

The present application relates to a power consumption prediction method and system based on fusion RAG and personalized graph federated learning, belonging to the technical field of power prediction. The method comprises the following steps: preprocessing the historical power consumption data of each municipal district, converting it into a data frame, and improving the data quality by removing all null columns, removing abnormal data, and using linear interpolation to fill in missing values; using Z-score and Min-Max standardization method for data normalization; using graph neural network as the basic model structure, combining with the geographical position information to generate the adjacency matrix, and capturing the spatial correlation between communities; introducing RAG knowledge base, integrating structured external knowledge in special scenarios, generating embedding vectors through Sentence-BERT to realize historical scene retrieval, combining with the gating mechanism to fuse the retrieval results and model prediction, under the federated learning framework, the server initializes multiple personalized models, the user trains and uploads the updated model parameters locally, and the server calculates the aggregation weight between users through the functional feature similarity.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to a power consumption prediction method and system based on fusion of RAG and personalized graph federated learning, and belongs to the technical field of power consumption prediction. BACKGROUND

[0002] Accurate residential power consumption prediction is of great significance for rational allocation of power resources, stable operation of power grids, and energy saving and emission reduction. However, under complex and changeable power consumption conditions and power consumption environment, the defects of traditional deep learning prediction methods are increasingly prominent.

[0003] For example, the Chinese patent application with the publication number CN118052331A discloses a residential power consumption prediction method based on deep learning and federated learning, which comprises the following steps: collecting user data; constructing an edge side training model based on federated learning; decomposing the data set; establishing a federated learning deep model; parameter training; obtaining available model parameters of each edge side model through edge side training, updating and optimizing all edge side models by receiving encrypted model parameters of the edge side, and aggregating the edge side models in the cloud. The patent constructs an FL edge side model for REC prediction based on EMD-LSTM, performs individualization processing on the FL, and reduces the error of REC prediction. However, the FL edge side model constructed based on EMD-LSTM is highly dependent on the quality and similarity of historical power consumption data, and has insufficient adaptability to abnormal data. At the same time, the error of the model will accumulate with the increase of the scale in long-term prediction, and the data generalization problem of cross-regional or new users is not fully considered, which will affect the scalability of the prediction model.

[0004] For another example, Chinese Patent Application Publication No. CN114781606A discloses a method for medium and long term prediction of regional power consumption based on federated learning. The method simultaneously trains power consumption prediction models for multiple regions in a federated manner, enriches the training samples and effectively improves the generalization ability of the model under the premise of protecting data privacy. The local base model of federated learning uses an LSTM network. In addition to traditional factors such as economy and society, the input features of the model also include carbon emissions. The power consumption prediction results are more consistent with the future low-carbon development path. The patent is a data-driven method and does not involve any explicit modeling. Compared with traditional statistical methods and regression models, the patent has better adaptive ability for high-dimensional nonlinear problems and can mine the potential change law of power consumption through self-learning to improve the prediction accuracy. However, the patent uses an LSTM-based time series model for prediction. The LSTM itself has limitations such as difficulty in accurately capturing complex nonlinear relationships and long-term dependencies, complex and high-cost training, high requirements for data quality and feature engineering, weak adaptability to new power consumption patterns, lack of robustness and uncertainty evaluation, and ignores the graph structure relationship between communities within a district. In the actual residential power consumption scenario, there are complex correlations and mutual influences between communities in the same district. The valuable information contained in this graph structure relationship is ignored, which leads to the loss of key information and affects the prediction accuracy. At the same time, the patent uses the same model to predict different districts. Due to significant differences in economic development level, population density, industrial structure, and lifestyle between different districts, the power consumption patterns and features are quite different. A unified model cannot adapt to the unique situation of each district and accurately depict the change law of power consumption, resulting in large prediction errors and difficulty in meeting the demand for rational allocation of power resources and stable operation of power grids, which limits its effectiveness in practical applications.

[0005] For example, the Chinese invention patent application with publication number CN113139341A discloses a power demand prediction method and system based on federated integrated learning, including the steps: the total power station randomly selects part of the sub-power stations participating in the training from all the sub-power stations participating in the training, and sends the pre-trained global model to the corresponding sub-power station; each sub-power station receives the global model and initializes its local model, and the sub-power station uses its own local data set for local training; the sub-power station uploads its local model to the total power station after local training, and the total power station performs aggregation operation on the received local model to obtain a new global model; the above steps are repeatedly executed until the global model converges. The patent constructs a multi-modal sub-model coordination and Bagging federated aggregation framework, which breaks through the limitation of single source data and improves the prediction accuracy in extreme environment by dividing the power consumption, weather and temperature data into independent training units and then dynamically weighting and fusing them. However, in the communication architecture, the sub-power station is forced to upload the complete LSTM model instead of parameter updates, which significantly increases the bandwidth pressure, and in the synchronous aggregation mechanism, there is no fault-tolerant solution for network interruption, which is easy to cause node disconnection and interrupt the training.

[0006] In summary, there is an urgent need for a resident electricity prediction method that can effectively capture the spatio-temporal relationship between communities in the municipal districts, and can provide different model parameters for different municipal districts through individualized methods according to the electricity difference between municipal districts, and can effectively improve the generalization ability of the model. SUMMARY

[0007] In order to solve the problems existing in the prior art, the present application provides a power prediction method and system based on fusion RAG and individualized graph federated learning.

[0008] The technical scheme of the present application is as follows:

[0009] On the one hand, the present application provides a power prediction method based on fusion RAG and individualized graph federated learning, which comprises the following steps:

[0010] A federated learning framework is constructed, including a server and participants, each municipal district is taken as a participant, and the standardized power data of each community in the municipal district, the adjacency matrix between each community in the municipal district and the scene feature vector are obtained; based on the scene feature vector, the historical power feature matrix is obtained by using the preset RAG knowledge base;

[0011] The server generates an initial individualized power consumption model based on a graph neural network and distributes it to the municipal district, the initial individualized power consumption model is trained locally by using the standardized power data, the adjacency matrix and the historical power feature matrix, and a local individualized power consumption model is obtained;

[0012] The local personalized power consumption model of the municipal district is uploaded to the server, the server inputs the local personalized power consumption model after generating pseudo-graph data using a random block model to obtain the functional characteristics corresponding to each community in the municipal district, and obtains the average functional characteristics of the municipal district by averaging the functional characteristics; the similarity between the average functional characteristics of any two participants is calculated, and the similarity obtained by calculation is normalized as the aggregation weight of the local personalized power consumption model; the local personalized power consumption model is aggregated based on the aggregation weight of the local personalized power consumption model to obtain a final personalized power consumption model;

[0013] The server distributes the final personalized power consumption model to the participants for resident power consumption prediction.

[0014] Preferably, the standardized power data is calculated using a z-score algorithm and a Max-Min algorithm, and specifically:

[0015] The historical power consumption data of each community in the municipal district is obtained, and the historical power consumption data is calculated by z-score, which is expressed by the formula:

[0016] ;

[0017] In the formula, is the historical power consumption data after z-score calculation; is the historical power consumption data; is the mean of the historical power consumption data; is the standard deviation of the historical power consumption data;

[0018] The historical power consumption data after z-score calculation is normalized by using the Max-Min algorithm to obtain the standardized power data, which is expressed by the formula:

[0019] ;

[0020] In the formula, is the minimum value of the historical power consumption data after z-score calculation, is the maximum value of the historical power consumption data after z-score calculation, is the standardized power data corresponding to the community.

[0021] Preferably, the step of constructing the adjacency matrix is specifically:

[0022] The geographical position data of each community in the municipal district is obtained, the distance between any two communities in the same municipal district is calculated according to the geographical position data, and the corresponding adjacency matrix is calculated based on the distance, which is expressed by the formula:

[0023] ;

[0024] wherein, denotes the standard deviation of the distances between all communities within the city district, denotes the adjacent distance between the community and the community ; denotes the adjacent relationship between the community and the community ; the adjacent matrix is composed of a plurality of .

[0025] Preferably, based on the scene feature vector, a preset RAG knowledge base is used to obtain a historical power feature matrix, specifically:

[0026] The current power consumption scene of each community in the city district is obtained, and a scene feature vector is extracted. The scene feature vector is matched in similarity based on a pre-constructed RAG knowledge base. A similarity matching threshold is set. When the similarity is within the set similarity matching threshold, the historical power feature matrix corresponding to the current power consumption scene is obtained.

[0027] Preferably, the specific process of obtaining the local individualized power consumption model by local training of the initial individualized power consumption model is as follows:

[0028] The standardized power data is feature extracted and constructed into a power feature matrix;

[0029] The power feature matrix and the adjacent matrix are used as inputs of the initial individualized power consumption model to generate an initial power prediction value. The initial power prediction value and the historical power feature matrix are weighted and fused through a gating mechanism to output a final power prediction value. Based on the final power prediction value, the initial individualized power consumption model is iteratively trained using a preset loss function until an iteration termination condition is reached, and a local individualized power consumption model is obtained.

[0030] Preferably, the initial individualized power consumption model includes two layers of graph convolution layers, wherein:

[0031] The first layer of graph convolution layers performs convolution operation, which is expressed by the formula:

[0032] ;

[0033] ;

[0034] wherein, is a power feature matrix, denotes the adjacent matrix between the communities in the th city district; is a normalized adjacent matrix between the communities in the th city district, This is the weight matrix of the first graph convolutional layer; The bias of the first graph convolutional layer. This is the output matrix of the first graph convolutional layer. For activation functions; for The degree matrix; It is the identity matrix;

[0035] The second convolutional layer performs a convolution operation, expressed by the formula:

[0036] ;

[0037] In the formula, This is the initial predicted power consumption value. This is the weight matrix of the second graph convolutional layer; This is the bias of the second graph convolutional layer.

[0038] Preferably, a weighted fusion of the initial energy prediction value and the historical energy feature matrix is ​​performed through a gating mechanism, as expressed by the formula:

[0039] ;

[0040] ;

[0041] In the formula, Indicates the first Within the municipal districts The community in the The final predicted power consumption value at each time step. Represents the historical electricity consumption feature matrix; For the gated vector, The weight matrix corresponding to the gate vector. This is the bias vector corresponding to the gate vector.

[0042] Preferably, the server uses a random block model to generate pseudo-graph data, specifically:

[0043] The total number of nodes in the pseudograph is obtained by calculating the node size of the actual participants, expressed by the formula:

[0044] ;

[0045] In the formula, This represents the total number of nodes in the pseudograph. This represents the total number of actual participants. For the first The total number of communities within each municipal district;

[0046] The pseudograph node set is defined based on the total number of nodes in the pseudograph. ;

[0047] Randomly assign the nodes of the pseudo graph into preset number of simulated community clustering blocks, wherein the block assignment probability is expressed by the formula:

[0048]

[0049] In the formula, P (i, j) represents the probability that the node i in the pseudo graph is assigned to the jth block;

[0050] According to the block assignment result of the nodes and the edge generation rule, the edges and the edge set of the pseudo graph are generated, and the edge generation rule is expressed by the formula:

[0051]

[0052] In the formula, E (i, j) represents the edge between the nodes i and j;

[0053] Based on the node set and the edge set, the pseudo graph data G is obtained.

[0054] In another aspect, the application also provides an electricity consumption prediction system based on fusion of RAG and personalized graph federated learning, comprising the following modules:

[0055] A framework construction and data acquisition module is used to construct a federated learning framework including a server and participants, taking a municipal district as a participant, to acquire standardized electricity consumption data, an adjacency matrix and a scenario feature vector of the participant; based on the scenario feature vector, a historical electricity consumption feature matrix is obtained by using a preset RAG knowledge base;

[0056] A model initialization and local training module is used to make the server generate an initial personalized electricity consumption model based on a graph neural network and distribute it to the municipal district, wherein the initial personalized electricity consumption model is locally trained by using the standardized electricity consumption data, the adjacency matrix and the historical electricity consumption feature matrix to obtain a local personalized electricity consumption model;

[0057] ​​​​​​​​​​​​​​​​​​​​A model aggregation module is configured to enable a municipal district to upload a local personalized power consumption model to a server, and the server inputs the local personalized power consumption model after generating pseudo-graph data using a random partition model, obtains functional features corresponding to each community in the municipal district, and obtains average functional features of the municipal district by averaging the functional features; similarity calculation is performed on the average functional features between any two participants, and the calculated similarity is normalized to serve as a local personalized power consumption model aggregation weight; the local personalized power consumption model is aggregated based on the local personalized power consumption model aggregation weight to obtain a final personalized power consumption model;

[0058] A power consumption prediction module is configured to enable the server to distribute the final personalized power consumption model to the participants for resident power consumption prediction.

[0059] In another aspect, the present application also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method of the present application.

[0060] The present application has the following advantages:

[0061] (1) The present application is a power consumption prediction method and system based on fusion of RAG and personalized graph federated learning, and a federated learning framework is constructed, with municipal districts as participants. In the steps of obtaining standardized power data, an adjacency matrix and a scene feature vector corresponding to the participants, and obtaining a historical power feature matrix based on the scene feature vector using a preset RAG knowledge base, the standardized power data is calculated by a z-score algorithm and a Max-Min algorithm, eliminating the influence of data dimension, so that the power data of different communities is comparable. The adjacency matrix is constructed according to the geographical location data of each community in the municipal district to capture the spatial correlation between communities. The historical power feature matrix is obtained using the RAG knowledge base combined with power consumption scene information, so that the model can adapt to different power consumption modes. The data quality obtained by the above steps is improved, and the adaptability and prediction accuracy of the subsequent model are further improved.

[0062] (2) The present application is a power consumption prediction method and system based on fusion of RAG and personalized graph federated learning. The server generates an initial personalized power consumption model based on a graph neural network and distributes it to the municipal districts. Each municipal district performs personalized training locally using standardized power data, an adjacency matrix and a historical power feature matrix, which can fully exploit local power consumption differences. The graph neural network combined with the adjacency matrix can effectively process graph structure data and capture community correlation information. Furthermore, the personalized power consumption model adaptively adjusts the weight through a gating mechanism in the final prediction process, fully utilizes the historical power feature information, and further improves the applicability and prediction accuracy of the model in each jurisdiction.

[0063] (3) The power consumption prediction method and system based on the federated learning of the fusion RAG and the personalized graph, the local personalized power consumption model of a city district is uploaded to a server, the server generates pseudo graph data by using a random block model and inputs the pseudo graph data into the local personalized power consumption model, the data diversity is increased, and the model robustness is enhanced; the functional characteristics of each community in the city district are obtained through the local personalized power consumption model, the average functional characteristics of the city district are obtained by taking the mean value, the similarity is calculated and normalized as the aggregation weight, the aggregation weight comprehensively considers the local model of each district, and the model generalization capability is improved; the final model is obtained by aggregating the local personalized power consumption model based on the aggregation weight and is distributed to the participants to perform the resident power consumption prediction, and the final model is predicted according to the characteristics of different city districts, and more accurate basis is provided for power management and planning. BRIEF DESCRIPTION OF DRAWINGS

[0064] Figure 1 The method flowchart of the present application is shown in the figure;

[0065] Figure 2 The preset RAG knowledge base flowchart in the first embodiment of the present application is shown in the figure;

[0066] Figure 3 The training flowchart of the initial personalized power consumption model in the first embodiment of the present application is shown in the figure;

[0067] Figure 4 The matching flowchart of the preset RAG knowledge base in the first embodiment of the present application is shown in the figure;

[0068] Figure 5 The aggregation schematic diagram of the local personalized power consumption model in the first embodiment of the present application is shown in the figure. DETAILED DESCRIPTION

[0069] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by those skilled in the art without creative labor fall within the protection scope of the present application.

[0070] It should be understood that the step numbers used herein are only for the convenience of description, and are not limited to the execution sequence of the steps.

[0071] It should be understood that the terms used in the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the present application specification and the appended claims, unless otherwise clear from the context, the singular forms "a", "an" and "the" are intended to include the plural forms.

[0072] The terms “comprise” and “contain” indicate the presence of the described features, integers, steps, operations, elements, and / or components but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0073] The term “and / or” means any combination of one or more of the associated listed items and all possible combinations thereof, and includes these combinations.

[0074] Embodiment one:

[0075] Referring to Figure 1 The embodiment provides a power consumption prediction method based on federated learning of fused RAG and personalized graph, the method comprising:

[0076] S1, constructing a federated learning framework including a server and participants, taking a municipal district as a participant, obtaining standardized power data, an adjacency matrix and a scenario feature vector of the participant; based on the scenario feature vector, obtaining a historical power feature matrix by using a preset RAG knowledge base;

[0077] S11, the standardized power data is the power data of each community in the municipal district, which is calculated by using a z-score algorithm and a Max-Min algorithm, specifically:

[0078] The historical power consumption data of each community in the municipal district is obtained from multiple source data channels (for example, a metering system of a local power supply company, statistical records and related public data platforms of a government energy management department, etc.), and the historical power consumption data includes power consumption and corresponding time stamps and community numbers, and the time stamps are converted into date and time formats;

[0079] The historical power consumption data is cleaned by using, for example, a Pandas library in Python or a data processing function in R language, to remove null values, error values, duplicate values and abnormal data in the historical power consumption data, and a linear interpolation method is used to fill in missing values, so as to ensure the accuracy and consistency of the historical power consumption data;

[0080] The date and time corresponding to the time stamp are used as the row index of the data frame, and each row represents a specific time point or time period; the community number is used as the column index of the data frame, and each column corresponds to a specific community; the historical power consumption data after data cleaning is filled into the corresponding row and column intersection position to construct a complete power data frame, which is used as the data source for the subsequent steps;

[0081] The historical power consumption data in the power data frame is calculated by using a z-score algorithm, which is expressed by a formula as follows:

[0082] ;

[0083] wherein, is the historical electricity consumption data after z-score calculation; is the historical electricity consumption data; is the mean of the historical electricity consumption data; is the standard deviation of the historical electricity consumption data;

[0084] The historical electricity consumption data after z-score calculation is normalized by using the Max-Min algorithm to obtain standardized electricity consumption data, which is expressed by the formula:

[0085] ;

[0086] wherein, is the minimum value of the historical electricity consumption data after z-score calculation, is the maximum value of the historical electricity consumption data after z-score calculation, is the standardized electricity consumption data corresponding to the community;

[0087] S12, the adjacency matrix is the adjacency matrix between each community in the municipal district, specifically:

[0088] Obtain the geographic location data of each community in the municipal district from multiple data sources (such as mobile map software data platform, related data platform, etc.), wherein the geographic location data includes the longitude and latitude of the location of the community;

[0089] Apply for a Web service API key from a map open platform, convert the longitude and latitude information of the community in the municipal district into a GCJ-02 coordinate system representation form, and call a map open platform distance calculation API to calculate the adjacency distance between any two communities in the municipal district;

[0090] Calculate the corresponding adjacency matrix according to the adjacency distance between any two communities in the municipal district, which is expressed by the formula:

[0091] ;

[0092] wherein, represents the standard deviation of the distance between all communities in the municipal district, represents the adjacency distance between the community and the community ; represents the adjacency matrix of the community and the community .

[0093] S13, extract the scene feature vector of the historical power consumption scene of each community in the city jurisdiction based on the historical power consumption data corresponding timestamp, and construct the RAG knowledge base based on the scene feature vector of the historical power consumption scene; specifically:

[0094] S131, referring to Figure 2 , the time step (such as a single day) of the historical power consumption data is taken as the benchmark dimension, the corresponding scene information of the time step is extracted and structured; among them, the meteorological data (such as temperature, precipitation, extreme weather warning signal, etc.) of the environmental scene can be obtained from the meteorological data network and other channels, and the time characteristics (such as legal holiday arrangement, rest identification, etc.) of the event scene are extracted in combination with news information; with the instruction generation ability of generative artificial intelligence, the above-mentioned multi-source scene information is preprocessed to form a unified format of scene description text; specifically:

[0095] In this embodiment, the description text of the meteorological scene information is, for example: “the highest temperature is 38°, lasting for 48 hours”; “heavy rain causes waterlogging, rainfall reaches 150mm / h”; the description text of the event scene information is, for example: “legal holiday: Spring Festival, 8 days off”.

[0096] The description text of the structured scene information is cleaned, irrelevant symbols and stop words are removed, and the format is unified; in this embodiment, the description text of the meteorological scene information is unified in the format of: “the highest temperature is () °, the duration is () h” or “the lowest temperature is () °, the duration is () h”, and the description text of the event scene information is unified in the format of: “legal holiday (), off () days”.

[0097] S132, scene feature vector generation and storage:

[0098] Referring to Figure 3 , the structured scene description text obtained after cleaning in step S131 is input into the Sentence-BERT model, and a fixed-length scene feature vector is generated and stored in the RAG knowledge base, the generation process of the scene feature vector is a conventional technical means in the art, which will not be described here.

[0099] The generated scene feature vector is taken as an index key, and the historical power consumption data of the current scene is stored as an index value in association with the index key.

[0100] S133, in this embodiment, the scene feature vector corresponding to the current power consumption scene of each community in the city jurisdiction is extracted, and the scene feature vector corresponding to the current power consumption scene is matched based on the RAG knowledge base, in this embodiment, the similarity is cosine similarity, which is expressed in the formula as:

[0101] ;

[0102] In the formula, This represents the scene feature vector stored in the RAG knowledge base. Represents the feature vector of the current scene. Let A be the angle between vectors A and B.

[0103] S2. The server generates an initial personalized electricity consumption model based on a graph neural network and distributes it to the municipal districts. The initial personalized electricity consumption model is trained locally using standardized electricity consumption data, an adjacency matrix, and a historical electricity consumption feature matrix to obtain a local personalized electricity consumption model.

[0104] S21, see also Figure 4 In this embodiment, a graph convolutional network is used as the initial personalized model; the server generates the model through random initialization. The initial personalized electricity consumption model for each municipal district was then distributed to the districts, expressed as a formula:

[0105] ;

[0106] In the formula, This is the initial personalized electricity consumption model for the first municipal district. This forms the initial personalized electricity consumption model for the second municipal district; and so on. For the first The initial personalized electricity consumption model for each municipal district.

[0107] It should be noted that, Each initial personalized electricity consumption model has the same model structure but different parameters; each community is a node in a graph convolutional network, and the connection between two communities is the edge of the graph convolutional network.

[0108] S22, No. Each municipal district received the initial personalized electricity consumption model from the server. Then, start local training; among which:

[0109] S221. Since the input value of the graph convolutional network needs to be a set of node features and graph structure, it is necessary to convert the standardized electricity data into node feature form to obtain the electricity feature matrix. Specifically:

[0110] The feature vector of each community (i.e., node) represents its history. Electricity consumption at each time step, node The features are represented as follows:

[0111] ;

[0112] In the formula, Indicates the time step in history. normalized standardization electric quantity data of the 1st to the 15th time step of the city proper,

[0113]

[0114]

[0115]

[0116] S222, according to the electric quantity feature matrix, the initial personalized power consumption model extracts the functional characteristics through two layers of graph convolution layers to obtain the initial electric quantity prediction value, specifically:

[0117]

[0118]

[0119]

[0120]

[0121] ​​​​​​​​​​​​​​​​​​​​​​​​​​In the city power consumption prediction task, the first layer of the graph convolution network is mainly used to capture the local spatial dependence of the regional power consumption behavior. Specifically, the power consumption of each node in the city is not only related to its historical power consumption data, population density, industrial distribution and other characteristics, but also affected by the power consumption mode of the first-order neighbors. For example, the power consumption peak of a commercial area may be closely related to the activities of residents in the surrounding residential areas. The first layer of convolution aggregates the power consumption feature matrix by weighting it with the identity matrix of the adjacency matrix, fuses the features of each node with those of its direct neighbors, and generates new node representations through a learnable weight matrix and an activation function.

[0122] This process is equivalent to extracting common rules in the local space, such as the complementarity or synergy of adjacent regions in power demand, thereby providing more robust local feature descriptions for subsequent prediction.

[0123] The second layer of the graph convolution layer is represented by the formula:

[0124] ;

[0125] In the formula, is the initial power consumption prediction value, is the weight matrix of the second layer of the graph convolution layer; is the bias of the second layer of the graph convolution layer.

[0126] The second layer of the graph convolution layer further expands the range of information perception by aggregating the information of the second-order neighbors (neighbors of neighbors) to mine more extensive inter-regional correlation patterns. In power consumption prediction, the power consumption behavior of some regions may be indirectly affected by more distant regions, such as the production activities of an industrial area may be related to the power demand of multiple downstream supply chain regions. The output matrix of the first layer of the graph convolution layer is used as input, and the identity matrix of the adjacency matrix is used for information propagation, and the features of multi-hop neighbors are mapped to a higher semantic space through a weight matrix.

[0127] The significance of this layer is to capture the global synergy effect across regions, such as the power consumption trends of the entire city or city cluster, and the complex interaction between different functional areas (such as business, industry, and residential areas);

[0128] Through layer-by-layer stacking, the graph convolution network can gradually abstract spatial dependencies from local to global, and finally integrate multi-level spatial features into power consumption prediction, improving the modeling ability of complex power consumption patterns.

[0129] S23, see Figure 3 The final power consumption prediction value is obtained by weighting and fusing the initial power consumption prediction value and the historical power consumption feature matrix through the gating mechanism, which is represented by the formula:

[0130] ;

[0131] ;

[0132] In the formula, Indicates the first Within the municipal districts The community in the The final predicted power consumption value at each time step. Represents the historical electricity consumption feature matrix; For the gated vector, The weight matrix corresponding to the gate vector. This is the bias vector corresponding to the gate vector.

[0133] S24. To obtain a more accurate local personalized electricity consumption model and evaluate its performance, this embodiment quantifies the difference or error between the model's predicted values ​​and the actual values ​​by constructing a loss function. The loss function includes:

[0134] S241, MAE error reflects the error between the final predicted electricity value and the actual value, expressed by the formula:

[0135] ;

[0136] In the formula, Indicates the first Within the municipal districts The community in the The final predicted power consumption value at each time step. Indicates the first The first of the municipal districts The first community (node) The actual data recorded at each time step; This represents the number of nodes within the aforementioned municipal district; Number of time steps to predict battery level; This represents the MAE error between the final predicted electricity consumption value and the actual value.

[0137] In the city district electricity consumption prediction, the application principle of MAE (Mean Absolute Error) error lies in directly measuring the absolute deviation between the model prediction value and the actual electricity consumption. Specifically, MAE quantitatively evaluates the global prediction accuracy of the model by calculating the average of the absolute value of the difference between the predicted value and the actual value. For example, if the actual electricity consumption of a city district is 5 million degrees, and the model predicts 4.8 million degrees, MAE will include this deviation in the statistics and average it to all prediction samples; its significance lies in guiding the model optimization direction to make the prediction result as close to the true value as possible, especially suitable for cases where there are abnormal fluctuations or long-tailed distribution in electricity consumption data, because the sensitivity of MAE to extreme values is lower than that of mean square error (MSE); in the training process, MAE as the core loss function drives the model parameter adjustment to minimize the prediction error, thereby improving the practicality of the prediction result.

[0138] S242, the proximal term loss can reflect the difference value between the local personalized electricity consumption model and the initial personalized electricity consumption model, and is used to prevent the local personalized electricity consumption model from deviating from the initial personalized electricity consumption model in the training process. It is expressed by the formula:

[0139] ;

[0140] In the formula, represents the local personalized electricity consumption model, represents the initial personalized electricity consumption model, represents the proximal term loss between the local personalized electricity consumption model and the initial personalized electricity consumption model.

[0141] In the city district electricity consumption prediction, the application principle of proximal term loss lies in constraining the parameter difference between the local personalized electricity consumption model and the initial personalized electricity consumption model to ensure that the local personalized electricity consumption model retains global synergy and maintains regional personalized characteristics in the training process.

[0142] Further, under the distributed learning framework, each city district may have an independent local model, while there is a shared personalized model; the proximal term loss calculates the difference between the local model parameters and the personalized model parameters and adds it as a regularization term to the loss function, thereby limiting the local model from deviating too much from the initial personalized electricity consumption model in the updating process. This mechanism is particularly important in electricity consumption prediction, because the electricity consumption patterns of different regions may be affected by heterogeneity factors such as climate and industrial structure, but at the same time, the stability of the global model is needed to avoid local overfitting or data bias;

[0143] In the federated learning scenario, if the local personalized electricity consumption model of a certain district fluctuates dramatically due to short-term abnormal electricity consumption data (such as temporary large-scale activities), the proximal term loss will punish the excessive parameter offset, forcing the model to return to the reasonable range of the initial personalized electricity consumption model; this not only conforms to the long-term electricity consumption law of the region, but also avoids model shock caused by local data noise; at the same time, the proximal term loss can also promote cross-regional knowledge transfer, and when some districts lack data, the initial personalized electricity consumption model can provide reliable prior constraints for them.

[0144] S243、According to the calculated MAE error and the proximal term loss, the total loss is obtained, which is expressed by the formula:

[0145] ;

[0146] In the formula, represents the MAE error between the final electricity prediction value and the true value, represents the proximal term loss between the local personalized electricity consumption model and the initial personalized electricity consumption model, is a hyperparameter used to control the weight of , and represents the standardized electricity data, represents the local personalized electricity consumption model.

[0147] S25、According to the loss function of the obtained local personalized electricity consumption model, in order to find the optimal value of the model parameters and improve the prediction accuracy of the model, the minimum value of the loss function needs to be calculated; because the expression of the loss function is complex, it is difficult to directly solve the analytical expression of the minimum value of the loss function, therefore, the model parameters are updated through back propagation to avoid repeated calculation; specifically:

[0148] By calculating the total loss of the local personalized electricity consumption model, the gradient can be obtained, and the specific formula is:

[0149] ;

[0150] In the formula, represents the gradient, reflecting the change direction and amplitude of the current local personalized electricity consumption model parameters in the loss function space, and the greater the value, the higher the sensitivity of parameter adjustment to loss; represents the partial derivative of the total loss with respect to the local personalized electricity consumption model , represents the partial derivative of the MAE loss with respect to the local personalized electricity consumption model , is a hyperparameter used to control the weight of ; and denotes a proximal term loss to the local model Partial derivatives are taken.

[0151] The gradient descent method is used to update the local personalized power consumption model parameters, and the specific formula is represented as:

[0152] ;

[0153] In the formula, denotes the learning rate, and the size of the learning rate directly affects the convergence speed and stability, and too large will cause parameter oscillation and even divergence, and too small will slow down the convergence; denotes the gradient at the moment, denotes the local personalized power consumption model at the moment, denotes the new local personalized power consumption model at the moment, denotes the new local personalized power consumption model at the moment, denotes the new local personalized power consumption model at the moment, denotes the new local personalized power consumption model at the moment;

[0154] In actual training, the gradient descent method repeatedly adjusts the parameters through iteration to gradually adjust the parameters, so that the loss function value continuously approaches the minimum value, and the optimal local personalized power consumption model is obtained, and the local personalized power consumption model is sent to the server.

[0155] S3, the local personalized power consumption model is uploaded to the server, the server uses the random block model to generate pseudo graph data, and inputs the local personalized power consumption model to obtain the functional characteristics corresponding to each community in the city district, and the average functional characteristics of the city district are obtained. The average functional characteristics of any two participants are calculated, and the similarity obtained by calculation is normalized and used as the local personalized power consumption model aggregation weight; the local personalized power consumption model is aggregated based on the local personalized power consumption model aggregation weight, and the final personalized power consumption model is obtained;

[0156] S31, the server uses the random block model to generate pseudo graph data, specifically:

[0157] The total number of nodes of the pseudo graph is obtained by counting the node size of the real participant, which is expressed by the formula:

[0158] ;

[0159] In the formula, is the total number of nodes of the pseudo graph, is the total number of real participants, is the total number of communities in the th city district;

[0160] Based on the total number of nodes of the pseudo graph, the pseudo graph node set is defined ;

[0161] The pseudo graph node set Each node is randomly assigned to a preset number of simulated community clustering blocks, where the block assignment probability is expressed by the formula:

[0162] ;

[0163] In the formula, Representing nodes in a pseudograph Assigned to the The probability of each block; For nodes in the pseudograph The block code that was assigned; To simulate the preset number of community cluster blocks;

[0164] Based on the block allocation results of the nodes and the edge generation rules, the edges and edge sets of the pseudograph are generated. The edge generation rules are expressed by the following formula:

[0165] ;

[0166] In the formula, For nodes and The edge between, For edge set, For nodes and The corresponding random numbers follow a uniform distribution. For block and The probability of edge generation between them;

[0167] Pseudograph data is obtained based on node sets and edge sets. .

[0168] S32. Perform calculations on the pseudo-map data using a local personalized electricity consumption model:

[0169] See Figure 5 The pseudo-graph data is input into the local personalized electricity consumption model to obtain the functional characteristics of the graph nodes. Then, the functional characteristics of the pseudo-graph nodes are analyzed. Figure 5 The average functional characteristics representing the municipal districts are obtained by taking the mean value of the embedded functions, which can be expressed by the formula:

[0170] ;

[0171] In the formula, Indicates the first The average functional characteristics of each municipal district This represents pseudo-image data. This represents a localized personalized electricity consumption model.

[0172] Based on the calculated first Average functional characteristics of each municipal district The cosine similarity between the average functional characteristics of the municipal districts is calculated, specifically expressed as:

[0173] ;

[0174] In the formula, Indicates municipal districts Average functional characteristics; Indicates municipal districts Average functional characteristics;

[0175] municipal districts With the municipal districts Average functional feature similarity between After normalization, the aggregated weights of the model are obtained, specifically as follows:

[0176] ;

[0177] In the formula, Indicates municipal districts With the municipal districts Average functional similarity between them Indicates the municipal districts With the municipal districts Average functional feature similarity between Take the minimum value. Indicates the municipal districts With the municipal districts Average functional feature similarity between Take the maximum value. This represents the aggregate weights of the model.

[0178] Based on the calculated model aggregation weights, the following methods are used:

[0179] ;

[0180] In the formula, Indicates the aggregate weights of the model. Representing the municipal districts The local personalized electricity consumption model is generated; the final personalized electricity consumption model is obtained after aggregation. .

[0181] S4. The server will then distribute the final personalized electricity consumption model to the participants for residential electricity consumption prediction.

[0182] Example 2:

[0183] This embodiment also provides a power consumption forecasting system based on the fusion of RAG and personalized graph federated learning, including the following modules:

[0184] A framework construction and data acquisition module is configured to construct a federated learning framework including a server and participants, take a district as a participant, and acquire standardized power consumption data, an adjacency matrix, and a scenario feature vector of the participant; based on the scenario feature vector, a historical power consumption feature matrix is obtained by using a preset RAG knowledge base;

[0185] A model initialization and local training module is configured to cause the server to generate an initial individualized power consumption model based on a graph neural network and distribute the initial individualized power consumption model to the district, wherein the initial individualized power consumption model is locally trained by using the standardized power consumption data, the adjacency matrix, and the historical power consumption feature matrix to obtain a local individualized power consumption model.

[0186] A model aggregation module is configured to cause the district to upload the local individualized power consumption model to the server, cause the server to input the local individualized power consumption model after generating pseudo-graph data by using a random block model, obtain functional features corresponding to each community in the district, take a mean value of the functional features to obtain an average functional feature of the district, perform similarity calculation on the average functional features between any two participants, normalize the calculated similarity to obtain a local individualized power consumption model aggregation weight, aggregate the local individualized power consumption models based on the local individualized power consumption model aggregation weight, and obtain a final individualized power consumption model.

[0187] A power consumption prediction module is configured to cause the server to distribute the final individualized power consumption model to the participants for resident power consumption prediction.

[0188] It should be noted that the electronic device and the computer readable storage medium described in the present application are based on the same inventive concept as the method described in Embodiment 1 of the present application, and will not be described here.

[0189] In the embodiments of the present application, "at least one" means one or more, and "multiple" means two or more. The "and / or" describes the association relationship between the associated objects, which means that there can be three kinds of relationships, 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. Wherein A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after it. "At least one of the following" and similar expressions mean any combination of these items, including any combination of single or multiple items. For example, at least one of a, b and c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, wherein a, b, and c can be single or multiple.

[0190] Those skilled in the art can clearly understand that the units and algorithm steps described in the embodiments disclosed herein can be realized by electronic hardware, computer software or a combination of the two. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0191] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be described here.

[0192] The above is only an embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation using the content of the present application specification and drawings, or direct or indirect application in other related technical fields, is also included in the patent protection scope of the present application.

Claims

1. A power consumption prediction method based on federated learning of fused RAG and personalized graph, characterized in that, Includes the following steps: A federated learning framework is constructed, including servers and participants. Each municipal district is included as a participant. Standardized electricity consumption data of each community within the municipal district, the adjacency matrix between communities within the municipal district, and scene feature vectors are obtained. Based on the scene feature vectors, a historical electricity consumption feature matrix is ​​obtained using a preset RAG knowledge base. The server generates an initial personalized electricity consumption model based on a graph neural network and distributes it to the municipal districts. The initial personalized electricity consumption model is trained locally using standardized electricity consumption data, an adjacency matrix, and a historical electricity consumption feature matrix to obtain a local personalized electricity consumption model. The municipal districts upload their local personalized electricity consumption models to the server. The server uses a random block model to generate pseudo-graph data and then inputs it into the local personalized electricity consumption model to obtain the functional characteristics of each community in the municipal district. The average value of the functional characteristics is then taken to obtain the average functional characteristics of the municipal district. The similarity between the average functional characteristics of any two participants is calculated, and the calculated similarity is normalized and used as the aggregation weight of the local personalized electricity consumption model. The local personalized electricity consumption model is aggregated based on the aggregation weight of the local personalized electricity consumption model to obtain the final personalized electricity consumption model. The server uses a random block model to generate pseudo-graph data as follows: The total number of nodes in the pseudograph is obtained by calculating the node size of the actual participants, expressed by the formula: ; In the formula, is the total number of pseudo-graph nodes, is the total number of real participants, is the total number of communities in the th municipal district. defining a set of pseudo-graph nodes based on a total number of pseudo-graph nodes ; To use fake images Each node is randomly assigned to a preset number of simulated community clustering blocks, where the block assignment probability is expressed by the formula: ; In the formula, Representing nodes in a pseudograph Assigned to the The probability of each block; For nodes in the pseudograph The block code that was assigned; To simulate the preset number of community cluster blocks; Based on the block allocation results of the nodes and the edge generation rules, the edges and edge sets of the pseudograph are generated. The edge generation rules are expressed by the following formula: ; wherein is a node and is an edge between nodes is an edge set, is a node and is a corresponding random number subject to a uniform distribution, is an edge generation probability between blocks and . Obtaining pseudo-graph data based on a set of nodes and a set of edges ; The server will then distribute the final personalized electricity consumption model to the participants for residential electricity consumption forecasting.

2. The electricity consumption prediction method based on federated learning of fused RAG and personalized graph according to claim 1, characterized in that, The standardized energy data was obtained using the z-score algorithm and the Max-Min algorithm. Specifically: Historical electricity consumption data for each community within the city's jurisdiction is obtained, and z-score calculation is performed on the historical electricity consumption data, expressed as a formula: ; In the formula, is the historical electricity consumption data after z-score calculation; is the historical electricity consumption data; is the mean of the historical electricity consumption data; is the standard deviation of the historical electricity consumption data; The historical electricity consumption data after z-score calculation is normalized using the Max-Min algorithm to obtain standardized electricity consumption data, expressed by the formula: ; In the formula, is the minimum value of the historical electricity consumption data after z-score calculation, is the maximum value of the historical electricity consumption data after z-score calculation, is the normalized electricity consumption data corresponding to the community.

3. The electricity consumption prediction method based on federated learning of fused RAG and personalized graph according to claim 1, characterized in that, The specific steps for constructing the adjacency matrix are as follows: Obtain the geographic location data of each community within the municipal district, calculate the distance between any two communities within the same municipal district based on the geographic location data, and calculate the corresponding adjacency matrix based on the distance, expressed by the formula: ; In the formula, This represents the standard deviation of the distance between all communities within the city's jurisdiction. Indicates communities within the city's jurisdiction and community Adjacency distance between them; Indicates communities within the city's jurisdiction and community The adjacency relationship, the adjacency matrix consists of multiple constitute.

4. The power consumption prediction method based on federated learning of fused RAG and personalized graph according to claim 1, characterized in that, Based on the scene feature vector, a historical electricity consumption feature matrix is ​​obtained using a pre-set RAG knowledge base, specifically as follows: The system obtains the current electricity consumption scenarios of each community in the city and extracts the scenario feature vectors. Based on the pre-built RAG knowledge base, it performs similarity matching on the scenario feature vectors and sets a similarity matching threshold. When the similarity is within the set similarity matching threshold, it obtains the historical electricity consumption feature matrix corresponding to the current electricity consumption scenario.

5. The power consumption prediction method based on federated learning of fused RAG and personalized graph according to claim 1, characterized in that, The specific process of obtaining the local personalized electricity consumption model through local training is as follows: Features are extracted from standardized electricity data and constructed into an electricity feature matrix; The electricity consumption feature matrix and adjacency matrix are used as inputs to the initial personalized electricity consumption model to generate initial electricity consumption prediction values. The initial power prediction value and the historical power feature matrix are weighted and fused through a gating mechanism to output the final power prediction value; Based on the final electricity consumption prediction value, the initial personalized electricity consumption model is iteratively trained by using a preset loss function until an iteration termination condition is reached, and a local personalized electricity consumption model is obtained.

6. The electricity consumption prediction method based on federated learning of fused RAG and personalized graph according to claim 5, characterized in that, The initial personalized electricity consumption model includes two layers of graph convolution layers, wherein: The first layer of graph convolution layers performs convolution operations, which are expressed by the formula: ; ; In the formula, is the electric quantity feature matrix, represents the adjacency matrix between communities in the th municipal district; is the normalized adjacency matrix between communities in the th municipal district, is the weight matrix of the first layer graph convolution layer; is the bias of the first layer graph convolution layer, is the output matrix of the first layer graph convolution layer, is an activation function; is the degree matrix of ; and is an identity matrix. The second layer of graph convolution layers performs convolution operations, which are expressed by the formula: ; In the formula, is an initial electric quantity prediction value, is a weight matrix of the second layer graph convolution layer; is a bias of the second layer graph convolution layer.

7. The electricity consumption prediction method based on federated learning of fused RAG and personalized graph according to claim 6, characterized in that, The initial electricity consumption prediction value and the historical electricity consumption feature matrix are weighted and fused by a gating mechanism, which is expressed by the formula: ; ; In the formula, represents the final power prediction value of the i-th community in the i-th municipal district at the i-th time step, represents a historical power feature matrix; is a gating vector, is a gating vector corresponding weight matrix, is a gating vector corresponding bias vector.​​​ 8. A power consumption prediction system based on federated learning of fused RAG and personalized graph, characterized in that, It comprises the following modules: The framework construction and data acquisition module is used to construct a federated learning framework including a server and participants, taking the municipal districts as the participants, to acquire standardized electricity consumption data, adjacency matrices and scene feature vectors of the participants; based on the scene feature vectors, a historical electricity consumption feature matrix is obtained by using a preset RAG knowledge base; The model initialization and local training module is used to make the server generate an initial personalized electricity consumption model based on a graph neural network and distribute it to the municipal districts, and the initial personalized electricity consumption model is locally trained by using standardized electricity consumption data, adjacency matrices and historical electricity consumption feature matrices to obtain a local personalized electricity consumption model; The model aggregation module is used to make the municipal districts upload the local personalized electricity consumption model to the server, the server inputs the local personalized electricity consumption model after generating pseudo-graph data by using a random block model, obtains the functional features corresponding to each community in the municipal districts, and obtains the average functional features of the municipal districts by taking the average of the functional features; The similarity between the average functional features of any two participants is calculated, and the calculated similarity is normalized to serve as the local personalized electricity consumption model aggregation weight; Based on the local personalized electricity consumption model aggregation weight, the local personalized electricity consumption models are aggregated to obtain a final personalized electricity consumption model; The electricity consumption prediction module is used to make the server distribute the final personalized electricity consumption model to the participants for resident electricity consumption prediction.

9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the method of any one of claims 1 to 7 when executing the program. The processor implements the method of any one of claims 1 to 7 when executing the program.

Citation Information

Patent Citations

  • Electric quantity demand prediction method and system based on federal ensemble learning

    CN113139341A

  • Residential electricity consumption prediction method based on deep learning and federated learning

    CN118052331A

  • Regional electricity consumption medium and long term prediction method based on federated learning

    CN114781606A

  • Electric power spot market clearing prediction method and device, electronic equipment and storage medium

    CN120374184A

  • Personalized federal learning method suitable for edge network

    CN120448851A