A Model Determination Method and Apparatus Based on Federated Learning and Differential Privacy

By pruning model gradients and adaptively allocating privacy budgets in federated learning, and combining this with smart contracts to manage privacy budgets and contributions, the problem of accuracy degradation in differential privacy within federated learning is solved, achieving higher model accuracy and secure collaboration.

CN123117261APending Publication Date: 2026-11-17STATE GRID BEIJING ELECTRIC POWER CO +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611528058.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-29
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In federated learning, differential privacy cannot allocate the privacy budget reasonably, leading to a decrease in model accuracy and an inability to effectively defend against advanced privacy inference attacks.

Method used

By acquiring a power feature dataset, a global model is trained, the model gradient is pruned, and differential privacy noise is added based on an adaptive privacy budget to generate a target gradient. Smart contracts are used for privacy budget management and contribution calculation to achieve weighted aggregation.

Benefits of technology

While protecting user data privacy, the model's prediction accuracy has been improved, advanced privacy attacks have been resisted, and fairness and accuracy in model training have been achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123117261A_ABST
    Figure CN123117261A_ABST
Patent Text Reader

Abstract

This invention discloses a model determination method and apparatus based on federated learning and differential privacy, relating to the field of electronic information technology. The method includes: acquiring a power feature dataset and training a global model based on the power feature data to obtain the model gradient for the current training round; pruning the model gradient to obtain a pruned model gradient; calculating the privacy budget consumed in training the global model and adding differential privacy noise to the pruned model gradient based on the privacy budget to obtain a target gradient; and uploading the target gradient to an aggregation server to obtain the target global model for the current training round. The target global model is generated by the aggregation server through weighted aggregation of all target gradients based on the amount of data. This invention solves the technical problem in related technologies where uneven allocation of privacy budget during model training leads to decreased model accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electronic information technology, and more specifically, to a model determination method and apparatus based on federated learning and differential privacy. Background Technology

[0002] With the advancement of dual-carbon goals and the construction of new power systems, the form of the power system is undergoing profound changes. The integration of distributed energy resources, energy storage systems, electric vehicles, and various flexible loads is constantly expanding the operational boundaries of the power system, and data sources are becoming increasingly multi-source, heterogeneous, massive, and high-frequency. Smart meters, data acquisition and monitoring control systems, phasor measurement units, distribution automation terminals, and various Internet of Things sensors generate operational data daily. This data is not only the foundation for the safe and stable operation of the power grid, but also a production factor for advanced applications such as load forecasting, renewable energy output forecasting, equipment condition-based maintenance, and electricity market trading.

[0003] Federated learning, as a distributed machine learning paradigm where the data remains stationary while the model moves, provides a technical path for the secure collaboration of power data. However, in practical applications, relying solely on federated learning is insufficient to defend against advanced privacy inference attacks such as model inversion attacks, gradient leakage attacks, and membership inference attacks. Differential privacy can provide privacy guarantees by adding noise to model parameters or gradients, but while ensuring model convergence accuracy, it cannot reasonably allocate the privacy budget, resulting in excessive noise and leading to low model accuracy or even model failure.

[0004] There is currently no effective solution to the above problems. Summary of the Invention

[0005] This invention provides a model determination method and apparatus based on federated learning and differential privacy, which at least solves the technical problem in related technologies where uneven allocation of privacy budget during model training leads to a decrease in model accuracy.

[0006] According to one aspect of the embodiments of this application, a model determination method based on federated learning and differential privacy is provided, comprising: acquiring an electricity feature dataset, and training a global model based on the electricity feature data to obtain the model gradient of the current training round, wherein the global model is a model obtained by an aggregation server aggregating the models of multiple model training participants in the previous training round; pruning the model gradient to obtain the pruned model gradient; calculating the privacy budget consumed in training the global model, and adding differential privacy noise to the pruned model gradient based on the privacy budget to obtain the target gradient; and uploading the target gradient to the aggregation server to obtain the target global model of the current training round, wherein the target global model is generated by the aggregation server by weighted aggregation of all target gradients based on the data volume, the data volume being the number of samples in the electricity feature dataset used by each model training participant to train the global model.

[0007] Further, the step of obtaining the power feature dataset includes: obtaining a power data sequence within a preset time window, wherein the power data sequence includes: multiple power data samples; performing anomaly detection on the multiple power data samples to obtain normal power data samples and abnormal power data samples; performing interpolation processing on the abnormal power data samples to obtain target power data samples; and performing feature processing on the normal power data samples and target power data samples to obtain the power feature dataset.

[0008] Further, the steps of performing anomaly detection on multiple power data samples to obtain normal power data samples and abnormal power data samples include: calculating the mean of all power data samples and calculating the standard deviation based on the mean; calculating the absolute value of the difference between each power data sample and the mean; constructing an anomaly threshold coefficient and calculating the product between the anomaly threshold coefficient and the standard deviation; determining the power data sample as a normal power data sample when the absolute value of the difference is less than or equal to the product; and determining the power data sample as an abnormal power data sample when the absolute value of the difference is greater than the product.

[0009] Furthermore, the step of calculating the privacy budget consumed in training the global model includes: for each training round, calculating the weight factor of the training round based on the preset decay coefficient, the preset total number of training rounds, and the number of training rounds, and calculating the sum of the weight factors of all training rounds; for the current training round, calculating the privacy budget consumed in training the global model based on the total privacy budget, the weight factor corresponding to the current training round, and the sum of the weight factors.

[0010] Furthermore, after uploading the target gradient to the aggregation server, the process also includes: triggering a first function in the smart contract to accumulate the privacy budget corresponding to each model training participant with the historical cumulative privacy budget to obtain a cumulative privacy budget, and comparing the cumulative privacy budget with the total privacy budget to obtain a comparison result; if the comparison result indicates that the cumulative privacy budget is less than or equal to the total privacy budget, triggering an aggregation event, wherein the aggregation event is used to instruct the aggregation server to generate the target global model.

[0011] Furthermore, after triggering the aggregation event, the process also includes: triggering a second function in the smart contract to calculate the contribution of each model training participant to the global model; and after calculating the contribution, triggering the training permission in the smart contract, wherein the training permission is used to instruct each model training participant to perform the next round of model training.

[0012] Furthermore, the step of calculating the contribution of each model training participant to the global model includes: constructing a participant set based on all model training participants; performing random sampling a preset number of times in the participant set to obtain multiple participant subsets corresponding to the preset number of times; for each model training participant, calculating the model utility increment generated after the model training participant is added to each participant subset, and calculating the mean of all model utility increments; and determining the mean as the contribution of the model training participant to the global model.

