Data processing method, device, equipment and storage medium
The encryption key and decryption key are generated through device identification, and the model parameters are encrypted and decrypted, solving the problem of model leakage and compatibility in the prior art, and improving the security and compatibility of model privatization scenarios.
Patent Information
- Application Number
- CN202411111307.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-08-14
AI Technical Summary
In the existing technology, in the privatization scenario of model, the model encryption method cannot effectively eliminate model information leakage, and is restricted by the inference framework, resulting in low security and compatibility.
By obtaining the device identifier of the target inference device, generating a seed key and performing matrix conversion, the encryption key and decryption key are obtained, and the model parameters are only encrypted to achieve secure transmission and decryption of the model, and avoiding the specific inference framework during model inference. dependency.
It improves security and compatibility in model privatization scenarios, prevents model parameters from being exposed in memory, eliminates the possibility of model parameters being dumped, and supports operations under the ordinary inference framework.
Smart Images

Figure CN118643521B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and more specifically, to a data processing method, device, equipment and storage medium. Background Art
[0002] Model privatization refers to migrating models from the cloud or third-party platforms to local machines to ensure data privacy, security and independence. In industries involving sensitive information such as finance, healthcare and scientific research, privatized models are particularly important. In addition to avoiding the risk of data leakage and unauthorized access, model privatization can adjust the model architecture and optimize performance according to its own needs without relying on the limitations of external platforms.
[0003] When models are privately deployed in a local environment, both physical and network security may become weak links. Illegal personnel may steal model information through network attacks, physical access, or social engineering, which includes not only the structure and parameters of the model, but also the training data and reasoning logic. Once the models are stolen, illegal personnel can use them to engage in unfair competition, create counterfeit products, or directly attack the original system.
[0004] The relevant technology proposes to encrypt the storage and transmission of the model. That is, the weight information and structure information of the model are encrypted and transmitted using an encryption algorithm. When the model reasoning process is started, the weight information and structure information will be transmitted to the memory for decryption. However, this model encryption method cannot effectively prevent the leakage of model information and is limited by the reasoning framework, resulting in low security and compatibility of model protection. Summary of the invention
[0005] The embodiments of the present application provide a data processing method, apparatus, device and storage medium, which can improve the security and compatibility of model protection.
[0006] According to one aspect of the present application, a data processing method is provided, which includes: obtaining a device identifier corresponding to a target reasoning device; generating a seed key based on the device identifier, and performing a first matrix transformation on the seed key to obtain an encryption key; encrypting model parameters of a model to be encrypted according to the encryption key to obtain a target model; sending the target model to the target reasoning device so that the target reasoning device performs computational reasoning on the target model, and decrypts an intermediate reasoning result of the computational reasoning based on a decryption key to obtain a target reasoning result, wherein the decryption key is obtained by converting the seed key through a second matrix, and the decryption key and the encryption key are inverse matrices of each other.
[0007] According to another aspect of the present application, a data processing method is provided, the method comprising: receiving a target model, the target model being obtained by encrypting a model to be encrypted using an encryption key generated corresponding to a device identifier; obtaining a decryption key generated corresponding to the device identifier, the decryption key and the encryption key being inverse matrices of each other; performing computational reasoning on the target model, and decrypting an intermediate reasoning result of the computational reasoning based on the decryption key to obtain a target reasoning result.
[0008] According to another aspect of the present application, a data processing device is provided, which includes: an identification acquisition module, a key generation module, a model encryption module and a model sending model. The identification acquisition module is used to obtain the device identification corresponding to the target reasoning device; the key generation module is used to generate a seed key based on the device identification, and perform a first matrix transformation on the seed key to obtain an encryption key; the model encryption module is used to perform parameter encryption on the model parameters of the model to be encrypted according to the encryption key to obtain a target model; the model sending model is used to send the target model to the target reasoning device, so that the target reasoning device performs computational reasoning on the target model, and decrypts the intermediate reasoning result of the computational reasoning based on the decryption key to obtain the target reasoning result, the decryption key is obtained by converting the seed key through the second matrix, and the decryption key and the encryption key are inverse matrices of each other.
[0009] Optionally, the model encryption module may include: a parameter acquisition unit, a parameter encryption unit, and a model determination unit. The parameter acquisition unit is used to acquire the parameters to be encrypted corresponding to the model to be encrypted; the parameter encryption unit is used to perform parameter encryption on the parameter matrix to be encrypted corresponding to the parameters to be encrypted according to the encryption key to obtain a target parameter matrix; the model determination unit is used to determine the target model based on the target parameter matrix and the calculation operator corresponding to the model to be encrypted.
[0010] Optionally, the parameter encryption unit can be specifically used to: obtain a weight parameter matrix and a bias parameter matrix corresponding to the parameters to be encrypted; perform matrix multiplication operation on the encryption key and the weight parameter matrix to obtain an encrypted weight matrix; perform matrix multiplication operation on the encryption key and the bias parameter matrix to obtain an encrypted bias matrix; and use the encrypted weight matrix and the encrypted bias matrix as target parameter matrices.
[0011] Optionally, the data processing device may further include: a framework type acquisition module, a decryption plug-in generation module, and an inference framework encapsulation module. The framework type acquisition module is used to acquire the framework type of the model inference framework corresponding to the model to be encrypted; the decryption plug-in generation module is used to generate a target decryption plug-in matching the model inference framework based on the framework type; and the inference framework encapsulation module is used to encapsulate the target decryption plug-in with the model inference framework to obtain a target inference framework.
[0012] Optionally, the model sending model can also be specifically used to send the target model and the target reasoning framework to the target reasoning device, so that the target reasoning device performs operational reasoning on the target model through the model reasoning framework, and executes the intermediate reasoning result of the decryption key decryption operational reasoning based on the target decryption plug-in to obtain the target reasoning result.
[0013] Optionally, the key generation module may include a matrix dimension acquisition unit and an encryption key generation unit. The matrix dimension acquisition unit is used to acquire the matrix dimension of the parameter matrix to be encrypted corresponding to the model to be encrypted; the encryption key generation unit is used to perform a first matrix transformation on the seed key according to the matrix dimension, and use the obtained target key matrix matching the matrix dimension as the encryption key.
[0014] Optionally, the encryption key generation unit can be specifically used to: perform a first matrix transformation on the seed key according to the matrix dimension to obtain an intermediate key matrix matching the matrix dimension; when it is detected that the intermediate key matrix is a reversible matrix, use the intermediate key matrix as the encryption key; when it is detected that the intermediate key matrix is not a reversible matrix, return to perform the first matrix transformation on the seed key according to the matrix dimension, and re-detect whether the obtained intermediate key matrix is a reversible matrix, until the intermediate key matrix is a reversible matrix to obtain the encryption key.
[0015] Optionally, the encryption key generation unit can be specifically used to: perform matrix reversible calculation on the intermediate key matrix corresponding to the encryption key to obtain a reversible matrix corresponding to the intermediate key matrix; use the reversible matrix corresponding to the intermediate key matrix as a decryption key, and send the decryption key to the target inference device.
[0016] Optionally, the key generation module may further include a time acquisition unit and a seed key generation unit. The time acquisition unit is used to acquire the first acquisition time corresponding to the device identifier when it is detected that the device identifier corresponding to the target inference device is acquired for the first time; and the seed key generation unit is used to generate a key based on the first acquisition time and the device identifier corresponding to the first acquisition time to obtain a seed key.
[0017] According to another aspect of the present application, a data processing device is provided, which includes: a model receiving module, a key acquisition module, and a model decryption module. The model receiving module is used to receive a target model, wherein the target model is obtained by encrypting a model to be encrypted using an encryption key generated corresponding to a device identifier; the key acquisition module is used to obtain a decryption key generated corresponding to the device identifier, wherein the decryption key and the encryption key are inverse matrices of each other; and the model decryption module is used to perform computational reasoning on the target model, and decrypt the intermediate reasoning result of the computational reasoning based on the decryption key to obtain a target reasoning result.
[0018] Optionally, the model decryption module may include a calculation graph construction unit, an operation reasoning unit, an intermediate decryption unit, and a decryption result transmission unit. The calculation graph construction unit is used to construct a calculation graph based on the calculation operator of the target model; the operation reasoning unit is used to execute each calculation operator in sequence for operation reasoning according to the topological order of the calculation graph; the intermediate decryption unit is used to decrypt the intermediate reasoning result of the operation reasoning of the current calculation operator based on the decryption key after detecting that the current calculation operator calls the model parameter, and obtain the intermediate decryption result; the decryption result transmission unit is used to transmit the intermediate decryption result to the next calculation operator of the current calculation operator for operation reasoning, until the operation reasoning of the calculation graph is completed and the target reasoning result is obtained.
[0019] Optionally, the intermediate decryption unit can be specifically used for: when it is detected that the current computing operator calls the model parameters, obtaining the encrypted weight matrix and encrypted bias matrix corresponding to the model parameters of the current computing operator, and the intermediate reasoning result obtained through computational reasoning; performing matrix multiplication operation on the decryption key and the intermediate reasoning result to obtain the intermediate decryption result.
[0020] Optionally, the model decryption module may also include a framework receiving unit and a decryption reasoning unit. The framework receiving unit is used to receive a target reasoning framework, which is obtained by encapsulating a target decryption plug-in and a model reasoning framework; the decryption reasoning unit is used to perform computational reasoning on the target model through the model reasoning framework, and to perform decryption key decryption computational reasoning based on the target decryption plug-in to obtain a target reasoning result.
[0021] Optionally, the key acquisition module can be specifically used to: generate a seed key based on the device identification, and perform a second matrix transformation on the seed key to obtain an intermediate key matrix; when it is detected that the intermediate key matrix is a reversible matrix, perform a matrix reversible calculation on the intermediate key matrix to obtain a reversible matrix corresponding to the intermediate key matrix; and use the reversible matrix corresponding to the intermediate key matrix as a decryption key.
[0022] According to another aspect of the present application, a computer-readable storage medium is provided, which stores a computer program, wherein the above-mentioned data processing method is executed when the computer program is executed by a processor.
[0023] According to another aspect of the present application, a computer device is provided. The computer device includes a processor and a memory. The memory stores a computer program. When the computer program is called by the processor, the above-mentioned data processing method is executed.
[0024] According to another aspect of the present application, a computer program product is provided, which includes a computer program or instructions, and the computer program or instructions are stored in a storage medium; a processor of a computer device reads the computer program or instructions from the storage medium, and the processor executes the computer program or instructions, so that the computer device executes the above-mentioned data processing method.
[0025] This application can obtain the device identification corresponding to the target reasoning device, and then generate a seed key based on the device identification, and perform a first matrix transformation on the seed key to obtain an encryption key. Furthermore, the model parameters of the model to be encrypted can be encrypted according to the encryption key to obtain the target model. In this way, the encryption of the model to be encrypted is achieved only by encrypting the model parameters. Compared with the encryption method of the model to be encrypted by encrypting the model operator in the related technology, it can avoid the problem of using a specific model reasoning framework during model reasoning due to the encryption of the model operator. When the model is reasoned, the reasoning operation can be completed using the ordinary model reasoning framework, thereby improving the compatibility of model protection in the model privatization scenario.
[0026] Furthermore, the target model is sent to the target reasoning device so that the target reasoning device performs computational reasoning on the target model, and decrypts the intermediate reasoning result of the computational reasoning based on the decryption key to obtain the target reasoning result, wherein the decryption key is obtained by converting the seed key through the second matrix, and the decryption key and the encryption key are inverse matrices of each other. Compared with the related technology, in the process of model reasoning, the unencrypted model parameters are first decrypted, and then the reasoning operation is performed based on the decrypted model parameters. In this application, the decryption key can be directly used to decrypt the reasoning result calculated by the encryption key under the condition that the encryption key and the decryption key are inverse matrices of each other to obtain the decrypted reasoning result. In this way, it is possible to effectively avoid the situation where the model parameters of the model to be encrypted are exposed to the memory due to decryption, thereby eliminating the possibility of the model parameters being dumped from the memory, and effectively improving the security of model protection in the model privatization scenario.
[0027] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0029] Figure 1 A schematic diagram of a system architecture provided in an embodiment of the present application is shown.
[0030] Figure 2 A schematic diagram of system deployment provided in an embodiment of the present application is shown.
[0031] Figure 3 An application scenario diagram of a data processing method provided in an embodiment of the present application is shown.
[0032] Figure 4 An application scenario diagram of another data processing method provided in an embodiment of the present application is shown.
[0033] Figure 5 A flow chart of a data processing method provided in an embodiment of the present application is shown.
[0034] Figure 6 A flow chart of another data processing method provided in an embodiment of the present application is shown.
[0035] Figure 7 A model reasoning decryption flow chart provided in an embodiment of the present application is shown.
[0036] Figure 8 A flow chart of another data processing method provided in an embodiment of the present application is shown.
[0037] Fig. 9 A flow chart for generating an encryption key and a decryption key provided in an embodiment of the present application is shown.
[0038] Fig.10 An encryption schematic diagram of a model parameter encryptor provided in an embodiment of the present application is shown.
[0039] Fig.11 A working schematic diagram of a decryption plug-in provided in an embodiment of the present application is shown.
[0040] Fig.12 This is a working diagram of an independent model reasoning framework provided in an embodiment of the present application.
[0041] Fig.13 It is a computational graph with decrypted operational reasoning provided in an embodiment of the present application.
[0042] Fig.14 It is a module block diagram of a data processing device provided in an embodiment of the present application.
[0043] Fig.15 It is a module block diagram of another data processing device provided in an embodiment of the present application.
[0044] Fig.16 It is a module block diagram of a computer device provided in an embodiment of the present application.
[0045] Fig.17 It is a module block diagram of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The implementation methods described with reference to the drawings are exemplary and are only used to explain the present application, and cannot be understood as limitations on the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.
[0047] In some processes described in the specification, claims and the above drawings, multiple steps appearing in a specific order are included, but it should be clearly understood that these steps may not be executed in the order in which they appear in this document or may be executed in parallel. The step numbers are only used to distinguish different steps, and the numbers themselves do not represent any execution order. In addition, the descriptions such as "first", "second" or "target" in this document are used to distinguish similar objects, and are not necessarily used to describe a specific order, sequence or quantity.
[0048] It is worth noting that in the specific implementation of the present application, related data such as device identification is involved. When the above embodiments of the present application are applied to specific products or technologies, it is necessary to obtain the permission or consent of the object, and the collection, use and processing of the relevant data need to comply with relevant laws, regulations and standards. For example, when the embodiment of the present application needs to obtain the device identification, a separate permission or separate consent for the device identification can be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the separate permission or separate consent, the necessary related data for the normal operation of the embodiment of the present application can be obtained.
[0049] Artificial Intelligence (AI) technology is gradually being applied to all aspects of people's lives, corresponding to various AI model privatization scenarios, such as deploying AI models on many electronic devices, including mobile phones, tablets, cars, and some large servers. In particular, the current large models / large language models (LLM) can be widely used in downstream tasks, and many AI products need to privatize large models. These models require AI manufacturers to invest a lot of manpower and material resources to train.
[0050] If the model is stolen by an illegal user in a privatized scenario, the user can analyze the model structure and deploy the model to their own hardware for retraining or fine-tuning, or even use it directly. This is equivalent to infringing the intellectual property rights of the original model manufacturer and weakening the technical competitiveness of the original model manufacturer. On the other hand, after understanding the true structure of the model, the illegal user can launch a white box attack to cause the model to misjudge or fail. After realizing the risks of model theft, algorithm experts began to explore effective model protection methods.
[0051] At present, the relevant technology uses traditional encryption and decryption algorithms to protect the model, for example, the solution adopted by the CoreML framework. This type of solution is to use encryption algorithms such as symmetric encryption to fully encrypt the model file before deploying the model to the use environment, including fully encrypting the model weights and model operators, and then store the encrypted model in the disk space; when the application starts a model inference process, the model will be transferred to the running memory for decryption. This solution can ensure the security of the model when it is statically stored.
[0052] However, this encryption method has some problems. Model file encryption technology can only ensure that the model file located in the disk space is encrypted. The model protected by model file encryption technology will eventually be decrypted in memory when the model is loaded and run in plain text. Although it exists in memory for a short time, malicious users can still dump the decrypted model information from the memory by attaching a debugger, thereby bypassing this protection mechanism. In addition, the decryption delay of the model file in memory is dozens of times the delay of importing the plain text model into the framework, which affects the inference performance and user experience on the end side.
[0053] In addition, in production environments, high-performance model inference frameworks are usually used, such as TensorFlowServing, Nvidia Triton Inference Server, etc. Model inference frameworks can accelerate model inference. When encrypting model operators, due to the use of complex encryption technology, a dedicated model inference framework is required to perform inference. Therefore, the encrypted model is no longer compatible with existing mature inference acceleration solutions, which limits the actual application of this technology in production.
[0054] In short, the technical solutions for encryption protection of AI models proposed by the relevant technologies have problems of low security and compatibility. In order to solve the above problems, the inventors have proposed the data processing method provided by the embodiment of the present application after research. The following is a description of the system implementation environment and related application scenarios of the above method involved in this application.
[0055] See also Figure 1 , Figure 1 A schematic diagram of a system architecture is shown. The above method provided in the embodiment of the present application can be applied in system 100. System 100 includes a service side and a user side. In the model privatization scenario, the service side can provide a trained neural network model. When the user side needs the service side to provide a model privatization service, the service side can encrypt the trained neural network model and send it to the user side. For example, Figure 1 As shown, the service-side device 120 can obtain training samples 110 through a data acquisition device. According to the application scenario of the model, the training samples 110 can be of different types.
[0056] For example, if the model is used in an image recognition scenario, the training sample 110 may be labeled image data. If the model is used in a generative chat scenario, the training sample 110 may be labeled text data. After acquiring the training sample 110, the data acquisition device may store the training sample 110 in a database, and the service-side device 120 may perform model training on a preset neural network based on the training sample 110 in the database until the preset neural network meets the training end condition, thereby obtaining the trained initial model 101.
[0057] Among them, the training end condition may be: the total loss value of the target loss is less than a preset value, the total loss value of the target loss is within a threshold range, or the number of training times reaches a preset number of times, etc. The initial model 101 may be a deep neural network or a network model composed of multiple neural networks, for example, a large language model. The service-side device 120 may perform parameter encryption corresponding to the initial model 101 based on the encryption key 102 to obtain the target model 103. The encryption key 102 may be generated by the service-side device 120 according to the device identifier of the user-side device 130. The above-mentioned service-side device 120 and user-side device 130 may be computer devices such as servers or terminals.
[0058] The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), blockchains, and big data and artificial intelligence platforms. The terminal can be a smart mobile device, a laptop, a car computer, a desktop computer, etc.
[0059] The user-side device 130 can receive the target model 103 sent by the service-side device 120. Furthermore, the processing module of the user-side device 130 can perform reasoning operations on the target model 103, and decrypt the intermediate reasoning results in the reasoning operation process based on the decryption key 104 to obtain the target reasoning result. Exemplarily, the user-side device 130 can use a model reasoning framework to perform reasoning operations on the target model 103. The model reasoning framework can be encapsulated with a decryption plug-in developed based on the data processing method of the present application. The decryption plug-in can be used to decrypt the intermediate reasoning results in the reasoning operation process according to the decryption key 104 to obtain the decrypted reasoning result. Among them, the decryption key 104 can be generated by the service-side device 120 according to the device identification of the user-side device 130, or it can be generated by the user-side device 130 according to the device identification of the user-side device 130. The encryption key 102 and the decryption key 104 are inverse matrices of each other.
[0060] It should be noted that Figure 1 It is only a schematic diagram of a system architecture provided in the embodiment of the present application. The system architecture and application scenarios described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. Figure 1 The user-side device 130 in the example may also be a server cluster, including a server for training a model, a server for encrypting model parameters, etc., in other cases.
[0061] See also Figure 2 , Figure 2 Schematic diagram of a system deployment is shown. For example, the data processing method provided in the embodiment of the present application can also be deployed in Figure 2 In the system shown, the system includes an inference device 240, the Internet 230, a gateway 220, a server 210, and the like.
[0062] The reasoning device 240 may include a desktop computer, a laptop computer, a personal digital assistant (PDA), a smart phone 240a, a vehicle terminal device 240b, and a server 240c. In addition, it can be a single device or a collection of multiple devices. The reasoning device 240 can communicate with the Internet 230 in a wired or wireless manner to exchange data. For example, the smart phone 240a can communicate with the Internet 230 through a wireless router 250.
[0063] The server 210 refers to a computer system that can provide certain services to the reasoning device 240. Compared with the common reasoning device 240, the server 210 has higher requirements in terms of stability, security, performance, etc. The server 210 can be a high-performance computer in a network platform, a cluster of multiple high-performance computers, a part of a high-performance computer (for example, a virtual machine), a combination of parts of multiple high-performance computers (for example, virtual machines), etc.
[0064] The gateway 220 is also called an internetwork connector or a protocol converter. The gateway realizes network interconnection at the transport layer and is a computer system or device that acts as a converter. The gateway is a translator between two systems that use different communication protocols, data formats or languages, or even completely different architectures. At the same time, the gateway can also provide filtering and security functions. The message sent by the inference device 240 to the server 210 can be transmitted to the corresponding server 210 through the gateway 220. The message sent by the server 210 to the inference device 240 can also be transmitted to the corresponding inference device 240 through the gateway 220.
[0065] As an implementation method, a part of the data processing method can be implemented in the inference device 240, and another part can be implemented in the server 210. Exemplarily, the server 210 can be used as a training device to train an initial model based on a training sample. The server 210 can also be used as an encryption device to encrypt the parameters of the initial model based on an encryption key to obtain a target model. Further, the server 210 can send the target model to the inference device 240, and the inference device 240 can be used as a locally deployed server cluster to perform inference operations on the target model, and decrypt the intermediate inference results in the inference operation process based on the decryption key to obtain the target inference result.
[0066] It should be noted that Figure 2 This is only a schematic diagram of a system deployment provided by the embodiment of the present application. The system deployment scheme described in the embodiment of the present application is only to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided by the embodiment of the present application. For example, the inference device 240 can generally refer to one of multiple devices. This embodiment only refers to Figure 2 The three devices shown in the figure are used as examples. A person skilled in the art will appreciate that, with the evolution of system deployment solutions, the technical solutions provided by the embodiments of the present invention are also applicable to similar technical problems.
[0067] The embodiments of the present application can be applied in various scenarios, such as Figure 3 The privatization model scenario shown, Figure 4 The autonomous driving scenario shown, etc.
[0068] (1) Privatization large model scenario.
[0069] The privatized deployment of large models can ensure that data is processed locally, thereby protecting user privacy and data security. At the same time, large models can be customized according to actual application scenarios to meet the needs of specific industries and enterprises. For example, dialogue communication, content generation, analysis and understanding based on large models can be widely used in various scenarios such as intelligent customer service, intelligent marketing, role-playing, advertising copywriting, product descriptions, script writing, and resume generation. The security of large models in privatized scenarios is a key issue, mainly involving aspects such as model information leakage and prevention of malicious use. The data processing method provided in the embodiment of the present application can be applied in privatized large model scenarios to improve security for privatization.
[0070] The big model application platform developed by the big model service provider can provide enterprises with application paradigms and interface services such as knowledge question and answer in combination with enterprise-specific data, helping enterprises to complete the construction of big model applications faster and more efficiently, and promote the application of big models in enterprise products. In this way, users can experience big model applications by using enterprise products. In order to show the model privatization protection scheme of this application in more detail, in this embodiment, Figure 3 As shown, the system of the entire model privatization protection solution can be divided into the following three parts: a supplier server cluster 810 of a large model service provider, an enterprise server cluster 840 of a large model service enterprise, and a user terminal device 860 of a user.
[0071] The supplier server cluster 810, the enterprise server cluster 840 and the user terminal device 860 communicate with each other through the Internet. The supplier server cluster 810 may include a training server for pre-training and fine-tuning of large models; a storage server for storing trained large models and encrypting the weight parameters of large models; an interface server for providing large model interface services, processing enterprise requests and returning results. The enterprise server cluster 840 may include an inference server for running and inferring large language models; an interaction server for storing enterprise-specific data and inference results and interacting with user terminal devices.
[0072] Exemplarily, the training server of the supplier server cluster 810 pre-trains and fine-tunes the large model, integrates the enterprise-specific data into the model, and generates the fine-tuned model weights, and then the storage server of the supplier server cluster 810 stores the model weights of the fine-tuned large model, and encrypts the model weights using an encryption key to obtain the encrypted target large model. When the inference server of the enterprise server cluster 840 calls the large model API interface to the supplier server cluster 810, the interface server of the supplier server cluster 810 can send the encrypted target large model to the inference server of the enterprise server cluster 840.
[0073] Further, the inference server of the enterprise server cluster 840 can use the target large model for model inference based on the decryption key. Specifically, the large model service enterprise develops a large model application software based on the target large model, for example, a homework tutoring assistant APP. The user can download and install the homework tutoring assistant APP on the user terminal device 860 through the network. When the user uses the homework tutoring assistant APP to answer questions through the user terminal device 860, the user terminal device 860 can send a request instruction to the interactive server of the enterprise server cluster 840. After receiving the request instruction, the interactive server can send the question to be answered in the request instruction to the inference server. Then, the inference server uses the target large model based on the decryption key to infer and answer the question to be answered, and obtains the inference result, that is, the answer to the question. Further, the inference server returns the answer to the question to the interactive server, and the interactive server returns the answer to the user terminal device 860 to display it to the user.
[0074] (2) Autonomous driving scenarios
[0075] Vision big models can capture global and local information in images, thus achieving excellent performance in various computer vision tasks. For example, Vision Transformers (ViT) are used for object detection and recognition, which can detect and classify pedestrians, vehicles, traffic signs and other important elements on the road in real time. By combining this visual information with path planning and control algorithms, intelligent driving systems can make accurate driving decisions, such as automatic lane changes, obstacle avoidance and emergency braking.
[0076] Since computing on the cloud requires a stable network connection, and the vehicle may encounter unstable or interrupted network signals while driving, and autonomous driving requires real-time perception and decision-making of the vehicle's surroundings. This requires that large visual models must run in real time inside the vehicle to ensure low latency and fast response. Deploying the model on the vehicle terminal can avoid delays caused by network transmission and can work normally even without a network connection.
[0077] Therefore, automobile manufacturers need to deploy the large visual model used by the intelligent driving system on the vehicle terminal device. Considering the security issues of model privatization, automobile manufacturers can use the data processing method provided in the embodiment of the present application to protect the large visual model. Figure 4 As shown, the server 910 of the automobile manufacturer and the vehicle-mounted terminal device 940 of the vehicle communicate through the network. The server 910 can obtain the trained initial model through model training, and send the encrypted initial model, that is, the target model, to the vehicle-mounted terminal device 940 so that the vehicle-mounted terminal device 940 can perform automatic driving. Specifically, the vehicle-mounted terminal device 940 can collect road condition information in real time during the driving process of the vehicle, such as road condition visual images and radar signals, etc. Further, the vehicle-mounted terminal device 940 performs road condition recognition on the collected road condition information based on the target model, and in the calculation and reasoning process of road condition recognition, the decryption key is used to decrypt the intermediate reasoning result calculated by the target model in real time to obtain the decrypted reasoning result, that is, the road condition recognition result.
[0078] It should be noted that Figure 3 and Figure 4 These are only two schematic diagrams of application scenarios provided by the embodiments of the present application. The application scenarios described in the embodiments of the present application are only for the purpose of more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. The data processing method proposed in this application can also be used in other application scenarios such as article writing, code generation, and data analysis that require model privatization. It is known to those of ordinary skill in the art that, with the evolution of application scenarios, the technical solutions provided by the embodiments of the present invention are also applicable to similar technical problems.
[0079] According to an embodiment of the present application, a data processing method is provided. The data processing method can be executed by a computer device (such as a server, an edge computing device, or other terminal device with certain processing capabilities, etc.), and the computer device has at least storage, computing, and communication functions. Figure 5 FIG. 2 shows a flow chart of the data processing method provided in this embodiment. Figure 5 As shown, the data processing method may specifically include the following.
[0080] S110: Obtain a device identifier corresponding to a target inference device.
[0081] In an embodiment of the present application, in order to prevent multiple devices from sharing the same model privatization license and prevent the model from being stolen, the model can be encrypted and decrypted based on the unique identification of the device to ensure that the privatization license can only be used on a specific device. Because the encrypted model is bound to the unique identification of the specific device, the model can only be correctly decrypted and used on this device. If the encrypted model is copied to other devices, the decryption process will fail due to the different unique identification of the device, and the model cannot be used normally. This mechanism ensures the security of model privatization. The target reasoning device refers to a device that performs model reasoning, and the target reasoning device is a computer device that can decrypt the encrypted model to perform model reasoning.
[0082] The device identification refers to an identifier used to uniquely identify the target reasoning device. In the embodiment of the present application, in addition to the assigned identifier assigned by the hardware manufacturer when the device is produced, the device identification may also include a combined identifier composed of multiple assigned identifiers to improve security, considering that relying on a single assigned identifier is easy to be obtained and forged by malicious users. Among them, the assigned identifier remains unchanged during the life cycle of the target reasoning device, and the form and type of the assigned identifier may vary depending on the device type and manufacturer. For example, common identifiers that can be used as assigned identifiers include MAC addresses (Media Access Control Address): Each network interface controller (such as a network card, Wi-Fi adapter) has a unique MAC address, which is usually used in network devices and communication devices to uniquely identify a device on the network.
[0083] As an implementation method, a hardware fingerprint can be generated as a device identification corresponding to the target inference device based on the multiple identifiers corresponding to the target inference device, for example, the CPU serial number, hard disk serial number, and motherboard serial number are obtained, and then the CPU serial number, hard disk serial number, and motherboard serial number are combined with identifiers through a third-party tool library, and the generated hardware fingerprint is used as the device identification. In this way, by generating a device identification by combining multiple allocated identifiers, the difficulty of forging a device identification can be increased and security can be improved. In addition, some single allocated identifiers of the inference device may change due to hardware replacement or upgrade, such as changing the MAC address due to replacing the network card. Combining multiple allocated identifiers can reduce the risk of device identification changes caused by hardware changes by including multiple hardware information that is not easy to change at the same time. At the same time, some allocated identifiers may not be obtained due to hardware failure or other reasons. By combining multiple allocated identifiers, a unique device identification can still be generated when some allocated identifiers are unavailable or cannot be obtained, thereby improving the robustness and stability of device identification generation.
[0084] S120: Generate a seed key based on the device identification, and perform a first matrix transformation on the seed key to obtain an encryption key.
[0085] Usually, a user with control over model deployment can easily obtain the model file locally. Since the model file stores model information such as the structure and parameters of the model, in order to protect the rights and interests of the model producer, the model can be encrypted on the service side before being licensed for privatization. Considering that the target inference device generally uses a model inference framework to accelerate the inference of the model. After the operator that can reflect the model structure is encrypted, the corresponding model inference framework that was originally available is no longer compatible with the encrypted model. For this reason, this application proposes a model encryption method that only encrypts model parameters. This method uses encryption keys and decryption keys to respectively implement encryption of model parameters and decryption of model inference during the model privatization process.
[0086] In the embodiment of the present application, the seed key refers to the initial value or basic key used to generate the encryption key and the decryption key. Since the seed key is a key generated by an encryption algorithm based on the device identification, the seed key serves as a secure starting point, based on which a pair of encryption keys and decryption keys can be generated to ensure that the model privatization can only take effect on a specific inference device during the encryption and decryption process, thereby ensuring the security of the model privatization. The encryption key refers to the key used to encrypt the model parameters, and correspondingly, the decryption key refers to the key used to decrypt the model inference results during model inference. Because the data structure of the seed key is usually in the form of a string, it cannot be directly used for matrix multiplication operations in the encryption and decryption process. Therefore, by performing matrix conversion on the seed key, a pair of inverse matrices can be generated, that is, the encryption key and the decryption key, to ensure the correct operation of the matrix multiplication during the encryption and decryption processes, and also ensure the consistency of the encryption and decryption processes.
[0087] Among them, the encryption process is the process of performing matrix multiplication operations on the parameter matrix corresponding to the model parameters and the encryption key. According to the relevant concepts of matrix multiplication, the two matrices need to be adapted in terms of the matrix row and column dimensions in order to perform matrix multiplication. For example, the condition for matrix A and matrix B to be multiplied is that the number of columns of matrix A is equal to the number of rows of matrix B. Therefore, the matrix dimension of the encryption key needs to be adapted to the matrix dimension of the parameter matrix of the model to be encrypted. Specifically, when the parameter matrix of the model to be encrypted is multiplied by the encryption key, the number of rows of the encryption key needs to be equal to the number of columns of the parameter matrix. When the encryption key is multiplied by the parameter matrix of the model to be encrypted, the number of columns of the encryption key needs to be equal to the number of rows of the parameter matrix. For this reason, the matrix dimension of the encryption key can be determined based on the matrix dimension of the parameter matrix of the model to be encrypted, so that the matrix dimension of the encryption key and the matrix dimension of the parameter matrix of the model to be encrypted can meet the requirements of matrix multiplication, thereby smoothly performing parameter encryption.
[0088] Considering that the method of encrypting model parameters using keys can adapt to different encryption algorithms and security requirements, directly using device identification to encrypt model parameters may be limited by the length and format of the device identification, which is not as flexible as the method of generating keys. In addition, the device identification itself is relatively simple and easy to obtain. If the device identification is used directly for encryption, once the device identification is leaked, the security of model parameter encryption will be threatened. Generating keys through device identification can use complex encryption algorithms, making the keys difficult to be guessed and cracked, adding a layer of protection to the encryption of model parameters, making it difficult for attackers to guess the keys from the device identification.
[0089] In some embodiments, first, a seed key can be generated based on the device identification of the target reasoning device. For example, an encryption algorithm is used to generate a seed key based on the device identification, and the seed key can be a license. For example, the encryption server can obtain the MAC address "00:1A:2B:3C", the CPU serial number "BFEBFB0003" and the hard disk serial number "WD-WX21A68E" of the target reasoning device from the target reasoning device. Further, the encryption server can combine the MAC address, CPU serial number and hard disk serial number of the target reasoning device to obtain the device identification.
[0090] The device identifier is recorded as device_identifier = "00:1A:2B:3CBFEBFB0003WD-WX21A68E".
[0091] Furthermore, the encryption server can use the SHA-256 hash algorithm to encrypt the device ID and generate a 45-character hash value "6e0f9f0e8bb91c0e3aaf6e3a517f9b8c27d6d0a9f87a" as the seed key. The generated seed key is unique and consistent when the device ID remains unchanged, ensuring the uniqueness of the device while also improving security.
[0092] After the seed key is generated based on the device identification of the target inference device, the matrix dimension of the parameter matrix corresponding to the model parameter, that is, the number of rows and columns, can be further determined, and then an encryption key adapted to the matrix dimension of the parameter matrix can be generated based on the seed key. The specific steps may include the following.
[0093] (1) Obtain the matrix dimension of the parameter matrix to be encrypted corresponding to the model to be encrypted.
[0094] Among them, the model to be encrypted is the original model in the process of model privatization, which is trained by the model manufacturer based on the training samples. The parameter matrix to be encrypted refers to the parameter matrix corresponding to the model to be encrypted, including the weight parameter matrix and the bias parameter matrix. The weight parameter matrix is a collection of weight values for the connection between each layer in the model to be encrypted. Each weight value represents the transmission effect of one neuron on another neuron. The bias parameter matrix is a collection of bias values added to the input value of each neuron. The bias value can help the model to be encrypted better fit the data. Each bias value is an additional input for each neuron, which is used to adjust the activation level of the neuron.
[0095] As an implementation method, the weight parameter matrix or bias parameter matrix corresponding to each neural layer of the model to be encrypted can be obtained. Further, the number of matrix columns corresponding to the weight parameter matrix or the bias parameter matrix can be obtained, and the number of matrix columns can be used as the matrix dimension, because the feature (vector) dimensions of the weight parameters and bias parameters corresponding to the same neural layer are the same. For example, the weight parameter matrix A is A matrix of size , where is the number of matrix columns, that is, the matrix dimension. In this way, by obtaining the matrix dimension of the parameter matrix to be encrypted corresponding to the model to be encrypted, an encryption key that can perform matrix multiplication operation (that is, parameter encryption) with the parameter matrix of the model to be encrypted can be accurately generated.
[0096] Considering that the matrix dimensions of the parameter matrices corresponding to each neural layer in the encrypted model may be different, for example, the convolutional layer corresponds to 78 78 parameter matrix, while the fully connected layer corresponds to 232 167. If the encryption key of the same matrix dimension is used to encrypt the parameter matrix corresponding to each neural layer with parameters, encryption errors may occur. In this way, the matrix dimension corresponding to each neural layer with parameters can be obtained respectively to generate an adaptive encryption key for each neural layer with parameters, where the neural layer with parameters refers to a neural layer with model parameters, such as a convolutional layer, a fully connected layer, etc. Correspondingly, the neural layer that does not require model parameters to participate in the calculation, such as an activation layer or a pooling layer, is a non-parameter neural layer.
[0097] Specifically, the number of matrix columns of the weight parameter matrix or the number of matrix columns of the bias parameter matrix corresponding to each neural layer with parameters in the model to be encrypted is obtained. Further, the number of matrix columns of the weight parameter matrix or the number of matrix columns of the bias parameter matrix is used as the matrix dimension to obtain the matrix dimension corresponding to each neural layer with parameters.
[0098] (2) Perform a first matrix transformation on the seed key according to the matrix dimension, and use the target key matrix that matches the matrix dimension as the encryption key.
[0099] As an implementation method, the seed key can be subjected to a first matrix transformation according to the matrix dimension to obtain an intermediate key matrix matching the matrix dimension. For example, the weight parameter matrix A is The size of the matrix, correspondingly, the intermediate key matrix B is The size of the matrix. When the intermediate key matrix is detected to be a reversible matrix, the intermediate key matrix is used as the encryption key. When it is detected that the intermediate key matrix is not a reversible matrix, the seed key is converted to the first matrix according to the matrix dimension, and the intermediate key matrix is re-detected to see if it is a reversible matrix until the intermediate key matrix is a reversible matrix to obtain the encryption key.
[0100] In this way, by judging whether the intermediate key matrix obtained by matrix transformation of the seed key is a reversible matrix, it is determined whether the intermediate key matrix can be used as an encryption key. Because, in this application, the encryption key and the decryption key must be reversible matrices of each other. Therefore, when the intermediate key matrix is a reversible matrix, it can be used as an encryption key. When the intermediate key matrix is not a reversible matrix, the seed key needs to be re-converted until the intermediate key matrix is a reversible matrix.
[0101] Since the matrix dimensions of the parameter matrices corresponding to each parameter neural layer in the model to be encrypted may be different, an adaptive encryption key can be generated for each parameter neural layer. Specifically, when obtaining the matrix dimensions corresponding to each parameter neural layer in the model to be encrypted, the seed key can be subjected to a first matrix transformation according to the matrix dimensions corresponding to each parameter neural layer to obtain the encryption key corresponding to each parameter neural layer.
[0102] Exemplarily, the seed key in the form of a string can be converted into a corresponding key number. For example, the characters of the seed key are randomly encoded into key numbers. Further, a matrix to be filled can be determined based on the matrix dimension. matrix and fill the key numbers into the Matrix, get the intermediate key matrix, if the length of the key number is not enough to fill The matrix can be filled with specific characters (such as 0 or X). Further, it is detected whether the intermediate key matrix is a reversible matrix. For example, it can be determined whether the determinant of the intermediate key matrix is not zero. If the determinant is not zero, the intermediate key matrix is a reversible matrix. If the determinant is zero, the intermediate key matrix is an irreversible matrix. When it is detected that the intermediate key matrix is not a reversible matrix, the seed key is randomly re-encoded, and the obtained intermediate key matrix is detected to be a reversible matrix, until the intermediate key matrix is a reversible matrix, and the encryption key is obtained.
[0103] As an implementation method, since the decryption key and the encryption key are inverse matrices of each other, the intermediate key matrix corresponding to the encryption key can be reversibly calculated to obtain the reversible matrix corresponding to the intermediate key matrix. For example, the augmented matrix corresponding to the intermediate key matrix is first calculated, and a series of elementary row transformations are performed on the augmented matrix to convert the matrix on the left of the augmented matrix into the unit matrix. After the transformation, the matrix on the right of the augmented matrix is the reversible matrix corresponding to the intermediate key matrix. For example, the intermediate key matrix is a reversible matrix, expressed as:
[0104]
[0105] Furthermore, the intermediate key matrix With the identity matrix Combine to form an augmented matrix , expressed as:
[0106]
[0107] Furthermore, by augmenting the matrix Perform elementary row transformations to augment the matrix Intermediate key matrix on the left Convert to the identity matrix:
[0108] ①The augmented matrix The value of the third column of the third row is set to 1, and then the value of the third column of the first and second rows is eliminated using the third row, and the resulting matrix is:
[0109]
[0110] ② Set the value of the second column of the second row of the above matrix to 1, and then use the second row to eliminate the value of the second column of the first row, and the resulting matrix is:
[0111]
[0112] Thus, the augmented matrix The matrix on the left is converted to the identity matrix. Correspondingly, the right part is the intermediate key matrix The inverse matrix , expressed as:
[0113]
[0114] Furthermore, the reversible matrix corresponding to the intermediate key matrix is used as the decryption key, and the decryption key is sent to the target reasoning device. As another implementation, the decryption key can also be generated by the target reasoning device based on the seed key determined by the device identifier. It should be noted that the method for calculating the inverse matrix of the intermediate key matrix is not limited to the above-mentioned Gauss-Jordan Elimination method based on the augmented matrix. The adjugate matrix and determinant of the intermediate key matrix can also be used to calculate the inverse matrix. The eigenvalue decomposition method can also be used for the diagonalized intermediate key matrix to solve the inverse matrix through its eigenvalues and eigenvectors. Optionally, the calculation method of the inverse matrix of the intermediate key matrix can be selected according to the actual application scenario, and is not limited here.
[0115] In order to facilitate a clearer understanding of the inventive concept of the present application, the following will first explain the technical principle of using an encryption key to encrypt model parameters and using a decryption key to decrypt model reasoning. The technical principle of model parameter encryption is to perform matrix multiplication on the parameter matrix corresponding to the model parameters and the encryption key. The technical principle of model reasoning decryption is to perform matrix multiplication on the reasoning result of the encrypted model and the decryption key. Exemplarily, the reasoning calculation process of a neuron can be expressed as an expression: ,in, is the output vector of the neuron. In the model inference stage, represents the inference result of the neuron, is the weight vector of the neuron, is the input feature vector of the neuron, is the bias vector. In this expression, the input eigenvector With the weight vector Perform a dot product and then add the bias vector , we get the linear combination output of neurons .
[0116] In the actual training and reasoning process of the neural network model, the model calculation is a series of matrix operations. For example, the calculation expression of the hidden layer of a neural network model is : Input matrix is a matrix composed of multiple input vectors. Among them, the weight matrix is a matrix consisting of weight vectors corresponding to all neurons in the hidden layer, and the bias matrix is a matrix consisting of the bias vectors corresponding to all neurons in the hidden layer. The output matrix of the hidden layer includes the output vectors of all neurons in the hidden layer. This calculation method can make full use of the efficiency of matrix operations, especially when performing parallel calculations, which can greatly accelerate the training and reasoning process of the neural network model.
[0117] Model parameter encryption is to perform matrix multiplication on the parameter matrix corresponding to the model parameters and the encryption key: , ,in, is the encryption key, is the encrypted weight matrix, is the encrypted bias matrix. Therefore, the calculation expression of the hidden layer of the encrypted model is: . Afterwards, in the model inference phase, the encrypted model inference result is matrix multiplied with the decryption key:
[0118]
[0119] Because the encryption key The corresponding inverse matrix is the decryption key , ,in, is the identity matrix. So, , that is, Through the above operation process, it can be seen that the associative law of matrix multiplication is used, and the weight matrix is not involved in the entire model inference stage. and the bias matrix That is, unencrypted model parameters will not appear in the inference stage. In this way, through the condition that the encryption key and the decryption key are inverse matrices of each other, the model inference result calculated with the encryption key can be directly operated with the decryption key for data equivalence, and the decrypted model inference result can be obtained. The model can be decrypted while inferring, avoiding the exposure of the weight matrix and bias matrix of the unencrypted model to the memory, and eliminating the possibility of the model parameters being dumped from the memory, thereby effectively improving the security of model protection.
[0120] S130: Encrypt the model parameters of the model to be encrypted according to the encryption key to obtain the target model.
[0121] Generally, a neural network model consists of model parameters and model operators. Model parameters are trainable parameters of the model, which are optimized through the training process to minimize the loss function. Model parameters include the weights and biases between connecting neurons, as mentioned above. The weights represented by Represents the bias. Model operators refer to functions or methods used to operate, transform or manage model elements in model construction and analysis. These functions or methods may include basic mathematical calculations, logical calculations, matrix calculations, etc. They are operators involved in the forward propagation of the model. In the embodiments of the present application, each operator involved in the forward propagation calculation process of the model is called a calculation operator, such as matrix multiplication can be a calculation operator, addition operation can be a calculation operator, activation function (such as ReLU, Sigmoid, Tanh, etc.) can be a calculation operator, convolution operation (in convolutional neural network) can be a calculation operator, pooling operation can also be a calculation operator, feature fusion (add / concat) can also be a calculation operator, etc.
[0122] In some embodiments, the parameter matrix of the model parameters of the model to be encrypted may be encrypted using an encryption key, and then the encrypted model parameters and various calculation operators corresponding to the model to be encrypted are combined to form an encrypted model, that is, a target model. Specifically, step S130 may include the following.
[0123] (1) Obtain the parameters to be encrypted corresponding to the model to be encrypted.
[0124] As an implementation method, the parameters to be encrypted refer to all types of model parameters in the model to be encrypted. From the above explanation of the principle of model encryption and decryption, it can be seen that the parameters to be encrypted must include both weight parameters and bias parameters, otherwise the associative law of matrix multiplication cannot be used. Optionally, the weight parameters and bias parameters corresponding to each neural layer with parameters can be obtained.
[0125] (2) Encrypt the parameter matrix to be encrypted corresponding to the parameter to be encrypted according to the encryption key to obtain the target parameter matrix.
[0126] As an implementation method, the weight parameter matrix and bias parameter matrix corresponding to the parameters to be encrypted can be obtained. Further, matrix multiplication operation is performed on the encryption key and the weight parameter matrix to obtain an encrypted weight matrix. Matrix multiplication operation is performed on the encryption key and the bias parameter matrix to obtain an encrypted bias matrix. The encrypted weight matrix and the encrypted bias matrix are then used as target parameter matrices. Further, the target model is determined based on the target parameter matrix and the calculation operator corresponding to the model to be encrypted.
[0127] Since the matrix dimensions of the parameter matrices corresponding to each neural layer with parameters in the model to be encrypted are different, the encryption key corresponding to each neural layer with parameters can be used to encrypt the weight parameter matrix and bias parameter matrix of this layer. Specifically, the weight parameter matrix and bias parameter matrix corresponding to each neural layer with parameters in the model to be encrypted can be obtained, and the encryption key corresponding to each neural layer with parameters can be used to perform matrix multiplication operations with the corresponding weight parameter matrix and bias parameter matrix to obtain the encrypted weight matrix and encrypted bias matrix corresponding to each neural layer with parameters, and the encrypted weight matrix and encrypted bias matrix corresponding to each neural layer with parameters are used as the target parameter matrix. Furthermore, based on the target parameter matrix and the calculation operator corresponding to the model to be encrypted, the target model is determined.
[0128] Since the neural network model is composed of model parameters and various computing operators, after encrypting the parameter matrix to be encrypted, the encrypted target parameter matrix and the computing operators corresponding to the model to be encrypted can be used to determine the encrypted target model.
[0129] Compared with the model to be encrypted, the encrypted target model has only model parameters encrypted by the encryption key, while the various computing operators are not encrypted. Therefore, the model structure of the target model remains the same as the model structure of the model to be encrypted. Therefore, in the model reasoning stage, the model reasoning framework corresponding to the model to be encrypted can continue to be used to perform model reasoning on the target model, avoiding modification or replacement of the model reasoning architecture. In this way, the encryption and decryption of the model are not constrained by the framework type of the model reasoning framework, which improves the compatibility of model protection in model privatization scenarios.
[0130] S140: Send the target model to the target reasoning device, so that the target reasoning device performs computational reasoning on the target model, and decrypts the intermediate reasoning result of the computational reasoning based on the decryption key to obtain the target reasoning result.
[0131] In the model privatization scenario, the model manufacturer can send the encrypted target model to the target reasoning device, and then the target reasoning device performs model reasoning based on the target model. In some embodiments, the service side can send the generated decryption key to the target reasoning device. In other embodiments, the decryption key can also be generated by the target reasoning device itself. Since the decryption key is obtained by converting the seed key through the second matrix, and the seed key is generated based on the device identification, whether it is the decryption key sent or the decryption key generated by the target reasoning device itself, as long as the seed key is the same, the decryption key and the encryption key are inverse matrices of each other.
[0132] This embodiment can obtain the device identification corresponding to the target inference device, and then can generate a seed key based on the device identification, and perform a first matrix transformation on the seed key to obtain an encryption key. Further, the model parameters of the model to be encrypted can be encrypted according to the encryption key to obtain the target model. In this way, the encryption of the model to be encrypted is achieved only by encrypting the model parameters. Compared with the encryption method of the model to be encrypted by encrypting the model operator in the related technology, it can avoid the problem of needing to use a specific model reasoning framework during model reasoning due to the encryption of the model operator. During model reasoning, the reasoning operation can be completed using the ordinary model reasoning framework, thereby improving the compatibility of model protection in the model privatization scenario.
[0133] Furthermore, the target model can be sent to the target reasoning device so that the target reasoning device performs calculation reasoning on the target model, and decrypts the intermediate reasoning result of the calculation reasoning based on the decryption key to obtain the target reasoning result, wherein the decryption key is obtained by converting the seed key through the second matrix, and the decryption key and the encryption key are inverse matrices of each other. Compared with the related technology, in the process of model reasoning, the unencrypted model parameters are first decrypted, and then the reasoning operation is performed based on the decrypted model parameters. This application uses the condition that the encryption key and the decryption key are inverse matrices of each other, and according to the product of the encryption key and the decryption key is the unit matrix and the associative law of matrix multiplication, the calculation process that originally needs to decrypt the model parameters can be equivalent to a calculation process that can directly use the decryption key to decrypt the reasoning result calculated by the encryption key, and calculate the reasoning result. In this way, it can effectively avoid the situation where the model parameters of the encrypted model are exposed to the memory because of being decrypted, thereby eliminating the possibility of the model parameters being dumped from the memory, and effectively improving the security of model protection in the model privatization scenario.
[0134] According to another embodiment of the present application, another data processing method is provided. The data processing method can be executed by a computer device (such as a server, an edge computing device or other terminal device with certain processing capabilities, etc.) after step S140 of the above embodiment, and the computer device has at least storage, computing and communication functions. Figure 6 , Figure 6 The following is a flow chart of the data processing method provided by this embodiment. Figure 6 The specific steps of the data processing method are described.
[0135] S210: Receive a target model.
[0136] The target model is obtained by encrypting the model to be encrypted using the encryption key generated by the device identification. Exemplarily, the enterprise user can log in to the model privatization platform using the registered account and password. After logging in, the enterprise user enters the model library of the model privatization platform and selects the model to be downloaded from the model library. Specifically, the enterprise user can open the device information acquisition permission of the target inference device required to generate the device identification to the model privatization platform.
[0137] Furthermore, after confirming the permission to open device information, the model privatization platform can generate a unique download link. When the enterprise user clicks the download link, the target inference device starts downloading the encrypted model file, which stores the model information corresponding to the target model.
[0138] S220: Obtain a decryption key generated corresponding to the device identification.
[0139] As an implementation method, the target reasoning device can generate a seed key based on the device identification, and perform a second matrix transformation on the seed key to obtain an intermediate key matrix. When it is detected that the intermediate key matrix is a reversible matrix, a matrix reversible calculation is performed on the intermediate key matrix to obtain a reversible matrix corresponding to the intermediate key matrix, and the reversible matrix corresponding to the intermediate key matrix is used as a decryption key, and the decryption key and the encryption key are inverse matrices of each other. As another implementation method, when downloading an encrypted model file, the target reasoning device can also download the decryption key corresponding to the model file.
[0140] The specific contents of generating a seed key based on the device identification and performing a second matrix transformation on the seed key to obtain an intermediate key matrix can be found in the above step S120, which will not be described in detail here.
[0141] S230: Perform computational reasoning on the target model, and decrypt the intermediate reasoning result of the computational reasoning based on the decryption key to obtain the target reasoning result.
[0142] The reasoning of the model can be performed based on the computation graph. The computation graph systematically represents the various operations (computation operators) and data dependencies of the neural network model, and then executes each computation operator in turn according to the topological order of the computation graph for forward calculation, which is model reasoning. After the input data is calculated by each computation operator, it is gradually passed to the next computation operator until the final output result is obtained.
[0143] In some embodiments, the target model can be operated and inferred based on the computation graph, and the intermediate inference results of the inference of each parameterized computation operator can be decrypted in sequence according to the topological order of the computation graph based on the decryption key to obtain the target inference result. The specific steps can include the following.
[0144] (1) Construct a computational graph based on the computational operators of the target model.
[0145] As an implementation method, the model file can be stored on the target inference device disk, and the model file may be in multiple formats (such as SavedModel, ONNX, etc.). When performing computational inference on the target model, the target inference device can read the model file from the disk and parse out the computational operators of the model contained therein, which may include computational operations such as matrix multiplication, convolution, activation function, etc. Each computational operator corresponds to a computational node in the target model, and the computational graph is the overall representation of these nodes and their connection relationships.
[0146] Exemplarily, if the target model includes a convolution layer and a fully connected layer, the corresponding model file contains the calculation graph definition and model parameters. The calculation graph definition includes the convolution layer (convolution, activation function) and the fully connected layer (matrix multiplication, activation function). The model parameters include the convolution kernel weight and the fully connected layer weight. Further, create a convolution layer node, and add the corresponding convolution operation and activation function to the calculation graph in sequence, create a fully connected layer node, and add the corresponding matrix multiplication and activation function to the calculation graph in sequence.
[0147] (2) According to the topological order of the computational graph, each computational operator is executed in sequence to perform computational reasoning.
[0148] As an implementation method, the model parameters can be loaded into the memory and associated with the corresponding computing operators. For example, each model parameter has a unique identifier in the model file, and the nodes in the computing graph also have corresponding identifiers. These identifiers have established a corresponding relationship when designing the model. According to the identifier, the parsed model parameters can be assigned to the corresponding nodes (computing operators). For example, for the convolution layer node, the framework will load the corresponding convolution kernel weight into the weight attribute of the node. Then, according to the topological order of the computing graph, each computing operator is executed in turn for computational reasoning.
[0149] (3) When it is detected that the current computing operator calls the model parameters, the intermediate inference result of the current computing operator's calculation inference is decrypted based on the decryption key to obtain the intermediate decrypted result.
[0150] As an implementation method, each calculation operator is executed in sequence according to the topological order of the calculation graph. When it is detected that the current calculation operator calls the model parameters, the encryption weight matrix and encryption bias matrix corresponding to the model parameters of the current calculation operator are obtained, and the intermediate reasoning result obtained through calculation reasoning is obtained, and the decryption key and the intermediate reasoning result are subjected to matrix multiplication operation to obtain the intermediate decryption result.
[0151] (4) The intermediate decryption result is passed to the next calculation operator of the current calculation operator for calculation reasoning until the calculation reasoning of the calculation graph is completed and the target reasoning result is obtained.
[0152] See also Figure 7 , Figure 7 A model inference decryption flow chart is shown. After the target inference device obtains the decryption key and the model file corresponding to the target model, it can start model inference on the target model. Figure 7 As shown, the target inference device can obtain the calculation operator and model parameters from the model file: the process of reading the model file and parsing the model definition from the model file includes the target parameter matrix corresponding to the calculation operator and model parameters. Further, a calculation graph is constructed based on each calculation operator: each calculation operator is used as a node, and the nodes are connected according to the model structure. The output tensor of each node will be used as the input of the next node.
[0153] Furthermore, according to the topological order of the computational graph, each computational operator is executed in sequence to perform computational reasoning. During the running reasoning process, it is detected whether the current computational operator calls the model parameters. When it is detected that the current computational operator calls the model parameters, the intermediate reasoning result of the computational reasoning of the current computational operator is decrypted based on the decryption key to obtain the intermediate decrypted result. Furthermore, the intermediate decrypted result is passed to the next computational operator of the current computational operator to continue to perform computational reasoning, otherwise, the intermediate reasoning result of the computational reasoning of the current computational operator is directly passed to the next computational operator of the current computational operator to continue to perform computational reasoning, until the computational reasoning of the computational graph is completed and the target reasoning result is obtained, wherein when the intermediate reasoning result of the computational reasoning of the current computational operator is decrypted using the decryption key, the intermediate reasoning result of the computational reasoning of the current computational operator can be decrypted based on the decryption key of the neural layer with parameters corresponding to the previous computational operator.
[0154] According to another embodiment of the present application, another data processing method is provided. It is executed by a computer device (such as a server, an edge computing device or other terminal device with certain processing capabilities, etc.), and the computer device has at least storage, computing and communication functions. Figure 8 , Figure 8 FIG. 2 shows a flow chart of another data processing method provided by this embodiment. The data processing method can be jointly executed by the encryption server and the target reasoning device. Figure 8 The specific steps of the data processing method are described.
[0155] Model manufacturers can provide model privatization services for enterprises or individual users. Exemplarily, the model manufacturer can complete model training on a server cluster to obtain an initial model. When an enterprise or individual user applies to use the initial model, the model manufacturer can encrypt the initial model and use it for the target reasoning device in the corresponding privatization scenario. Specifically, the server cluster may also include an encryption server. The encryption server is connected to each target reasoning device in communication, and is mainly used to receive model privatization requests from the target reasoning device, encrypt the initial model, and perform distribution operations on the target model, keys, etc.
[0156] S310: The encryption server obtains a device identifier corresponding to the target inference device.
[0157] Exemplarily, the target inference device can send a model privatization request to the encryption server. When the encryption server receives the model privatization request, it can send a device information acquisition request to the target inference device. Then, when the target inference device receives the device information acquisition request, it can send device information to the encryption server. The device information includes the device's MAC address, IMEI number, and other identifiers that can represent unique identification. Further, after receiving the device information, the encryption server can generate a device identifier corresponding to the target inference device based on the device information.
[0158] S320: The encryption server generates a seed key based on the device identifier, and performs a first matrix transformation on the seed key to obtain an encryption key.
[0159] Exemplarily, the seed key can be an electronic license. The encryption server generates an electronic license as a seed key based on the device identification through a hash function or an encryption algorithm. Considering that the device identification corresponding to the target reasoning device may be stolen by illegal personnel to defraud encryption keys and decryption keys. Usually, the reasoning device corresponding to the device identification when the device identification is first obtained is usually a legal device, that is, the target reasoning device. This is because the initial process of model privatization involves multiple levels of verification and authentication, including purchase and authorization processes, hardware binding and digital licenses, user agreements and legal liabilities, and high-risk costs of illegal behavior. To this end, the seed key can be generated together with the time when the device identification corresponding to the target reasoning device is first obtained.
[0160] As an implementation method, when the encryption server detects that the device identifier corresponding to the target inference device is obtained for the first time, it obtains the first acquisition time corresponding to the device identifier. Further, the key can be generated based on the first acquisition time and the device identifier corresponding to the first acquisition time to obtain a seed key. Further, the encryption server can obtain the weight parameter matrix or bias parameter matrix corresponding to each neural layer of the initial model, and obtain the number of matrix columns corresponding to the weight parameter matrix or the bias parameter matrix, and use the number of matrix columns as the matrix dimension. Further, the seed key is subjected to a first matrix transformation according to the matrix dimension, and the obtained target key matrix matching the matrix dimension is used as the encryption key.
[0161] See also Fig. 9 , Fig. 9 A flow chart of generating an encryption key and a decryption key is shown. Fig. 9 As shown, when the encryption server detects that the device identification corresponding to the target inference device is obtained for the first time, it obtains the first acquisition time corresponding to the device identification, and generates a key based on the first acquisition time and the device identification corresponding to the first acquisition time to obtain a seed key. Further, the encryption server can perform a random matrix conversion on the seed key to obtain an encryption key.
[0162] Specifically, the encryption server can generate a random seed: use the seed key to generate a random seed to ensure that the same key always generates the same matrix. Initialize the random number generator: use the generated random seed to initialize the random number generator. Define the dimension of the matrix: define the number of rows and columns of the intermediate key matrix to be generated later according to the matrix dimension of the model to be encrypted, that is, the model parameter matrix of the initial model. Generate the intermediate key matrix: use the random number generator to fill the elements of the intermediate key matrix to obtain the filled intermediate key matrix.
[0163] Further, determine whether the intermediate key matrix is a reversible matrix. If it is not a reversible matrix, initialize the random number generator again to generate the intermediate key matrix until the intermediate key matrix obtained is not a reversible matrix. At this time, the reversible intermediate matrix is used as the encryption key. Further, perform a matrix reversible operation on the encryption key to obtain the inverse matrix corresponding to the encryption key, and then use the inverse matrix corresponding to the encryption key as the decryption matrix.
[0164] The seed key is generated by combining the first time the device identification is obtained and the device identification corresponding to the first time, and then the encryption key and the decryption key corresponding to the encryption key are generated based on the seed key. In this way, even if an illegal user steals the device identification to generate an illegal decryption key, the illegal decryption key is only generated based on the device identification, not the inverse matrix corresponding to the encryption key, so it cannot be used in the model reasoning process, thereby improving the security of model privatization.
[0165] S330: The encryption server encrypts the model parameters of the model to be encrypted according to the encryption key to obtain the target model.
[0166] Exemplarily, the encryption server can obtain the weight parameter matrix and the bias parameter matrix corresponding to the parameters to be encrypted, and further, perform matrix multiplication operation on the encryption key and the weight parameter matrix to obtain the encryption weight matrix, and perform matrix multiplication operation on the encryption key and the bias parameter matrix to obtain the encryption bias matrix. Then, the encryption server can use the encryption weight matrix and the encryption bias matrix as the target parameter matrix, and further, determine the target model based on the target parameter matrix and the calculation operator corresponding to the model to be encrypted. Please refer to Fig.10 , Fig.10 Figure 2 shows a schematic diagram of an encryption model parameter encryptor. Fig.10 The model parameter encryptor shown can be developed based on the implementation principle of parameter encryption of the model parameters of the model to be encrypted in the above embodiment. A license can be generated based on the terminal device, and further, a seed key is generated according to the license. Further, the model parameter encryptor is used to generate an encryption key based on the seed key, and the model parameter encryptor can encrypt the model parameters of the model to be encrypted based on the encryption key to obtain the target model.
[0167] S340: The encryption server obtains the framework type of the model reasoning framework corresponding to the model to be encrypted.
[0168] In order to improve the compatibility with model protection privatization, this application proposes to develop different types of decryption plug-ins for different model reasoning frameworks, encapsulate the model reasoning framework and its adapted target decryption plug-in, and then users can download the encapsulated model reasoning framework with decryption plug-in to perform model reasoning according to their needs.
[0169] Since there are differences between model inference frameworks developed by different manufacturers, it is necessary to develop pre-made adaptive decryption plug-ins for different framework types. The model inference framework used by the target inference device is determined by the model to be encrypted. This is because the training of the model to be encrypted mostly uses a deep learning framework, and different model inference frameworks do have some requirements and support ranges for the type of neural network models, which usually depends on the design goals and optimization strategies of the framework.
[0170] For example, the model reasoning framework TensorFlow Serving mainly supports models trained by the deep learning framework TensorFlow (SavedModel format). The model reasoning framework NVIDIA TensorRT mainly supports models trained in deep learning frameworks such as TensorFlow, PyTorch, and Caffe. Exemplarily, the encryption server can obtain the deep learning framework used to train the model to be encrypted, and further determine the framework type of the model reasoning framework that can support model reasoning based on the deep learning framework.
[0171] S350: The encryption server generates a target decryption plug-in that matches the model reasoning framework based on the framework type.
[0172] In the embodiment of the present application, a decryption plug-in refers to an optional component or module used to extend the decryption function of the model reasoning framework without changing the core code of the original software of the model reasoning framework. The decryption plug-in is used to decrypt the intermediate reasoning results obtained during the target model operation reasoning process based on the decryption key. Exemplarily, the encryption server can generate a target decryption plug-in that matches the model reasoning framework corresponding to the framework type based on the framework type.
[0173] S360: The encryption server encapsulates the target decryption plug-in and the model reasoning framework to obtain the target reasoning framework.
[0174] For example, the encryption server can use the code hook to encapsulate the target decryption plug-in with the corresponding model reasoning framework. The encryption server can also encapsulate the target decryption plug-in with the corresponding model reasoning framework by directly modifying the relevant code of the model reasoning framework, and then develop an adapted decryption plug-in for different model reasoning frameworks, and then encapsulate the model reasoning framework with its adapted decryption plug-in. Users can download the encapsulated model reasoning framework with the decryption plug-in to perform model reasoning.
[0175] For example, insert a hook in the calculation graph or forward propagation process of the model inference framework to call the target decryption plug-in: In the model inference framework, by inserting a hook function at the location where the model parameters are called to calculate the result during the forward propagation process, each time the model parameters are called to calculate the result, the target decryption plug-in can be called to decrypt the calculated result. This method allows users to dynamically insert and execute decryption operations without modifying the core code of the framework.
[0176] S370: The encryption server sends the target model and the target reasoning framework to the target reasoning device.
[0177] Exemplarily, when a user sends a model download request to the encryption server through a target reasoning device, the encryption server can send the target model and the target reasoning framework to the target reasoning device. Optionally, the target model is obtained by parameter encryption using an encryption key generated based on the first time and its corresponding device identification. The encryption server can also send the inverse matrix of the encryption key generated based on the first time and its corresponding device identification as a decryption key to the target reasoning device. This allows the target reasoning device to perform computational reasoning on the target model through the model reasoning framework, and to perform decryption of the intermediate reasoning result of the computational reasoning using the decryption key based on the target decryption plug-in to obtain the target reasoning result.
[0178] S380: The target inference device receives the target model and obtains the decryption key generated corresponding to the device identifier.
[0179] In order to improve the security of model decryption and prevent illegal users from stealing device identification to generate illegal decryption keys for model decryption, the encryption server can directly generate a decryption key for the target reasoning model. Exemplarily, the target reasoning device can receive the target model sent by the encryption server and the decryption key generated based on the first time and its corresponding device identification.
[0180] S390: The target reasoning device receives the target reasoning framework, performs computational reasoning on the target model through the model reasoning framework, and executes the intermediate reasoning result of the decryption key decryption computational reasoning based on the target decryption plug-in to obtain the target reasoning result.
[0181] As an implementation method, the target inference device can receive the target model and target inference framework sent by the encryption server. Then, the target model is inferred and decrypted based on the target inference framework. Fig.11 , Fig.11The figure shows a working diagram of a decryption plug-in. The target model can be loaded into the memory of the target inference device. After the data to be processed is received, the target inference device can use the target model to perform computational inference on the data to be processed through the model inference framework of the target inference framework, and perform decryption based on the intermediate inference result of the computational inference with the decryption key of the target decryption plug-in to obtain the target inference result. If the target inference device does not deploy the model inference framework with the decryption plug-in, such as Fig.12 The figure shows a working diagram of an independent model reasoning framework, in which the model reasoning framework performs computational reasoning on the target model and obtains an erroneous reasoning result.
[0182] For example, take the target reasoning framework encapsulated in the TensorFlow Serving type as an example. After the target reasoning device receives the target reasoning framework sent by the encryption server, the model reasoning framework of the target reasoning framework can read the model file corresponding to the target model from the disk. The model file is a file in the SavedModel format, which contains the calculation graph definition and model parameters of the target model. Furthermore, the model reasoning framework can parse the SavedModel file to extract the calculation graph definition and the corresponding model parameters.
[0183] Furthermore, the model reasoning framework can reconstruct the computational graph in memory based on the parsed computational graph definition. Each node (computational operator) corresponds to a layer or an operation of the model. The construction of the computational graph ensures that the forward propagation path of the model is correctly defined for computational reasoning. The parsed model parameters are loaded into memory and assigned to the corresponding nodes in the computational graph. These model parameters will be used to transform and calculate the processed data in computational reasoning. Based on the identifier, the model reasoning framework can assign the parsed model parameters to the corresponding nodes. For example, for a convolutional layer node, the model reasoning framework will load the corresponding convolution kernel weight into the weight attribute of the node.
[0184] See also Fig.13 , Fig.13 A computational graph of a computational reasoning with decryption is shown. For example, Fig.13 The figure shows a partial structure of a neural network model, which includes five operators: convolution layer, activation function (ReLU), pooling layer, fully connected layer, and activation function (ReLU). Correspondingly, each operator is a node in the computational graph, and the edges in the computational graph represent the data flow between nodes.
[0185] The model reasoning framework can decrypt the intermediate results of the previous calculation operator according to the topological order of the calculation graph. Input to the convolutional layer, and then the convolutional layer decrypts the intermediate result based on the corresponding parameter matrix Perform inference calculations to obtain intermediate inference results , and the decryption key and intermediate inference results Perform matrix multiplication to obtain the intermediate decryption result , and then the intermediate decryption result Input to the activation function ReLU, the activation function ReLU decrypts the intermediate result Perform inference calculations to obtain intermediate inference results , and the intermediate inference results Input to the pooling layer, the pooling layer decrypts the intermediate results Perform inference calculations to obtain intermediate inference results , and the intermediate inference results Input to the fully connected layer, the fully connected layer performs inference on the intermediate results based on the corresponding parameter matrix Perform inference calculations to obtain intermediate inference results , and the decryption key and intermediate inference results Perform matrix multiplication to obtain the intermediate decryption result .
[0186] Furthermore, the fully connected layer converts the intermediate decryption result Input to the activation function ReLU for subsequent reasoning operations until the calculation graph is completed and the target reasoning result is obtained. Among them, the parameter matrix may include an encrypted weight matrix and an encrypted bias matrix. Optionally, the decryption key can be obtained by matrix conversion based on the same seed key according to the matrix dimensions of the parameter matrix corresponding to different calculation operators in the model. For example, the decryption key and the decryption key It is obtained by performing different matrix transformations on the same seed key. Specifically, the decryption key is obtained by performing the first matrix transformation on the seed key according to the matrix dimension of the parameter matrix corresponding to the convolutional layer. , according to the matrix dimension of the parameter matrix corresponding to the fully connected layer, the seed key is transformed into the second matrix to obtain the decryption key Optionally, if the matrix dimensions of the parameter matrices corresponding to the computing operators are the same, the decryption keys may be the same.
[0187] The encryption server of this embodiment can obtain the device identification corresponding to the target reasoning device, and generate a seed key based on the device identification, and perform a first matrix conversion on the seed key to obtain an encryption key. Further, the encryption server can perform parameter encryption on the model parameters of the to-be-encrypted model according to the encryption key to obtain the target model, and obtain the framework type of the model reasoning framework corresponding to the to-be-encrypted model, and then generate a target decryption plug-in matching the model reasoning framework based on the framework type. Further, the encryption server can encapsulate the target decryption plug-in with the model reasoning framework to obtain the target reasoning framework, and send the target model and the target reasoning framework to the target reasoning device. Further, the target reasoning device can receive the target model and obtain the decryption key generated corresponding to the device identification, and then the target reasoning device receives the target reasoning framework, performs computational reasoning on the target model through the model reasoning framework, and executes the decryption key based on the target decryption plug-in to decrypt the intermediate reasoning result of the computational reasoning to obtain the target reasoning result. In this way, the user cannot normally perform model privatization for an unauthorized reasoning device, because the decryption key generated based on the device identification of the unauthorized reasoning device cannot decrypt the reasoning result of the encrypted model, and since the target reasoning device deploys the encrypted model, the user cannot obtain the information of the unencrypted initial model. Thereby, the security of model privatization is improved.
[0188] See also Fig.14 , which shows a structural block diagram of a data processing device 400 provided in an embodiment of the present application. The device 400 may include: an identification acquisition module 410, a key generation module 420, a model encryption module 430 and a model sending model 440. The identification acquisition module 410 is used to obtain the device identification corresponding to the target reasoning device; the key generation module 420 is used to generate a seed key based on the device identification, and perform a first matrix transformation on the seed key to obtain an encryption key; the model encryption module 430 is used to perform parameter encryption on the model parameters of the model to be encrypted according to the encryption key to obtain a target model; the model sending model 440 is used to send the target model to the target reasoning device, so that the target reasoning device performs computational reasoning on the target model, and decrypts the intermediate reasoning result of the computational reasoning based on the decryption key to obtain a target reasoning result, the decryption key is obtained by converting the seed key through the second matrix, and the decryption key and the encryption key are inverse matrices of each other.
[0189] In some embodiments, the model encryption module 430 may include: a parameter acquisition unit, a parameter encryption unit, and a model determination unit. The parameter acquisition unit is used to acquire the parameters to be encrypted corresponding to the model to be encrypted; the parameter encryption unit is used to perform parameter encryption on the parameter matrix to be encrypted corresponding to the parameters to be encrypted according to the encryption key to obtain a target parameter matrix; and the model determination unit is used to determine the target model based on the target parameter matrix and the calculation operator corresponding to the model to be encrypted.
[0190] In some embodiments, the parameter encryption unit can be specifically used to: obtain a weight parameter matrix and a bias parameter matrix corresponding to the parameters to be encrypted; perform matrix multiplication operations on the encryption key and the weight parameter matrix to obtain an encrypted weight matrix; perform matrix multiplication operations on the encryption key and the bias parameter matrix to obtain an encrypted bias matrix; and use the encrypted weight matrix and the encrypted bias matrix as target parameter matrices.
[0191] In some embodiments, the data processing device 400 may further include: a framework type acquisition module, a decryption plug-in generation module, and an inference framework encapsulation module. The framework type acquisition module is used to acquire the framework type of the model inference framework corresponding to the model to be encrypted; the decryption plug-in generation module is used to generate a target decryption plug-in matching the model inference framework based on the framework type; and the inference framework encapsulation module is used to encapsulate the target decryption plug-in with the model inference framework to obtain a target inference framework.
[0192] In some embodiments, the model sending model 440 can also be specifically used to send the target model and the target reasoning framework to the target reasoning device, so that the target reasoning device performs operational reasoning on the target model through the model reasoning framework, and executes the intermediate reasoning result of the decryption key decryption operational reasoning based on the target decryption plug-in to obtain the target reasoning result.
[0193] In some embodiments, the key generation module 420 may include a matrix dimension acquisition unit and an encryption key generation unit. The matrix dimension acquisition unit is used to acquire the matrix dimension of the parameter matrix to be encrypted corresponding to the model to be encrypted; the encryption key generation unit is used to perform a first matrix transformation on the seed key according to the matrix dimension, and use the obtained target key matrix matching the matrix dimension as the encryption key.
[0194] In some embodiments, the encryption key generation unit can be specifically used to: perform a first matrix transformation on the seed key according to the matrix dimension to obtain an intermediate key matrix matching the matrix dimension; when it is detected that the intermediate key matrix is a reversible matrix, use the intermediate key matrix as the encryption key; when it is detected that the intermediate key matrix is not a reversible matrix, return to perform the first matrix transformation on the seed key according to the matrix dimension, and re-detect whether the obtained intermediate key matrix is a reversible matrix, until the intermediate key matrix is a reversible matrix to obtain the encryption key.
[0195] In some embodiments, the encryption key generation unit can be specifically used to: perform matrix reversible calculation on the intermediate key matrix corresponding to the encryption key to obtain a reversible matrix corresponding to the intermediate key matrix; use the reversible matrix corresponding to the intermediate key matrix as a decryption key, and send the decryption key to the target inference device.
[0196] In some embodiments, the key generation module 420 may further include a time acquisition unit and a seed key generation unit. The time acquisition unit is used to acquire the first acquisition time corresponding to the device identifier when it is detected that the device identifier corresponding to the target inference device is acquired for the first time; and the seed key generation unit is used to generate a key based on the first acquisition time and the device identifier corresponding to the first acquisition time to obtain a seed key.
[0197] This embodiment can obtain the device identification corresponding to the target reasoning device, and then can generate a seed key based on the device identification, and perform a first matrix conversion on the seed key to obtain an encryption key. Further, the model parameters of the model to be encrypted can be encrypted according to the encryption key to obtain the target model. In this way, the encryption of the model to be encrypted is achieved only by encrypting the model parameters. Compared with the encryption method of the model to be encrypted by using an encrypted model operator in the related technology, it can avoid the problem of using a specific model reasoning framework when the model is reasoned due to the encryption of the model operator. When the model is reasoned, the reasoning operation can be completed using a common model reasoning framework, thereby improving the compatibility of model protection in the model privatization scenario. Furthermore, the target model can be sent to the target reasoning device so that the target reasoning device performs arithmetic reasoning on the target model, and decrypts the intermediate reasoning result of the arithmetic reasoning based on the decryption key to obtain the target reasoning result, wherein the decryption key is obtained by converting the seed key through the second matrix, and the decryption key and the encryption key are inverse matrices of each other. Compared with the related technologies, in the process of model reasoning, the unencrypted model parameters are first decrypted, and then the reasoning operation is performed based on the decrypted model parameters. This application, through the condition that the encryption key and the decryption key are inverse matrices of each other, according to the product of the encryption key and the decryption key is the unit matrix and the associative law of matrix multiplication, can make the calculation process that originally needs to decrypt the model parameters equivalent to the calculation process that can directly use the decryption key to decrypt the reasoning result calculated by the encryption key, and calculate the reasoning result. In this way, it can effectively avoid the situation where the model parameters of the encrypted model are exposed to the memory due to decryption, thereby eliminating the possibility of the model parameters being dumped from the memory, and effectively improving the security of model protection in the model privatization scenario.
[0198] See also Fig.15 , which shows a structural block diagram of another data processing device 500 provided in an embodiment of the present application. The device 500 may include: a model receiving module 510, a key acquisition module 520 and a model decryption module 530. The model receiving module 510 is used to receive a target model, and the target model is obtained by encrypting the model to be encrypted with the encryption key generated corresponding to the device identification; the key acquisition module 520 is used to obtain the decryption key generated corresponding to the device identification, and the decryption key and the encryption key are inverse matrices of each other; the model decryption module 530 is used to perform computational reasoning on the target model, and decrypt the intermediate reasoning result of the computational reasoning based on the decryption key to obtain the target reasoning result.
[0199] In some embodiments, the model decryption module 530 may include a calculation graph construction unit, an operation reasoning unit, an intermediate decryption unit, and a decryption result transmission unit. The calculation graph construction unit is used to construct a calculation graph based on the calculation operator of the target model; the operation reasoning unit is used to execute each calculation operator in sequence for operation reasoning according to the topological order of the calculation graph; the intermediate decryption unit is used to decrypt the intermediate reasoning result of the operation reasoning of the current calculation operator based on the decryption key after detecting that the current calculation operator calls the model parameter, and obtain the intermediate decryption result; the decryption result transmission unit is used to transmit the intermediate decryption result to the next calculation operator of the current calculation operator for operation reasoning until the operation reasoning of the calculation graph is completed to obtain the target reasoning result.
[0200] In some embodiments, the intermediate decryption unit can be specifically used for: when it is detected that the current computing operator calls the model parameters, obtaining the encrypted weight matrix and encrypted bias matrix corresponding to the model parameters of the current computing operator, and the intermediate reasoning result obtained through computational reasoning; performing matrix multiplication operation on the decryption key and the intermediate reasoning result to obtain the intermediate decryption result.
[0201] In some embodiments, the model decryption module 530 may also include a framework receiving unit and a decryption reasoning unit. The framework receiving unit is used to receive a target reasoning framework, which is obtained by encapsulating a target decryption plug-in and a model reasoning framework; the decryption reasoning unit is used to perform computational reasoning on the target model through the model reasoning framework, and perform the intermediate reasoning result of the decryption key decryption computational reasoning based on the target decryption plug-in to obtain the target reasoning result.
[0202] In some embodiments, the key acquisition module 520 can be specifically used to: generate a seed key based on the device identification, and perform a second matrix transformation on the seed key to obtain an intermediate key matrix; when it is detected that the intermediate key matrix is a reversible matrix, perform a matrix reversible calculation on the intermediate key matrix to obtain a reversible matrix corresponding to the intermediate key matrix; and use the reversible matrix corresponding to the intermediate key matrix as a decryption key.
[0203] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, modules, etc. can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0204] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.
[0205] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0206] like Fig.16 As shown, the embodiment of the present application also provides a computer device 600, which includes a processor 610, a memory 620, a power supply 630 and an input unit 640. The memory 620 stores a computer program. When the computer program is called by the processor 610, the various method steps provided in the above embodiment can be implemented. Those skilled in the art can understand that the structure of the computer device shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:
[0207] The processor 610 may include one or more processing cores. The processor 610 uses various interfaces and lines to connect various parts of the entire battery management system, and by running or executing instructions, programs, instruction sets or program sets stored in the memory 620, calls the data stored in the memory 620, executes various functions of the battery management system and processes data, and executes various functions and processes data of the computer device, thereby controlling the computer device as a whole. Optionally, the processor 610 can be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor 610 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 610, but may be implemented separately through a communication chip.
[0208] The memory 620 may include a random access memory (RAM) or a read-only memory (ROM). The memory 620 may be used to store instructions, programs, instruction sets or program sets. The memory 620 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc. The data storage area may also store data (such as a phone book and audio and video data) created by the computer device during use. Accordingly, the memory 620 may also include a memory controller to provide the processor 610 with access to the memory 620.
[0209] The power supply 630 can be logically connected to the processor 610 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 630 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.
[0210] The input unit 640 can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0211] Although not shown, the computer device 600 may also include an output unit, a display unit, etc., which are not described in detail herein. Specifically, in the embodiment of the present application, the processor 610 of the computer device will load the executable files corresponding to the processes of one or more computer programs into the memory 620 according to the following instructions, and the processor 610 will run the data stored in the memory 620, such as the phone book and audio and video data, so as to implement the various method steps provided in the aforementioned embodiments.
[0212] like Fig.17 As shown, an embodiment of the present application further provides a computer-readable storage medium 700, in which a computer program or computer instruction 710 is stored. The computer program or computer instruction 710 can be called by a processor of a computer device to execute various method steps provided in the embodiment of the present application.
[0213] The computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium (Non-Transitory Computer-Readable Storage Medium). The computer-readable storage medium 700 has a storage space for a computer program that executes any method step in the above embodiments. These computer programs can be read from or written to one or more computer program products. The computer program can be compressed in an appropriate form.
[0214] According to one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program or instructions, the computer program or instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer program or instructions from the computer-readable storage medium, and the processor executes the computer program or instructions, so that the computer device performs various method steps provided in the above embodiments.
[0215] The terms "include" and "comprising" and any variations thereof in the specification of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices. The term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that contains the function of the module or unit.
[0216] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0217] It should be understood that in the description of the embodiments of the present application, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to not include the number, and above, below, within, etc. are understood to include the number.
[0218] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0219] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware or in the form of software functional units.
[0220] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. It should also be understood that the various implementation methods provided in the embodiments of the present application can be arbitrarily combined to achieve different technical effects.
[0221] The above are only preferred embodiments of the present application, and are not intended to limit the present application in any form. Although the present application has been disclosed as above with preferred embodiments, it is not intended to limit the present application. Any technical personnel in the field can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present application. However, any brief modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present application without departing from the content of the technical solution of the present application are still within the scope of the technical solution of the present application.
Claims
1. A data processing method, characterized in that: The method comprises: Get the device ID corresponding to the target inference device; Generate a seed key based on the device identification, and perform a first matrix transformation on the seed key to obtain an encryption key; Encrypting the model parameters of the model to be encrypted according to the encryption key to obtain a target model; The target model is sent to the target reasoning device so that the target reasoning device constructs a calculation graph based on the calculation operators of the target model, and executes each calculation operator in sequence for calculation reasoning according to the topological order of the calculation graph. When it is detected that the current calculation operator calls the model parameter, the intermediate reasoning result of the calculation reasoning of the current calculation operator is decrypted based on the decryption key to obtain the intermediate decrypted result, and the intermediate decrypted result is passed to the next calculation operator of the current calculation operator to perform calculation reasoning until the calculation reasoning of the calculation graph is completed to obtain the target reasoning result. The decryption key is obtained by converting the seed key through the second matrix, and the decryption key and the encryption key are inverse matrices of each other.
2. The method according to claim 1, characterized in that The step of encrypting the model parameters of the to-be-encrypted model according to the encryption key to obtain the target model comprises: Obtain the parameters to be encrypted corresponding to the model to be encrypted; Perform parameter encryption on the parameter matrix to be encrypted corresponding to the parameter to be encrypted according to the encryption key to obtain a target parameter matrix; Based on the target parameter matrix and the calculation operator corresponding to the model to be encrypted, a target model is determined.
3. The method according to claim 2, characterized in that The step of encrypting the parameter matrix to be encrypted corresponding to the parameter to be encrypted according to the encryption key to obtain a target parameter matrix includes: Obtaining a weight parameter matrix and a bias parameter matrix corresponding to the parameters to be encrypted; Performing a matrix multiplication operation on the encryption key and the weight parameter matrix to obtain an encryption weight matrix; Performing a matrix multiplication operation on the encryption key and the bias parameter matrix to obtain an encryption bias matrix; The encrypted weight matrix and the encrypted bias matrix are used as target parameter matrices.
4. The method according to claim 1, characterized in that: The method further comprises: Obtaining the framework type of the model reasoning framework corresponding to the model to be encrypted; Generate a target decryption plug-in matching the model reasoning framework based on the framework type; The target decryption plug-in and the model reasoning framework are encapsulated to obtain a target reasoning framework.
5. The method according to claim 4, characterized in that The target model is sent to the target reasoning device so that the target reasoning device constructs a calculation graph based on the calculation operator of the target model, and executes each calculation operator in sequence for calculation reasoning according to the topological order of the calculation graph. When it is detected that the current calculation operator calls the model parameter, the intermediate reasoning result of the calculation reasoning of the current calculation operator is decrypted based on the decryption key to obtain the intermediate decrypted result, and the intermediate decrypted result is passed to the next calculation operator of the current calculation operator to perform calculation reasoning until the calculation reasoning of the calculation graph is completed to obtain the target reasoning result, including: The target model and the target reasoning framework are sent to the target reasoning device, so that the target reasoning device constructs a calculation graph based on the calculation operators of the target model through the model reasoning framework, and executes each calculation operator in turn for calculation reasoning according to the topological order of the calculation graph. When it is detected that the current calculation operator calls the model parameters, the decryption key is executed by the target decryption plug-in to decrypt the intermediate reasoning result of the calculation reasoning of the current calculation operator to obtain the intermediate decrypted result, and the intermediate decrypted result is passed to the next calculation operator of the current calculation operator to perform calculation reasoning until the calculation reasoning of the calculation graph is completed to obtain the target reasoning result.
6. The method according to any one of claims 1 to 5, characterized in that: The step of performing a first matrix transformation on the seed key to obtain an encryption key includes: Obtain the matrix dimension of the parameter matrix to be encrypted corresponding to the model to be encrypted; A first matrix transformation is performed on the seed key according to the matrix dimension, and the obtained target key matrix matching the matrix dimension is used as the encryption key.
7. The method according to claim 6, characterized in that The step of performing a first matrix transformation on the seed key according to the matrix dimension and using the obtained target key matrix matching the matrix dimension as the encryption key includes: Performing a first matrix transformation on the seed key according to the matrix dimension to obtain an intermediate key matrix matching the matrix dimension; When it is detected that the intermediate key matrix is a reversible matrix, using the intermediate key matrix as an encryption key; When it is detected that the intermediate key matrix is not a reversible matrix, return to perform the first matrix transformation on the seed key according to the matrix dimension, and re-detect whether the obtained intermediate key matrix is a reversible matrix, until the intermediate key matrix is a reversible matrix, and obtain the encryption key.
8. The method according to claim 7, characterized in that The method further comprises: Performing matrix reversible calculation on the intermediate key matrix corresponding to the encryption key to obtain a reversible matrix corresponding to the intermediate key matrix; The reversible matrix corresponding to the intermediate key matrix is used as a decryption key, and the decryption key is sent to the target inference device.
9. The method according to claim 1, characterized in that: The generating a seed key based on the device identification includes: When it is detected that the device identification corresponding to the target inference device is obtained for the first time, obtaining the first acquisition time corresponding to the device identification; A key is generated based on the first acquisition time and a device identifier corresponding to the first acquisition time to obtain a seed key.
10. A data processing method, characterized in that: The method comprises: Receiving a target model, wherein the target model is obtained by encrypting a model to be encrypted using an encryption key generated corresponding to the device identifier; Obtaining a decryption key generated corresponding to the device identification, wherein the decryption key and the encryption key are inverse matrices of each other; Perform computational reasoning on the target model, build a computational graph based on the computational operators of the target model, and execute each computational operator in sequence for computational reasoning according to the topological order of the computational graph. When it is detected that the current computational operator calls the model parameters, decrypt the intermediate reasoning result of the computational reasoning of the current computational operator based on the decryption key to obtain the intermediate decrypted result, and pass the intermediate decrypted result to the next computational operator of the current computational operator to perform computational reasoning until the computational reasoning of the computational graph is completed and the target reasoning result is obtained.
11. The method according to claim 10, characterized in that When it is detected that the current computing operator calls the model parameter, the intermediate inference result of the current computing operator calculation inference is decrypted based on the decryption key to obtain the intermediate decryption result, including: When it is detected that the current computing operator calls the model parameters, the encrypted weight matrix and the encrypted bias matrix corresponding to the model parameters of the current computing operator are obtained, and the intermediate reasoning results obtained through calculation reasoning; A matrix multiplication operation is performed on the decryption key and the intermediate inference result to obtain an intermediate decryption result.
12. The method according to claim 10, characterized in that The target model is operated and reasoned, a calculation graph is constructed based on the calculation operators of the target model, and each calculation operator is executed in sequence to perform calculation and reasoning according to the topological order of the calculation graph. When it is detected that the current calculation operator calls the model parameter, the intermediate reasoning result of the calculation and reasoning of the current calculation operator is decrypted based on the decryption key to obtain the intermediate decrypted result, and the intermediate decrypted result is passed to the next calculation operator of the current calculation operator to perform calculation and reasoning until the calculation and reasoning of the calculation graph are completed to obtain the target reasoning result, including: Receiving a target reasoning framework, wherein the target reasoning framework is obtained by encapsulating a target decryption plug-in and a model reasoning framework; The target model is subjected to computational reasoning through the model reasoning framework, a computational graph is constructed based on the computational operators of the target model, and each computational operator is executed in sequence for computational reasoning according to the topological order of the computational graph. When it is detected that the current computational operator calls the model parameters, the decryption key is executed through the target decryption plug-in to decrypt the intermediate reasoning result of the computational reasoning of the current computational operator to obtain the intermediate decrypted result, and the intermediate decrypted result is passed to the next computational operator of the current computational operator to perform computational reasoning until the computational reasoning of the computational graph is completed to obtain the target reasoning result.
13. The method according to any one of claims 10 to 12, characterized in that: The obtaining of the decryption key generated corresponding to the device identification includes: Generate a seed key based on the device identification, and perform a second matrix transformation on the seed key to obtain an intermediate key matrix; When it is detected that the intermediate key matrix is a reversible matrix, performing matrix reversible calculation on the intermediate key matrix to obtain a reversible matrix corresponding to the intermediate key matrix; The reversible matrix corresponding to the intermediate key matrix is used as the decryption key.
14. A data processing device, characterized in that: The device comprises: An identification acquisition module, used to obtain a device identification corresponding to a target inference device; A key generation module, used to generate a seed key based on the device identification, and perform a first matrix transformation on the seed key to obtain an encryption key; A model encryption module, used for encrypting the model parameters of the to-be-encrypted model according to the encryption key to obtain a target model; A model sending model is used to send the target model to the target reasoning device, so that the target reasoning device constructs a calculation graph based on the calculation operators of the target model, and executes each calculation operator in turn for calculation reasoning according to the topological order of the calculation graph. When it is detected that the current calculation operator calls the model parameter, the intermediate reasoning result of the calculation reasoning of the current calculation operator is decrypted based on the decryption key to obtain the intermediate decrypted result, and the intermediate decrypted result is passed to the next calculation operator of the current calculation operator to perform calculation reasoning until the calculation reasoning of the calculation graph is completed to obtain the target reasoning result. The decryption key is obtained by converting the seed key through the second matrix, and the decryption key and the encryption key are inverse matrices of each other.
15. A data processing device, characterized in that: The device comprises: A model receiving module, used for receiving a target model, wherein the target model is obtained by encrypting a model to be encrypted using an encryption key generated corresponding to a device identifier; A key acquisition module, used to acquire a decryption key generated corresponding to the device identification, wherein the decryption key and the encryption key are inverse matrices of each other; A model decryption module is used to perform computational reasoning on the target model, construct a computational graph based on the computational operators of the target model, and execute each computational operator in sequence for computational reasoning according to the topological order of the computational graph. When it is detected that the current computational operator calls the model parameters, the intermediate reasoning result of the computational reasoning of the current computational operator is decrypted based on the decryption key to obtain the intermediate decrypted result, and the intermediate decrypted result is passed to the next computational operator of the current computational operator to perform computational reasoning until the computational reasoning of the computational graph is completed and the target reasoning result is obtained.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data processing method according to any one of claims 1 to 9 or the data processing method according to any one of claims 10 to 13 is implemented.
17. A computer device, characterized in that: include: Memory; A processor, wherein a computer program is stored on the memory, and when the computer program is executed by the processor, the data processing method according to any one of claims 1 to 9 or the data processing method according to any one of claims 10 to 13 is implemented.
18. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the data processing method according to any one of claims 1 to 9 or the data processing method according to any one of claims 10 to 13 is implemented.
