Model training method and apparatus, and storage medium and electronic device

By using encryption functions to encrypt and decrypt gradients in the work unit of the federated learning system, and calculating the sum of the gradients, the problem of potential security risks of training samples caused by the untrustworthy parameter server is solved, and no parameter server is involved in the federated learning system. model training tasks to ensure information security.

WO2024187902A1PCT designated stage expired Publication Date: 2024-09-19ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/141802
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-10
Filing Date
2023-12-26
Publication Date
2024-09-19

AI Technical Summary

Technical Problem

In the federated learning system, when the parameter server is untrustworthy, there is a security risk that the parameter server reverses the training samples in the working node, leading to the risk of information leakage of the training samples.

Method used

Adopting a model training method, by determining the encryption function in each work unit, performing slice encryption on the gradient according to the encryption function, receiving the slice encrypted data of other work units, and decrypting to obtain the sum of the gradients of each work unit, thereby completing The model training task avoids the participation of the parameter server and ensures the information security of training samples and model parameters.

Benefits of technology

This method completes model training without the need for a parameter server, effectively protects the training samples and model parameters in the work unit, prevents information leakage, and ensures information security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023141802_19092024_PF_FP_ABST
    Figure CN2023141802_19092024_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in the present description are a model training method and apparatus, and a storage medium and an electronic device. The method comprises: for each working unit in a training system, determining an encryption function by using the gradient of the working unit as a parameter, and according to the encryption function, determining encrypted slice data, which corresponds to a specified value, of the gradient; and then according to the encrypted slice data, which corresponds to a specified value, of the gradient and encrypted slice data, which corresponds to specified values, of gradients of the other working units, determining the sum of the gradients of the other working units and the gradient of the working unit, so as to complete the aggregation of the gradients, and then completing a model training task according to an aggregated gradient. An execution process of the model training method does not requires the involvement of a parameter server, and therefore related information of training samples and model parameters in working units cannot be stolen even if the parameter server is untrusted, thereby ensuring the information security of the training samples and the model parameters.
Need to check novelty before this filing date? Find Prior Art

Description

Model training method, device, storage medium and electronic device Technical Field

[0001] This specification relates to the field of computer technology, and in particular to a model training method, device, storage medium, and electronic device. Background Art

[0002] With the development of computer technology and people's increasing attention to their own privacy data, the use of federated learning to train models has been widely used in the field of model training.

[0003] A federated learning system typically consists of multiple worker nodes and parameter servers. Each worker node stores different data, while the parameter server stores model parameters. When a model training task is required, the worker node determines the model gradient based on the model parameters issued by the parameter server, its own stored training samples, and the pre-deployed model structure, and returns the model gradient to the parameter server. The parameter server updates its stored model parameters based on the model gradients received from each worker node and sends the updated model parameters to each worker node, completing the model training task.

[0004] However, when the parameter server is untrustworthy, there is a situation where the parameter server reversely infers the training samples in each working node based on the model parameters and gradients stored in itself, resulting in security risks for the training samples in each working node.

[0005] Based on this, this specification provides a model training method.

[0006] Summary of the Invention

[0007] This specification provides a model training method, device, storage medium and electronic device to partially solve the above-mentioned problems existing in the related technology.

[0008] This specification adopts the following technical solution: This specification provides a model training method, which is applied to a training system, wherein the training system includes several working units, each working unit storing different training samples, including: for each working unit, in response to the model training task, determining the gradient according to the training samples stored in the working unit itself; using the gradient as the parameter of the encryption function, determining the encryption function corresponding to the working unit; for each specified value, determining the slice encrypted data of the gradient corresponding to the specified value according to the specified value and the encryption function, as the first encrypted data, wherein the number of each specified value is not less than the number of working units performing the model training task; receiving the slice encrypted data of the gradient of the other working units corresponding to the specified value sent by other working units as the second encrypted data; decrypting the slice encrypted data corresponding to each specified value to obtain the sum of the gradient of the other working units and the gradient of the working unit, and performing the model training task according to the sum of the gradients.

[0009] The present specification provides a model training device, which is applied to a model training system. The training system includes several working units, each of which stores different training samples, including: a gradient determination module, which is used to determine the gradient of each working unit in response to a model training task based on the training samples stored in the working unit itself; a function determination module, which is used to determine the encryption function corresponding to the working unit with the gradient as the parameter of the encryption function; a slice determination module, which is used to determine, for each specified value, the slice encryption data of the gradient corresponding to the specified value based on the specified value and the encryption function, as the first encryption data, wherein the number of each specified value is not less than the number of working units performing the model training task; a receiving module, which is used to receive the slice encryption data of the gradient of the other working units corresponding to the specified value sent by other working units, as the second encryption data; an execution module, which is used to determine the sum of the gradient of the other working units and the gradient of the working unit based on the slice encryption data corresponding to each specified value, and execute the model training task based on the sum of the gradients.

