Vertical federated learning system optimization method, device and readable storage medium
By sampling and encrypting sample data in vertical federated learning, and generating and completing intermediate results, the problem of high encryption and communication costs in vertical federated learning is solved, and more efficient model training is achieved.
Patent Information
- Application Number
- CN202010089045.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-02-12
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2040-02-12
AI Technical Summary
Vertical federated learning requires frequent encryption and exchange of a large number of intermediate results during the model training process, resulting in high encryption and communication costs and increased modeling time.
By sampling and processing sample data between participating devices, a streamlined intermediate result is generated, and data is completed after encrypting it, so that the amount of data in the encrypted and completed intermediate result is the same as the original intermediate result, thereby reducing the need for encryption and communication. data volume, reduces encryption and communication costs, and shortens modeling time.
It effectively reduces the encryption and communication costs during the vertical federated learning training process, significantly shortens the modeling time, and improves the training efficiency.
Smart Images

Figure CN111340247B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine learning technology, and in particular to a method, device and readable storage medium for optimizing a vertical federated learning system. Background Art
[0002] With the development of artificial intelligence, people have proposed the concept of "federated learning" to solve the problem of data silos. This allows both parties in the federation to train models and obtain model parameters without providing their own data, and can avoid the problem of data privacy leakage.
[0003] Vertical federated learning is to take out the users and data of the same participants but different user data features to jointly train the machine learning model when the data features of the participants overlap less but the users overlap more. For example, there are two participants A and B in the same region, where participant A is a bank and participant B is an e-commerce platform. Participants A and B have many of the same users in the same region, but A and B have different businesses and the recorded user data features are different. In particular, the user data features recorded by A and B may be complementary. In such a scenario, vertical federated learning can be used to help A and B build a joint machine learning prediction model to help A and B provide better services to their customers.
[0004] During the modeling process of vertical federated learning, participants interact in encrypted form to calculate intermediate results of gradients and loss functions. Each round of model training requires encryption and exchange of each data in the intermediate results. The number of intermediate results is the same as the number of data owned by the participants. Therefore, the amount of encrypted and interacted data is large, and the encryption and communication costs are high, which also increases the vertical federated modeling time. Summary of the invention
[0005] The main purpose of the present invention is to provide a method, device, equipment and readable storage medium for optimizing a vertical federated learning system, aiming to reduce the encryption and communication costs in the vertical federated learning training process and shorten the modeling time.
[0006] To achieve the above object, the present invention provides a method for optimizing a vertical federated learning system, which is applied to a first device participating in vertical federated learning, wherein the first device is communicatively connected to a second device, and the method for optimizing a vertical federated learning system comprises the following steps:
[0007] Receiving the encrypted and simplified intermediate result of the second device sent by the second device, wherein the second device is used to perform sampling processing on the original intermediate result corresponding to each piece of sample data of the second device obtained by calculation, to obtain the simplified intermediate result corresponding to part of the sample data of the second device, and to encrypt the simplified intermediate result of the second device, to obtain the encrypted and simplified intermediate result of the second device;
[0008] Performing data padding on the encrypted simplified intermediate result of the second device to obtain an encrypted padded intermediate result of the second device, wherein the amount of data in the encrypted padded intermediate result is the same as the amount of data in the original intermediate result;
[0009] The encrypted first gradient value corresponding to the model parameter in the first device is calculated using the encrypted completion intermediate result of the second device, and the model parameter of the first device is updated based on the encrypted first gradient value. The loop is iterated until it is detected that the preset stop condition is met, and the target model parameters of the first device after training are obtained.
[0010] Optionally, the step of performing data padding on the encrypted simplified intermediate result of the second device to obtain the encrypted padded intermediate result includes:
[0011] Obtaining a sampling comparison table of the second device, and determining padding data and a padding position corresponding to the padding data in the encrypted simplified intermediate result of the second device based on the sampling comparison table of the second device;
[0012] In the encrypted simplified intermediate result of the second device, the padding data is inserted based on the padding position to obtain the encrypted completed intermediate result of the second device.
[0013] Optionally, the step of calculating the encrypted first gradient value corresponding to the model parameter in the first device by using the encrypted and padded intermediate result of the second device includes:
[0014] Calculate and obtain an encrypted simplified intermediate result of the first device used to calculate the gradient value;
[0015] Using the encrypted completed intermediate result of the second device and the encrypted simplified intermediate result of the first device, calculate and obtain the encrypted intermediate result of the first device;
[0016] The encrypted intermediate result of the first device is used to calculate the encrypted first gradient value corresponding to the model parameter in the first device.
[0017] Optionally, the step of calculating and obtaining an encrypted and simplified intermediate result of the first device for calculating the gradient value includes:
[0018] The first device performs sampling processing on the original intermediate results corresponding to each piece of sample data of the first device obtained by calculation, so as to obtain a simplified intermediate result corresponding to part of the sample data of the first device;
[0019] The simplified intermediate result of the first device is encrypted to obtain an encrypted simplified intermediate result of the first device.
[0020] Optionally, the step of calculating the encrypted intermediate result of the first device by using the encrypted completed intermediate result of the second device and the encrypted simplified intermediate result of the first device includes:
[0021] Performing data padding on the encrypted simplified intermediate result of the first device to obtain the encrypted padded intermediate result of the first device;
[0022] The encrypted intermediate result of the first device is calculated using the encrypted padded intermediate result of the first device and the encrypted intermediate result of the second device.
[0023] To achieve the above object, the present invention further provides a method for optimizing a vertical federated learning system, which is applied to a second device participating in vertical federated learning. The method for optimizing a vertical federated learning system comprises the following steps:
[0024] Performing sampling processing on the original intermediate results corresponding to each piece of sample data of the second device obtained by calculation, to obtain a simplified intermediate result corresponding to part of the sample data of the second device;
[0025] Encrypting the simplified intermediate result of the second device, obtaining the simplified intermediate result corresponding to part of the sample data of the second device and sending it to the first device, so that the first device can feed back the encrypted intermediate result of the first device based on the encrypted simplified intermediate result of the second device, wherein the first device is used to perform data padding on the received encrypted simplified intermediate result of the second device to obtain the encrypted padded intermediate result of the second device, and calculate the encrypted intermediate result of the first device using the encrypted padded intermediate result of the second device;
[0026] The encrypted intermediate result of the first device is used to calculate the encrypted second gradient value corresponding to the model parameter in the second device, and the model parameter of the second device is updated based on the encrypted second gradient value. The loop is iterated until it is detected that the preset stop condition is met, and the target model parameter of the second device after training is obtained.
[0027] Optionally, the step of performing sampling processing on the original intermediate results corresponding to each piece of sample data of the second device obtained by calculation to obtain a simplified intermediate result corresponding to part of the sample data of the second device includes:
[0028] Using the model parameters of the second device, weighted summation is performed on each piece of sample data of the second device to calculate and obtain an original intermediate result of the second device;
[0029] Splitting the original intermediate result of the second device based on the threshold to obtain a first sub-original intermediate result and a second sub-original intermediate result, wherein each data in the first sub-original intermediate result is less than or equal to the threshold, and each data in the second sub-original intermediate result is greater than the threshold;
[0030] Grouping all data of the first sub-original intermediate result, and determining representative data of each group, and forming a third sub-original intermediate result with the representative data of each group;
[0031] A reduced intermediate result of the second device is obtained based on the third sub-original intermediate result and the second sub-original intermediate result.
[0032] To achieve the above-mentioned objectives, the present invention also provides a vertical federated learning system optimization device, which includes: a memory, a processor, and a vertical federated learning system optimization program stored in the memory and executable on the processor, and the vertical federated learning system optimization program, when executed by the processor, implements the steps of the vertical federated learning system optimization method as described above.
[0033] In addition, to achieve the above-mentioned purpose, the present invention also proposes a readable storage medium, on which a vertical federated learning system optimization program is stored. When the vertical federated learning system optimization program is executed by a processor, the steps of the vertical federated learning system optimization method as described above are implemented.
[0034] In the present invention, the encrypted simplified intermediate result of the second device sent by the second device is received, wherein the second device performs sampling processing on the original intermediate result corresponding to each sample data of the second device obtained by calculation, obtains the simplified intermediate result corresponding to part of the sample data of the second device, and encrypts the simplified intermediate result of the second device to obtain the encrypted simplified intermediate result of the second device, and then performs data padding on the encrypted simplified intermediate result of the second device to obtain the encrypted padded intermediate result of the second device, wherein the number of data in the encrypted padded intermediate result is the same as the number of data in the original intermediate result, and then the encrypted first gradient value corresponding to the model parameter in the first device is calculated using the encrypted padded intermediate result of the second device, and the model parameter of the first device is updated based on the encrypted first gradient value, and iterates until it is detected that the preset stop condition is met, and the target model parameter of the first device after training is obtained. By reducing the number of data contained in the intermediate results corresponding to the participating devices, the amount of data that needs to be encrypted and communicated is reduced, the encryption and communication costs are reduced, and the vertical federation modeling time is greatly shortened. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a schematic diagram of the structure of the hardware operating environment involved in the embodiment of the present invention;
[0036] Figure 2 It is a flowchart of the first embodiment of the vertical federated learning system optimization method of the present invention;
[0037] Figure 3 A schematic diagram of sample data involved in an embodiment of the present invention.
[0038] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0039] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0040] like Figure 1 As shown, Figure 1 It is a structural diagram of the hardware operating environment involved in the embodiment of the present invention.
[0041] It should be noted that Figure 1 The vertical federated learning system optimization device of the embodiment of the present invention can be a PC, or a terminal device with a display function such as a smart phone, a smart TV, a tablet computer, or a portable computer.
[0042] like Figure 1As shown, the vertical federated learning system optimization device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0043] Those skilled in the art will understand that Figure 1 The system structure shown in the figure does not constitute a limitation on the terminal system, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0044] like Figure 1 As shown, the memory 1005 as a readable storage medium may include an operating system, a network communication module, a user interface module, and a vertical federated learning system optimization program.
[0045] exist Figure 1 In the system shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (client) and communicate data with the client; and the processor 1001 can be used to call the vertical federated learning system optimization program stored in the memory 1005.
[0046] In this embodiment, the terminal system includes: a memory 1005, a processor 1001, and a vertical federated learning system optimization program stored on the memory 1005 and executable on the processor 1001, wherein when the processor 1001 calls the vertical federated learning system optimization program stored in the memory 1005, the steps of the vertical federated learning system optimization method provided in each embodiment of the present application are executed.
[0047] Based on the above structure, various embodiments of the vertical federated learning system optimization method are proposed.
[0048] The embodiment of the present invention provides an embodiment of a method for optimizing a vertical federated learning system. It should be noted that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here. The first device and the second device involved in the embodiment of the present invention may be participating devices participating in vertical federated learning, and the participating devices may be devices such as smart phones, personal computers, and servers.
[0049] Reference Figure 2 , Figure 2 1 is a flow chart of the first embodiment of the vertical federated learning system optimization method of the present invention. In this embodiment, the vertical federated learning system optimization method includes:
[0050] Step S10, receiving the encrypted and simplified intermediate result of the second device sent by the second device, wherein the second device is used to perform sampling processing on the original intermediate result corresponding to each piece of sample data of the second device obtained by calculation, to obtain the simplified intermediate result corresponding to part of the sample data of the second device, and to encrypt the simplified intermediate result of the first device, to obtain the encrypted and simplified intermediate result of the first device;
[0051] In this embodiment, the first device and the second device establish a communication connection in advance. The local data of the first device and the second device have overlapping parts in the user dimension and different parts in the data features (may be completely different). The first device and the second device use their respective local data to perform sample alignment to determine the common users and different data features of both parties. The first device uses the data of the common users in the local data as training data, and the second device uses the data of the common users in the local data that has different data features from the first device as training data. That is, the users in the first sample data and the second sample data that are ultimately determined are the same, but the data features are different. The way the first device and the second device perform sample alignment can use existing sample alignment technology, which will not be described in detail here. For example, Figure 3 This is a schematic diagram of sample data in the first device and the second device. The local data of the first device includes three users {U1, U2, U3}, and the data features include {X1, X2, X3}. The local data of the second device includes three users {U1, U2, U4}, and the data features include {X4, X5}. After sample alignment, the training data determined by the first device is the data of users U1 and U2 under data features X1, X2 and X3, and the training data determined by the second device is the data of users U1 and U2 under data features X4 and X5.
[0052] Specifically, during a round of model parameter update process of longitudinal federated linear model learning, the first device and the second device interact in encrypted form to calculate the intermediate results of the gradient and loss function, wherein the encryption adopts a homomorphic encryption algorithm, and a public key and a private key are generated by a third-party coordinator trusted by both the first device and the second device, and the public key is sent to the first device and the second device for encryption. The first device and the second device send the encrypted gradient value and the encrypted loss function to the coordinator for decryption, and then update the local model of the first device and the local model of the second device according to the decrypted gradient value.
[0053] The linear models involved in this application include but are not limited to: logistic regression, linear regression, Poisson regression and other linear weight learning-based model algorithms. For the convenience of description, the present invention takes the longitudinal logistic regression model training as an example to illustrate that the first device and the second device participating in longitudinal federated learning jointly construct a logistic regression model. The second device has data Among them, D A Represents a data set on the second device, the first device has the data and tags Among them, D B a data set representing a first device, and are all multidimensional vectors, and y i is a scalar (i.e., a scalar with a value of 0 or 1, indicating yes or no). Among them, w A and w B are respectively corresponding to and The machine learning model parameters are
[0054]
[0055] The loss function (also called the cost function) is:
[0056]
[0057] loss is calculated on the first device. According to the definition of the loss function, the second device is required to send the intermediate result u A and To the first device, so that the first device can calculate the loss value. During the federated training process, the intermediate results need to be encrypted to avoid data privacy leakage, so the second device sends the encrypted intermediate results [[u A ]]and To the first device, wherein [[·]] represents homomorphic encryption.
[0058] Furthermore, define
[0059] After homomorphic encryption
[0060] The gradient function G is: G = dx = ∑ dx i , then [[G]]=[[dx]]=∑[[d]]x i The first device receives the encrypted intermediate result [[u A ]], and u of the first device B Calculate [[d]], and further calculate the encrypted gradient value [[G] of the local model of the first device according to [[d]] B ]], and at the same time, the first device sends [[d]] to the second device for the second device to calculate the encrypted gradient value [[G A ]].
[0061] Specifically, u A and The number of The number of samples is the same as the number of samples, which is usually very large. The second device needs to A and The second device encrypts the original intermediate result u and then sends it to the first device for interaction. Therefore, the entire encryption process is very time-consuming and has a large amount of communication. A and Perform sampling processing to obtain the simplified intermediate result u' A and The amount of data in the data dimension is reduced from the original intermediate result to the simplified intermediate result, that is, the number of data in the simplified intermediate result is less than the number of data in the original intermediate result, thereby reducing the amount of data that needs to be encrypted and communicated, and reducing the encryption and communication costs. Further, the second device encrypts the simplified intermediate result to obtain the encrypted simplified intermediate result of the second device, and then sends the encrypted simplified intermediate result to the first device. A and The processing process is similar to that of A Take this as an example to illustrate.
[0062] Step S20, performing data padding on the encrypted simplified intermediate result of the second device to obtain an encrypted padded intermediate result of the second device, wherein the amount of data in the encrypted padded intermediate result is the same as the amount of data in the original intermediate result;
[0063] In this embodiment, The intermediate results of the first device and the second device need to be aligned before performing related calculations. Therefore, after the first device receives the encrypted and simplified intermediate result of the second device, it is necessary to perform data padding to obtain the encrypted and padded intermediate result to ensure that the amount of data in the encrypted and padded intermediate result is the same as the amount of data in the original intermediate result.
[0064] Specifically, step S20 includes:
[0065] Step S21, obtaining a sampling comparison table of the second device, and determining padding data and a padding position corresponding to the padding data in the encrypted simplified intermediate result of the second device based on the sampling comparison table of the second device;
[0066] Step S22: inserting the padding data into the encrypted simplified intermediate result of the second device based on the padding position to obtain the encrypted completed intermediate result of the second device.
[0067] In this embodiment, the sampling comparison table is generated by the second device when sampling the original intermediate result. The sampling comparison table records the substitution relationship between each data in the simplified intermediate result and the data in the original intermediate result. For example, data a in the simplified intermediate result is the replacement data of data 1, data 2, and data 3 in the original intermediate result. Data a can be used to restore data 1, data 2, and data 3. Because the homomorphic encryption algorithm is used for the simplified intermediate result, the order of the data will not be affected during the encryption process. Therefore, the encrypted simplified intermediate result can be padded according to the sampling comparison table, thereby ensuring that the encrypted padded intermediate result of the second device is aligned with the corresponding data in the first device.
[0068] Specifically, obtain the sampling comparison table of the second device, which is sent by the second device to the first device. Select the padding data in the encrypted and simplified intermediate result of the second device according to the sampling comparison table, and then determine which data the padding data replaces. For example, the padding data is data a, which is a replacement for data 1, data 2, and data 3. It should be noted that data 1, data 2, and data 3 are not in the encrypted and simplified intermediate result. It is only recorded in the sampling comparison table that there is a replacement relationship between data a and data 1, data 2, and data 3. In the process of completing the encrypted and simplified intermediate result, data a needs to be used to supplement the location of data 1, data 2, and data 3. Further determine the padding position corresponding to the padding data, insert the corresponding padding data in the padding position in the encrypted and simplified intermediate result of the second device, and obtain the encrypted and completed intermediate result of the second device.
[0069] Step S30, using the encrypted completion intermediate result of the second device to calculate the encrypted first gradient value corresponding to the model parameter in the first device, and updating the model parameters of the first device based on the encrypted first gradient value, and iterating the loop until it is detected that the preset stop condition is met, to obtain the target model parameters of the first device after the training is completed.
[0070] In this embodiment, after using the encrypted padded intermediate result of the second device, the encrypted first gradient value corresponding to the model parameter in the first device is calculated with the encrypted padded intermediate result of the first device, the encrypted first gradient value is sent to the coordinating party for decryption, the coordinating party sends the decrypted first gradient value back to the first device, and the first device updates the local model parameter using the first gradient value. At the same time, the encrypted loss function is calculated using the encrypted padded intermediate result of the first device and the encrypted padded intermediate result of the second device, and sent to the coordinating party, which decrypts the encrypted loss function and detects whether the preset stop condition is met. If the preset stop condition is not met, the next round of iterative training is continued.
[0071] Specifically, step S30 includes:
[0072] Step S31, calculating and obtaining an encrypted simplified intermediate result of the first device for calculating the gradient value;
[0073] Specifically, step S31 includes:
[0074] Step a, the first device performs sampling processing on the original intermediate results corresponding to each piece of sample data of the first device obtained by calculation, to obtain a simplified intermediate result corresponding to part of the sample data of the first device;
[0075] Step b: encrypting the simplified intermediate result of the first device to obtain the encrypted simplified intermediate result of the first device.
[0076] In this embodiment, the original intermediate result of the first device needs to be encrypted before it can be calculated with the encrypted intermediate result of the second device. In order to reduce the encryption time and improve the model training speed, the original intermediate result of the first device is also sampled, thereby reducing the amount of encrypted data and saving encryption costs and model training time.
[0077] According to the model parameters of the first device and the data owned by the first device, the original intermediate results corresponding to each piece of sample data of the first device are calculated, Among them, w B are the model parameters of the first device, The first device has data. The original intermediate result of the first device is sampled to obtain a simplified intermediate result of the first device.
[0078] In order to avoid the loss of accuracy in longitudinal logistic regression model training, only u with smaller absolute values is replaced i For larger values of u i The original value is still retained. Therefore, the specific processing process of sampling is to split the original intermediate result of the first device according to the threshold value to obtain two subsets of the original intermediate results, where each data in the first subset is less than or equal to the threshold value, and each data in the second subset is greater than the threshold value. The threshold value is determined according to the actual situation, and only the data in the first subset is sampled. The data in the first subset is grouped, and the representative data of each group is determined. The representative data of each group constitutes a third subset. The data of the third subset and the second subset are the simplified intermediate results of the first device. The simplified intermediate results of the first device are further encrypted. The encryption algorithm uses homomorphic encryption to obtain the encrypted simplified intermediate results of the first device.
[0079] Step S32, using the encrypted completed intermediate result of the second device and the encrypted simplified intermediate result of the first device to calculate the encrypted intermediate result of the first device;
[0080] Specifically, step S32 includes:
[0081] Step c, performing data padding on the encrypted simplified intermediate result of the first device to obtain the encrypted padded intermediate result of the first device;
[0082] Step d: using the encrypted and padded intermediate result of the first device and the encrypted and padded intermediate result of the second device, calculate and obtain the encrypted intermediate result of the first device.
[0083] In this embodiment, data padding is performed on the encrypted and simplified intermediate result of the first device to obtain the encrypted and padded intermediate result of the first device. The specific process is: obtaining a sampling comparison table of the first device, and determining padding data and a padding position corresponding to the padding data in the encrypted and simplified intermediate result of the first device according to the sampling comparison table of the first device, inserting padding data according to the padding position in the encrypted and simplified intermediate result of the first device to obtain the encrypted and padded intermediate result of the first device, and the number of data in the encrypted and padded intermediate result of the first device is the same as the number of data in the original intermediate result of the first device.
[0084] Furthermore, the encrypted padded intermediate result of the first device is aligned with the encrypted padded intermediate result data of the second device, and the encrypted intermediate result [[d]] of the first device is calculated using the encrypted padded intermediate result of the first device and the encrypted padded intermediate result of the second device.
[0085] Step S33: using the encrypted intermediate result of the first device, calculate and obtain the encrypted first gradient value corresponding to the model parameter in the first device.
[0086] In this embodiment, the encrypted intermediate result [[d]] of the first device, the encrypted first gradient value [[G B ]], An encrypted first gradient value is calculated based on the encrypted intermediate result of the first device and the data owned by the first device.
[0087] The vertical federated learning system optimization method proposed in this embodiment receives the encrypted and simplified intermediate result of the second device sent by the second device, and then performs data padding on the encrypted and simplified intermediate result of the second device to obtain the encrypted and padded intermediate result of the second device, and finally uses the encrypted and padded intermediate result of the second device to calculate the encrypted first gradient value corresponding to the model parameter in the first device, and updates the model parameter of the first device based on the encrypted first gradient value, and iterates until it detects that the preset stop condition is met, and obtains the target model parameter of the first device after training. In vertical federated training, by reducing the number of data contained in the intermediate results of the participating devices, the amount of data that needs to be encrypted and communicated is reduced, the encryption and communication costs are reduced, and the vertical federated modeling time is greatly shortened.
[0088] Further, according to the first embodiment, the second embodiment of the vertical federated learning system optimization method of the present invention provides a vertical federated learning system optimization method, the vertical federated learning system optimization method is applied to a second device, the second device may be a smart phone, a personal computer or other device, the vertical federated learning system optimization method includes:
[0089] Step A10, performing sampling processing on the original intermediate results corresponding to each piece of sample data of the second device obtained by calculation, to obtain a simplified intermediate result corresponding to part of the sample data of the second device;
[0090] In this embodiment, during a round of model parameter update process of vertical federated learning, the first device and the second device interact in encrypted form to calculate the intermediate results of the gradient and the loss function, wherein the encryption adopts a homomorphic encryption algorithm, and a public key and a private key are generated by a third-party coordinator trusted by both the first device and the second device, and the public key is sent to the first device and the second device for encryption. The first device and the second device send the encrypted gradient value and the encrypted loss function to the coordinator for decryption, and then update the local models of the first device and the second device according to the decrypted gradient value.
[0091] The linear models involved in this application include but are not limited to: linear weight learning-based model algorithms such as logistic regression, linear regression, and Poisson regression. For the convenience of description, the present invention takes the longitudinal logistic regression model training as an example to illustrate that the first device and the second device participating in longitudinal federated learning jointly construct a logistic regression model. The second device has data Among them, D A Represents a data set on the second device, the first device has the data and tags Among them, D B a data set representing a first device, and are all multidimensional vectors, and y i is a scalar (i.e., a scalar with a value of 0 or 1, indicating yes or no). Among them, w A and w B are respectively corresponding to and The machine learning model parameters are
[0092]
[0093] The loss function (also called the cost function) is:
[0094]
[0095] loss is calculated on the first device. According to the definition of the loss function, the second device needs to send the intermediate result u. A and To the first device, so that the first device can calculate the loss value. During the federated training process, the intermediate results need to be encrypted to avoid data privacy leakage, so the second device sends the encrypted intermediate results [[u A ]]and To the first device, wherein [[·]] represents homomorphic encryption.
[0096] definition
[0097] Homomorphically encrypted The gradient function G is: G = dx = ∑ dx i , then [[G]]=[[dx]]=∑[[d]]x i The first device receives the encrypted intermediate result [[u A ]], and u of the first device B Calculate [[d]], and further calculate the encrypted gradient value [[G] of the local model of the first device according to [[d]] B]], and at the same time, the first device sends [[d]] to the second device for the second device to calculate the encrypted gradient value [[G A ]].
[0098] Specifically, u A and The number of The number of samples is the same as the number of samples, which is usually very large. The second device needs to A and The second device encrypts the original intermediate result u and then sends it to the first device for interaction. Therefore, the entire encryption process is very time-consuming and has a large amount of communication. A and Perform sampling processing to obtain the simplified intermediate result u' A and The amount of data in the data dimension is reduced from the original intermediate result to the simplified intermediate result, that is, the number of data in the simplified intermediate result is less than the number of data in the original intermediate result, thereby reducing the amount of data that needs to be encrypted and communicated, and reducing the encryption and communication costs. Further, the second device encrypts the simplified intermediate result to obtain the encrypted simplified intermediate result of the second device, and then sends the encrypted simplified intermediate result to the first device. A and The processing process is similar to that of A Take this as an example to illustrate.
[0099] Specifically, step A10 includes:
[0100] Step A12, splitting the original intermediate result of the second device based on the threshold to obtain a first sub-original intermediate result and a second sub-original intermediate result, wherein each data in the first sub-original intermediate result is less than or equal to the threshold, and each data in the second sub-original intermediate result is greater than the threshold;
[0101] Step A13, grouping all data of the first sub-original intermediate result, and determining representative data of each group, and forming a third sub-original intermediate result with the representative data of each group;
[0102] Step A14: obtaining a simplified intermediate result of the second device based on the third sub-original intermediate result and the second sub-original intermediate result.
[0103] In this embodiment, in order to avoid the loss of accuracy in the longitudinal logistic regression model training, only the u with a smaller absolute value is replaced. i For larger values of u iThe original value is still retained. Therefore, the specific processing process of sampling is to split the original intermediate result of the second device according to the threshold value to obtain two subsets of the original intermediate results: the first sub-original intermediate result and the second sub-original intermediate result, wherein each data in the first sub-original intermediate result is less than or equal to the threshold value, and each data in the second sub-original intermediate result is greater than the threshold value, and the threshold value is determined according to the actual situation, and only the data in the first sub-original intermediate result is sampled. The data in the first sub-original intermediate result is grouped, and the representative data of each group is determined, and the third sub-original intermediate result is composed of the representative data of each group. The data of the third sub-original intermediate result and the second sub-original intermediate result are the simplified intermediate results of the second device. Among them, the specific method of grouping the data in the first sub-original intermediate result and determining the representative data can be determined according to the actual situation, for example, the data in the first sub-original intermediate result is arranged in order from large to small, and then evenly divided into N groups, and the average is calculated for each group, and the average is used as the representative data of each group; N initial cluster centers can also be manually set, and then the final cluster center point is obtained by using k-means, and the final cluster center point is used as the representative data of each group.
[0104] Step A20, encrypting the simplified intermediate result of the second device, obtaining the simplified intermediate result corresponding to part of the sample data of the second device and sending it to the first device, so that the first device can feed back the encrypted intermediate result of the first device based on the encrypted simplified intermediate result of the second device, wherein the first device performs data padding on the received encrypted simplified intermediate result of the second device to obtain the encrypted padded intermediate result of the second device, and uses the encrypted padded intermediate result of the second device to calculate the encrypted intermediate result of the first device;
[0105] In this embodiment, the simplified intermediate result of the second device is further encrypted, and the encryption algorithm adopts homomorphic encryption to obtain the encrypted simplified intermediate result of the second device, and the encrypted simplified intermediate result of the second device is sent to the first device. When the first device receives the encrypted simplified intermediate result of the second device, it is necessary to perform data padding on the encrypted simplified intermediate result of the second device to obtain the encrypted padded intermediate result of the second device, and then use the encrypted padded intermediate result of the first device and the encrypted padded intermediate result of the second device to calculate the encrypted intermediate result [[d]] of the first device, and the first device sends the encrypted intermediate result [[d]] of the first device to the second device, wherein the encrypted padded intermediate result of the first device and the encrypted padded intermediate result of the second device are aligned.
[0106] Step A30, using the encrypted intermediate result of the first device to calculate the encrypted second gradient value corresponding to the model parameter in the second device, and updating the model parameter of the second device based on the encrypted second gradient value, the loop is iterated until it is detected that the preset stop condition is met, and the target model parameters of the second device after training are obtained.
[0107] In this embodiment, the encrypted intermediate result [[d]] of the first device is obtained, and the encrypted first gradient value [[G A ]], According to the encrypted intermediate result of the first device and the data owned by the second device, the encrypted second gradient value is obtained through settlement. The coordinator to which the encrypted second gradient value is sent is decrypted, and the coordinator sends the decrypted second gradient value back to the second device, and the second device updates the local model parameters using the second gradient value. At the same time, the coordinator detects whether the preset stop condition is met. If the preset stop condition is not met, the next round of iterative training is continued.
[0108] The vertical federated learning system optimization method proposed in this embodiment performs sampling processing on the original intermediate results corresponding to each sample data of the second device obtained by calculation, obtains the simplified intermediate results corresponding to part of the sample data of the second device, encrypts the simplified intermediate results of the second device, obtains the simplified intermediate results corresponding to part of the sample data of the second device and sends them to the first device, so that the first device can feed back the encrypted intermediate results of the first device based on the encrypted simplified intermediate results of the second device, calculates the encrypted second gradient values corresponding to the model parameters in the second device using the encrypted intermediate results of the first device, and updates the model parameters of the second device based on the encrypted second gradient values, and iterates until it is detected that the preset stop condition is met, and obtains the target model parameters of the second device after the training is completed. In the vertical federated training, by reducing the number of data contained in the intermediate results of the participating devices, the amount of data that needs to be encrypted and communicated is reduced, the encryption and communication costs are reduced, and the vertical federated modeling time is greatly shortened.
[0109] In addition, an embodiment of the present invention further proposes a readable storage medium, on which a vertical federated learning system optimization program is stored. When the vertical federated learning system optimization program is executed by a processor, the steps of the vertical federated learning system optimization method described below are implemented.
[0110] The various embodiments of the vertical federated learning system optimization device and the readable storage medium of the present invention can all refer to the various embodiments of the vertical federated learning system optimization method of the present invention, and will not be repeated here.
[0111] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0112] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0113] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0114] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for optimizing a vertical federated learning system, characterized in that: Applied to a first device participating in vertical federated learning, the first device is communicatively connected with a second device, and the vertical federated learning system optimization method comprises the following steps: Receiving the encrypted and simplified intermediate result of the second device sent by the second device, wherein the second device is used to perform sampling processing on the original intermediate result corresponding to each piece of sample data of the second device obtained by calculation, to obtain the simplified intermediate result corresponding to part of the sample data of the second device, and to encrypt the simplified intermediate result of the second device, to obtain the encrypted and simplified intermediate result of the second device; Performing data padding on the encrypted simplified intermediate result of the second device to obtain an encrypted padded intermediate result of the second device, wherein the amount of data in the encrypted padded intermediate result is the same as the amount of data in the original intermediate result; The encrypted first gradient value corresponding to the model parameter in the first device is calculated by using the encrypted completion intermediate result of the second device, and the model parameter of the first device is updated based on the encrypted first gradient value, and the target model parameter of the first device after training is obtained by looping and iterating until a preset stop condition is detected to be met; The step of performing data padding on the encrypted simplified intermediate result of the second device to obtain the encrypted padded intermediate result comprises: Obtaining a sampling comparison table of the second device, and determining padding data and a padding position corresponding to the padding data in the encrypted simplified intermediate result of the second device based on the sampling comparison table of the second device, wherein the sampling comparison table is generated by the second device when performing sampling processing on the original intermediate result, and the sampling comparison table records the substitution relationship between each data in the simplified intermediate result and the data in the original intermediate result; In the encrypted simplified intermediate result of the second device, the padding data is inserted based on the padding position to obtain the encrypted completed intermediate result of the second device.
2. The method for optimizing a vertical federated learning system according to claim 1, wherein: The step of calculating the encrypted first gradient value corresponding to the model parameter in the first device by using the encrypted and padded intermediate result of the second device comprises: Calculate and obtain an encrypted simplified intermediate result of the first device used to calculate the gradient value; Using the encrypted completed intermediate result of the second device and the encrypted simplified intermediate result of the first device, calculate and obtain the encrypted intermediate result of the first device; The encrypted intermediate result of the first device is used to calculate the encrypted first gradient value corresponding to the model parameter in the first device.
3. The method for optimizing a vertical federated learning system according to claim 2, wherein: The step of calculating and obtaining an encrypted simplified intermediate result of a first device for calculating a gradient value comprises: The first device performs sampling processing on the original intermediate results corresponding to each piece of sample data of the first device obtained by calculation, so as to obtain a simplified intermediate result corresponding to part of the sample data of the first device; The simplified intermediate result of the first device is encrypted to obtain an encrypted simplified intermediate result of the first device.
4. The method for optimizing a vertical federated learning system according to claim 2, wherein: The step of calculating the encrypted intermediate result of the first device by using the encrypted complementary intermediate result of the second device and the encrypted simplified intermediate result of the first device comprises: Performing data padding on the encrypted simplified intermediate result of the first device to obtain the encrypted padded intermediate result of the first device; The encrypted intermediate result of the first device is calculated using the encrypted padded intermediate result of the first device and the encrypted intermediate result of the second device.
5. A method for optimizing a vertical federated learning system, characterized in that: Applied to a second device participating in vertical federated learning, the vertical federated learning system optimization method comprises the following steps: Performing sampling processing on the original intermediate results corresponding to each piece of sample data of the second device obtained by calculation, to obtain a simplified intermediate result corresponding to part of the sample data of the second device; Encrypt the simplified intermediate result of the second device, obtain the encrypted simplified intermediate result corresponding to part of the sample data of the second device and send it to the first device, so that the first device can feed back the encrypted intermediate result of the first device based on the encrypted simplified intermediate result of the second device, wherein the first device is used to receive the encrypted simplified intermediate result of the second device and the sampling comparison table of the second device, and determine the padding data and the padding position corresponding to the padding data in the encrypted simplified intermediate result of the second device based on the sampling comparison table of the second device, wherein the sampling comparison table is generated by the second device when sampling the original intermediate result, and the sampling comparison table records the substitution relationship between each data in the simplified intermediate result and the data in the original intermediate result; insert the padding data into the encrypted simplified intermediate result of the second device based on the padding position to obtain the encrypted padded intermediate result of the second device, and use the encrypted padded intermediate result of the second device to calculate the encrypted intermediate result of the first device; The encrypted intermediate result of the first device is used to calculate the encrypted second gradient value corresponding to the model parameter in the second device, and the model parameter of the second device is updated based on the encrypted second gradient value. The loop is iterated until it is detected that the preset stop condition is met, and the target model parameter of the second device after training is obtained.
6. The method for optimizing a vertical federated learning system according to claim 5, wherein: The step of performing sampling processing on the original intermediate results corresponding to each piece of sample data of the second device obtained by calculation to obtain a simplified intermediate result corresponding to part of the sample data of the second device includes: Splitting the original intermediate result of the second device based on the threshold to obtain a first sub-original intermediate result and a second sub-original intermediate result, wherein each data in the first sub-original intermediate result is less than or equal to the threshold, and each data in the second sub-original intermediate result is greater than the threshold; Grouping all data of the first sub-original intermediate result, and determining representative data of each group, and forming a third sub-original intermediate result with the representative data of each group; A reduced intermediate result of the second device is obtained based on the third sub-original intermediate result and the second sub-original intermediate result.
7. A vertical federated learning system optimization device, characterized in that: The vertical federated learning system optimization device includes: a memory, a processor, and a vertical federated learning system optimization program stored in the memory and executable on the processor. When the vertical federated learning system optimization program is executed by the processor, the steps of the vertical federated learning system optimization method as described in any one of claims 1 to 4 are implemented.
8. A vertical federated learning system optimization device, characterized in that: The vertical federated learning system optimization device includes: a memory, a processor, and a vertical federated learning system optimization program stored in the memory and executable on the processor. When the vertical federated learning system optimization program is executed by the processor, the steps of the vertical federated learning system optimization method as described in any one of claims 5 to 6 are implemented.
9. A readable storage medium, characterized in that: The readable storage medium stores a vertical federated learning system optimization program, and when the vertical federated learning system optimization program is executed by the processor, the steps of the vertical federated learning system optimization method according to any one of claims 1 to 6 are implemented.