[0013] According to another aspect of the embodiments of this application, a model determination apparatus based on federated learning and differential privacy is also provided, comprising: a training unit, configured to acquire an electricity feature dataset and train a global model based on the electricity feature data to obtain the model gradient of the current training round, wherein the global model is a model obtained by an aggregation server aggregating the models of multiple model training participants in the previous training round; a pruning unit, configured to prune the model gradient to obtain the pruned model gradient; an adding unit, configured to calculate the privacy budget consumed in training the global model and add differential privacy noise to the pruned model gradient based on the privacy budget to obtain the target gradient; and an uploading unit, configured to upload the target gradient to the aggregation server to obtain the target global model of the current training round, wherein the target global model is generated by the aggregation server by weighted aggregation of all target gradients based on the data volume, the data volume being the number of samples in the electricity feature dataset used by each model training participant to train the global model.

[0014] Furthermore, the training unit includes: a first acquisition module for acquiring a power data sequence within a preset time window, wherein the power data sequence includes multiple power data samples; a first detection module for performing anomaly detection on the multiple power data samples to obtain normal power data samples and abnormal power data samples; a first processing module for performing interpolation processing on the abnormal power data samples to obtain target power data samples; and a second processing module for performing feature processing on the normal power data samples and the target power data samples to obtain a power feature dataset.

[0015] Furthermore, the first detection module includes: a first calculation submodule, used to calculate the mean of all power data samples and calculate the standard deviation based on the mean; a second calculation submodule, used to calculate the absolute value of the difference between each power data sample and the mean; a third calculation submodule, used to construct an anomaly threshold coefficient and calculate the product between the anomaly threshold coefficient and the standard deviation; a first determination submodule, used to determine the power data sample as a normal power data sample when the absolute value of the difference is less than or equal to the product; and a second determination submodule, used to determine the power data sample as an abnormal power data sample when the absolute value of the difference is greater than the product.

[0016] Furthermore, the added unit includes: a first calculation module, used to calculate the weight factor of each training round based on a preset decay coefficient, a preset total number of training rounds, and the number of training rounds, and to calculate the sum of the weight factors of all training rounds; and a second calculation module, used to calculate the privacy budget consumed in training the global model for the current training round based on the total privacy budget, the weight factor corresponding to the current training round, and the sum of the weight factors.

[0017] Furthermore, the model determination device based on federated learning and differential privacy includes: a first triggering module, used to trigger a first function in the smart contract after the target gradient is uploaded to the aggregation server, to accumulate the privacy budget corresponding to each model training participant with the historical cumulative privacy budget to obtain a cumulative privacy budget, and to compare the cumulative privacy budget with the total privacy budget to obtain a comparison result; a second triggering module, used to trigger an aggregation event when the comparison result indicates that the cumulative privacy budget is less than or equal to the total privacy budget, wherein the aggregation event is used to instruct the aggregation server to generate the target global model.

[0018] Furthermore, the model determination device based on federated learning and differential privacy also includes: a third triggering module, used to trigger a second function in the smart contract after triggering an aggregation event, so as to use the second function to calculate the contribution of each model training participant to the global model; and a fourth triggering module, used to trigger the training permission in the smart contract after calculating the contribution, wherein the training permission is used to instruct each model training participant to perform the next round of model training.

[0019] Furthermore, the third triggering module includes: a first construction submodule, used to construct a participant set based on all model training participants; a first sampling submodule, used to perform a preset number of random samplings in the participant set to obtain multiple participant subsets corresponding to the preset number of samplings; a fourth calculation submodule, used to calculate the model utility increment generated after each model training participant is added to each participant subset, and to calculate the mean of all model utility increments; and a third determination submodule, used to determine the mean as the contribution of the model training participants to the global model.

[0020] According to another aspect of the embodiments of this application, a computer program product is also provided, including a non-volatile computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements any of the above-described model determination methods based on federated learning and differential privacy.

[0021] According to another aspect of the embodiments of this application, an electronic device is also provided, including one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement any of the above-described model determination methods based on federated learning and differential privacy.

[0022] In this invention, an electricity feature dataset is acquired, and a global model is trained based on the electricity feature data to obtain the model gradient for the current training round. The global model is obtained by an aggregation server aggregating the models from multiple training participants in the previous training round. The model gradient is then pruned to obtain the pruned model gradient. The privacy budget consumed in training the global model is calculated, and differential privacy noise is added to the pruned model gradient based on the privacy budget to obtain the target gradient. The target gradient is then uploaded to the aggregation server to obtain the target global model for the current training round. The target global model is generated by the aggregation server through weighted aggregation of all target gradients based on the amount of data, where the amount of data is the number of samples in the electricity feature dataset used by each training participant to train the global model. This solves the technical problem in related technologies where uneven allocation of privacy budget during model training leads to decreased model accuracy.

[0023] In this invention, firstly, an electricity feature dataset is acquired, and based on this dataset, a global model obtained by weighted aggregation of models from multiple training participants in the previous training round is trained locally to obtain the model gradient for the current training round. Subsequently, the model gradient is pruned to limit its sensitivity, resulting in a pruned model gradient. Then, the privacy budget consumed in the current training round is calculated, and noise parameters are dynamically determined based on this privacy budget. Differential privacy noise is added to the pruned model gradient to generate the target gradient. The target gradient is then uploaded to the aggregation server, which uses the number of samples in the electricity feature dataset used by each training participant as weights to perform weighted aggregation of all received target gradients, thereby generating the target global model for the current training round. Through the above training mechanism based on adaptive privacy budget allocation and weighted aggregation, the technical problem of decreased model training accuracy caused by uneven privacy budget allocation in related technologies is solved, thereby improving the model prediction accuracy. Attached Figure Description

[0024] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:

[0025] Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a model determination method based on federated learning and differential privacy is shown.

[0026] Figure 2 This is a flowchart of a model determination method based on federated learning and differential privacy according to Embodiment 1 of this application;

[0027] Figure 3 This is a schematic diagram of a model determination device based on federated learning and differential privacy according to an embodiment of this application;

[0028] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation

[0029] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0031] It should be noted that all relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, and displayed data) collected and involved in this invention are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data comply with the relevant laws, regulations, and standards of the relevant regions, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse. For example, this system has an interface with relevant users or organizations. Before obtaining relevant information, a request to obtain the information needs to be sent to the aforementioned user or organization through the interface. After receiving consent from the aforementioned user or organization, the relevant information is obtained. If the user chooses to refuse, the process enters the expert decision-making process.

