Model training method, system, medium, device and product based on transverse federated learning
By negotiating random seeds to generate noisy gradients among participants in horizontal federated learning and aggregating them on the server side, the security assumptions and computational complexity issues of model gradient encryption and decryption processes in existing technologies are resolved, thereby achieving correct updates of model parameters and improving computational efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2026-03-31
AI Technical Summary
In existing horizontal federated learning, the encryption and decryption process of model gradients requires an additional decryption server, which increases security assumptions and computational complexity.
In each round of training, the participants negotiate random seeds to generate noise gradients, which are then aggregated on the server side to ensure that the sum of the noise gradients is zero, thereby updating the model parameters and avoiding the use of the decryption server.
It achieves correct aggregation of model gradients, reduces security assumptions, and lowers computational complexity, making the aggregation of noisy gradients comparable to that of plaintext gradients.
Smart Images

Figure CN120494128B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of federated learning technology, and more specifically, to a model training method, system, medium, device, and product based on horizontal federated learning. Background Technology
[0002] Horizontal Federated Learning (HFL) is a core paradigm of federated learning, designed to address the problem of multiple participants jointly training a model without sharing the original data. A key characteristic of HFL is overlapping data features but non-overlapping samples, making it suitable for collaborative modeling among different institutions within the same industry (e.g., banks, hospitals). The model training process in HFL follows the process of distributed model training. The distributed model training process is as follows... Figure 1A and Figure 1B As shown, this involves the continuous repetition of the forward propagation and backward propagation processes. Figure 1A As shown, in forward propagation, the parameter server (PS) distributes model parameters to each worker node (i.e., the participants in model training). Each worker calculates the model output value using the model parameters distributed by the parameter server and its private data. Figure 1B As shown, in backpropagation, each worker calculates the model gradient based on the output value and the label of the private data, and sends the model gradient to the parameter server. The parameter server aggregates the model gradients sent by each worker and updates the model parameters. Then, forward propagation is performed based on the updated model parameters.
[0003] The training process of lateral federated learning is basically the same as that of distributed model training, with the only difference being that during backpropagation, the model gradients sent by each worker to the parameter server need to be encrypted to prevent the parameter server from obtaining data information from the worker side from the model gradients. While encrypting the model gradients, it is also necessary to ensure that the parameter server can aggregate the data based on the encrypted model gradients. In related technologies, the PS architecture typically uses a decryption server for homomorphic encryption and decryption of model gradients. This not only adds an extra security assumption—that the parameter server cannot obtain the key held by the decryption server—but also results in higher computational complexity for homomorphic ciphertext computation compared to plaintext computation. Summary of the Invention
[0004] This summary section is provided to briefly introduce the concepts, which will be described in detail in the detailed description section below. This summary section is not intended to identify key or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0005] In a first aspect, this disclosure provides a model training method based on lateral federated learning, the method being applied to a first participant, wherein the first participant is any one of multiple participants involved in model training, the method comprising:
[0006] For each training round, a first random number is generated based on a first random seed and a second random seed. The first random seed and the second random seed are random seeds negotiated by the first participant and two first adjacent participants respectively. The two first adjacent participants are two participants adjacent to the first participant in the first ring topology formed by the multiple participants. The sum of the first random numbers generated by the multiple participants in the current training round is zero.
[0007] The first random number is used to add noise to the current gradient of the local model to obtain a noisy gradient;
[0008] The noise gradient is sent to the server, wherein the server is used to aggregate the noise gradients sent by the multiple participants respectively, update the model parameters according to the noise gradient obtained after aggregation, and synchronize the updated model parameters to the multiple participants.
[0009] The local model is updated using the updated model parameters synchronized from the server.
[0010] Secondly, this disclosure provides a model training system based on lateral federated learning, comprising:
[0011] Server; and
[0012] Multiple parties, wherein each of the multiple parties is used to perform the model training method based on lateral federated learning provided in the first aspect of this disclosure.
[0013] Thirdly, this disclosure provides a model training apparatus based on horizontal federated learning, the apparatus being applied to a first participant, wherein the first participant is any one of a plurality of participants in model training, and the apparatus includes:
[0014] The generation module is used to generate a first random number for each training round based on a first random seed and a second random seed. The first random seed and the second random seed are random seeds negotiated by the first participant and two first adjacent participants respectively. The two first adjacent participants are two participants adjacent to the first participant in the first ring topology formed by the multiple participants. The sum of the first random numbers generated by the multiple participants in the current training round is zero.
[0015] The noise-adding module is used to add noise to the current gradient of the local model using the first random number to obtain a noise gradient;
[0016] A sending module is used to send the noise gradient to a server, wherein the server is used to aggregate the noise gradients sent by the multiple participants, update the model parameters according to the aggregated noise gradients, and synchronize the updated model parameters to the multiple participants.
[0017] The update module is used to update the local model using the updated model parameters synchronized from the server.
[0018] Fourthly, this disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the model training method based on lateral federated learning provided in the first aspect of this disclosure.
[0019] Fifthly, this disclosure provides an electronic device, comprising:
[0020] A storage device on which computer programs are stored;
[0021] A processing device is configured to execute the computer program in the storage device to implement the steps of the model training method based on lateral federated learning provided in the first aspect of this disclosure.
[0022] In a sixth aspect, this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the model training method based on lateral federated learning provided in the first aspect of this disclosure.
[0023] In the above technical solution, in each training round, the first participant first generates a first random number based on a first random seed and a second random seed. The first random seed and the second random seed are random seeds negotiated by the first participant and two first adjacent participants, which are two participants adjacent to the first participant in a first circular topology formed by multiple participants. The sum of the first random numbers generated by the multiple participants in the current training round is zero. Then, the first participant uses the first random number to add noise to the current gradient of the local model to obtain a noise gradient, and sends the noise gradient to the server. The server then aggregates the noise gradients sent by the multiple participants, updates the model parameters based on the aggregated noise gradient, and synchronizes the updated model parameters to the multiple participants. The first participant uses the updated model parameters synchronized by the server to update its local model. The sum of the first random numbers generated by multiple participants in the current training round is zero, which makes the aggregated value of the noise gradients of multiple participants in the current training round equal to the aggregated value of the current gradient of the local model. In this way, the correct aggregation of the model gradient can be guaranteed while avoiding the server from obtaining the private data of each participant from the model gradient. Furthermore, no additional decryption server is required, reducing security assumptions. It also makes the computational complexity of the aggregation operation of the noise gradient comparable to that of the plaintext gradient.
[0024] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0025] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale. In the drawings:
[0026] Figure 1A and Figure 1B This is a schematic diagram illustrating a distributed model training process according to an exemplary embodiment.
[0027] Figure 2 This is a schematic diagram illustrating the homomorphic encryption and decryption of model gradients using a decryption server in related technologies.
[0028] Figure 3 This is a schematic diagram illustrating the structure of a model training system based on lateral federated learning, according to an exemplary embodiment.
[0029] Figure 4 This is a flowchart illustrating a model training method based on lateral federated learning according to an exemplary embodiment.
[0030] Figure 5 This is a schematic diagram of a first ring topology according to an exemplary embodiment.
[0031] Figure 6 This is a flowchart illustrating a model training method based on lateral federated learning according to another exemplary embodiment.
[0032] Figure 7 This is a block diagram illustrating a model training apparatus based on lateral federated learning according to an exemplary embodiment.
[0033] Figure 8 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment. Detailed Implementation
[0034] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0035] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0036] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0037] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0038] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0039] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0040] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0041] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0042] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0043] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0044] Meanwhile, it is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0045] As discussed in the background section, in related technologies, the PS architecture typically utilizes a decryption server for homomorphic encryption and decryption of model gradients to achieve secure aggregation of model gradients. Specifically, such as... Figure 2As shown, after obtaining the model gradient, each worker in the PS first homomorphically encrypts the model gradient using the public key of the decryption server, and then sends the encrypted model gradient to the parameter server. The parameter server aggregates the encrypted model gradients sent by each worker to obtain the aggregated encrypted gradient, and sends this aggregated encrypted gradient to the decryption server. The decryption server homomorphically decrypts the aggregated encrypted gradient using its private key to obtain the plaintext aggregated gradient, and sends this plaintext aggregated gradient to the parameter server. Finally, the parameter server updates the model parameters using the plaintext aggregated gradient. This not only adds an extra security assumption—that the parameter server cannot obtain the private key held by the decryption server—but also makes homomorphic ciphertext computation more computationally complex than plaintext computation.
[0046] In view of this, this disclosure provides a model training method, system, medium, device and product based on lateral federated learning.
[0047] This disclosure provides a model training system based on lateral federated learning, such as Figure 3 As shown, this model training system based on horizontal federated learning can include a server and multiple participants, such as... Figure 3 As shown, multiple participants include participant P1, participant P2, ..., participant P... n , where n is the number of participants in the model training system based on horizontal federated learning, that is, the number of multiple participants involved in model training.
[0048] like Figure 3As shown, the model training system for lateral federated learning can adopt a PS architecture, where the server acts as a parameter server and each participant acts as a worker to perform lateral federated learning. Each participant holds an initial model to be trained, i.e., a local model. During the initial model training phase, the server distributes the initial model parameters to each participant. Each participant trains its local model based on the model parameters and private sample data distributed by the server, obtains the model output value, and calculates the current gradient of the local model based on the model output value and the labels of the private sample data. Then, noise is added to the current gradient of the local model to obtain a noisy gradient, which is sent to the server. Next, the server aggregates the noisy gradients sent by multiple participants, updates the model parameters based on the aggregated noise gradient, and synchronizes the updated model parameters to multiple participants. Each participant can continue to train its local model based on the updated model parameters and private sample data distributed by the server, and so on, until the model converges. In order to ensure that the model noise can be correctly aggregated by the server, it is necessary to ensure that the aggregated value of the noise gradient is consistent with the aggregated value of the gradient before adding noise. To this end, it is necessary to ensure that the sum of the noise (i.e. the first random number in the following text) applied by each participant to the current gradient is zero.
[0049] Figure 4 This is a flowchart illustrating a model training method based on lateral federated learning according to an exemplary embodiment.
[0050] The model training method based on horizontal federated learning can be applied to the first participant, which is any one of the multiple participants involved in model training; that is, the first participant is any participant in the aforementioned model training system based on horizontal federated learning. This disclosed model training method based on horizontal federated learning is applicable to collaborative modeling between different institutions (such as banks and hospitals) within the same industry, for example, in scenarios such as financial risk control and medical research. It is also applicable to collaborative modeling between different institutions in different industries, for example, in scenarios such as cross-industry collaboration. For financial risk control scenarios, multiple banks can jointly train credit scoring models, sharing features (such as user behavior) but with different samples. For medical research scenarios, different hospitals can jointly analyze patient data (such as genetic features), with independent samples but overlapping features. For cross-industry collaboration scenarios, e-commerce platforms and logistics companies can collaborate to optimize delivery models, sharing features such as user geographic location.
[0051] like Figure 4 As shown, the model training method based on horizontal federated learning for the first participant provided in this disclosure may include the following S101 to S104.
[0052] In S101, for each training round, a first random number is generated based on the first random seed and the second random seed. The sum of the first random numbers generated by multiple participants in the current training round is zero.
[0053] In this disclosure, the first random seed and the second random seed are random seeds negotiated separately by the first participant and two first adjacent participants. The two first adjacent participants are the two participants adjacent to the first participant in the first ring topology composed of multiple participants. The ring topology consists of nodes connected in a closed loop along a fixed direction. Each node is connected to its left and right adjacent nodes, forming a point-to-point closed structure (e.g., ...). Figure 5 The first ring topology shown in the figure.
[0054] In this approach, each participant in the first ring topology can be sequentially numbered to form an index of the participant within the first ring topology. For example... Figure 3 As shown, the multiple participants in model training include participant P1, participant P2, ..., participant P... n Among them, participant P i P is the i-th participant in the first circular topology, with index i, i = 0, 1, ..., n-1. i With P (i+1)modn Negotiating a random seed i,((i+1)modn) Participant P i The two first adjacent participants include P (i+1)modn and P (i-1)modn Participant P i The first adjacent participant P (i+1)modn Negotiated random seed i,((i+1)modn) This is called the first random seed, and the participant P i The first adjacent participant P (i-1)modn Negotiated random seed (i-1)modn,i This is called the second random seed.
[0055] For example, the multiple participants in model training include participant P0, participant P1, participant P2, and participant P3, i.e., n=4. These four participants constitute... Figure 5 The first ring topology shown in the figure, wherein participant P0 and participant P1 negotiate a random seed. 0,1 Participant P1 and participant P2 negotiate a random seed. 1,2 Participant P2 and participant P3 negotiate a random seed. 2,3 Participant P3 and participant P0 negotiate a random seed. 3,0 .
[0056] For example, if the first participant is participant P2, then the two first adjacent participants of the first participant P2 include participant P1 and participant P3. Participant P2 can negotiate the first random seed with participant P3. 2,3 The first participant, P2, negotiates with participant P1 to obtain a second random seed. 1,2 .
[0057] For example, if the first participant is participant P3, then the two first adjacent participants of the first participant P3 include participant P2 and participant P0. Participant P3 can negotiate the first random seed with participant P0. 3,0 The first participant, P3, can negotiate with participant P2 for a second random seed. 2,3 .
[0058] In S102, the current gradient of the local model is denoised using the first random number to obtain a noisy gradient.
[0059] For example, a noisy gradient can be obtained by adding noise to the current gradient of the local model using the first random number and the following equation (1):
[0060]
[0061] in, For participant P i noise gradient; x i For participant P i The current gradient of the local model; mask i For participant P i The first random number generated in the current training round.
[0062] In S103, the noise gradient is sent to the server. The server aggregates the noise gradients sent by multiple participants, updates the model parameters based on the aggregated noise gradient, and synchronizes the updated model parameters to multiple participants.
[0063] In S104, the local model is updated using the updated model parameters obtained from the server synchronization.
[0064] In this disclosure, after obtaining the noise gradient, each participant can send the noise gradient to the server. After receiving the noise gradients from n participants, the server can aggregate the n noise gradients, i.e., calculate the average of the n noise gradients. Then, the server updates the model parameters based on the aggregated noise gradients and synchronizes the updated model parameters to the n participants. After receiving the updated model parameters synchronized by the server, each participant can use these updated model parameters to update its local model.
[0065] The noise gradient obtained after polymerization is If the sum of the first random numbers generated by each of the multiple participants in the current training round is zero, then... Therefore, the noise gradient obtained after aggregation That is, the aggregated value of the noise gradient of each participant in the current training round is equal to the aggregated value of the current gradient of the local model of each participant in the current training round. Thus, the correct aggregation of model gradients can be guaranteed.
[0066] In the above technical solution, in each training round, the first participant first generates a first random number based on a first random seed and a second random seed. The first random seed and the second random seed are random seeds negotiated by the first participant and two first adjacent participants, which are two participants adjacent to the first participant in a first circular topology formed by multiple participants. The sum of the first random numbers generated by the multiple participants in the current training round is zero. Then, the first participant uses the first random number to add noise to the current gradient of the local model to obtain a noise gradient, and sends the noise gradient to the server. The server then aggregates the noise gradients sent by the multiple participants, updates the model parameters based on the aggregated noise gradient, and synchronizes the updated model parameters to the multiple participants. The first participant uses the updated model parameters synchronized by the server to update its local model. The sum of the first random numbers generated by multiple participants in the current training round is zero, which makes the aggregated value of the noise gradients of multiple participants in the current training round equal to the aggregated value of the current gradient of the local model. In this way, the correct aggregation of the model gradient can be guaranteed while avoiding the server from obtaining the private data of each participant from the model gradient. Furthermore, no additional decryption server is required, reducing security assumptions. It also makes the computational complexity of the aggregation operation of the noise gradient comparable to that of the plaintext gradient.
[0067] The following is a detailed description of the specific implementation method for generating the first random number based on the first random seed and the second random seed in S101 above. Specifically, it can be achieved through the following steps (1) and (2).
[0068] Step (1): Generate a second random number based on the first random seed, and generate a third random number based on the second random seed.
[0069] Step (2): Determine the difference between the second random number and the third random number as the first random number.
[0070] In this disclosure, a second random number can be generated in multiple ways based on a first random seed, and a third random number can be generated in multiple ways based on the second random seed, wherein the second random number and the third random number are generated in the same way.
[0071] In one implementation, a second random number can be generated based solely on a first random seed, and a third random number can be generated based solely on the second random seed. Specifically, both the first and second random seeds are bit strings of length λ, and their lengths are equal. The first random seed can be input into a first pseudo-random function to obtain the second random number, and similarly, the second random seed can be input into the first pseudo-random function to obtain the third random number.
[0072] In this implementation, mask i =F(seed) i,(i+1modn) )-F(seed (i-1modn),i F(x) is the first pseudo-random function, where x is a bit string of length λ, representing the random seed. By inputting x into F(x), the corresponding random numbers can be obtained; F(seed) i,(i+1modn) ) is the second random number, F(seed) (i-1modn),i ) is the third random number.
[0073] because Therefore, it can be guaranteed that the sum of the first random numbers generated by each of the multiple participants in the current training round is zero.
[0074] In the above implementation, the first random number used for adding noise by the first participant is the same in different training rounds. This may cause the parameter server to learn the difference in the gradient of the first participant in different training rounds, and thus recover information about the original data of the first participant based on this difference. This cannot effectively prevent the server from obtaining the participant's private data from the model gradient. To effectively avoid the problem of the server obtaining the participant's private data from the model gradient, in addition to being based on the first random seed, the current training round can also be referenced when generating the second and third random numbers. Specifically, in another implementation, the second random number can be generated based on the first random seed and the current training round; simultaneously, the third random number can be generated based on the second random seed and the current training round.
[0075] Specifically, the first random seed and the current training round can be input into a preset pseudo-random function to obtain the second random number; similarly, the second random seed and the current training round can be input into a preset pseudo-random function to obtain the third random number.
[0076] In this implementation, mask i =F(seed) i,(i+1modn) ,epoch)-F(seed (i-1modn),i F(x, epoch) is a preset pseudo-random function, where x is a bit string of length λ representing the random seed, and epoch is the current training epoch. By inputting the bit string x of length λ and epoch into F(x, epoch), the corresponding random numbers can be obtained; F(seed) i,(i+1modn) ,epoch) is the second random number, F(seed) (i-1modn),i ,epoch) is the third random number.
[0077] because Therefore, it can be guaranteed that the sum of the first random numbers generated by each of the multiple participants in the current training round is zero.
[0078] In federated modeling with multiple participants, the Mini-Batch Stochastic Gradient Descent (MBDD) training method is frequently used. This involves training the model with a batch of data at a time, which accelerates convergence. Commonly used batch sizes are 128, 256, and 512. However, when there are many participants in the model training, MBDD has the following problems: Because there are numerous participants in the horizontal federated modeling (e.g., tens of thousands), even if each participant provides only one sample in each training batch, the batch size will still reach tens of thousands, which is detrimental to rapid model convergence. To ensure rapid convergence, when the number of participants exceeds a preset threshold, the participants can be grouped. Each group is responsible for one training batch in the current training epoch. When training the model for its assigned batch, each participant in that group provides only one sample. In different training epochs, if the grouping of multiple participants is fixed, the inconsistent distribution of sample data provided by different groups will lead to inconsistent data distribution in different training batches, affecting the model's convergence speed. Therefore, in different training epochs, multiple participants can be dynamically grouped to shuffle the data, ensuring that the data distribution in each batch remains as consistent as possible. This allows the model loss to decrease steadily, resulting in faster model convergence. Specifically, when the number of participants in model training exceeds a preset threshold, such as... Figure 6 As shown, prior to S101 above, the model training method based on horizontal federated learning applied to the first participant may also include the following S105 and S106.
[0079] In S105, for each training round, the first group to which the first participant belongs is determined based on the current training round, batch size, and the index of the first participant in the first ring topology.
[0080] In this disclosure, the aforementioned preset threshold can be the batch size, wherein the number of participants in model training is greater than the batch size but less than the square of the batch size. The participants are divided into K groups. `batch_size` is the batch size, and `batch_size` is a power of 2. Each training round includes K training batches. There are K groups, each corresponding to one of the K training batches. Each group is used to train the model for its corresponding training batch. Specifically, the j-th group in the K groups corresponds to the j-th training batch in the K training round. The j-th group is used to train the model for the j-th training batch in the current training round. The K groups can be sequentially numbered to form a group index, where j is the group index and j = 0, 1, 2, ..., K.
[0081] For example, if n = 10000 and batch_size = 1024, then K = 10, meaning that 10000 participants are divided into 10 groups, and one training round is divided into 10 training batches with a batch size of 1024 or higher. The 10 groups correspond one-to-one with the 10 batches, and each group is used to complete the model training for the corresponding training batch. For example, the j-th group in the 10 groups is used to complete the j-th training batch in the current training round, where j = 0, 1, 2, ..., 9.
[0082] For example, the first group to which the first participant belongs can be determined by the following equation (2) based on the current training round, batch size, and the index of the first participant in the first ring topology:
[0083]
[0084] Where i is the index of the first participant in the first ring topology.
[0085] In S106, the first random seed and the second random seed of the first training batch are negotiated with the two second adjacent participants respectively.
[0086] In this context, the first training batch refers to the training batch corresponding to the first group, and the two second adjacent participants are the two participants adjacent to the first participant in the second ring topology formed by the participants in the first group. The participants in the second ring topology can be sequentially numbered to form an index for each participant within the second ring topology.
[0087] At this time, the above S101 may include:
[0088] Based on the first random seed and the second random seed of the first training batch, a first random number for the first training batch is generated, and the sum of the first random numbers generated by each participant in the first group in the first training batch is zero.
[0089] In this disclosure, a method similar to that described above for generating the first random number based on the first random seed and the second random seed can be used to generate the first random number of the first training batch based on the first random seed and the second random seed of the first training batch. This disclosure will not elaborate further.
[0090] Since the sum of the first random numbers generated by each participant in the first group in the first training batch is zero, the aggregated value of the noise gradient of the participants in the first group in the first training batch can be equal to the aggregated value of the current gradient of the local model of the participants in the first group. In this way, the correct aggregation of the model gradient can be guaranteed while avoiding the server from obtaining the private data of each participant in the first group from the model gradient.
[0091] At this point, the server aggregates the noise gradients sent by each participant in the first group, updates the model parameters based on the aggregated noise gradients, and synchronizes the updated model parameters to each participant in the first group. Thus, after receiving the updated model parameters synchronized by the server, each participant in the first group can use these updated model parameters to update its local model.
[0092] If two participants are assigned to the same group in a certain training round, they will not be assigned to the same group in the next training batch. This allows for dynamic grouping, which shuffles the data and keeps the data distribution as consistent as possible in each batch. This results in a stable decrease in model loss and faster model convergence.
[0093] Assuming two participants, i0 and i1, are assigned to the same group in the t-th training round, then we have
[0094]
[0095] Assuming that in the (t+1)th training round, participants i0 and i1 are also assigned to the same group, then we have
[0096]
[0097] Subtracting equation (3) from equation (4) yields:
[0098] i0 modbatch_size≡(i1 modbatch_size)mod batch_size(5)
[0099] Substituting equation (5) into equation (3), we get:
[0100]
[0101] From equations (5) and (6), we can obtain i0 = i1, that is, i0 and i1 belong to the same participant, which contradicts the above statement that i0 and i1 belong to two different participants. Therefore, if two participants are assigned to the same group in a certain training round, they will not be assigned to the same group in the next training batch.
[0102] Figure 7 This is a block diagram illustrating a model training apparatus based on lateral federated learning according to an exemplary embodiment. The model training apparatus 200 based on lateral federated learning is applied to a first participant, which is any one of a plurality of participants in model training. The model training apparatus 200 based on lateral federated learning includes:
[0103] The generation module 201 is used to generate a first random number for each training round based on a first random seed and a second random seed. The first random seed and the second random seed are random seeds negotiated by the first participant and two first adjacent participants respectively. The two first adjacent participants are two participants adjacent to the first participant in the first ring topology formed by the multiple participants. The sum of the first random numbers generated by the multiple participants in the current training round is zero.
[0104] The noise-adding module 202 is used to add noise to the current gradient of the local model using the first random number to obtain a noise gradient;
[0105] The sending module 203 is used to send the noise gradient to the server, wherein the server is used to aggregate the noise gradients sent by the multiple participants respectively, update the model parameters according to the noise gradient obtained after aggregation, and synchronize the updated model parameters to the multiple participants.
[0106] The update module 204 is used to update the local model using the updated model parameters synchronized from the server.
[0107] In the above technical solution, in each training round, the first participant first generates a first random number based on a first random seed and a second random seed. The first random seed and the second random seed are random seeds negotiated by the first participant and two first adjacent participants, which are two participants adjacent to the first participant in a first circular topology formed by multiple participants. The sum of the first random numbers generated by the multiple participants in the current training round is zero. Then, the first participant uses the first random number to add noise to the current gradient of the local model to obtain a noise gradient, and sends the noise gradient to the server. The server then aggregates the noise gradients sent by the multiple participants, updates the model parameters based on the aggregated noise gradient, and synchronizes the updated model parameters to the multiple participants. The first participant uses the updated model parameters synchronized by the server to update its local model. The sum of the first random numbers generated by multiple participants in the current training round is zero, which makes the aggregated value of the noise gradients of multiple participants in the current training round equal to the aggregated value of the current gradient of the local model. In this way, the correct aggregation of the model gradient can be guaranteed while avoiding the server from obtaining the private data of each participant from the model gradient. Furthermore, no additional decryption server is required, reducing security assumptions. It also makes the computational complexity of the aggregation operation of the noise gradient comparable to that of the plaintext gradient.
[0108] Optionally, the generation module 201 includes:
[0109] A generation submodule is used to generate a second random number based on the first random seed, and to generate a third random number based on the second random seed;
[0110] A determination submodule is used to determine the difference between the second random number and the third random number as the first random number.
[0111] Optionally, the generation submodule is used to generate the second random number based on the first random seed and the current training round, and to generate the third random number based on the second random seed and the current training round.
[0112] Optionally, both the first random seed and the second random seed are bit strings;
[0113] The generation submodule is used to input the first random seed and the current training round into a preset pseudo-random function to obtain the second random number, and input the second random seed and the current training round into the preset pseudo-random function to obtain the third random number.
[0114] Optionally, when the number of the multiple participants exceeds a preset threshold, the model training device 200 based on lateral federated learning further includes:
[0115] The determination module is used to determine, for each training round, the first group to which the first participant belongs, based on the current training round, batch size, and the index of the first participant in the first ring topology, wherein the multiple participants are divided into K groups. n is the number of the multiple participants, batch_size is the batch size and is a power of 2. Each round of training includes K training batches. The K groups correspond one-to-one with the K training batches. Each group is used to complete the model training of the corresponding training batch.
[0116] The negotiation module is used to negotiate the first random seed and the second random seed of the first training batch with two second adjacent participants respectively. The first training batch is the training batch corresponding to the first group, and the two second adjacent participants are two participants adjacent to the first participant in the second ring topology formed by the participants in the first group.
[0117] The generation module 201 is used to generate a first random number for the first training batch based on a first random seed and a second random seed for the first training batch, wherein the sum of the first random numbers generated by each participant in the first group in the first training batch is zero.
[0118] The server is configured to aggregate the noise gradients sent by each participant in the first group, update the model parameters based on the aggregated noise gradients, and synchronize the updated model parameters to each participant in the first group.
[0119] Optionally, the determining module is configured to determine the first group to which the first participant belongs based on the current training round, the batch size, and the index of the first participant in the first ring topology using the following formula, including:
[0120]
[0121] Where j is the index of the first group; epoch is the current training round; and i is the index of the first participant in the first ring topology.
[0122] This disclosure also provides a model training system based on lateral federated learning, including:
[0123] Server; and
[0124] Multiple participants, wherein each of the multiple participants is used to perform the model training method based on horizontal federated learning provided in this disclosure.
[0125] This disclosure also provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the model training method based on lateral federated learning provided in this disclosure.
[0126] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the model training method based on lateral federated learning provided in this disclosure.
[0127] The following is for reference. Figure 8 The diagram illustrates a structural schematic of an electronic device (e.g., a terminal device or a server) 600 suitable for implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 8 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0128] like Figure 8 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0129] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 8An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0130] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, it performs the functions defined in the methods of embodiments of this disclosure.
[0131] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0132] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0133] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0134] The aforementioned computer-readable medium carries one or more programs. When the electronic device executes the aforementioned one or more programs, the electronic device causes the following: For each training round, it generates a first random number based on a first random seed and a second random seed, wherein the first random seed and the second random seed are random seeds negotiated by the first participant and two first adjacent participants, and the two first adjacent participants are two participants adjacent to the first participant in a first ring topology formed by the plurality of participants, and the sum of the first random numbers generated by the plurality of participants in the current training round is zero; it adds noise to the current gradient of the local model using the first random number to obtain a noise gradient; it sends the noise gradient to a server, wherein the server is used to aggregate the noise gradients sent by the plurality of participants, update the model parameters based on the aggregated noise gradient, and synchronize the updated model parameters to the plurality of participants; and it updates the local model using the updated model parameters synchronized by the server.
[0135] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0136] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0137] The modules described in the embodiments of this disclosure can be implemented in software or in hardware. The names of the modules are not necessarily limiting in certain circumstances; for example, a noise-adding module can also be described as "a module that adds noise to the current gradient of the local model using the first random number to obtain a noise gradient."
[0138] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0139] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0140] According to one or more embodiments of this disclosure, Example 1 provides a model training method based on lateral federated learning, the method being applied to a first participant, wherein the first participant is any one of a plurality of participants in model training, the method comprising:
[0141] For each training round, a first random number is generated based on a first random seed and a second random seed. The first random seed and the second random seed are random seeds negotiated by the first participant and two first adjacent participants respectively. The two first adjacent participants are two participants adjacent to the first participant in the first ring topology formed by the multiple participants. The sum of the first random numbers generated by the multiple participants in the current training round is zero.
[0142] The first random number is used to add noise to the current gradient of the local model to obtain a noisy gradient;
[0143] The noise gradient is sent to the server, wherein the server is used to aggregate the noise gradients sent by the multiple participants respectively, update the model parameters according to the noise gradient obtained after aggregation, and synchronize the updated model parameters to the multiple participants.
[0144] The local model is updated using the updated model parameters synchronized from the server.
[0145] According to one or more embodiments of this disclosure, Example 2 provides the method of Example 1, wherein generating a first random number based on a first random seed and a second random seed includes:
[0146] Based on the first random seed, generate a second random number, and based on the second random seed, generate a third random number;
[0147] The difference between the second random number and the third random number is determined as the first random number.
[0148] According to one or more embodiments of this disclosure, Example 3 provides the method of Example 2, wherein generating a second random number based on the first random seed includes:
[0149] Generate the second random number based on the first random seed and the current training round;
[0150] The step of generating a third random number based on the second random seed includes:
[0151] The third random number is generated based on the second random seed and the current training round.
[0152] According to one or more embodiments of this disclosure, Example 4 provides the method of Example 3, wherein both the first random seed and the second random seed are bit strings;
[0153] The step of generating the second random number based on the first random seed and the current training round includes:
[0154] The first random seed and the current training round are input into a preset pseudo-random function to obtain the second random number;
[0155] The step of generating the third random number based on the second random seed and the current training round includes:
[0156] The second random seed and the current training round are input into the preset pseudo-random function to obtain the third random number.
[0157] According to one or more embodiments of this disclosure, Example 5 provides a method of any one of Examples 1-4, wherein when the number of the plurality of participants is greater than a preset threshold, the method further includes:
[0158] For each training round, based on the current training round, batch size, and the index of the first participant in the first ring topology, the first group to which the first participant belongs is determined, wherein the multiple participants are divided into K groups. n is the number of the multiple participants, batch_size is the batch size and is a power of 2. Each round of training includes K training batches. The K groups correspond one-to-one with the K training batches. Each group is used to complete the model training of the corresponding training batch.
[0159] The first random seed and the second random seed of the first training batch are negotiated with the two second adjacent participants respectively. The first training batch is the training batch corresponding to the first group. The two second adjacent participants are the two participants adjacent to the first participant in the second ring topology formed by the participants in the first group.
[0160] The step of generating a first random number based on a first random seed and a second random seed includes:
[0161] Based on the first random seed and the second random seed of the first training batch, a first random number for the first training batch is generated, wherein the sum of the first random numbers generated by each participant in the first group in the first training batch is zero.
[0162] The server is configured to aggregate the noise gradients sent by each participant in the first group, update the model parameters based on the aggregated noise gradients, and synchronize the updated model parameters to each participant in the first group.
[0163] According to one or more embodiments of this disclosure, Example 6 provides the method of Example 5, wherein determining the first group to which the first participant belongs based on the current training round, batch size, and the index of the first participant in the first ring topology includes:
[0164] Based on the current training round, the batch size, and the index of the first participant in the first ring topology, the first group to which the first participant belongs is determined using the following formula:
[0165]
[0166] Where j is the index of the first group; epoch is the current training round; and i is the index of the first participant in the first ring topology.
[0167] According to one or more embodiments of this disclosure, Example 7 provides a model training system based on lateral federated learning, comprising:
[0168] Server; and
[0169] Multiple participants, wherein each of the multiple participants is used to perform the model training method based on lateral federated learning as described in any one of Examples 1-6.
[0170] According to one or more embodiments of the present disclosure, Example 8 provides a computer-readable medium having a computer program stored thereon that, when executed by a processing device, implements the steps of the method described in any one of Examples 1-6.
[0171] According to one or more embodiments of this disclosure, Example 9 provides an electronic device, including:
[0172] A storage device on which computer programs are stored;
[0173] A processing device for executing the computer program in the storage device to implement the steps of any one of the methods in Examples 1-6.
[0174] According to one or more embodiments of the present disclosure, Example 10 provides a computer program product including a computer program that, when executed by a processor, implements the steps of the method described in any one of Examples 1-6.
[0175] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0176] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0177] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative forms of implementing the claims. Regarding the apparatus in the above embodiments, the specific manner in which the various modules perform their operations has been described in detail in the embodiments relating to the method, and will not be elaborated upon here.
Claims
1. A model training method based on transverse federated learning, characterized in that, The method is applied to a first participant, wherein the first participant is any one of a plurality of participants participating in model training, and the method comprises: For each round of training, a first random number is generated according to a first random seed and a second random seed, wherein the first random seed and the second random seed are random seeds negotiated by the first participant with two first adjacent participants respectively, the two first adjacent participants are two participants adjacent to the first participant in a first ring topology formed by the plurality of participants, and the sum of the first random numbers generated by the plurality of participants at the current training round is zero; The current gradient of the local model is subjected to noise processing using the first random number to obtain a noise gradient; The noise gradient is sent to a server, wherein the server is configured to aggregate the noise gradients sent by the plurality of participants respectively, update model parameters according to the aggregated noise gradient, and synchronize the updated model parameters to the plurality of participants; The local model is updated using the updated model parameters synchronized by the server; The first random number is generated according to the first random seed and the second random seed, comprising: A second random number is generated according to the first random seed, and a third random number is generated according to the second random seed; The difference between the second random number and the third random number is determined as the first random number; The second random number is generated according to the first random seed and the current training round, comprising: The second random number is generated according to the first random seed and the current training round; The third random number is generated according to the second random seed and the current training round. The first random seed and the second random seed are both bit strings; 2. The method of claim 1, wherein, The second random number is generated according to the first random seed and the current training round, comprising: The first random seed and the current training round are input into a preset pseudo-random function to obtain the second random number; The third random number is generated according to the second random seed and the current training round, comprising: The second random seed and the current training round are input into the preset pseudo-random function to obtain the third random number. When the number of the plurality of participants is greater than a preset threshold, the method further comprises:
3. The method according to any one of claims 1-2, characterized in that, The first random seed and the second random seed of the first training batch are negotiated with two second adjacent participants respectively, wherein the first training batch is a training batch corresponding to the first group, and the two second adjacent participants are two participants adjacent to the first participant in a second ring topology formed by the participants in the first group; For each training round, based on the current training round, batch size, and the index of the first participant in the first ring topology, the first group to which the first participant belongs is determined, wherein the plurality of participants are divided into K Groups, , n The number of the aforementioned multiple participating parties. For the batch size, and The power of 2, each round of training includes K Each training batch, the K The group and the above K Each training batch corresponds one-to-one, and each group is used to complete the model training for the corresponding training batch. The first random number is generated according to the first random seed and the second random seed, comprising: The first random number of the first training batch is generated according to the first random seed of the first training batch and the second random seed of the first training batch, wherein the sum of the first random numbers generated by each participant in the first group at the first training batch is zero; The server is configured to aggregate the noise gradients respectively sent by each participant in the first group, update the model parameters according to the aggregated noise gradients, and synchronize the updated model parameters to each participant in the first group.
4. The method of claim 3, wherein, The first group in which the first participant is located is determined according to the current training round, the batch size, and the index of the first participant in the first ring topology, and includes: The first group in which the first participant is located is determined according to the current training round, the batch size, and the index of the first participant in the first ring topology, and includes: wherein, j is an index of the first group; is the current training round; is an index of the first participant in the first ring topology. 5.A model training system based on transverse federated learning, characterized in that, The first group in which the first participant is located is determined according to the current training round, the batch size, and the index of the first participant in the first ring topology, and includes: A server; And A plurality of participants, wherein each participant in the plurality of participants is configured to perform the model training method based on the horizontal federated learning according to any one of claims 1-4.
6. A computer readable medium having stored thereon a computer program, characterized in that, The computer program is executed by the processing device to implement the steps of the method according to any one of claims 1-4.
7. An electronic device, comprising: The computer program is executed by the processing device to implement the steps of the method according to any one of claims 1-4. A storage device having stored thereon a computer program; The processing device is configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1-4.
8. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processing device to implement the steps of the method according to any one of claims 1-4.
Citation Information
Patent Citations
Classification model training method and device, electronic equipment and storage medium
CN112529101A
Federal learning-based model training method and device
CN116957103A