[0010] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned model training method is implemented.

[0011] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned model training method when executing the program.

[0012] At least one of the above-mentioned technical solutions adopted in this specification can achieve the following beneficial effects: This specification provides the model training method, by determining an encryption function for each working unit with the gradient of the working unit as a parameter, and then determining the sliced ​​encrypted data of the gradient corresponding to the specified value based on the encryption function, and receiving the sliced ​​encrypted data of the gradient of other working units corresponding to the specified value sent by other working units, and then determining the sum of the gradient of other working units and the gradient of the working unit based on the slice encrypted data corresponding to each specified value, so as to complete the gradient aggregation, and then complete the model training task based on the aggregated gradient.

[0013] The execution process of this model training method does not require the participation of the parameter server. Therefore, even if the parameter server is untrusted, the relevant information of the training samples and model parameters in the working unit cannot be stolen, ensuring the information security of the training samples and model parameters. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0015] FIG1 is a flow chart of the model training method provided in this specification;

[0016] FIG2 is a schematic diagram of the structure of the model training device provided in this specification;

[0017] FIG3 is a schematic diagram of an electronic device corresponding to FIG1 provided in this specification. DETAILED DESCRIPTION

[0018] To make the objectives, technical solutions, and advantages of this specification more clear, the following will clearly and completely describe the technical solutions of this specification in conjunction with the specific embodiments of this specification and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this specification.

[0019] It should be noted that all actions of obtaining signals, information or data in this manual are performed in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.

[0020] Deep learning is a key branch of computer science and artificial intelligence, and a further extension of neural networks. By automatically learning effective feature representations from data and improving the accuracy of prediction models, it has been widely used in fields such as speech recognition, image recognition, and object detection.

[0021] With the rapid expansion of deep learning data, traditional model training requires iterative computations that can only utilize the hardware resources of the host computer hosting the current process. However, the scalability of a single machine is always limited. Therefore, a single machine is powerless when faced with massive amounts of data and large-scale models. It is necessary to split the data or model into multiple parts and accelerate training on multiple machines using the hardware resources of different hosts. For this reason, the method of using multiple worker nodes to execute model training jobs in parallel has become widely used.

[0022] As a distributed training system, the model training process of federated learning includes the following steps.

[0023] First, configure several worker nodes and parameter servers.

[0024] Secondly, the parameter server sends the model parameters stored in itself to each working node.

[0025] Each worker node then trains the model based on its own stored model structure, the training samples allocated from the training sample set, and the model parameters sent by the parameter server, determining the model gradient. The determined model gradient is then sent to the parameter server.

[0026] Afterwards, the parameter server updates the model parameters based on all received model gradients and sends the updated model parameters to the working nodes.

[0027] Finally, repeat the above steps until the model training is completed.

[0028] However, when the parameter server is untrustworthy, there is a situation where the parameter server reversely infers the training samples in each working node based on the model parameters stored in itself and the gradients sent by each working node, resulting in security risks for the training samples in the federated learning system.

[0029] Based on this, this specification provides a new model training method that enables the training system to complete model training tasks without the participation of parameter servers, ensuring the security of training samples in work units.

[0030] It should be noted that the model corresponding to this model training task is typically a risk control model. Risk control models typically determine training samples based on sensitive user data. Therefore, if the parameter server is untrustworthy, the parameter server can infer the status of each training sample in each worker node based on its own stored model parameters and the gradients received from each worker node. This significantly increases the likelihood of exposing sensitive user data stored in each worker node, posing a security risk.

[0031] The technical solutions provided by the embodiments of this specification are described in detail below with reference to the accompanying drawings.

[0032] FIG1 is a flow chart of the model training method provided in this specification, which specifically includes the following steps S100 to S108.

[0033] S100: For each work unit, in response to a model training task, a gradient is determined based on the training samples stored in the work unit itself.

[0034] Different from the current model training task completed collaboratively based on the parameter server and each work unit, the security of the training samples in each work unit cannot be guaranteed when the parameter server is untrustworthy. This specification provides a new model training method, which is applied to a training system that does not include a parameter server. For each work unit in the training system, the gradient of the work unit is used as a parameter to determine the encryption function, and based on the encryption function, the sliced ​​encrypted data corresponding to the specified value of the gradient is determined. Then, based on the sliced ​​encrypted data corresponding to the specified value of the gradient and the sliced ​​encrypted data corresponding to the specified value of the gradient of other work units, the sum of the gradients of other work units and the gradient of the work unit is determined, and then the model training task is completed based on the sum of the gradients.

[0035] The execution process of this model training method does not require the participation of the parameter server. Therefore, even if the parameter server is untrusted, the relevant information of the training samples in the working unit cannot be stolen, ensuring the information security of the training samples.