[0032] Centralized data sharing models pose privacy risks. Current power data sharing models require the aggregation of raw data from various parties to a central node for joint modeling or analysis, inevitably exposing sensitive user-side privacy information. Although data anonymization and desensitization techniques are widely used, research shows that under multidimensional correlation analysis, desensitized data still faces the risk of re-identification attacks. Once attackers combine publicly available social networks, geographic information, and other multi-source data for cross-comparison, they can re-identify sensitive information of specific users or devices, leading to serious privacy breaches. In this invention, by introducing gradient pruning and adaptive privacy budget allocation mechanisms, the problem of significant model accuracy degradation due to noise accumulation in differential privacy during federated learning is overcome. The adaptive allocation strategy can allocate more privacy budget in the early stages of training when gradient information is abundant to accelerate convergence, and reduce ineffective budget consumption in the later stages when the model tends to stabilize. Thus, with the same total privacy budget, a higher model accuracy than uniform allocation is obtained. Furthermore, by constructing a decentralized trusted sharing and automated execution environment, the sharing protocol, contribution calculation, and access control logic are solidified in smart contracts, eliminating dependence on centralized intermediaries. The immutable records and automated execution logic on the blockchain ensure that data is shared according to the agreement and distributed according to work done, effectively preventing data abuse and unequal distribution of benefits. This technological trust mechanism reduces the communication costs of cross-entity collaboration.

[0033] The present invention will now be described in detail with reference to various embodiments.

[0034] Example 1

[0035] According to an embodiment of this application, an embodiment of a model determination method based on federated learning and differential privacy is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0036] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or mobile device) for implementing a model determination method based on federated learning and differential privacy is shown. Figure 1 As shown, computer terminal 10 (or mobile device) may include one or more ( Figure 1The processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions may also be included. In addition, it may include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera, wherein the network interface can be connected to wired and / or wireless networks. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0037] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0038] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the model determination method based on federated learning and differential privacy in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the aforementioned model determination method based on federated learning and differential privacy. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0039] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0040] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).

[0041] Under the aforementioned operating environment, this application provides the following: Figure 2 The model determination method shown is based on federated learning and differential privacy. Figure 2 This is a flowchart of the model determination method based on federated learning and differential privacy according to Embodiment 1 of this application, as follows: Figure 2 As shown, the method includes the following steps:

[0042] Step S201: Obtain the power feature dataset and train the global model based on the power feature data to obtain the model gradient of the current training round. The global model is obtained by aggregating the models of multiple model training participants in the previous training round through the aggregation server.

[0043] In this embodiment of the invention, the power feature dataset is a collection of power feature data that has undergone preprocessing (e.g., anomaly detection, imputation, standardization, and time alignment). The global model is a set of model parameters maintained by the aggregation server and aggregated in the previous round of federated learning; it serves as the starting point or benchmark for the current training round. Model training participants are nodes that hold local power data and participate in federated learning. The model gradient is the derivative of the loss function with respect to the model parameters, calculated by the model training participants after they have locally trained the global model using their own data. The gradient represents the direction and magnitude in which the parameters need to be adjusted to make the model more accurate.

[0044] In this embodiment of the invention, the model training participant i first loads the global model parameters obtained from the previous round of aggregation into its local machine. In the current round of federated learning, the model training participant i utilizes the local power feature dataset. and global model parameters The backpropagation algorithm is executed to calculate the update direction of the model parameters in the current round, i.e., the model gradient. By utilizing the unique information of local data to optimize the model, while ensuring that the original data does not leave the domain, and sharing knowledge indirectly only through gradient information, privacy protection is achieved by keeping the data still while the model moves.

[0045] Step S202: Clip the model gradient to obtain the clipped model gradient.

[0046] In this embodiment of the invention, in order to prevent the gradient from leaking too much sensitive information, it is also necessary to control the model gradient. Pruning is performed, and the gradient of the pruned model is obtained. The calculation is as follows: ,in, The preset gradient clipping threshold, For the L2 norm of the gradient, this operation restricts the sensitivity of the gradient to 0. Within.

[0047] Step S203: Calculate the privacy budget consumed in training the global model, and based on the privacy budget, add differential privacy noise to the pruned model gradient to obtain the target gradient.

[0048] In this embodiment of the invention, Gaussian noise is added before gradient uploading, and the gradient after adding noise (i.e., the target gradient) is: ,in, This indicates that the mean is 0 and the covariance matrix is... Gaussian distribution; As the noise multiplier, its magnitude directly determines the trade-off between the strength of privacy protection and the utility of the model; Let be the identity matrix, and c be the preset gradient clipping threshold. According to the Gaussian mechanism theorem, when At that time, a single gradient update satisfies - Differential privacy, where It is the privacy budget for computation, and δ is the failure probability parameter, which is a non-negative real number that allows the algorithm to violate differential privacy with a very small probability.

[0049] Step S204: Upload the target gradient to the aggregation server to obtain the target global model for the current training round. The target global model is generated by the aggregation server through weighted aggregation of all target gradients based on the amount of data. The amount of data is the number of samples in the power feature dataset used by each model training participant to train the global model.

