Model training method, inference method, device, system, apparatus and storage medium
By using homomorphic encryption technology to encrypt the training data and parameters of deep learning models, the security issues of data during transmission and computation are solved, and the security protection of data and model parameters is achieved.
Patent Information
- Application Number
- CN202310297930.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-24
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-03-24
AI Technical Summary
During the training and deployment of existing deep learning models, data is at risk of being stolen and model parameters are stolen during transmission and computation. Traditional encryption technologies cannot effectively protect data security.
Homomorphic encryption technology is used to encrypt training data and model parameters, and data processing and calculation are performed through ciphertext space to ensure the security of data and model parameters during training and deployment.
It effectively eliminates the possibility of data theft attacks, reduces the risk of model parameters being stolen, and improves data security and protection of the computation process.
Smart Images

Figure CN116011552B_ABST
Abstract
Description
Technical Field
[0001] This application relates to, but is not limited to, the field of deep learning technology, and in particular to a model training method, inference method, apparatus, system, device, and storage medium. Background Technology
[0002] Deep learning is a popular machine learning paradigm. Deep learning models have been applied to a large number of productive machine learning systems.
[0003] The training and deployment of deep learning models typically involves the following processes: data acquisition; data storage and preprocessing; model training; model optimization and deployment preparation; and model deployment to the deployment platform. Deep learning models face the risk of data theft during training and inference. Furthermore, the trained model parameters are also at risk of being stolen on the deployment platform. Therefore, current deep learning data platforms face numerous data risks.
[0004] Traditional symmetric encryption technology can only encrypt training and inference data and model parameter data. Because it encrypts the communication process and storage system, it cannot guarantee the security of data during the data calculation process, such as model training, model inference, and model optimization. Summary of the Invention
[0005] In view of the above, embodiments of this application provide at least one model training method, inference method, apparatus, system, device, and storage medium.
[0006] The technical solution of this application embodiment is implemented as follows: In a first aspect, embodiments of this application provide a model training method, the method comprising: Acquire encrypted training data; wherein the encrypted training data is obtained by homomorphically encrypting the collected plaintext data; use the encrypted training data to train the model to obtain a first set of model parameters for the target learning model; deploy the target learning model to the model deployment platform based on the first set of model parameters.
[0007] Secondly, embodiments of this application provide a model reasoning method, the method comprising: Receive a user's inference request; wherein the inference request carries ciphertext inference data encrypted using a second public key; predict the ciphertext inference data using a trained target learning model to obtain a ciphertext inference result; wherein the target learning model is obtained using the model training method described in the first aspect.
[0008] Thirdly, embodiments of this application provide a model training apparatus, the apparatus comprising: An acquisition module is used to acquire ciphertext training data; wherein the ciphertext training data is obtained by homomorphically encrypting the collected plaintext data; The training module is used to train the model using the encrypted training data to obtain the first set of model parameters for the target learning model. The deployment module is used to deploy the target learning model to the model deployment platform based on the first set of model parameters.
[0009] Fourthly, embodiments of this application provide a model inference apparatus, the apparatus comprising: A receiving module is used to receive a user's inference request; wherein the inference request carries ciphertext inference data encrypted using a second public key; The inference module is used to predict the ciphertext inference data using a trained target learning model to obtain the ciphertext inference result; wherein the target learning model is obtained using the model training method described in the first aspect.
[0010] Fifthly, embodiments of this application provide a model service deployment system, including a data storage center and a model deployment platform, wherein: The data storage center is used to acquire encrypted training data; wherein, the encrypted training data is obtained by homomorphically encrypting the collected plaintext data; the encrypted training data is used to train the model to obtain a first set of model parameters for the target learning model; and the target learning model is deployed to the model deployment platform based on the first set of model parameters. The model deployment platform is used to receive inference requests from users; wherein the inference request carries ciphertext inference data encrypted using a second public key; and the ciphertext inference result is obtained by predicting the ciphertext inference data through a trained target learning model.
[0011] In a sixth aspect, embodiments of this application provide a computer device, including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements some or all of the steps in the method of the first aspect described above; or it implements some or all of the steps in the method of the second aspect described above.
[0012] In a seventh aspect, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements some or all of the steps in the method of the first aspect described above; or implements some or all of the steps in the method of the second aspect described above.
[0013] In this embodiment, homomorphically encrypted ciphertext training data is first acquired; then, the ciphertext training data is used for model training in a data storage center to obtain the first set of model parameters for the target learning model; finally, the target learning model is deployed to a model deployment platform based on the first set of model parameters. Thus, by using homomorphic encryption technology to encrypt the data acquisition process, model training process, and other computational processes, and deploying the target learning model to the model deployment platform based on the first set of model parameters identified by the ciphertext space, the security of computational data and model parameters can be guaranteed. This eliminates the possibility of data theft attacks during training and reduces the risk of model parameters being stolen from the system storing the model parameters.
[0014] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of this disclosure. Attached Figure Description
[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the technical solutions of this application.
[0016] Figure 1 A schematic diagram illustrating the training and deployment process of deep learning models for related technologies; Figure 2 A schematic diagram of an encrypted deep learning training and deployment system provided for related technologies; Figure 3 A schematic diagram of an optional process for a model training method provided in an embodiment of this application; Figure 4 A schematic diagram of an optional process for the model inference method provided in an embodiment of this application; Figure 5 A schematic diagram of the model service deployment system provided in this application embodiment; Figure 6A A schematic diagram illustrating the training and deployment method of the deep learning model provided in the embodiments of this application; Figure 6B A logical flowchart illustrating the training and deployment method of the deep learning model provided in the embodiments of this application; Figure 7 This is a schematic diagram of the composition structure of a model training device provided in an embodiment of this application; Figure 8 This is a schematic diagram of the composition structure of a model inference device provided in an embodiment of this application; Figure 9 This is a schematic diagram of the hardware entity of a computer device provided in an embodiment of this application. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application are further described in detail below with reference to the accompanying drawings and embodiments. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0018] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0019] The terms “first / second / third” are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that “first / second / third” may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used herein is for descriptive purposes only and is not intended to limit the scope of this application.
[0021] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.
[0022] Deep learning is a popular machine learning paradigm. Deep learning models have been applied to numerous production-ready machine learning systems. The training and deployment process of a deep learning model typically involves the following steps: data acquisition; data storage and preprocessing; model training; model optimization and deployment preparation; and model deployment for the deployment platform. Figure 1 A schematic diagram illustrating the training and deployment process of deep learning models for related technologies, such as... Figure 1As shown, the plaintext data 101 collected in data acquisition 11 is stored in data storage center 12. Model training 13 then retrieves the plaintext data 101 from data storage center 12 for training, obtaining plaintext model parameters 102. Model optimization 14 further optimizes the parameters of the model trained in the previous process, obtaining new plaintext model parameters 103, which are then stored in the cloud / edge model deployment platform 15. Subsequently, model inference can be performed using plaintext inference data 104 sent by the user. This scheme carries the risk of privacy data theft during data transmission from data acquisition 11 to data storage center 12 and during the retrieval of plaintext data 101 from data storage center 12. Simultaneously, the cloud / edge model deployment platform 15 also faces the risk of model asset theft and privacy data theft.
[0023] It's important to note that there are two key data types throughout the production process: one is training and inference data, typically structured or unstructured data such as images, text, and audio; the other is model parameter data, usually a set of tensors represented by floating-point or integer numbers, recording the model parameters required by the deep learning model. Both types of data are stored and exchanged in plaintext throughout the entire production process.
[0024] The training and deployment process of deep learning models raises several risks. Firstly, during training, this data is vulnerable to theft. Attackers could intercept data transmission from the data acquisition module to the data storage center or directly steal data from the data storage center. Secondly, during model inference on the deployment platform, this data is also at risk of theft. Thirdly, on the deployment platform, this data is vulnerable to model theft. Attackers could steal commercially valuable model parameter data from the deployment platform. Therefore, current deep learning data platforms face numerous data risks.
[0025] Deep learning systems often need to process training and inference data containing personal, private, or confidential information, and commercially valuable model data also has high protection value. Therefore, data security protection is a crucial function of deep learning training and deployment systems. Currently, the main protection scheme involves encrypting both types of data. Encryption uses traditional symmetric encryption algorithms, such as AES-256-bit and AES-128-bit. The encryption algorithm typically uses a securely stored key to encrypt both types of data. The encrypted deep learning training and deployment system is shown below. Figure 2As shown, after the raw data is collected in the data acquisition section 21, it is encrypted by the encryption module 22 of the symmetric encryption algorithm to obtain ciphertext data 201, which is then stored in the data storage center 23. When needed, the ciphertext data 201 is retrieved from the data storage center 23 and sent to the decryption module 24 of the symmetric encryption algorithm for decryption. The decrypted data is then used in the model training section 25 to train the model and obtain plaintext model parameters 202. After parameter optimization in the model optimization section 26, the parameters are encrypted again by the encryption module 27 of the symmetric encryption algorithm. The encrypted optimized model parameters are then transmitted to the plaintext space through the encrypted model transmission section 28. After being decrypted by the decryption module 29 of the symmetric encryption algorithm, the plaintext optimized model parameters are obtained and stored in the cloud / edge model deployment platform 30 for subsequent model inference when plaintext inference data 203 from the user is received. In other words, the data storage and data transmission processes are all in the ciphertext space, while other processes are in the plaintext space.
[0026] This scheme can encrypt both types of data. However, traditional encryption technologies can only encrypt the communication process and storage system, thus only eliminating the risk of data theft due to interception when Type I data is transmitted to the data storage center or deployment platform, and the risk of model theft when Type II data is transmitted from the data storage center to the deployment platform. In computational processes... Figure 2 The system still requires decrypting all data and returning the first and second types of data to the plaintext space for use. These processes include 1) model training; 2) model optimization; and 3) model inference. Model training and optimization are performed in the data storage center, while model inference is performed on the deployment platform. Because the data is represented in plaintext during these processes, it remains vulnerable to data theft. Traditional symmetric encryption techniques cannot provide data security protection for these processes.
[0027] This application provides a model training method that can be executed by a processor of a computer device. The computer device refers to a device with model training capabilities, such as a server, laptop, tablet, desktop computer, smart TV, set-top box, or mobile device (e.g., mobile phone, portable video player, personal digital assistant, dedicated messaging device, portable gaming device). Figure 3 A schematic diagram of an optional process for the model training method provided in the embodiments of this application is shown below. Figure 3 As shown, the method includes the following steps S310 to S330: Step S310: Obtain encrypted training data.
[0028] Here, the encrypted training data is obtained by homomorphically encrypting the collected plaintext data. In some embodiments, the encrypted training data is stored directly in the model training device. In other embodiments, the encrypted training data is pre-stored in a data storage center. In the data storage center, the encrypted training data can be represented as a series of floating-point numbers, typically including the data itself and a data label.
[0029] This application embodiment first applies homomorphic encryption protection to the data acquisition process, saving the acquired plaintext data in ciphertext form. Simultaneously, the key pair used in the encryption process is stored separately in a trusted data center storage system.
[0030] In practice, plaintext data acquisition devices can be used to acquire data and obtain plaintext data for training models. Appropriate model training data is acquired according to the task type of the model to be trained. The data acquisition device can be a camera, vehicle camera, visual robot, etc., but this application embodiment does not limit it.
[0031] It should be noted that homomorphic encryption refers to homomorphically encrypting the original data, performing specific operations on the resulting ciphertext, and then homomorphically decrypting the result to obtain plaintext, which is equivalent to the data result obtained by directly performing the same operations on the original plaintext data.
[0032] Unlike conventional encryption schemes that focus on data storage security, homomorphic encryption focuses on data processing security. Homomorphic encryption provides the ability to process encrypted data. This means that others can process the encrypted data without revealing any of the original content. Decryption after processing yields the same result as the original data. In some implementations, a key pair, including a public key and a private key, can be generated based on a random number seed. The public key is used to encrypt plaintext data, and the private key is used to decrypt the encrypted ciphertext data.
[0033] Step S320: Use the encrypted training data to train the model to obtain the first set of model parameters for the target learning model.
[0034] Here, the model training process can be decomposed into a series of algebraic operations, allowing deep learning model training to be performed directly within the ciphertext space. The training result is the target learning model represented by the first set of model parameters, which are also in ciphertext form. For a deep learning model with N layers, the first set of model parameters includes the model parameters of each layer in the N layers, and each model parameter can be represented as a series of floating-point numbers.
[0035] Therefore, the possibility of data theft attacks is eliminated during the training process, and the risk of the model parameters being stolen from the system storing the model parameters is also avoided.
[0036] In practice, the parameters of each layer of the deep learning model to be trained are initialized, and the parameters of at least one layer are encrypted using the same public key as the encrypted training data. The encrypted training data is then input into the deep learning model to be trained, and the model is run layer by layer. After obtaining the prediction result of the final output of the model, the learning loss is calculated with the data label encrypted with the same public key. The gradient of the parameters of each layer is calculated using the backpropagation algorithm, and the parameters are updated through the gradient until the training process ends, and the first set of trained model parameters is obtained.
[0037] Step S330: Deploy the target learning model to the model deployment platform based on the first set of model parameters.
[0038] Here, the model deployment platform is a cloud platform or edge platform, used to deploy a large number of models and the model parameters corresponding to each model. When inference data is received subsequently, the trained target learning model is directly used for inference to obtain the inference result.
[0039] In this embodiment, homomorphically encrypted ciphertext training data is first acquired; then, the ciphertext training data is used for model training in a data storage center to obtain the first set of model parameters for the target learning model; finally, the target learning model is deployed to a model deployment platform based on the first set of model parameters. Thus, by using homomorphic encryption technology to encrypt the data acquisition process, model training process, and other computational processes, and deploying the target learning model to the model deployment platform based on the first set of model parameters identified by the ciphertext space, the security of computational data and model parameters can be guaranteed. This eliminates the possibility of data theft attacks during training and reduces the risk of model parameters being stolen from the system storing the model parameters.
[0040] In some embodiments, the model training method is applied to a data storage center, where the encrypted training data and the first public key are stored respectively. This ensures that the model training data is stored in encrypted form (ciphertext training data) in the data storage center, eliminating the possibility of data theft attacks during training while reducing the storage and computational burden on the model training device. Simultaneously, the first public key used in encrypting the encrypted training data is stored separately in the data storage center, reducing the risk of data leakage.
[0041] In some embodiments, the encrypted training data is obtained by encrypting the collected plaintext data using a generated first public key; the above step S320 "using the encrypted training data to train the model to obtain the first set of model parameters of the target learning model" may include the following steps S321 to S324: Step S321: The encrypted training data is processed layer by layer by the first neural network to obtain the prediction result of the encrypted training data.
[0042] Here, the model parameters of at least one layer in the first neural network are ciphertext parameters encrypted using the first public key.
[0043] In some implementations, the model parameters of at least one layer in the first neural network are encrypted once using the first public key. At the same time, the ciphertext training data, which encrypts the plaintext data once, is input into the first neural network for layer-by-layer computation, and the output of the last layer is used as the prediction result of the ciphertext training data.
[0044] In some implementations, the model parameters of the i-th layer in the first neural network are encrypted i times using the first public key. Simultaneously, the encrypted training data is input into the first layer for computation. The intermediate output of the first layer is then re-encrypted and input into the second layer for computation, and so on, until the output of the last layer is no longer encrypted and is directly used as the prediction result of the encrypted training data. In other words, the intermediate output of the i-th layer resides in the i-th encryption space.
[0045] Step S322: Determine the learning loss based on the prediction results of the encrypted training data and the initial labels of the encrypted training data.
[0046] Here, the corresponding learning loss is determined according to the type of loss result, such as cross-entropy loss, binary classification loss, multi-class classification loss, etc. The embodiments of this application do not limit the form of the learning loss.
[0047] In some implementations, instead of re-encrypting the intermediate results output from the previous layer layer by layer during the process of obtaining the prediction results of the encrypted training data, the loss value is directly calculated by using the expression of the learning loss on the prediction results and the encrypted initial labels.
[0048] In some implementations, the first neural network comprises an N-layer network; the input data of the i-th layer in the N-layer network is obtained by encrypting the intermediate result of the output of the (i-1)-th layer; where i is any natural number from 2 to N; the initial label of the ciphertext training data is encrypted N times using the first public key to obtain the target label; the learning loss is determined based on the prediction result of the ciphertext training data and the target label. The reason for re-encrypting the output of each layer here is to control the noise level in the homomorphic encryption algorithm to prevent situations where decryption is impossible.
[0049] Step S323: Update the model parameters of each layer in the first neural network using the learning loss.
[0050] In some implementations, updating the model parameters of each layer in the first neural network using the learning loss includes: determining the gradient value of the learning loss with respect to the model parameters of each layer in the first neural network; and updating the model parameters of the same layer based on the gradient values of the model parameters of each layer. In this way, updating the model parameters of the same layer can be achieved by calculating the gradient of the parameters of each layer using the backpropagation algorithm and performing gradient descent, enabling the model to converge quickly and complete the training process.
[0051] In some implementations, determining the gradient value of the learning loss with respect to the model parameters of each layer in the first neural network includes: determining the input partial derivative of the i-th layer based on the partial derivative of the output data of the i-th layer and the i-th ciphertext parameter; wherein the partial derivative of the output data of the N-th layer is the derivative of the learning loss; encrypting the corresponding first private key using the first public key to obtain private key ciphertext; decrypting the input partial derivative of the i-th layer using the private key ciphertext to obtain the partial derivative of the output data of the (i-1)-th layer; and determining the gradient value of the model parameters of the (i-1)-th layer based on the partial derivative of the output data of the (i-1)-th layer and the ciphertext result of the (i-2)-th layer.
[0052] Here, the ciphertext result of layer i-2 is obtained by encrypting the intermediate result of layer i-2 using the first public key, and is used as the input data for layer i-1. Both the ciphertext result of layer i-2 and the ciphertext parameter of layer i are calculated during the forward operation, and do not need to be calculated again in this step.
[0053] In implementation, the derivative of the learning loss obtained in the previous step is first calculated to obtain the partial derivative of the output data of the Nth layer. Then, the input partial derivative of the Nth layer is determined by combining the Nth ciphertext parameters. The input partial derivative of the Nth layer is decrypted using the encrypted first private key to obtain the partial derivative of the output data of the (N-1)th layer. This process is repeated until the partial derivative of the output data of the 2nd layer is calculated. At the same time, after calculating the partial derivative of the output data of the current layer, the gradient value of the model parameters of the current layer is calculated by combining the ciphertext result of the previous layer. This allows for the descent adjustment of the model parameters of the current layer.
[0054] It should be noted that the decryption steps in this section are performed using a trusted computing platform to ensure that no plaintext data is generated during the entire model training process.
[0055] Step S324: Under the condition that the preset training stopping condition is met, the first set of model parameters of the target learning model is obtained.
[0056] Here, the preset training stopping conditions include, but are not limited to, the number of iterations reaching a preset number, the training time meeting a preset duration, or the loss value being lower than a preset threshold. The preset number of iterations is an empirical value, such as 300,000 or 50 million iterations. That is, the process of repeating steps S321 to S323 is repeated until the preset number of iterations is reached, after which the training process is considered complete, and the first set of model parameters for the target learning model is obtained.
[0057] In the above embodiment, ciphertext parameters are obtained by encrypting the model parameters of at least one layer in the first neural network using the public key of the encrypted training data. The ciphertext training data is then input into the first neural network for forward computation to obtain the learning loss. Finally, the backpropagation algorithm is used to update the model parameters of each layer, thus completing the model training process. In this way, a deep learning training and deployment platform built on homomorphic encryption algorithms achieves high security and ease of use. As long as the encrypted private key used for training is not leaked, the trained target learning model and the first set of model parameter data remain in the ciphertext space and will not be leaked.
[0058] In some embodiments, step 321 above can be implemented by steps 3211 to S3215: Step 3211: In the N-layer network, the first layer processes the ciphertext training data to obtain the intermediate result output by the first layer.
[0059] Step 3212: Use the first public key to encrypt the model parameters of the i-th layer in the N-layer network i times to obtain the i-th ciphertext parameter.
[0060] Here, i is a natural number from 2 to N, and the i-th ciphertext parameter is the model parameter of the i-th encryption space. For example, the model parameter of the first layer is encrypted once to obtain the first ciphertext parameter, the model parameter of the second layer is encrypted twice to obtain the second ciphertext parameter, and so on, the model parameter of the N-th layer is encrypted N times to obtain the N-th ciphertext parameter.
[0061] It is worth noting that the first public key is the public key used to encrypt the ciphertext training data. The same public key is used to encrypt the input data of each layer and the model parameters of each layer, so as to realize the deep learning training process based on homomorphic encryption algorithm.
[0062] Step 3213: Use the first public key to encrypt the intermediate result output of the (i-1)th layer in the N-layer network to obtain the ciphertext result of the (i-1)th layer.
[0063] Here, the intermediate result of the output of the (i-1)th layer is in the i-th encryption space. The reason for re-encrypting the output of each layer in this embodiment is to control the noise level in the homomorphic encryption algorithm and prevent the situation where decryption is impossible.
[0064] Step 3214: Determine the intermediate result output by the i-th layer based on the i-th ciphertext parameter and the ciphertext result of the (i-1)-th layer.
[0065] Here, the i-th ciphertext parameter is in the i-th encryption space. The intermediate result of the i-th layer output is also in the i-th encryption space after the ciphertext result of the input i-1 layer is calculated in the i-th layer.
[0066] Step 3215: When iterating layer by layer until i is N, the intermediate result of the Nth layer is used as the prediction result of the ciphertext training data.
[0067] In the above embodiments, the input data of each layer is encrypted using the first public key. Simultaneously, the intermediate output of the current layer is calculated by combining the ciphertext parameters of each layer, and this process is iterated layer by layer until the prediction result of the ciphertext training data is output by the last layer. In this way, the forward computation process, which uses a homomorphic encryption algorithm to achieve layer-by-layer encryption, ensures that the intermediate output of each layer is within the ciphertext space and reduces the risk of decryption failures due to noise.
[0068] In some embodiments, step S320 above can also be implemented as the following process: training the first neural network using the encrypted training data to obtain a second set of model parameters for the initial learning model; optimizing the initial learning model using the second set of model parameters to obtain a first set of model parameters for the target learning model.
[0069] In some embodiments, the model obtained after training is in an encrypted space and can be optimized. Optimization methods include model pruning, model quantization, and model distillation. This application uses model distillation as an example to illustrate the optimization of a multi-layer deep learning model under homomorphic encryption. In other embodiments, commonly used quantization or pruning techniques can also be used to optimize the trained model.
[0070] The above step of "optimizing the initial learning model using the second set of model parameters to obtain the first set of model parameters for the target learning model" can be further implemented through the following steps: constructing a second neural network; wherein the number of model parameters of the second neural network is less than the number of model parameters of the first neural network; predicting the encrypted training data using the initial learning model and the second set of model parameters, and using the prediction result as a new data label; training the second neural network using the encrypted training data and the new data label to obtain the first set of model parameters for the target learning model.
[0071] Here, the number of layers in the second neural network can be the same as that in the first neural network, both being N layers, or it can be less than N layers. When the second neural network has N layers, the number of parameters in each layer is designed to be less than the number of parameters in the corresponding layer of the first neural network.
[0072] In the above embodiments, a second neural network with a small number of model parameters is first designed. The results of the initial learning model, which is obtained through preliminary model training, are used to predict the encrypted training data and are used as new data labels. The second neural network is then trained using the encrypted training data and the new data labels to obtain the first set of model parameters of the optimized target learning model, thereby realizing the optimization of the multi-layer deep learning model under homomorphic encryption.
[0073] Figure 4 The following is a schematic diagram of an optional flowchart of the model inference method provided in the embodiments of this application, such as... Figure 4 As shown, the method includes the following steps S410 to S420: Step S410: Receive the user's inference request; Here, the inference request carries ciphertext inference data encrypted using a second public key; wherein the second public key is a key generated on the user side that can perform homomorphic encryption, and may be the same as or different from the first public key.
[0074] This application embodiment uses a second public key on the user side to encrypt the encrypted inference data, making it impossible to decrypt on the model deployment platform, thus eliminating the risk of theft. Even if the model deployment platform experiences a data breach, the encrypted inference data sent by the user remains safe from theft.
[0075] Step S420: Predict the encrypted inference data using the trained target learning model to obtain the encrypted inference result.
[0076] Here, the target learning model is obtained by training the model using encrypted training data through the data storage center and then deploying it to the model deployment platform; the encrypted training data is obtained by homomorphically encrypting the collected plaintext data.
[0077] It should be noted that during the forward computation process, if the target learning model is run layer by layer for N layers, and the input data of each layer is homomorphically encrypted before being input into the next layer, the resulting ciphertext inference result is in an N-fold encryption space. The inference result in the plaintext space can be obtained by decrypting the ciphertext inference result N times.
[0078] In some implementations, after receiving the encrypted inference data, the parameters of the trained target learning model can be optimized, and the optimized model can be used to predict the encrypted inference data to obtain optimized encrypted inference results. In this way, since the optimized model has fewer model parameters, encrypted inference data can be obtained quickly while reducing computational load.
[0079] In some implementations, after obtaining the encrypted reasoning result, it can also be sent to the user so that the user can decrypt the encrypted reasoning result using the second private key corresponding to the second public key. Thus, since a homomorphic key pair of the second public key and the second private key can be generated on the user's side, the user can directly decrypt the encrypted reasoning data using their own generated key.
[0080] In this embodiment, firstly, encrypted inference data sent by the user using a second public key is received; then, the encrypted inference data is predicted using a trained target learning model to obtain the encrypted inference result. In this way, cloud platform inference of homomorphically encrypted data is achieved using user-side encryption. Even if all data on the cloud platform is leaked, the user inference data still exists in the ciphertext space and cannot be decrypted. Therefore, the user data is still not at risk of being stolen, thereby improving user usability and confidence in the computing security of the cloud platform.
[0081] Figure 5 A schematic diagram of the model service deployment system provided in the embodiments of this application, such as... Figure 5 As shown, the model service deployment system 50 includes: a data storage center 51 and a model deployment platform 52, wherein: The data storage center 51 is used to acquire encrypted training data; wherein, the encrypted training data is obtained by homomorphically encrypting the collected plaintext data; the encrypted training data is used to train the model to obtain a first set of model parameters of the target learning model; and the target learning model is deployed to the model deployment platform based on the first set of model parameters. The model deployment platform 52 is used to receive inference requests from users; wherein the inference request carries ciphertext inference data encrypted using a second public key; and the ciphertext inference result is obtained by predicting the ciphertext inference data through a trained target learning model.
[0082] The model service deployment system provided in this application embodiment builds a deep learning training and deployment platform based on homomorphic encryption algorithms. It trains multi-layer deep learning models using homomorphically encrypted ciphertext training data in the data storage center; and it performs cloud platform inference on the user side by encrypting homomorphically encrypted inference data. This ensures that training data, training results, ciphertext inference data, and ciphertext inference results are all in ciphertext space, and cloud platform staff cannot access any plaintext data. This model service deployment system can defend against the risk of data theft during training, communication, and computation.
[0083] Figure 6A A schematic diagram illustrating the training and deployment method of the deep learning model provided in the embodiments of this application, as shown below. Figure 6A As shown, after the data acquisition section 61 collects the original plaintext data 601, it encrypts the plaintext data 601 using the homomorphic encryption algorithm encryption module 62 to obtain ciphertext data 602, which is then stored in the data storage center 63. When needed, the ciphertext data 602 is retrieved from the data storage center 63 and sent to the model training section 64 for training to obtain the corresponding ciphertext model parameters 603. After parameter optimization by the model optimization section 65, new ciphertext model parameters 604 are obtained and stored in the cloud / edge model deployment platform 66. Subsequently, when a user's inference request 605 carrying plaintext data is received, it is first encrypted using the homomorphic encryption algorithm encryption module 67 to obtain the corresponding ciphertext inference data 606, which is then sent to the cloud / edge model deployment platform 66 for model inference. Afterward, the ciphertext inference result 607 obtained by the inference is decrypted using the homomorphic encryption algorithm decryption module 68 to obtain the plaintext inference result 608.
[0084] In other words, in the embodiments of this application, the data storage process, data transmission process, model training process, model optimization process, and model inference process are all in the ciphertext space. At the same time, the data acquisition process and inference data are homomorphically encrypted in the plaintext space to ensure that the data security performance of the deep learning training and deployment system covers all processes involving data.
[0085] It should be noted that, in implementation, the cloud / edge model deployment platform mentioned above can correspond to the model deployment platform in the aforementioned embodiments, and the user inference data mentioned above can correspond to the user encrypted inference results in the aforementioned embodiments.
[0086] Figure 6B A logical flowchart of the training and deployment method of the deep learning model provided in the embodiments of this application is shown below. Figure 6B As shown, the process includes the following steps S601 to S608: Step S601: Collect data and use homomorphic encryption to obtain ciphertext training data.
[0087] Step S602: The encrypted training data is stored in the data storage center of the cloud platform, and the first public key used for encryption is stored securely and separately.
[0088] Step S603: Obtain the ciphertext training data and train the model in the data storage center. The training result is the second set of model parameters represented in the ciphertext space.
[0089] Step S604: Optimize the parameters of the initial learning model obtained from training to obtain the target learning model in the ciphertext space representation and the first set of model parameters.
[0090] Step S605: Deploy the optimized target learning model and the decrypted first set of model parameters to the cloud / edge model deployment platform.
[0091] Step S606: Receive inference data from the user, generate a key pair on the user side and encrypt it, and send the encrypted inference data to the cloud / edge model deployment platform.
[0092] Here, the key pair may include a second public key and a second private key, wherein the second public key may be the same as the first public key or may be different from the first public key.
[0093] In step S607, the cloud / edge model deployment platform uses the inference data provided by the user to perform inference, obtains the inference result encrypted with the second public key, and returns it to the user.
[0094] In step S608, the user decrypts the reasoning result using the second private key.
[0095] The characteristic of homomorphic encryption algorithms is that algebraic operations can be performed in the ciphertext space. The plaintext result obtained after decryption is the same as the result of performing equivalent algebraic operations on the original data directly in the plaintext space, and this property is transitive.
[0096] Therefore, since the training process of current deep learning models can be decomposed into a series of algebraic operations, deep learning models can be trained directly in encrypted space. The training result is a series of model parameters, all represented in encrypted form. This eliminates the possibility of data theft attacks during training and avoids the risk of the system storing model parameters being attacked and having those parameters stolen.
[0097] The model training process based on the homomorphic encryption algorithm in step S603 above may include the following steps S1 to S7: Step S1: Generate a key pair based on the random number seed x. , The public key (Equivalent to the first public key mentioned above) is used for encryption; the private key... (Equivalent to the first private key mentioned above) is used for decryption.
[0098] Step S2, apply the public key to the input plaintext data m. Encrypt it.
[0099] This process can be expressed as the following formula (1): Formula (1); in, This represents the ciphertext training data corresponding to the plaintext data m. In this embodiment, the encryption process can use the CKKS (Cheon-Kim-Kim-Song) algorithm. m is a series of floating-point numbers representing the training data, which typically includes the input data. and tags The encrypted training data and labels are as follows: and .
[0100] Step S3: For a deep learning model M with N layers, initialize its model parameters p, where p is represented by a series of floating-point numbers. Encrypt the model parameters using the public key to obtain the ciphertext parameters. .
[0101] Step S4, Forward computation: Run the model layer by layer. The execution of the i-th layer can be expressed as the following formula (2): Formula (2); in, It is the intermediate result output by the i-th layer of the model in the i-th encryption space. It is the i-th layer parameter of the model after i-th encryption, i.e., the i-th ciphertext parameter. To utilize public keys The ciphertext result obtained by encrypting the output of the (i-1)th layer. The reason for re-encrypting the output of each layer is to control the noise level in the homomorphic encryption algorithm and prevent situations where decryption is impossible.
[0102] Step S5: Obtain the final prediction result output by the model. The learning loss and its derivative are then calculated according to the following formulas (3) and (4).
[0103] Formula (3); Formula (4); in, For a tag that is encrypted N times, This represents the prediction result output by the Nth layer. The value of the learning loss. The derivative of the learning loss.
[0104] Step S6: Back-calculate the learning loss and the partial derivative function of each layer of the model with respect to the input data. and parameter partial derivatives Next, the backpropagation algorithm is used to calculate the gradients of the model parameters for all layers. In the i-th layer, it is necessary to calculate the partial derivatives of the input data, the model parameters of the i-th layer (i.e., the i-th ciphertext parameters), and the partial derivatives of the output data.
[0105] Formula (6); Formula (7); Here, function D represents the decryption process, and function E represents the encryption process. To use public key Encrypted private key , This represents the partial derivative of the input data at layer i, calculated using the partial derivatives of the ciphertext parameters at layer i and the output data at layer i. Decrypting this partial derivative using the encrypted private key yields the partial derivative of the input data at layer i-1 in the encryption space. This is the partial derivative of the output data of the (i-1)th layer. For the first layer i=1, there is no need to calculate this. .
[0106] To utilize public keys The ciphertext result obtained by encrypting the output of the (i-1)th layer. The partial derivative of the output data of the i-th layer. Let be the partial derivative of the i-th ciphertext parameter, i.e., the gradient.
[0107] It is worth noting that in this step With the i-th ciphertext parameter The computation has already been performed in the forward pass and does not need to be repeated. Some decryption steps in this process need to be executed using a trusted computing platform to ensure that no plaintext data is generated.
[0108] Step S7: Repeat steps S4 to S6 S times to complete the training process and obtain a series of model parameters. The parameters of the i-th layer are located in the i-th encryption space.
[0109] The model obtained after training is in an encrypted space and can be optimized. The model optimization part in step S604 above can be implemented through the following process: First, design an N-layer model with fewer parameters than the initial model. For model M Forward computation results As its label, it is trained using the methods described in steps S1 to S7 above. This allows us to obtain a model with a computational cost less than model M. Subsequent model inference uses .
[0110] Model inference requires the use of the optimized model. and inference data First of all, Ciphertext reasoning data was obtained using the homomorphic encryption algorithm CKKS. Using the forward process described in step S4, to As data, model data is obtained. .at this time It is located in an i-fold encrypted space. The decryption result can be obtained by decrypting it N times.
[0111] It should be noted that, in implementation, the cloud / edge model deployment platform can correspond to the model deployment platform in the aforementioned embodiments, and the user inference data can correspond to the user encrypted inference results in the aforementioned embodiments.
[0112] The machine learning training and deployment platform described in this application ensures that training data, training results, user inference data, and user inference results are all stored in an encrypted space, and cloud platform staff cannot access any plaintext data. When partial data leakage occurs on the cloud platform: 1) If the encryption private key used for training is not leaked, the model parameter data remains in the encrypted space and will not be leaked; only the optimized model parameters are at risk of leakage. 2) User inference data is encrypted using the user-side public key and cannot be decrypted on the cloud platform, therefore there is no risk of theft. When all data on the cloud platform is leaked, the user inference data still exists in the encrypted space and cannot be decrypted, therefore there is still no risk of user data being stolen.
[0113] This application's embodiments construct a deep learning training and deployment platform based on homomorphic encryption algorithms. On one hand, it enables training of multi-layer deep learning models with homomorphically encrypted data; on the other hand, it optimizes multi-layer deep learning models under homomorphic encryption. Furthermore, user-side encryption is used to achieve cloud platform inference of homomorphically encrypted data, achieving both high security and ease of use for the machine learning training and deployment platform. This allows users to encrypt inference data using their own generated keys, improving user usability and confidence in the security of cloud platform computing.
[0114] Existing deep learning systems typically encrypt only the data storage process. No encryption measures are implemented for the computation process, leaving model parameters and training / inference data vulnerable to theft during computation. Another approach focuses solely on homomorphically encrypted neural network inference systems. This type of approach neglects the security of the deep learning model training process and training data, thus remaining susceptible to model and training data theft. The embodiments of this application can defend against data theft risks at each stage of the computation process.
[0115] Based on the foregoing embodiments, this application provides a model training device, which includes the included modules, as well as the sub-modules and units included in each module. It can be implemented by a processor in a computer device; of course, it can also be implemented by specific logic circuits. In the implementation process, the processor can be a central processing unit (CPU), a microprocessor unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.
[0116] Figure 7 This is a schematic diagram of the composition structure of a model training device provided in an embodiment of this application, as shown below. Figure 7 As shown, the model training device 700 includes: an acquisition module 710, a training module 720, and a deployment module 730, wherein: The acquisition module 710 is used to acquire ciphertext training data; wherein, the ciphertext training data is obtained by homomorphically encrypting the collected plaintext data; The training module 720 is used to train the model using the encrypted training data to obtain the first set of model parameters of the target learning model. The deployment module 730 is used to deploy the target learning model to the model deployment platform based on the first set of model parameters.
[0117] In some possible embodiments, the encrypted training data is obtained by encrypting the collected plaintext data using a generated first public key; the training module 720 includes: a first prediction submodule, which processes the encrypted training data layer by layer through a first neural network to obtain a prediction result for the encrypted training data; wherein, the model parameters of at least one layer in the first neural network are encrypted parameters encrypted using the first public key; a first determination submodule, which determines the learning loss based on the prediction result of the encrypted training data and the initial label of the encrypted training data; an update submodule, which updates the model parameters of each layer in the first neural network using the learning loss; and a second determination submodule, which obtains a first set of model parameters of the target learning model when a preset training stopping condition is met.
[0118] In some possible embodiments, the first neural network includes an N-layer network; the input data of the i-th layer in the N-layer network is obtained by encrypting the intermediate result of the output of the (i-1)-th layer; where i is any natural number from 2 to N; the first determining submodule includes: a first encryption unit, used to encrypt the initial label of the ciphertext training data N times using the first public key to obtain the target label; and a first determining unit, used to determine the learning loss based on the prediction result of the ciphertext training data and the target label.
[0119] In some possible embodiments, the prediction submodule includes: a processing unit, configured to process the ciphertext training data at the first layer of the N-layer network to obtain an intermediate result output by the first layer; a second encryption unit, configured to encrypt the model parameters of the i-th layer of the N-layer network i times using a first public key to obtain the i-th ciphertext parameter; a third encryption unit, configured to encrypt the intermediate result output by the (i-1)-th layer of the N-layer network using the first public key to obtain the ciphertext result of the (i-1)-th layer; a second determination unit, configured to determine the intermediate result output by the i-th layer based on the i-th ciphertext parameter and the ciphertext result of the (i-1)-th layer; and a third determination unit, configured to use the intermediate result of the N-th layer as the prediction result of the ciphertext training data when iterating layer by layer until i is N.
[0120] In some possible embodiments, the update submodule includes: a fourth determining unit, configured to determine the gradient value of the learning loss with respect to the model parameters of each layer in the first neural network; and a parameter updating unit, configured to update the model parameters of the same layer according to the gradient value of the model parameters of each layer.
[0121] In some possible embodiments, the fourth determining unit is further configured to determine the input partial derivative result of the i-th layer based on the partial derivative of the output data of the i-th layer and the i-th ciphertext parameter; wherein the partial derivative of the output data of the N-th layer is the derivative of the learning loss; encrypt the corresponding first private key using the first public key to obtain private key ciphertext; decrypt the input partial derivative result of the i-th layer using the private key ciphertext to obtain the partial derivative of the output data of the (i-1)-th layer; and determine the gradient value of the model parameter of the (i-1)-th layer based on the partial derivative of the output data of the (i-1)-th layer and the ciphertext result of the (i-2)-th layer.
[0122] In some possible embodiments, the training module 720 includes: a training submodule, used to train the first neural network using the encrypted training data to obtain a second set of model parameters for an initial learning model; and an optimization submodule, used to optimize the initial learning model using the second set of model parameters to obtain a first set of model parameters for the target learning model.
[0123] In some possible embodiments, the optimization submodule includes: a construction unit for constructing a second neural network; wherein the number of model parameters of the second neural network is less than the number of model parameters of the first neural network; a prediction unit for predicting the ciphertext training data using the initial learning model and the second set of model parameters, and using the prediction result as a new data label; and a training unit for training the second neural network using the ciphertext training data and the new data label to obtain a first set of model parameters of the target learning model.
[0124] In some embodiments, the model training apparatus is applied to a data storage center, and the encrypted training data and the first public key are stored in the data storage center.
[0125] The description of the above device embodiments is similar to the description of the above model training method side embodiments, and has similar beneficial effects as the method embodiments. In some embodiments, the functions or modules included in the device provided in this application can be used to execute the methods described in the above model training method side embodiments. For technical details not disclosed in the device embodiments of this application, please refer to the description of the model training method side embodiments of this application for understanding.
[0126] Based on the foregoing embodiments, this application provides a model inference device, which includes various modules and sub-modules included in each module. It can be implemented by a processor in a computer device; of course, it can also be implemented by specific logic circuits. In the implementation process, the processor can be a central processing unit, a microprocessor, a digital signal processor, or a field-programmable gate array, etc.
[0127] Figure 8 This is a schematic diagram of the composition structure of a model inference training device provided in an embodiment of this application, as shown below. Figure 8 As shown, the model inference device 800 includes: a receiving module 810 and a prediction module 820, wherein: The receiving module 810 is used to receive a user's inference request; wherein the inference request carries ciphertext inference data encrypted using a second public key; The prediction module 820 is used to predict the encrypted inference data using a trained target learning model to obtain the encrypted inference result; wherein, the target learning model is obtained by training the model using encrypted training data in the data storage center and then deploying it to the model deployment platform; the encrypted training data is obtained by homomorphically encrypting the collected plaintext data.
[0128] In some embodiments, the model inference apparatus further includes sending the encrypted inference result to the user so that the user can decrypt the encrypted inference result using the second private key corresponding to the second public key.
[0129] The descriptions of the above device embodiments are similar to those of the above model inference method-side embodiments, and have similar beneficial effects. In some embodiments, the functions or modules included in the device provided in this application can be used to execute the methods described in the above model inference method-side embodiments. For technical details not disclosed in the device embodiments of this application, please refer to the descriptions of the model inference method-side embodiments of this application for understanding.
[0130] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the user through pop-up information or by asking the user to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.
[0131] It should be noted that, in the embodiments of this application, if the above-described model training method or model inference method is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the related technology, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware, software, or firmware, or any combination of hardware, software, and firmware.
[0132] This application provides a computer device including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements some or all of the steps in the above-described method.
[0133] This application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements some or all of the steps in the above-described method. The computer-readable storage medium can be transient or non-transient.
[0134] This application provides a computer program including computer-readable code, wherein when the computer-readable code is executed in a computer device, a processor in the computer device performs some or all of the steps in the above-described method.
[0135] This application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. When the computer program is read and executed by a computer, it implements some or all of the steps in the above-described method. This computer program product can be implemented specifically through hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium; in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.
[0136] It should be noted that the descriptions of the various embodiments above tend to emphasize the differences between them, while their similarities or commonalities can be referred to interchangeably. The descriptions of the above embodiments of the device, storage medium, computer program, and computer program product are similar to the descriptions of the above method embodiments and have similar beneficial effects. For technical details not disclosed in the embodiments of the device, storage medium, computer program, and computer program product of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0137] It should be noted that, Figure 9 This is a schematic diagram of a hardware entity of a computer device in an embodiment of this application, such as... Figure 9 As shown, the hardware entity of the computer device 900 includes: a processor 901, a communication interface 902, and a memory 903, wherein: Processor 901 typically controls the overall operation of computer device 900.
[0138] Communication interface 902 enables computer devices to communicate with other terminals or servers over a network.
[0139] The memory 903 is configured to store instructions and applications executable by the processor 901, and can also cache data to be processed or already processed (e.g., image data, audio data, voice communication data, and video communication data) in the processor 901 and various modules in the computer device 900. It can be implemented using flash memory or random access memory (RAM). Data transfer between the processor 901, the communication interface 902, and the memory 903 can be performed via bus 904.
[0140] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above steps / processes do not imply a sequential order of execution; the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above embodiments of this application are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0141] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0142] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0143] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, the functional units in the embodiments of this application may all be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the integrated unit may be implemented in hardware or in a combination of hardware and software functional units.
[0144] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0145] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, or the part that contributes to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, magnetic disks, or optical disks.
[0146] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A model training method, characterized in that, The method includes: Obtain ciphertext training data; wherein, the ciphertext training data is obtained by homomorphically encrypting the collected plaintext data using the first public key; The first neural network is trained using the encrypted training data to obtain the first set of model parameters for the target learning model; wherein the first neural network comprises an N-layer network, and the initial model parameters of the i-th layer in the N-layer network are encrypted parameters encrypted i times using the first public key; the input data of the first layer in the N-layer network is the encrypted training data, and the input data of the (i+1)-th layer is obtained by encrypting the intermediate results of the output of the i-th layer; i is any natural number from 1 to N; Based on the first set of model parameters, the target learning model is deployed to the model deployment platform; The step of training the model using the encrypted training data to obtain the first set of model parameters for the target learning model includes: The first neural network processes the ciphertext training data layer by layer to obtain the prediction result of the ciphertext training data. The initial label of the encrypted training data is encrypted N times using the first public key to obtain the target label; The learning loss is determined based on the prediction results of the encrypted training data and the target label; The learning loss is used to update the model parameters of each layer in the first neural network; Under the condition that the preset training stopping condition is met, the first set of model parameters of the target learning model is obtained.
2. The method according to claim 1, characterized in that, The step of processing the ciphertext training data layer by layer through the first neural network to obtain the prediction result of the ciphertext training data includes: The model parameters of the i-th layer in the N-layer network are encrypted i times using the first public key to obtain the i-th ciphertext parameter. In the N-layer network, the first layer processes the ciphertext training data to obtain the intermediate result output by the first layer; The intermediate result output from the i-th layer in the N-layer network is encrypted using the first public key to obtain the ciphertext result of the i-th layer. Based on the (i+1)th ciphertext parameter of the (i+1)th layer in the N-layer network and the ciphertext result of the (i)th layer, determine the intermediate result output by the (i+1)th layer; As the iteration continues until i is N-1, the intermediate result output from the Nth layer is used as the prediction result of the ciphertext training data.
3. The method according to claim 2, characterized in that, Updating the model parameters of each layer in the first neural network using the learning loss includes: Determine the gradient value of the learning loss with respect to the model parameters of each layer in the first neural network; The model parameters of the same layer are updated based on the gradient values of the model parameters of each layer.
4. The method according to claim 3, characterized in that, Determining the gradient value of the learning loss with respect to the model parameters of each layer in the first neural network includes: The partial derivative of the output data of the i-th layer and the i-th ciphertext parameter are used to determine the input partial derivative of the i-th layer; wherein, the partial derivative of the output data of the N-th layer is the derivative of the learning loss; The first public key is used to encrypt the corresponding first private key to obtain the private key ciphertext; The partial derivative of the input of the i-th layer is decrypted using the private key ciphertext to obtain the partial derivative of the output data of the (i-1)-th layer. The gradient values of the model parameters of the (i-1)th layer are determined based on the partial derivatives of the output data of the (i-1)th layer and the ciphertext results of the (i-2)th layer.
5. The method according to any one of claims 1 to 4, characterized in that, The step of training the model using the encrypted training data to obtain the first set of model parameters for the target learning model includes: The first neural network is trained using the encrypted training data to obtain a second set of model parameters for the initial learning model. The initial learning model is optimized using the second set of model parameters to obtain the first set of model parameters for the target learning model.
6. The method according to claim 5, characterized in that, The step of optimizing the initial learning model using the second set of model parameters to obtain the first set of model parameters for the target learning model includes: Construct a second neural network; wherein the number of model parameters of the second neural network is less than the number of model parameters of the first neural network; The encrypted training data is predicted using the initial learning model and the second set of model parameters, and the prediction results are used as new data labels. The second neural network is trained using the encrypted training data and the new data labels to obtain the first set of model parameters for the target learning model.
7. The method according to any one of claims 1 to 4, characterized in that, The model training method is applied to a data storage center, where the encrypted training data and the first public key are stored respectively.
8. A model reasoning method, characterized in that, The method includes: Receive a user's inference request; wherein the inference request carries ciphertext inference data encrypted using a second public key; The encrypted reasoning data is predicted by a trained target learning model to obtain the encrypted reasoning result; wherein the target learning model is obtained by the model training method according to any one of claims 1 to 7.
9. The method according to claim 8, characterized in that, The method further includes: The encrypted reasoning result is sent to the user so that the user can decrypt the encrypted reasoning result using the second private key corresponding to the second public key.
10. A model training device, characterized in that, The model training device includes: An acquisition module is used to acquire ciphertext training data; wherein, the ciphertext training data is obtained by homomorphically encrypting the collected plaintext data using a first public key; The training module is used to process the encrypted training data layer by layer through a first neural network to obtain a prediction result for the encrypted training data; to encrypt the initial label of the encrypted training data N times using the first public key to obtain a target label; to determine the learning loss based on the prediction result of the encrypted training data and the target label; to update the model parameters of each layer in the first neural network using the learning loss; and to obtain the first set of model parameters of the target learning model when a preset training stopping condition is met; wherein, the first neural network includes an N-layer network, and the initial model parameters of the i-th layer in the N-layer network are encrypted parameters encrypted i times using the first public key; the input data of the first layer in the N-layer network is the encrypted training data, and the input data of the (i+1)-th layer is obtained by encrypting the intermediate result of the output of the i-th layer; i is any natural number from 1 to N. The deployment module is used to deploy the target learning model to the model deployment platform based on the first set of model parameters.
11. A model reasoning device, characterized in that, The model inference device includes: A receiving module is used to receive a user's inference request; wherein the inference request carries ciphertext inference data encrypted using a second public key; The inference module is used to predict the ciphertext inference data using a trained target learning model to obtain the ciphertext inference result; wherein the target learning model is obtained using the model training method according to any one of claims 1 to 7.
12. A model service deployment system, characterized in that, This includes a data storage center and a model deployment platform, among which: The data storage center is used to acquire encrypted training data; wherein the encrypted training data is obtained by homomorphically encrypting the collected plaintext data using a first public key; the encrypted training data is processed layer by layer by a first neural network to obtain a prediction result for the encrypted training data; the initial label of the encrypted training data is encrypted N times using the first public key to obtain a target label; a learning loss is determined based on the prediction result of the encrypted training data and the target label; the model parameters of each layer in the first neural network are updated using the learning loss; and a first set of model parameters for the target learning model is obtained when a preset training stopping condition is met; wherein the first neural network includes an N-layer network, and the model parameters of the i-th layer in the N-layer network are encrypted parameters encrypted i times using the first public key; the input data of the (i+1)-th layer in the N-layer network is obtained by encrypting the intermediate result of the output of the i-th layer; wherein i is any natural number from 1 to N; and the target learning model is deployed to the model deployment platform based on the first set of model parameters. The model deployment platform is used to receive inference requests from users; wherein the inference request carries ciphertext inference data encrypted using a second public key; and the ciphertext inference result is obtained by predicting the ciphertext inference data through the trained target learning model.
13. A computer device comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 7; or implements the steps of the method according to claim 8 or 9.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 7; or implements the steps of the method according to claim 8 or 9.