[0036] Based on the above brief description of the model training method provided in this specification, the model training method provided in this specification can be applied to a training system that only includes working units. The working units in the training system can be different electronic devices or different modules in the same electronic device. The electronic device can be a smart terminal, a server, etc. The specific type of electronic device can be set as needed and is not limited in this specification.

[0037] Specifically, the training system can be a data-parallel federated learning system. That is, each work unit pre-deploys the complete network structure corresponding to the model, and each work unit stores different training samples. In this case, based on the different training samples stored in each work unit, training can be performed in parallel within each work unit. The gradients obtained from the training are then shared, and model parameters are adjusted based on the shared gradients.

[0038] Therefore, for each work unit, the work unit can determine the data to be risk-controlled based on the sensitive user data stored in the work unit as training samples, and determine the risk control results corresponding to the data to be risk-controlled as labels for the training samples. The work unit can then use its own training samples as input to the target model corresponding to the training task to be trained, and obtain the predicted risk control results output by the target model.

[0039] Afterwards, the work unit may determine the loss corresponding to the training sample of the work unit based on the predicted risk control results and the annotations of the training samples.

[0040] Finally, the working unit can determine the gradient based on the loss corresponding to the training samples stored in itself.

[0041] Among them, the target model consists of the network structure and model parameters of the model corresponding to the model training task. The network structure is pre-deployed in the working unit, or determined by the working unit from the stored network structures according to the model identifier corresponding to the model training task. The model parameters are adjusted by the working unit based on the sum of the gradients determined after the last sharing of encrypted data with other working units that perform the model processing task, or they can be sent by other working units that perform the model processing task and received by the working unit. How to determine the specific network structure and model parameters of the target model can be set as needed, and this manual does not impose any restrictions on this.

[0042] It should be noted that the gradient in this specification can be the gradient of the loss determined by the working unit based on the training samples, or the adjustment amount of the model parameters determined based on the gradient. In other words, the gradient can be any adjustment amount that the training system needs to aggregate during the training process in order to execute the model training task based on the aggregated result.

[0043] S102: Determine the encryption function corresponding to the work unit using the gradient as a parameter of the encryption function.

[0044] In one or more embodiments provided in this specification, this specification adopts a method of using an encryption function to homomorphically encrypt the gradients of each working unit that executes the model training task to determine the sliced ​​encrypted data corresponding to the gradient, and then based on the sliced ​​encrypted data, decrypt the sum of the gradients of each working unit that executes the model training task, and then execute the model training task based on the sum of the gradients.

[0045] Based on this, the working unit may determine an encryption function for encrypting the gradient, wherein the encryption function may be a homomorphic encryption function, such as a homomorphic encryption function based on Lagrange polynomials.

[0046] Specifically, each working unit in the training system may be pre-set with a paradigm of the encryption function. For example, the paradigm of the encryption function is f(x) = ax + b. Assuming x is the independent variable and f(x) is the dependent variable, a and b in the above paradigm are the parameters of the encryption function.

[0047] Therefore, the working unit can determine the parameters required to generate the encryption function based on the preset encryption function paradigm and the gradient. That is to say, the working unit can determine the parameters corresponding to the encryption function based on the gradient. Among them, the working unit can directly use the gradient as at least one of the parameters of the encryption function, or it can perform homomorphic calculation on the gradient and then use the processing result as at least one of the parameters of the encryption function. How to determine the parameters required to generate the encryption function based on the gradient can be set as needed, and this manual does not limit this. Among them, homomorphic calculation is a calculation method in the ciphertext domain, which allows a specific form of algebraic calculation to be performed on the ciphertext to obtain a result that is still encrypted, and the result obtained by decrypting it is the same as the result of the same calculation on the plaintext.

[0048] After determining the parameters required to generate the encryption function, the working unit may determine, based on the parameters, an encryption function with the gradient as a parameter as the encryption function corresponding to the working unit.

[0049] S104: For each specified value, determine the sliced ​​encrypted data of the gradient corresponding to the specified value according to the specified value and the encryption function as the first encrypted data, wherein the number of each specified value is not less than the number of working units performing the model training task.

[0050] In one or more embodiments provided in this specification, after determining an encryption function with a gradient as a parameter, the encryption function is sliced ​​at a specified value, and the obtained sliced ​​encrypted data is the sliced ​​encrypted data with a gradient corresponding to the specified value. On this basis, if the sliced ​​encrypted data with the gradient corresponding to each specified value corresponding to each work unit can be obtained, the sum of the gradients of each work unit can be determined based on the principle of homomorphic encryption. The above is the idea of ​​using an encryption function to homomorphically encrypt the gradients of each work unit that performs the model training task as described above. Based on this, the work unit can determine the sliced ​​encrypted data.

[0051] Specifically, the work unit is preset with multiple specified values. The number of specified values ​​must be no less than the number of work units executing the model training task. Only then can the sum of the gradients of each work unit be decrypted based on the encrypted data of the slices corresponding to the specified values.