[0050] In this embodiment of the invention, the model training participants send their target gradients and their own data volume (sample count) to the aggregation server. After collecting the target gradients of all participants, the aggregation server calculates the weight coefficients based on the data volume of each participant (i.e., the data volume of that participant). ) accounts for the total sample size (i.e. Then, all objective gradients are weighted and summed according to their respective weights to update the global model parameters. This generates a new target global model, where... is the global learning rate; N is the number of participants in the model training; The local sample size of participant i; This is the total sample size (i.e., the total amount of data from all participants).

[0051] In summary, by acquiring an electricity feature dataset and training the model locally based on a global model to obtain model gradients, the gradients are pruned to limit sensitivity. Differential privacy noise is added to the pruned gradients according to an adaptively allocated privacy budget to obtain the target gradient. This target gradient is then uploaded to an aggregation server, which performs weighted aggregation of all target gradients based on the number of samples in each participant's local electricity feature dataset to generate the target global model. This achieves iterative updates of the federated learning model while protecting user data privacy. The gradient pruning and adaptive privacy budget allocation mechanism overcomes the problem of decreased model accuracy due to noise accumulation in differential privacy models, improving model accuracy under the same total privacy budget. Weighted aggregation based on sample size ensures that participants with larger datasets contribute more to the global model, achieving fairness and accuracy in model updates. The injection of differential privacy noise resists advanced privacy attacks such as model inversion, achieving secure collaboration where the model moves while the data remains stationary. This solves the technical problem of uneven privacy budget allocation during model training, which leads to decreased model accuracy in related technologies.

[0052] To accurately obtain the power feature dataset, the model determination method based on federated learning and differential privacy provided in Embodiment 1 of this application obtains a power data sequence within a preset time window. The power data sequence includes: multiple power data samples; anomaly detection is performed on the multiple power data samples to obtain normal power data samples and abnormal power data samples; interpolation processing is performed on the abnormal power data samples to obtain target power data samples; feature processing is performed on the normal power data samples and target power samples to obtain the power feature dataset.

[0053] In this embodiment of the invention, a sliding window-based statistical test method is used to identify outliers in smart meter and sensor data that are commonly caused by communication failures or equipment malfunctions. A preset time window can be set first. The power data sequence of the i-th participant is collected within the preset time window. , where n is the number of sampling points, the power data sequence includes: multiple power data samples (i.e. It can also perform anomaly detection on multiple power data samples to obtain normal power data samples and abnormal power data samples. Then, it can perform interpolation processing on the abnormal power data samples to obtain the target power data sample, effectively removing extreme noise while preserving the true fluctuation characteristics of the data.

[0054] Because the power equipment dimensions and sampling frequencies of different participants vary, standardization is necessary to obtain a unified power feature dataset. We can define the original feature vector of any data point in the power data sequence as v, and the standardized feature vector as... Z-Score standardization can be used: ,in, Let v be the mean of feature v; Var(v) is the local variance of feature v; For a minimal constant (e.g.) (), used to prevent numerical instability caused by a denominator of zero.

[0055] In addition, a global time base can be set to address the timestamp alignment issue of multi-source data. Each participating party needs to map its local data to a unified time grid. Let the local sampling time be... The time after alignment is Mapping function The constraint of minimizing time deviation must be met: The constraints are ,in, For the j-th local sampling time, It is a time alignment mapping function (aligning any local time to a global time base). It is the j-th standard time on the global time grid. This is the maximum allowable time synchronization error. The standardized process described above ensures that all parties involved in the federated learning process train the model within the same feature space.

[0056] To accurately identify abnormal power data samples, the model determination method based on federated learning and differential privacy provided in Embodiment 1 of this application calculates the mean of all power data samples and calculates the standard deviation based on the mean; calculates the absolute value of the difference between each power data sample and the mean; constructs an anomaly threshold coefficient and calculates the product between the anomaly threshold coefficient and the standard deviation; if the absolute value of the difference is less than or equal to the product, the power data sample is determined as a normal power data sample; if the absolute value of the difference is greater than the product, the power data sample is determined as an abnormal power data sample.

[0057] In this embodiment of the invention, the mean and standard deviation of the power data sequence can be calculated, respectively. and For any data point in this power data sequence If the following conditions are met: If the difference is greater than the product, the power data sample is identified as an outlier and interpolation is performed. This is a preset abnormal threshold coefficient, typically ranging from 2.5 to 3.0.

[0058] Optionally, for data points identified as anomalous, interpolation can be performed using linear interpolation of adjacent valid values ​​or the median within the window to ensure the continuity of the time series.

[0059] To accurately calculate the privacy budget, in the model determination method based on federated learning and differential privacy provided in Embodiment 1 of this application, for each training round, the weight factor of the training round is calculated based on the preset decay coefficient, the preset total number of training rounds, and the number of training rounds, and the sum of the weight factors of all training rounds is calculated; for the current training round, the privacy budget consumed in training the global model is calculated based on the total privacy budget, the weight factor corresponding to the current training round, and the sum of the weight factors.

[0060] In this embodiment of the invention, the total privacy budget is set to... An adaptive allocation strategy can be used to allocate privacy budgets to each participant. In the early stages of training, when the model has abundant gradient information and convergence is fast, a larger budget is allocated to accelerate convergence. Later, as the model stabilizes, the budget allocation is gradually reduced. Specifically, for each training round, a preset decay coefficient can be used... Preset total number of training rounds And the number of training rounds t, calculate the weight factor for the training rounds. And calculate the sum of the weight factors for all training rounds. For the current training round, based on the total privacy budget The weight factor corresponding to the current training round and the sum of weighting factors Calculate the privacy budget consumed in training the global model. .

[0061] To accurately trigger the aggregation event, in the model determination method based on federated learning and differential privacy provided in Embodiment 1 of this application, a first function in the smart contract is triggered to accumulate the privacy budget corresponding to each model training participant with the historical cumulative privacy budget to obtain a cumulative privacy budget. The cumulative privacy budget is then compared with the total privacy budget to obtain a comparison result. If the comparison result indicates that the cumulative privacy budget is less than or equal to the total privacy budget, an aggregation event is triggered. The aggregation event is used to instruct the aggregation server to generate the target global model.

[0062] Optionally, to address trust and execution issues during the sharing process, the federated learning protocol and value assessment rules can be encoded into smart contracts and deployed on a consortium blockchain to automate the execution and ensure immutable recording of the sharing process. For example, consider a power data sharing protocol as a quintuple. ,in: For the gathering of participants; For data sharing relationship matrix, express Agree to Provide data gradients; Metadata for federated learning models (structure, accuracy requirements); Mapping to the value assessment function; This refers to the access control policy.

[0063] The smart contract FL_Sharing_Contract can include the following core state variables and functions: `mapping(address=>uint)privacyBudgetSpent`: records the privacy budget consumed by each participant; `mapping(address=>uint)contributionScore`: records the contribution score of each participant; `function submitGradient(bytes calldata gradient,uint epsilonUsed)`: this function is called when a participant submits a gradient (i.e., the first function). This function is used to verify that the sum of historical cumulative consumption and the participant's current submission does not exceed the total budget. Where k represents the participating party. Let the gradient submitted by the k-th participant be... The cumulative privacy budget is calculated based on historical data. If the verification is successful (i.e., the cumulative privacy budget is calculated based on historical data), the cumulative privacy budget will be calculated based on historical data. Less than or equal to the total privacy budget If the aggregate event is triggered, the privacyBudgetSpent (i.e., the cumulative budget consumption) will be updated.

[0064] In order to accurately calculate the contribution, in the model determination method based on federated learning and differential privacy provided in Embodiment 1 of this application, a second function in the smart contract is triggered to calculate the contribution of each model training participant to the global model. After the contribution is calculated, the training permission in the smart contract is triggered, wherein the training permission is used to instruct each model training participant to perform the next round of model training.

[0065] In this embodiment of the invention, the smart contract may also include the following function evaluateAndDistribute(), also known as the second function, which is called after each round of aggregation. This function can calculate the contribution of each party according to a preset value evaluation model, and then release the training permission for the next round.

[0066] Alternatively, the valuation model can be a contribution calculation model based on Shapley values: ,in, For the gathering of participants, For the model utility function, , This indicates that the set S is traversed for all subsets S that do not contain participant i. This indicates that participant i has joined the participant alliance. The resulting increase in model utility can be the increase in the accuracy of the global model on the test set, etc.

[0067] To improve the accuracy of contribution calculation, in the model determination method based on federated learning and differential privacy provided in Embodiment 1 of this application, a participant set is constructed based on all model training participants; random sampling is performed on the participant set a preset number of times to obtain multiple participant subsets corresponding to the preset number of times; for each model training participant, the model utility increment generated after the model training participant is added to each participant subset is calculated, and the mean of all model utility increments is calculated; the mean is determined as the contribution of the model training participant to the global model.

[0068] In this embodiment of the invention, a participant set is constructed based on all model training participants. Since the complexity of accurately calculating the Shapley value is exponential, Monte Carlo sampling can be used to approximate the calculation of the Shapley value. ,in, For the number of samples, For distribution according to Shapley weights (and The formula represents the proportional random sampling of participant subsets (i.e., random sampling is performed a preset number of times within the participant set to obtain multiple participant subsets corresponding to the preset number of samplings). This formula indicates that for each model training participant i, the incremental model utility generated after the model training participant is added to each participant subset is calculated. The algorithm calculates the mean of the utility increments of all models. This means that for each sampling, a subset of participants is obtained, and each time participant i is added to the subset, the accuracy increment of the model is calculated. Finally, the average value is calculated, and this average is used to determine the contribution of each participant in the model training to the global model. This approximate formula, while ensuring computational efficiency, converges to the true Shapley value with a high probability, providing a mathematical basis for value allocation.

[0069] In this embodiment of the invention, a comprehensive evaluation model covering data quality, privacy protection strength, model contribution and compliance risk can also be constructed to realize dynamic value quantification and tiered pricing of the power data assets of each participant.

[0070] First, construct the indicator evaluation vector sequence. Among them, the indicator evaluation vector (Data Quality): Consists of completeness (number of valid records / number of expected records), accuracy (percentage of outliers), and timeliness (corresponding to...). , , Weighted composition, , , , These are the weights corresponding to completeness, accuracy, and timeliness; the indicator evaluation vector. (Privacy protection strength): Inversely proportional to privacy budget expenditure. , For privacy sensitivity, It represents the cumulative budget consumption of a certain participant i; the indicator evaluation vector. (Model contribution): This refers to the normalized result of the aforementioned Shapley values. ( ); Indicator evaluation vector (Compliance and Risk): Compliance scoring based on data classification and usage scenarios, with values ​​ranging from [0,1]. Considering the varying sensitivities of different application scenarios to various indicators, a dynamic weight calculation combining entropy weighting and AHP (Analytic Hierarchy Process) can be used. Let the weight vector for the k-th scenario be... Then, the comprehensive value score of data asset i in scenario k is... for: Where j=1,…,4, Let be the evaluation vector of the j-th indicator of data asset i in scenario k. The time decay factor, The attenuation rate, This represents the time difference since the data was generated. Based on the overall value score. Data assets can be divided into four levels: core level ( High-value, highly sensitive information, for internal or authorized core business use only; Importance level ( High-value, moderately sensitive, can be shared across domains but requires strict auditing; General level ( ): Medium value, open and shareable; Low value ( ): Low value or high noise, only for archiving or free access. This classification result is directly written into the smart contract as the basis for automatic execution of access control and pricing.

[0071] It can also provide regulators and stakeholders with full lifecycle audit traceability capabilities: metadata standards (such as DCAT (Data Catalog Vocabulary)) can be used to describe power data assets and asset catalog entries. for: The ID is used to uniquely identify the data asset instance; the Meta records descriptive information such as the source, type, and granularity of the data, which facilitates data discovery and retrieval. The data fingerprint ensures its integrity and immutability during sharing; the ValueScore is a real-time calculated comprehensive value score reflecting the economic utility of the data in a specific scenario; the AccessPolicy sets access permissions and control logic, linked to blockchain smart contracts to achieve automated permission verification; the Timestamp records the latest update time of asset information, supporting audit traceability throughout the entire lifecycle. This entry E is written to the consortium blockchain along with the transaction record during data registration, value updates, or access authorization, forming an immutable data asset ledger.

[0072] Each data sharing or model aggregation operation generates an on-chain transaction. : ,in, For on-chain hashing, For transaction number, The sender (the sender can be a participant or an aggregation server, depending on who sends the data to whom; for example, if the aggregation server distributes the global model to the participants, then the aggregation server is the sender). The recipient (the recipient can also be a participant or an aggregation server). For operation type, These correspond to gradient upload operation, model aggregation operation, access authorization operation, and value assessment operation, respectively. The privacy budget consumed in this operation, This represents the change in value rating. Digital signatures for participating parties.

[0073] Alternatively, anomalies can be detected by verifying the integrity of the on-chain transaction sequence, assuming the transaction sequence within the audit window is... Define the privacy budget conservation check function: ,in, The remaining budget recorded for the contract; The allowed floating-point error threshold; This refers to the budget expenditure of a specific participant within the audit window. If... If this occurs, an audit alert will be triggered, indicating a possible budget overrun or record tampering. Simultaneously, by incorporating the monotonicity constraint of value assessment (value should not suddenly drop without cause under normal circumstances), an anomaly detection model is constructed to achieve reliable auditing of the entire data circulation lifecycle.

[0074] Alternatively, in addition to the Gaussian mechanism, the Laplace mechanism or a local differential privacy scheme can be used, or it can be combined with homomorphic encryption or secure multi-party computation technologies. Regarding the smart contract platform, it can be replaced by hardware components based on a trusted execution environment, a privacy computing platform based on zero-knowledge proofs, or a distributed identity system based on permissioned blockchain technology. Regarding value assessment methods, the dynamic weight calculation combining entropy weighting and AHP can be replaced by fuzzy comprehensive evaluation methods or regression prediction models based on machine learning; the approximate calculation of the Shapley value can also be achieved by alternative algorithms such as the SHAP value. Regarding data standardization methods, Z-Score standardization and sliding window anomaly detection can be replaced by deep learning-based autoencoder anomaly detection or multi-scale feature extraction methods based on wavelet transform. The above alternatives do not constitute a limitation on the scope of protection of this invention.

[0075] The model determination method based on federated learning and differential privacy provided in this application can obtain a high-quality power feature dataset by performing anomaly detection and interpolation processing on power data sequences within a preset time window using sliding window statistical tests, and by performing feature processing using standardization and time alignment. Based on this, weight factors are calculated according to preset attenuation coefficients, the total number of training epochs, and the current epoch. Then, the privacy budget for the current epoch is dynamically allocated according to the total privacy budget, adding Gaussian noise that meets differential privacy requirements to the gradients of each model training participant. Subsequently, a verification function in the smart contract is triggered, accumulating the current and historical privacy budgets and comparing them with the total budget. If the budget is not exceeded, an aggregation event is triggered, and the aggregation server weights and aggregates the target gradients according to the data volume of each participant to generate the target global model. Through the above process, high-quality input of multi-source heterogeneous power data after cleaning and standardization is achieved. Adaptive privacy budget allocation accelerates convergence in the early stage of training and protects accuracy in the later stage. The automatic execution of privacy budget verification and model aggregation through smart contracts eliminates the risk of human intervention, ensures the compliant use of privacy budget and the reliable execution of model updates in the federated learning process, and ultimately improves the prediction accuracy of the global model and the security of system operation while protecting data privacy.

[0076] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0077] The present invention will now be described in further detail with reference to another specific embodiment.

[0078] For example, a provincial power company built a load forecasting federated learning and data value assessment system. The participants are configured as follows: Participant A is the provincial power dispatch center, providing SCADA (Supervisory Control and Data Acquisition) system operation data and PMU phasor measurement data, with approximately 5 million data entries per day; Participant B is a municipal power supply company, providing load data from 5 million smart meters within its jurisdiction, collected every 15 minutes, with approximately 480 million data entries per day; Participant C is a third-party load forecasting service provider, providing the forecasting model architecture and evaluation requirements as a model user. The aggregation server is deployed by the provincial power company in a dedicated network environment, and the monitoring node is accessed by the energy regulatory department, possessing read-only audit permissions. All participants are interconnected through a consortium blockchain network, and the consensus mechanism adopts the PBFT (Practical Byzantine Fault Tolerance) algorithm to ensure the finality and consistency of transaction confirmation.

[0079] Participant B deploys 5 million smart meters, collecting data every 15 minutes, generating 96 sampling points daily. The raw data undergoes sliding window anomaly detection processing; the window size... Hour (96 sampling points), anomaly threshold coefficient Statistics show that the daily anomaly rate is approximately 0.3% to 0.5%, mainly due to communication interruptions and meter malfunctions, all of which are compensated for by linear interpolation of adjacent valid values. After standardization, the feature dimensions are expanded from the original 32 dimensions to 128 dimensions (including historical load, temperature, humidity, day type, holiday markings, etc.), using Z-Score standardization. Global time base Using UTC full quarter-hour clocks, the maximum time synchronization error is minimized. Seconds. Participant A's SCADA data sampling frequency is 1 second / time, and its PMU data sampling frequency is 30 times / second. After resampling and alignment to a 15-minute granularity, the data is consistent with Participant B's data in the time dimension.

[0080] An LSTM load forecasting model is used, with approximately 500,000 parameters. (Total number of communication rounds in federated learning.) Rounds, global learning rate Gradient clipping threshold Noise multiplier Total privacy budget , According to the Gaussian mechanism theorem, ,satisfy - Differential privacy requirements.

[0081] The sharing protocol is deployed on the Hyperledger Fabric consortium blockchain, with 3 participants ( The smart contract FL_Sharing_Contract checks the cumulative privacy budget consumption during each gradient submission round, and the cumulative consumption over 200 training rounds. No budget overrun occurred. Shapley values ​​were calculated using Monte Carlo sampling, with the number of samples... The Shapley value for participant A (the scheduling center) was calculated. Shapley value of participant B (power supply company) Shapley value of participant C (prediction service provider) It is evident that the power company's load data contributes the most to the model performance, consistent with its data volume proportion. The contract automatically updates the contributionScore of each party based on the Shapley value, serving as the basis for subsequent value allocation. Throughout the training process, the contract automatically performed 200 gradient submission verifications, 200 aggregation triggers, and 200 contribution evaluations, requiring no manual intervention.

[0082] In load forecasting scenarios, the weight vector is determined by combining the entropy weight method with AHP. These correspond to data quality, privacy protection strength, model contribution, and compliance risk, respectively. The comprehensive value score of participant B's smart meter data was calculated. It belongs to the importance level ( (This can be shared across domains but requires strict auditing.) Time decay factor. ,in / day means that the value of data from 7 days ago decays to 93.2%, and data from 30 days ago decays to 74.1%, reflecting the timeliness characteristic that the fresher the power load data, the more valuable it is. Participant A's SCADA data has a comprehensive value score of 0.812, which is considered core level and can only be used internally or for authorized core business purposes.

[0083] A standardized power data asset catalog was constructed, adopting the DCAT metadata standard. Each data asset entry... Includes a unique ID, metadata, data fingerprint hash (SHA256 algorithm), real-time value score (ValueScore), access policy, and timestamp. The audit window is set to 7 days, and the privacy budget conservation threshold is used. During the 200 rounds of federated learning, the audit module verified a total of 200 gradient upload transactions and 200 model aggregation transactions. All transactions... All values ​​were less than 0.01, and no audit alarms were triggered, verifying the integrity and consistency of the privacy budget consumption. Meanwhile, the monotonicity test of the value assessment did not detect any abnormal drops, and all transaction records were verified through digital signatures, achieving trusted auditing and compliance traceability throughout the entire data circulation lifecycle. Regulatory nodes can query the on-chain data asset catalog and circulation audit records in real time through a read-only interface, meeting compliance audit requirements.

[0084] Through the system deployment and operation of this embodiment, joint training of cross-domain load forecasting models was successfully achieved without disclosing any original data, thus improving the model's prediction accuracy. The data asset catalog records data asset entries, providing a scientific basis for subsequent data asset inclusion and market transactions. The on-chain audit module records circulation transactions, achieving transparent auditing and compliance supervision across the entire chain.

[0085] Example 2

[0086] This application also provides a model determination apparatus based on federated learning and differential privacy. It should be noted that this apparatus can be used to execute the model determination method based on federated learning and differential privacy provided in this application. The following describes the model determination apparatus based on federated learning and differential privacy provided in this application.

[0087] According to an embodiment of this application, an apparatus for implementing the above-described model determination method based on federated learning and differential privacy is also provided. Figure 3 This is a schematic diagram of a model determination device based on federated learning and differential privacy according to an embodiment of this application, as shown below. Figure 3 As shown, the model determination device based on federated learning and differential privacy may include: a training unit 30, a pruning unit 31, an adding unit 32, and an uploading unit 33.

[0088] Among them, the training unit 30 is used to acquire the power feature dataset and train the global model based on the power feature data to obtain the model gradient of the current training round. The global model is obtained by the aggregation server aggregating the models of multiple model training participants in the previous training round.

[0089] The trimming unit 31 is used to trim the model gradient to obtain the trimmed model gradient.

[0090] Add unit 32 to calculate the privacy budget consumed in training the global model, and add differential privacy noise to the pruned model gradient based on the privacy budget to obtain the target gradient;

[0091] Upload unit 33 is used to upload the target gradient to the aggregation server to obtain the target global model of the current training round. The target global model is generated by the aggregation server by weighting and aggregating all target gradients according to the amount of data. The amount of data is the number of samples in the power feature dataset used by each model training participant to train the global model.

[0092] The model determination device based on federated learning and differential privacy provided in this application embodiment can acquire an electricity feature dataset through the training unit 30, and train a global model based on the electricity feature data to obtain the model gradient of the current training round. The model gradient can be clipped by the clipping unit 31 to obtain the clipped model gradient. The privacy budget consumed by training the global model can be calculated by the adding unit 32, and differential privacy noise can be added to the clipped model gradient based on the privacy budget to obtain the target gradient. The target gradient can be uploaded to the aggregation server by the uploading unit 33 to obtain the target global model of the current training round.

[0093] Optionally, the training unit 30 includes: a first acquisition module for acquiring a power data sequence within a preset time window, wherein the power data sequence includes: multiple power data samples; a first detection module for performing anomaly detection on the multiple power data samples to obtain normal power data samples and abnormal power data samples; a first processing module for performing interpolation processing on the abnormal power data samples to obtain target power data samples; and a second processing module for performing feature processing on the normal power data samples and the target power data samples to obtain a power feature dataset.

[0094] Optionally, the first detection module includes: a first calculation submodule for calculating the mean of all power data samples and calculating the standard deviation based on the mean; a second calculation submodule for calculating the absolute value of the difference between each power data sample and the mean; a third calculation submodule for constructing an anomaly threshold coefficient and calculating the product between the anomaly threshold coefficient and the standard deviation; a first determination submodule for determining the power data sample as a normal power data sample when the absolute value of the difference is less than or equal to the product; and a second determination submodule for determining the power data sample as an abnormal power data sample when the absolute value of the difference is greater than the product.

[0095] Optionally, the added unit 32 includes: a first calculation module, used to calculate the weight factor of each training round based on a preset decay coefficient, a preset total number of training rounds, and the number of training rounds, and to calculate the sum of the weight factors of all training rounds; and a second calculation module, used to calculate the privacy budget consumed in training the global model for the current training round based on the total privacy budget, the weight factor corresponding to the current training round, and the sum of the weight factors.

[0096] Optionally, the model determination device based on federated learning and differential privacy includes: a first triggering module, used to trigger a first function in the smart contract after the target gradient is uploaded to the aggregation server, to accumulate the privacy budget corresponding to each model training participant with the historical cumulative privacy budget to obtain a cumulative privacy budget, and to compare the cumulative privacy budget with the total privacy budget to obtain a comparison result; a second triggering module, used to trigger an aggregation event when the comparison result indicates that the cumulative privacy budget is less than or equal to the total privacy budget, wherein the aggregation event is used to instruct the aggregation server to generate the target global model.

[0097] Optionally, the model determination device based on federated learning and differential privacy further includes: a third triggering module, used to trigger a second function in the smart contract after triggering an aggregation event, so as to use the second function to calculate the contribution of each model training participant to the global model; and a fourth triggering module, used to trigger the training permission in the smart contract after calculating the contribution, wherein the training permission is used to instruct each model training participant to perform the next round of model training.

[0098] Optionally, the third triggering module includes: a first construction submodule, used to construct a participant set based on all model training participants; a first sampling submodule, used to perform random sampling a preset number of times in the participant set to obtain multiple participant subsets corresponding to the preset number of times; a fourth calculation submodule, used to calculate the model utility increment generated after the model training participant is added to each participant subset for each model training participant, and to calculate the mean of all model utility increments; and a third determination submodule, used to determine the mean as the contribution of the model training participant to the global model.

[0099] The aforementioned model determination device based on federated learning and differential privacy may also include a processor and a memory. The training unit 30, pruning unit 31, adding unit 32, uploading unit 33, etc., are all stored in the memory as program units, and the processor executes the aforementioned program units stored in the memory to realize the corresponding functions.

[0100] The aforementioned processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and by adjusting kernel parameters, the target gradient is uploaded to the aggregation server to obtain the target global model for the current training round. The target global model is generated by the aggregation server through a weighted aggregation of all target gradients based on the amount of data, where the amount of data is the number of samples in the power feature dataset used by each model training participant to train the global model.

[0101] The aforementioned memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0102] It should be noted that the training unit 30, cropping unit 31, adding unit 32, and uploading unit 33 mentioned above correspond to steps S201 to S204 in Embodiment 1. The instances and application scenarios implemented by the above units and corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above units can also be part of a device and run in the computer terminal 10 provided in Embodiment 1.

[0103] Example 3

[0104] Embodiments of this application may provide a computer terminal, which may be any computer terminal device in a group of computer terminals. Optionally, in this embodiment, the aforementioned computer terminal may also be replaced with a mobile terminal or an electronic device, etc.

[0105] Optionally, in this embodiment, the computer terminal may be located in at least one of a plurality of network devices in a computer network.

[0106] In this embodiment, the aforementioned computer terminal can execute the following steps in the model determination method based on federated learning and differential privacy: acquiring an electricity feature dataset, and training a global model based on the electricity feature data to obtain the model gradient for the current training round, wherein the global model is obtained by the aggregation server aggregating the models of multiple model training participants in the previous training round; pruning the model gradient to obtain the pruned model gradient; calculating the privacy budget consumed in training the global model, and adding differential privacy noise to the pruned model gradient based on the privacy budget to obtain the target gradient; uploading the target gradient to the aggregation server to obtain the target global model for the current training round, wherein the target global model is generated by the aggregation server by weighted aggregation of all target gradients based on the data volume, where the data volume is the number of samples in the electricity feature dataset used by each model training participant to train the global model.

[0107] Optionally, the aforementioned computer terminal can execute program code for the following steps in the model determination method based on federated learning and differential privacy: acquiring a power data sequence within a preset time window, wherein the power data sequence includes: multiple power data samples; performing anomaly detection on the multiple power data samples to obtain normal power data samples and abnormal power data samples; performing interpolation processing on the abnormal power data samples to obtain target power data samples; and performing feature processing on the normal power data samples and target power data samples to obtain a power feature dataset.

[0108] Optionally, the aforementioned computer terminal can execute program code for the following steps in the model determination method based on federated learning and differential privacy: calculating the mean of all power data samples and calculating the standard deviation based on the mean; calculating the absolute value of the difference between each power data sample and the mean; constructing an anomaly threshold coefficient and calculating the product between the anomaly threshold coefficient and the standard deviation; determining the power data sample as a normal power data sample if the absolute value of the difference is less than or equal to the product; and determining the power data sample as an abnormal power data sample if the absolute value of the difference is greater than the product.

[0109] Optionally, the aforementioned computer terminal can execute program code for the following steps in the model determination method based on federated learning and differential privacy: for each training round, calculate the weight factor of the training round based on the preset decay coefficient, the preset total number of training rounds, and the number of training rounds, and calculate the sum of the weight factors of all training rounds; for the current training round, calculate the privacy budget consumed in training the global model based on the total privacy budget, the weight factor corresponding to the current training round, and the sum of the weight factors.

[0110] Optionally, the aforementioned computer terminal can execute program code for the following steps in the model determination method based on federated learning and differential privacy: triggering a first function in the smart contract to accumulate the privacy budget corresponding to each model training participant with the historical cumulative privacy budget to obtain a cumulative privacy budget, and comparing the cumulative privacy budget with the total privacy budget to obtain a comparison result; if the comparison result indicates that the cumulative privacy budget is less than or equal to the total privacy budget, triggering an aggregation event, wherein the aggregation event is used to instruct the aggregation server to generate the target global model.

[0111] Optionally, the aforementioned computer terminal can execute program code for the following steps in the model determination method based on federated learning and differential privacy: triggering a second function in the smart contract to calculate the contribution of each model training participant to the global model; after calculating the contribution, triggering training permission in the smart contract, wherein the training permission is used to instruct each model training participant to perform the next round of model training.

[0112] Optionally, the aforementioned computer terminal can execute program code for the following steps in the model determination method based on federated learning and differential privacy: constructing a participant set based on all model training participants; performing a preset number of random samplings in the participant set to obtain multiple participant subsets corresponding to the preset number of samplings; for each model training participant, calculating the model utility increment generated after the model training participant is added to each participant subset, and calculating the mean of all model utility increments; determining the mean as the contribution of the model training participant to the global model.

[0113] Optionally, Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 4 As shown, the electronic device may include: one or more ( Figure 4 (Only one is shown) Processor 402, memory 404, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.

[0114] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the model determination method and apparatus based on federated learning and differential privacy in this application embodiment. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby realizing the aforementioned model determination method based on federated learning and differential privacy. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0115] The processor can access the information and application programs stored in the memory via the transmission device to execute the steps described above in the model determination method based on federated learning and differential privacy.

[0116] This application provides a model determination scheme based on federated learning and differential privacy. By introducing gradient pruning and adaptive privacy budget allocation mechanisms, it overcomes the problem of severe model accuracy degradation caused by noise accumulation in federated learning, a common issue with differential privacy. This adaptive allocation strategy allocates more privacy budget to accelerate convergence when gradient information is abundant in the early stages of training, and reduces ineffective budget consumption as the model stabilizes in the later stages. Thus, with the same total privacy budget, it achieves higher model accuracy than uniform allocation. The sharing protocol, contribution calculation, and access control logic are embedded in a smart contract, eliminating dependence on centralized intermediaries. The immutable on-chain records and automatic execution logic ensure sharing according to the contract and distribution according to contribution, effectively preventing data abuse and uneven distribution of benefits. This solves the technical problem of uneven privacy budget allocation during model training, which leads to decreased model accuracy in related technologies.

[0117] Those skilled in the art will understand that Figure 4 The structure shown is for illustrative purposes only. Electronic devices can also be terminal devices such as smartphones, tablets, PDAs, and mobile internet devices (MIDs). Figure 4 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 4 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 4 The different configurations shown.

[0118] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0119] Example 4

[0120] Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the model determination method based on federated learning and differential privacy provided in Embodiment 1.

[0121] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.

[0122] This application also provides a computer program product that, when executed on a data processing device, is suitable for performing steps of a model determination method based on federated learning and differential privacy.

[0123] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0124] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0125] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0126] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0127] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0128] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0129] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A model determination method based on federated learning and differential privacy, characterized in that, include: Obtain the power feature dataset, and train the global model based on the power feature data to obtain the model gradient of the current training round. The global model is obtained by the aggregation server aggregating the models of multiple model training participants in the previous training round. The model gradient is clipped to obtain the clipped model gradient; Calculate the privacy budget consumed in training the global model, and based on the privacy budget, add differential privacy noise to the pruned model gradient to obtain the target gradient; The target gradient is uploaded to the aggregation server to obtain the target global model for the current training round. The target global model is generated by the aggregation server by weighting and aggregating all the target gradients based on the amount of data. The amount of data is the number of samples in the power feature dataset used by each model training participant to train the global model.