[0052] Therefore, for each specified value, the working unit can determine the slice encrypted data corresponding to the specified value based on the specified value and the encryption function. Taking the encryption function as f(x) = ax + b, a and b are the parameters of the encryption function, and b is the gradient determined by the working unit as an example, assuming that the specified value is 1, the working unit can determine the slice encrypted data f(1) corresponding to the specified value based on the encryption function and the specified value, that is, a + b.

[0053] Of course, the slice encryption data may also be [1, f(1)]. The specific data format corresponding to the slice encryption data may be set as needed, and this specification does not impose any limitation on this.

[0054] In addition, in order to conveniently distinguish the slice encrypted data corresponding to the gradient of the working unit and the slice encrypted data corresponding to the gradient determined by other working units that perform the model processing task, the working unit can use the slice encrypted data corresponding to its own gradient as the first encrypted data.

[0055] S106: Receive encrypted data of slices of the other working units, whose gradients correspond to the specified value, sent by the other working units, as second encrypted data.

[0056] In one or more embodiments provided herein, as previously described, upon obtaining encrypted slice data corresponding to designated values ​​for each work unit, the sum of the gradients of each work unit can be decrypted. Based on this, the work unit can receive encrypted slice data sent by other work units.

[0057] Specifically, the work unit may send a first acquisition request to other work units that execute the model training task.

[0058] The other working units send the encrypted data of the slices whose gradients determined by themselves correspond to the specified values ​​to the working unit according to the received first acquisition request.

[0059] The working unit can receive the slice encrypted data of other working units whose gradients correspond to specified values ​​sent by other working units, and use the received slice encrypted data of other working units whose gradients correspond to specified values ​​as the second encrypted data.

[0060] Of course, for each work unit, after determining that its own gradient corresponds to the encrypted slice data of the specified value, it can send the encrypted slice data of its own gradient corresponding to the specified value to other work units performing the model training task. In this way, the work unit can directly receive the encrypted slice data sent by other work units of the model training task.

[0061] S108: Determine the sum of the gradients of the other working units and the gradient of the working unit based on the sliced ​​encrypted data corresponding to each specified value, and execute the model training task based on the sum of the gradients.

[0062] In one or more embodiments provided herein, as described above, after determining that the gradients corresponding to the sliced ​​encrypted data for each work unit correspond to the specified values, the sum of the gradients of the work units performing the model training task can be decrypted. The model training task can then be executed based on the decrypted sum of the gradients.

[0063] Specifically, the working unit may determine the encrypted data of the slice whose gradient corresponds to the specified value, i.e., the first encrypted data, and receive the encrypted data of the slice whose gradient corresponds to the specified value from other working units, i.e., the second encrypted data.

[0064] Therefore, the working unit can determine the encrypted data of each slice corresponding to the specified value based on the first encrypted data and the second encrypted data. The encrypted data of each slice corresponding to the specified value is the encrypted data of the slice whose gradient of the working unit executing the encrypted data of each slice corresponds to the specified value.

[0065] The work unit then determines the encrypted data for each slice corresponding to each specified value. Thus, for each specified value, the encrypted data for each slice corresponding to that specified value can be considered the result of encrypting different gradients using different encryption functions and the same specified value. Conversely, for each gradient, the encrypted data for each slice corresponding to that gradient can be considered the result of encrypting that gradient using the same encryption function and different specified values.

[0066] Finally, the work unit can encrypt the data according to the slices corresponding to each specified value, and decrypt it to obtain the sum of the gradients of each work unit that performs the data processing task, that is, the sum of the gradients of other work units and the gradient of this work unit.

[0067] After decrypting and obtaining the sum of the gradients, the working unit can determine whether an iteration termination condition has been met. This iteration termination condition can be when the number of iterations reaches a preset threshold, or when the loss determined in step S100 is less than a preset loss threshold. The specific setting of this iteration termination condition can be customized and is not limited in this specification.

[0068] If yes, the work unit can determine that the model corresponding to the model training task has been trained. In other words, this federated learning task has ended.

[0069] If not, the work unit may adjust the model parameters of the model corresponding to the model training task based on the determined sum of gradients, and re-determine the gradient of the work unit based on the adjusted model parameters and the training samples stored by the work unit itself. Furthermore, based on the determined gradient, the first encrypted data is re-determined, and based on the re-determined first encrypted data, the sum of the gradients of each work unit executing the model training task is continuously determined until the iteration termination condition is met.

[0070] That is, after determining that the model corresponding to the model training task has not been trained, the work unit can adjust the model parameters of the model deployed by itself according to the sum of the determined gradients, and determine the model gradient under the adjusted model parameters according to the adjusted model parameters. Then, based on the determined gradients, the sliced ​​encrypted data corresponding to the specified values ​​of the gradients are re-determined to continue to complete the gradient aggregation according to the sliced ​​encrypted data corresponding to each specified value, and thereby continue to update the model parameters, so as to perform the next iteration process according to the updated model parameters. The iterative process is repeated until the model training is completed.

[0071] Therefore, the risk control model trained based on the above model training method can determine the risk control results corresponding to the data to be risk controlled based on the user's sensitive data, etc. during the user's business execution, and then perform risk control on the user based on the risk control results.

[0072] The model training method provided in this specification uses homomorphic encryption to encrypt the gradients of each work unit. After receiving the first and second encrypted data, each work unit cannot directly determine the gradients of other work units. It can only determine the sum of the gradients of other work units and its own. Therefore, it is also impossible to reverse-infer the training samples and model parameters of other work units, ensuring data security.

[0073] As shown in Figure 1, the model training method determines an encryption function for each work unit in the training system, using the gradient of the work unit as a parameter. Based on the encryption function, the sliced ​​encrypted data corresponding to the specified value of the gradient is determined. Then, based on the sliced ​​encrypted data corresponding to the specified value of the gradient and the sliced ​​encrypted data corresponding to the specified value of the gradient of other work units, the sum of the gradient of the other work units and the gradient of the work unit is determined to complete the aggregation of the gradient, and then the model training task is completed based on the aggregated gradient. The execution process of this model training method does not require the participation of the parameter server. Therefore, even if the parameter server is untrusted, the relevant information of the training samples and model parameters in the work unit cannot be stolen, thereby ensuring the information security of the training samples and model parameters.

[0074] In the process of training the risk control model based on the model training method in this specification, the data security of the sensitive data stored in each working unit in the training system is guaranteed.

[0075] In addition, to ensure model training efficiency and avoid the situation where the model training task is determined to be completed after the sum of the gradients of each work unit performing the model training task has been re-determined, the above step of determining whether the iteration termination condition has been met can also be performed by the work unit in step S100.

[0076] Furthermore, in step S102, the working unit can also directly use the gradient as the parameter of the encryption function, randomly select any function containing the parameter and the independent variable as the encryption function, and then broadcast the function type of the determined encryption function to other working units that execute the model training task.

[0077] Other working units can determine their own encryption functions based on the received function type and their own determined gradients.

[0078] Furthermore, for each second encrypted data, it is possible that the second encrypted data is intercepted and tampered with during transmission. In this case, when the working unit executes subsequent steps based on the received tampered second encrypted data, an attacker who tampered with the second encrypted data may be able to reverse-infer the training samples and model parameters in the working unit based on the execution results. To avoid this, before step S108, the working unit may verify the second encrypted data after receiving it.

[0079] Specifically, the work unit may further encrypt each parameter in its corresponding encryption function to determine a first encryption parameter, and broadcast the first encrypted data and the first encryption parameter. The encryption method may be to perform homomorphic computation on each parameter in the encryption function, or to determine the signature of the work unit based on each parameter in the encryption function.

[0080] Similarly, for each second encrypted data, the working unit may also receive a second encryption parameter corresponding to the second encrypted data. The second encryption parameter is encrypted in the same manner as the first encryption parameter and is sent by the working unit that sent the second encrypted data.

[0081] Then, the working unit can verify the second encrypted data based on the second encryption parameter. If the encryption method of the second encryption parameter is homomorphic calculation, the working unit can perform homomorphic calculation on the second encrypted data and determine whether the product of the processing result and the second encryption parameter is the same to verify the second encrypted data. If the encryption method of the second encryption parameter is only symmetric encryption or asymmetric encryption, the working unit can reversely infer the plaintext corresponding to the second encryption parameter based on the encryption method of the first encryption parameter. If the second encryption parameter is a signature, the working unit can verify the second encrypted data based on the received digital signature.

[0082] If the verification is successful, the working unit may determine that the second encrypted data is secure data and may execute subsequent steps.

[0083] If the verification fails, the worker unit may determine that the training system has a security risk. This means that the data transmitted by the worker units in the training system could be intercepted by an attacker, or that some of the worker units in the training system are transmitting erroneous data. The worker unit may then return a warning indicating a security risk in the training system.

[0084] In addition, groups are an important sampling model in cryptography and are often used to encrypt data. Therefore, in this specification, the encryption method used when determining the first encryption parameter and the second encryption parameter can be an encryption method using generators of the group.

[0085] Specifically, the working unit may first determine a generator: the working unit may predefine a relatively large prime number as the modulus prime number, and determine a prime factor from the factors of the value corresponding to the modulus prime number - 1 as the order prime number.

[0086] After determining the modulus prime and the order prime, the work unit can construct the multiplication cyclic group Z P={1,2,……,p-1}, and determine the generator of the cyclic group. For example, if the modulus prime number is p, the order prime number is q, and the generator is g, then g q =e. That is, g is a generator of the multiplicative cyclic group, and its order is q.