2. The model determination method based on federated learning and differential privacy according to claim 1, characterized in that, The steps to obtain a power characteristic dataset include: Obtain a power data sequence within a preset time window, wherein the power data sequence includes: multiple power data samples; Anomaly detection is performed on the multiple power data samples to obtain normal power data samples and abnormal power data samples. The abnormal power data sample is interpolated to obtain the target power data sample; The normal power data sample and the target power data sample are subjected to feature processing to obtain the power feature dataset.

3. The model determination method based on federated learning and differential privacy according to claim 2, characterized in that, The steps of performing anomaly detection on the multiple power data samples to obtain normal power data samples and abnormal power data samples include: Calculate the mean of all the power data samples, and calculate the standard deviation based on the mean; Calculate the absolute value of the difference between each of the power data samples and the mean; Construct an anomaly threshold coefficient and calculate the product between the anomaly threshold coefficient and the standard deviation; If the absolute value of the difference is less than or equal to the product, the power data sample is determined to be the normal power data sample. If the absolute value of the difference is greater than the product, the power data sample is identified as the abnormal power data sample.

4. The model determination method based on federated learning and differential privacy according to claim 1, characterized in that, The steps for calculating the privacy budget consumed in training the global model include: For each training round, the weight factor of the training round is calculated based on the preset decay coefficient, the preset total number of training rounds, and the number of training rounds, and the sum of the weight factors of all training rounds is calculated. For the current training round, the privacy budget consumed in training the global model is calculated based on the total privacy budget, the weight factor corresponding to the current training round, and the sum of the weight factors.