[0087] Therefore, after determining the modulus prime number, the order prime number and the generator, the working unit may broadcast the modulus prime number, the order prime number and the generator as the third encrypted data.

[0088] Other working units can verify the received third encrypted data, that is, verify the third encrypted data based on any of the following conditions: g is a generator of a penalized cyclic group, the order is q, the order is a prime number, the modulus is a prime number, and the like.

[0089] If the verification is successful, the other work unit can subsequently encrypt the parameters of the encryption function based on the generator.

[0090] If the verification fails, the other working unit may send a prompt message indicating that there is a safety hazard in the training system.

[0091] After verification, for each work unit, the work unit can use the generator as the base, the parameter as the exponent, and the corresponding result based on the modulus prime number to encrypt the gradient of the work unit.

[0092] Take the encryption function of the work unit as f(x) = ax + b, a and b are the parameters of the encryption function, and b is the gradient determined by the work unit as an example. Assuming that the specified value is 1, the work unit can determine the slice encryption data f(1) of the specified value, that is, a + b. Then the first encryption parameter corresponding to the work unit is g a and g b .

[0093] Therefore, other working units can receive the slice encryption data of the working unit and the first encryption parameter corresponding to the slice encryption data, and verify the received slice encryption data based on the first encryption parameter.

[0094] Furthermore, a commonly used homomorphic encryption method is to perform the same processing on different data, and then reversely calculate the sum of the different data based on the sum of the processing results of the different data. Similarly, in step S110 of this specification, the work unit can also decrypt the sum of the gradients of each work unit performing the model training task based on this principle.

[0095] Specifically, the working unit may add up the slice encrypted data corresponding to each specified value to obtain the sum of the slice encrypted data corresponding to the specified value.

[0096] Therefore, the work unit can decrypt the sum of the gradients of each work unit that executes the model training task based on the principle of homomorphic encryption according to the sum of the slice encrypted data corresponding to each specified value.

[0097] Taking the existence of work unit 1 and work unit 2 in the training system as an example, it is assumed that the encryption function corresponding to work unit 1 is f1(x) = a1x + a2, and the encryption function corresponding to work unit 2 is f2(x) = b1x + b2, and a2 and b2 are the gradients of work unit 1 and work unit 2 respectively. If the specified values ​​are 1 and 2 respectively, then the sum of the encrypted data of the slices corresponding to the specified value 1 is f1(1) + f2(1) = a1 + b1 + a2 + b2. The sum of the encrypted data of the slices corresponding to the specified value 2 is f1(2) + f2(2) = 2a1 + 2b1 + a2 + b2. Therefore, based on the above-mentioned sum of the encrypted data of the slices corresponding to the specified value 1 and the sum of the encrypted data of the slices corresponding to the specified value 2, the specific value corresponding to the sum of the gradients a2 + b2 of work unit 1 and work unit 2 can be determined. Then, the model training task can be continued based on the sum of the gradients.

[0098] It should be noted that the number of each specified value is no less than the number of work units performing the model training task. This is because only when the encrypted data of the slices corresponding to the number of work units performing the model training task is obtained can the accurate sum of the gradients of each work unit be decrypted. At the same time, if the number of encrypted slices corresponding to the same gradient is too small, the work unit can still decrypt the gradient sum, which will obviously not be secure enough. Therefore, to ensure security, the number of each specified value is set to no less than the number of work units performing the model training task.

[0099] Furthermore, for each working unit, if the sum of the gradients determined by the working unit is inconsistent with the sum of the gradients determined by other working units, there may be a safety hazard in the training system.

[0100] Specifically, for each work unit, the work unit may send a second acquisition request to other work units that perform the model training task, and the second acquisition request is used to obtain the sum of the gradients determined by the other work units.

[0101] The other working units may return the sum of the gradients determined by themselves to the working unit according to the received second acquisition request.

[0102] Therefore, the working unit can determine whether the sum of the gradients received from other working units is consistent with the sum of the gradients determined by itself.

[0103] If they are consistent, the work unit can continue to perform the model training task based on the determined sum of gradients.

[0104] If they are inconsistent, the working unit may send a prompt message indicating that there is a safety hazard in the training system.

[0105] In addition, for security reasons of the training samples stored in the working unit, to avoid the situation where the training system has security risks that cannot be discovered in time and may lead to information leakage, the working unit can also verify the sum of the encrypted data of the slice corresponding to each specified value using the first encryption parameter and the second encryption parameter.

[0106] Specifically, the working unit may determine, for each specified value, the sum of the sliced ​​encrypted data corresponding to the specified value.

[0107] The working unit may then verify the sum of the slice encrypted data corresponding to the specified value based on the first encryption parameter and the second encryption parameter.

[0108] Finally, if the sum of the encrypted data of the slices corresponding to each specified value is verified, the work unit decrypts the sum of the gradient of the work unit and the gradients of other work units based on the sum of the encrypted data of the slices corresponding to each specified value.

[0109] If any verification result is failed, the working unit may send a prompt message indicating that there is a safety hazard in the training system.

[0110] Furthermore, in this specification, each work unit may only receive the encrypted slice data corresponding to the target value of the work unit. The work unit is used to complete the aggregation of the encrypted slice data corresponding to the target value of the work unit. That is, the work unit is used to determine the sum of the encrypted slice data corresponding to the target value of the work unit.

[0111] Therefore, the work unit can also receive the sum of the encrypted slice data corresponding to the target value of the other work unit sent by the other work unit, and determine the sum of the encrypted slice data corresponding to each specified value based on the received sum of the encrypted slice data corresponding to the target value of the other work unit.

[0112] It should be noted that all actions of obtaining signals, information or data in this manual are performed in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.

[0113] Based on the same idea, this specification also provides a model training device, as shown in Figure 2.

[0114] Figure 2 shows a model training device provided in this specification. The device is applied to a model training system. The training system includes several working units, each of which stores different training samples. Among them, a gradient determination module 200 is used to determine the gradient for each working unit in response to a model training task based on the training samples stored in the working unit itself.

[0115] The function determination module 202 is configured to determine the encryption function corresponding to the work unit using the gradient as a parameter of the encryption function.

[0116] The slice determination module 204 is used to determine, for each specified value, the slice encrypted data whose gradient corresponds to the specified value according to the specified value and the encryption function, as the first encrypted data, wherein the number of each specified value is not less than the number of working units that perform the model training task.

[0117] The receiving module 206 is configured to receive, from other working units, slice encrypted data of the gradient of the other working units corresponding to the specified value as second encrypted data.

[0118] The execution module 208 is used to determine the sum of the gradients of the other work units and the gradient of the work unit based on the sliced ​​encrypted data corresponding to each specified value, and execute the model training task based on the sum of the gradients.

[0119] Optionally, the function determination module 202 is used to determine the parameters required to generate the encryption function based on the preset encryption function paradigm and the gradient, and determine the encryption function with the gradient as a parameter based on the parameters as the encryption function corresponding to the working unit.

[0120] Optionally, before decrypting the sliced ​​encrypted data corresponding to each specified numerical value to obtain the sum of the gradients of the other working units and the gradient of the working unit, the receiving module 206 is used to encrypt the parameters in the encryption function, determine the first encryption parameter, broadcast the first encrypted data and the first encryption parameter, and for each second encrypted data, receive the second encryption parameter corresponding to the second encrypted data, the second encryption parameter and the first encryption parameter are encrypted in the same way, the second encryption parameter is sent by the working unit that sends the second encrypted data, and based on the second encryption parameter, it is determined that the second encrypted data has been verified.

[0121] Optionally, the execution module 208 is used to determine the sum of the encrypted data of each slice corresponding to each specified value, and decrypt the gradient of the other working units and the sum of the gradient of the working unit according to the sum of the encrypted data of the slices corresponding to each specified value.

[0122] Optionally, the execution module 208 is used to adjust the model parameters of the working unit according to the sum of the gradients, redetermine the gradients according to the adjusted model parameters and the training samples stored in the working unit itself, redetermine the first encrypted data according to the redetermined gradients, and continue to determine the sum of the gradients of each working unit that executes the model training task according to the redetermined first encrypted data until the iteration termination condition is reached.

[0123] Optionally, the execution module 208 is used to receive the sum of the gradients decrypted by other working units and sent by other working units, and determine whether the sum of the gradients decrypted by the working unit itself is consistent with the sum of the gradients decrypted by the other working units. If so, execute the model training task; if not, send a prompt message indicating that there is a security risk in the training system.

[0124] Optionally, the execution module 208 is used to verify the sum of the slice encrypted data corresponding to each specified numerical value according to the first encryption parameter and the second encryption parameter. When the sum of the slice encrypted data corresponding to each specified numerical value is verified, the sum of the gradients of the other working units and the gradient of the working unit is decrypted according to the sum of the slice encrypted data corresponding to each specified numerical value.

[0125] This specification also provides a computer-readable storage medium, which stores a computer program. The computer program can be used to execute the model training method provided in Figure 1 above.

[0126] This specification also provides a schematic structural diagram of the electronic device shown in Figure 3. As shown in Figure 3, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory and a non-volatile memory, and of course may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the model training method described in Figure 1 above. Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit application container, but can also be hardware or logic devices.

[0127] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages ​​and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.

[0128] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.

[0129] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or physical devices, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0130] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0131] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0132] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0133] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0134] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0135] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0136] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0137] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0138] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0139] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Thus, this specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0140] This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.

[0141] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.

[0142] The foregoing is merely an example of the present invention and is not intended to limit the present invention. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.