5. The model determination method based on federated learning and differential privacy according to claim 1, characterized in that, After uploading the target gradient to the aggregation server, the process also includes: The first function in the smart contract is triggered to accumulate the privacy budget corresponding to each model training participant with the historical cumulative privacy budget to obtain the cumulative privacy budget, and the cumulative privacy budget is compared with the total privacy budget to obtain the comparison result. If the comparison result indicates that the cumulative privacy budget is less than or equal to the total privacy budget, an aggregation event is triggered, wherein the aggregation event is used to instruct the aggregation server to generate the target global model.

6. The model determination method based on federated learning and differential privacy according to claim 5, characterized in that, After the aggregation event is triggered, it also includes: Trigger a second function in the smart contract to calculate the contribution of each model training participant to the global model. After calculating the contribution, the training permission in the smart contract is triggered, wherein the training permission is used to instruct each participant in the model training to perform the next round of model training.

7. The model determination method based on federated learning and differential privacy according to claim 6, characterized in that, The step of calculating the contribution of each participant in the model training to the global model includes: Train participants based on all the described models, and construct a participant set; Random sampling is performed a preset number of times on the set of participants to obtain multiple subsets of participants corresponding to the preset number of times; For each of the model training participants, calculate the model utility increment generated after the model training participant joins each subset of participants, and calculate the mean of all model utility increments; The mean is determined as the contribution of the model training participants to the global model.

8. A model determination device based on federated learning and differential privacy, characterized in that, include: The training unit is used to acquire the power feature dataset and train the global model based on the power feature data to obtain the model gradient of the current training round. The global model is obtained by the aggregation server aggregating the models of multiple model training participants in the previous training round. A clipping unit is used to clip the model gradient to obtain the clipped model gradient; An additional unit is added to calculate the privacy budget consumed in training the global model, and based on the privacy budget, differential privacy noise is added to the pruned model gradient to obtain the target gradient. An upload unit is used to upload the target gradient to the aggregation server to obtain the target global model of the current training round. The target global model is generated by the aggregation server through weighted aggregation of all the target gradients based on the amount of data. The amount of data is the number of samples in the power feature dataset used by each model training participant to train the global model.

9. A computer program product, characterized in that, The method includes a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the model determination method based on federated learning and differential privacy as described in any one of claims 1 to 7.

10. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the model determination method based on federated learning and differential privacy as described in any one of claims 1 to 7.