Claims

1. A model training method, the method is applied to a training system, the training system includes a plurality of working units, each working unit stores different training samples, the method include: For each work unit, in response to the model training task, a gradient is determined based on the training samples stored in the work unit itself; Determine the encryption function corresponding to the work unit by taking the gradient as a parameter of the encryption function; For each designated value, according to the designated value and the encryption function, determine the sliced ​​encrypted data of the gradient corresponding to the designated value as the first encrypted data, wherein the number of the designated values ​​is not less than the number of working units executing the model training task; receiving encrypted data of slices of the other working units, in which the gradients of the other working units correspond to the specified value, sent by the other working units, as second encrypted data; According to the sliced ​​encrypted data corresponding to each specified value, the gradient of the other working units and the sum of the gradient of the working unit are decrypted, and the model training task is executed according to the sum of the gradients.

2. The method according to claim 1, wherein the encryption function corresponding to the work unit is determined according to the gradient and the gradient is used as a parameter of the encryption function, specifically: include: Determining parameters required to generate an encryption function according to a preset encryption function paradigm and the gradient; According to the parameters, an encryption function with the gradient as a parameter is determined as the encryption function corresponding to the work unit.

3. The method according to claim 1, before decrypting the encrypted data of the slices corresponding to the specified values ​​to obtain the sum of the gradients of the other working units and the gradient of the working unit, the method further include: Encrypting each parameter in the encryption function, determining a first encryption parameter, and broadcasting the first encrypted data and the first encryption parameter; For each second encrypted data, receiving a second encryption parameter corresponding to the second encrypted data, where the second encryption parameter is encrypted in the same manner as the first encryption parameter, and the second encryption parameter is sent by a working unit that sends the second encrypted data; According to the second encryption parameter, it is determined that the second encrypted data has passed verification.

4. The method according to claim 1, wherein the slice encrypted data corresponding to each specified value is decrypted to obtain the sum of the gradient of the other working unit and the gradient of the working unit, specifically: include: For each specified value, determine the sum of the encrypted data of each slice corresponding to the specified value; According to the sum of the slice encrypted data corresponding to each specified value, the sum of the gradient of the other working unit and the gradient of the working unit is decrypted.

5. The method according to claim 1, performing the model training task according to the sum of the gradients, specifically include: Adjusting the model parameters of the working unit according to the sum of the gradients; The gradient is redetermined according to the adjusted model parameters and the training samples stored in the working unit itself, and the first encrypted data is redetermined according to the redetermined gradient, and the sum of the gradients of each working unit that executes the model training task continues to be determined according to the redetermined first encrypted data until the iteration termination condition is reached.

6. The method according to claim 1, wherein before executing the model training task according to the sum of the gradients, the method further comprises: include: Receive the sum of gradients decrypted by other working units and sent by other working units; Determine whether the sum of the gradients obtained by decryption of the working unit itself is consistent with the sum of the gradients obtained by decryption of the other working units; If yes, execute the model training task; If not, a prompt message is sent to indicate that the training system has potential safety hazards.

7. The method according to claim 3, wherein the gradient of the other working unit and the gradient of the working unit are decrypted according to the slice encrypted data corresponding to each specified value, and the gradient of the other working unit and the gradient of the working unit are decrypted. include: For each specified value, verifying the sum of the slice encrypted data corresponding to the specified value according to the first encryption parameter and the second encryption parameter; When the sum of the encrypted data of the slices corresponding to each specified value is verified, the sum of the gradients of the other working units and the gradient of the working unit is decrypted according to the sum of the encrypted data of the slices corresponding to each specified value.

8. A model training device, the device is applied to a model training system, the training system comprises a plurality of working units, each working unit stores a different training sample, the device include: A gradient determination module, for determining a gradient for each work unit in response to a model training task and based on training samples stored in the work unit itself; A function determination module, used to determine the encryption function corresponding to the work unit by taking the gradient as a parameter of the encryption function; A slice determination module, configured to determine, for each designated value, slice encrypted data whose gradient corresponds to the designated value according to the designated value and the encryption function, as first encrypted data, wherein the number of designated values ​​is not less than the number of working units that perform the model training task; A receiving module, configured to receive encrypted slice data of the gradient of the other working unit corresponding to the specified value sent by the other working unit as second encrypted data; An execution module is used to determine the other work units according to the slice encryption data corresponding to each specified value. The model training task is performed based on the sum of the gradients and the gradient of the work unit.

9. A computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

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

Citation Information

Patent Citations

  • Model parameter training method and device based on federated learning, equipment and medium

    CN109886417A

  • Model training method based on federated learning

    CN110955907A

  • Federated learning gradient fusion method and device and electronic equipment

    CN110995737A

  • Method and system for updating model parameters based on federated learning

    CN111931950A

  • Federal learning-based model training method, apparatus and device, and medium

    CN114817958A