Large-model training method, apparatus and device, and storage medium
Patent Information
- Application Number
- PCT/CN2024/141657
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-05
- Filing Date
- 2024-12-23
- Publication Date
- 2025-10-02
AI Technical Summary
During the training process of large models, there are problems with low data security and insufficient utilization of computing power. In particular, small and medium-sized enterprises are unable to effectively participate in the training and reasoning of large models due to limited computing power.
The large model is split into head adapter and tail adapter, deployed on the cloud and local client respectively, and sharded training is performed through multi-party secure computing. Cloud computing power is used for model training and inference to ensure data privacy.
It achieves effective training of large models while ensuring data security and full utilization of computing power, improves data security and utilization of computing resources, and the number of Adaptor parameters only accounts for a few percent or a few thousandths of the entire model, achieving the same effect as fine-tuning all parameters of the entire model.
Smart Images

Figure CN2024141657_02102025_PF_FP_ABST
Abstract
Description
Large model training method, device, equipment and storage medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 5, 2024, with application number 202410252065.9 and application name “Training method, device, equipment and storage medium for large models”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of big data technology, and specifically to a large model training method, device, equipment and storage medium. Background Art
[0003] With the further development of big model technology and big data, paying attention to data privacy and security has become a global trend. How to ensure data and model privacy while enabling both parties to collaborate on large model training and inference is a key focus.
[0004] Currently, a trained large model typically contains billions or tens of billions of parameters, requiring computing power and private data for fine-tuning. Small and medium-sized enterprises often have localized data that can be used to fine-tune large models. Model and data owners want to collaborate on a large model, but neither party is willing to disclose their data to the other. However, small and medium-sized enterprises have limited computing power on their local clients.
[0005] Therefore, in the relevant technologies, during the training of large models, there are technical problems such as low data security and insufficient utilization of computing power. Summary of the Invention
[0006] The present application provides a large-model training method, apparatus, equipment, and storage medium, thereby solving the technical problems of low data security and insufficient computing power utilization during large-model training.
[0007] In a first aspect, the present application provides a method for training a large model, the large model comprising a head adapter, a model body, and a tail adapter; wherein the head adapter comprises a first cloud portion and a first local portion, and the tail adapter comprises a second cloud portion and a second local portion; during training of the large model, the first cloud portion, the model body, and the second cloud portion are deployed in the cloud, and the first local portion and the second local portion are deployed on a local client;
[0008] The method comprises:
[0009] The local client obtains the training data and performs sharding processing on the training data to obtain first sharded training data and second sharded training data;
[0010] The local client sends the first shard training data to the cloud;
[0011] The cloud inputs the first segmented training data into the first cloud part for calculation, and the local client inputs the second segmented training data into the first local part for calculation, so as to output a first feature vector and send it to the cloud;
[0012] The cloud inputs the first feature vector into the model body to output a second feature vector;
[0013] The cloud performs sharding processing on the second feature vector to obtain a first shard feature vector and a second shard feature vector, and sends the second shard feature vector to the client;
[0014] The cloud inputs the first shard feature vector to the second cloud part for calculation, and the local client inputs the second shard feature vector to the second local part for calculation, so as to output a prediction result of the training data;
[0015] The cloud and local clients iteratively adjust the large model according to the prediction results of a preset amount of training data until the model converges.
[0016] In the process of training the large model, the present application splits the large model into three parts, the middle model body M0 and two adapter parts, the head adapter Adaptor Header and the tail adapter Adaptor Tail. The head adapter includes a first cloud part AH1 and a first local part AH2, and the tail adapter includes a second cloud part AT1 and a second local part AT2. Each adapter is divided into two parts, half of which is located in the cloud Cloud and half is located in the local client Client. The training data for the large model is industry privatized data from the Client. After it is sliced and entered, it enters the cloud and the local client respectively for the first joint training. After the first training, the first eigenvector in the form of a eigenvector is obtained, and then input into the cloud for plaintext training of all the training data. The output of the cloud is then sliced and processed for a second joint training in the cloud and the local client respectively to obtain the prediction result of the training data. According to the prediction result of the training data, a trained large model can be obtained. Based on the above training method, during the collaborative reasoning operation of the large model and the small model, neither the model nor the data leaves the local machine. The cloud can only obtain part of the data after sharding, and it is difficult to restore the feature vector of the original input, which protects privacy and improves data security. In addition, only the head and tail Adaptors are distributed to the cloud and the client, and the encrypted client data is used for the Adaptor model training. The main structure of the model is still located in the cloud, and the Cloud computing power is used for training and reasoning, which ensures the computing power performance. At the same time, the Adaptor fine-tuning mechanism is effectively utilized. The number of Adaptor parameters only accounts for a few percent or a few thousandths of the entire original large model, which can achieve almost the same effect as the fine-tuning of all parameters of the full model, realizing the effective training of large models under the premise of safety and full utilization of computing power.
[0017] Optionally, the cloud inputs the first segmented training data into the first cloud part for calculation, and the local client inputs the second segmented training data into the first local part for calculation, so as to output a first feature vector and send it to the cloud, including:
[0018] The cloud inputs the first shard training data into the first cloud part for calculation, and the local client inputs the second shard training data into the first local part for calculation. During the calculation process of the first cloud part and the first local part, an encrypted calculation method of multi-party secure computing is used to output the first feature vector after the calculation of the first cloud part and the first local part and send it to the cloud.
[0019] Among them, the present application can share computing parameters based on multi-party secure computing, thereby realizing joint training of the first cloud part and the first local part based on a secret sharing protocol, and converting the original data into a difficult-to-restore feature vector through multi-party secure computing, further improving the security and feasibility of large-scale model training.
[0020] Optionally, the cloud inputs the first shard feature vector to the second cloud part for calculation, and the local client inputs the second shard feature vector to the second local part for calculation, to output a prediction result of the training data, including:
[0021] The cloud inputs the first shard feature vector into the second cloud part for calculation, and the local client inputs the second shard feature vector into the second local part for calculation. During the calculation process of the second cloud part and the second local part, an encrypted calculation method of multi-party secure computing is used to output the prediction result of the training data through the calculation of the second cloud part and the second local part.
[0022] Among them, the operation of the tail adapter in this application is also based on multi-party secure computing to share operation parameters, thereby realizing joint training of the second cloud part and the second local part based on the secret sharing protocol, further improving the security and feasibility of large model training.
[0023] Optionally, the multi-party secure computation includes an ABY hybrid protocol or a secret sharing protocol.
[0024] Optionally, the cloud and local client iteratively adjust the large model according to prediction results of a preset amount of training data until the model converges, including:
[0025] The cloud obtains a loss parameter based on the preset label corresponding to the prediction result and the training data; the cloud adjusts the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter; the local client adjusts the model parameters of the first local part and the second local part of the large model according to the loss parameter; if the local client determines that the prediction error of the large model is greater than the preset threshold, the step of "local client obtaining training data" is re-executed to continue training the large model; if it is determined that the prediction error of the large model is less than or equal to the preset threshold, the iterative training is stopped.
[0026] Optionally, the cloud obtains a loss parameter according to the prediction result and a preset label corresponding to the training data, including:
[0027] The cloud inputs the prediction result and the preset label into the loss function to output the loss parameter.
[0028] Optionally, the loss function is calculated as follows:
[0029] Among them, L represents the loss function, M represents the number of categories, N represents the number of samples, and y ic Is a symbolic function that represents the probability that the i-th sample belongs to the c-th category, p ic It represents the probability that the model predicts that the i-th sample belongs to the c-th category, where i and N are any positive integers.
[0030] Here, after obtaining the prediction results of the training data, this application calculates the loss with the predicted labels and feeds back the entire model network for model convergence calculation, thereby adjusting the model parameters of the large model to adjust the large model until the requirements are met, thereby realizing the training of the large model.
[0031] Optionally, before obtaining a loss parameter on the cloud according to the prediction result and the preset label corresponding to the training data, and adjusting the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter, the method further includes:
[0032] The local client encrypts the preset label corresponding to the training data according to a preset encryption algorithm to obtain an encrypted label; the local client sends the encrypted label to the cloud.
[0033] Here, in order to further ensure data security during the large-scale model training process, when the local client of this application sends the preset labels corresponding to the training data to the cloud, the preset labels are first encrypted. The cloud cannot obtain the original preset labels, which further improves the security of large-scale model training.
[0034] Optionally, the cloud obtains a loss parameter based on the prediction result and a preset label corresponding to the training data, and adjusts model parameters of the first cloud part and the second cloud part of the large model based on the loss parameter, including:
[0035] The cloud encrypts the prediction result according to the preset encryption algorithm to obtain an encrypted preset result; the cloud obtains a loss parameter based on the encrypted prediction result and the encrypted label, and adjusts the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter.
[0036] Optionally, the preset encryption algorithm is a homomorphic encryption algorithm.
[0037] Here, the cloud encrypts the prediction results of the training data according to the preset encryption algorithm of the local client for the preset labels, so that the encrypted prediction results can be processed with the encrypted labels to obtain the loss parameters, and then the model parameters can be adjusted under the premise of safety and reliability.
[0038] Optionally, the sharding the training data to obtain first sharded training data and second sharded training data includes:
[0039] The training data is randomly fragmented to obtain first fragmented training data and second fragmented training data.
[0040] Among them, when sharding the training data, this application can adopt a random sharding method. Through this method, the cloud cannot restore the original training data, thereby fully protecting the data security of the local client.
[0041] Optionally, the sharding the training data to obtain first sharded training data and second sharded training data includes:
[0042] The training data is sliced according to a first preset secret slice algorithm to obtain first sliced training data and second sliced training data.
[0043] Among them, when sharding the training data, this application can adopt a first preset secret sharding algorithm. Through this method, the cloud cannot restore the original training data, thereby fully protecting the data security of the local client.
[0044] Optionally, the cloud performs sharding processing on the second feature vector to obtain a first sharding feature vector and a second sharding feature vector, including:
[0045] The cloud performs random sharding on the second feature vector to obtain a first shard feature vector and a second shard feature vector.
[0046] Optionally, the cloud performs sharding processing on the second feature vector to obtain a first sharding feature vector and a second sharding feature vector, including:
[0047] The cloud performs sharding on the second feature vector according to a second preset secret sharding algorithm to obtain a first sharding feature vector and a second sharding feature vector.
[0048] Here, the cloud of this application can slice the second eigenvector through random or preset algorithms, and further split the data to achieve safe and reliable joint training of the cloud and local client, further improving the data security and data privacy of large model training.
[0049] Optionally, the head adapter and tail adapter of the trained large model are deployed on the local client, and the model body is deployed on the cloud.
[0050] Among them, the head adapter and tail adapter of the large model trained in this application are deployed locally, and the main body of the model is deployed in the cloud. The data inference and prediction stage also requires cooperation between both parties to complete. No one party can complete the inference independently. The data rights and interests of the local client are guaranteed, and the model and computing power rights and interests of the cloud are guaranteed, which improves the security of large model predictions and the utilization of computing resources.
[0051] Optionally, the above method further includes:
[0052] The local client obtains a piece of data to be predicted; the local client inputs the data to be predicted into the head adapter to output a first prediction vector; the local client sends the first prediction vector to the cloud; the cloud inputs the first prediction vector into the model body to output a second prediction vector; the cloud sends the second prediction vector to the local client; the local client inputs the second prediction vector into the tail adapter to output a prediction result of the data to be predicted.
[0053] Here, this application can perform inference and prediction based on the trained large model. For the data to be predicted on the local client, the head adapter of the local client is first used to convert the data to be predicted into a first prediction vector encrypted relative to the cloud, and then the computing power of the cloud is used to fully infer and predict the data to be predicted, and then the prediction result of the data to be predicted is output through the tail adapter of the local client, thereby realizing safe and efficient data inference and prediction.
[0054] Optionally, the data format of the first prediction vector is an encrypted format.
[0055] The encrypted format of the first prediction vector further ensures the security of local client data.
[0056] In a second aspect, the present application provides a training device for a large model, the large model comprising a head adapter, a model body, and a tail adapter; wherein the head adapter comprises a first cloud portion and a first local portion, and wherein the tail adapter comprises a second cloud portion and a second local portion; during training of the large model, the first cloud portion, the model body, and the second cloud portion are deployed in the cloud, and the first local portion and the second local portion are deployed on a local client;
[0057] The device comprises:
[0058] A first processing module is configured to obtain training data from a local client and perform sharding processing on the training data to obtain first sharded training data and second sharded training data;
[0059] A first sending module, configured for the local client to send the first segmented training data to the cloud;
[0060] a second processing module, configured to input the first segmented training data into the first cloud portion for calculation on the cloud side, and to input the second segmented training data into the first local portion for calculation on the local client side, so as to output a first feature vector and send the result to the cloud side;
[0061] A first input module, configured to input the first feature vector into the model body on the cloud to output a second feature vector;
[0062] A third processing module is configured to perform sharding processing on the second feature vector in the cloud to obtain a first sharding feature vector and a second sharding feature vector, and send the second sharding feature vector to the client;
[0063] a fourth processing module, configured to input the first shard feature vector to the second cloud part for calculation on the cloud side, and to input the second shard feature vector to the second local part for calculation on the local client side, so as to output a prediction result of the training data;
[0064] The fifth processing module is used for the cloud and the local client to iteratively adjust the large model according to the prediction results of a preset amount of training data until the model converges.
[0065] Optionally, the second processing module is specifically configured to:
[0066] The cloud inputs the first shard training data into the first cloud part for calculation, and the local client inputs the second shard training data into the first local part for calculation. During the calculation process of the first cloud part and the first local part, an encrypted calculation method of multi-party secure computing is used to output the first feature vector after the calculation of the first cloud part and the first local part and send it to the cloud.
[0067] Optionally, the fourth processing module is specifically configured to:
[0068] The cloud inputs the first shard feature vector into the second cloud part for calculation, and the local client inputs the second shard feature vector into the second local part for calculation. During the calculation process of the second cloud part and the second local part, an encrypted calculation method of multi-party secure computing is used to output the prediction result of the training data through the calculation of the second cloud part and the second local part.
[0069] Optionally, the multi-party secure computation includes an ABY hybrid protocol or a secret sharing protocol.
[0070] Optionally, the fifth processing module is specifically configured to:
[0071] The cloud obtains a loss parameter based on the preset label corresponding to the prediction result and the training data; the cloud adjusts the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter; the local client adjusts the model parameters of the first local part and the second local part of the large model according to the loss parameter; if the local client determines that the prediction error of the large model is greater than the preset threshold, the step of "local client obtaining training data" is re-executed to continue training the large model; if it is determined that the prediction error of the large model is less than or equal to the preset threshold, the iterative training is stopped.
[0072] Optionally, the fifth processing module is further specifically configured to: input the prediction result and the preset label into a loss function on the cloud side to output the loss parameter.
[0073] Optionally, the loss function is calculated as follows:
[0074] Among them, L represents the loss function, M represents the number of categories, N represents the number of samples, and y ic Is a symbolic function that represents the probability that the i-th sample belongs to the c-th category, p ic It represents the probability that the model predicts that the i-th sample belongs to the c-th category, where i and N are any positive integers.
[0075] Optionally, before the fifth processing module is used in the cloud to obtain a loss parameter based on the prediction result and the preset label corresponding to the training data, and adjusts the model parameters of the first cloud-based part and the second cloud-based part of the large model based on the loss parameter, the apparatus further includes an encryption processing module configured to:
[0076] The local client encrypts the preset label corresponding to the training data according to a preset encryption algorithm to obtain an encrypted label; the local client sends the encrypted label to the cloud.
[0077] Optionally, the fifth processing module is specifically configured to:
[0078] The cloud encrypts the prediction result according to the preset encryption algorithm to obtain an encrypted preset result; the cloud obtains a loss parameter based on the encrypted prediction result and the encrypted label, and adjusts the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter.
[0079] Optionally, the preset encryption algorithm is a homomorphic encryption algorithm.
[0080] Optionally, the first processing module is specifically configured to:
[0081] The training data is randomly fragmented to obtain first fragmented training data and second fragmented training data.
[0082] Optionally, the first processing module is specifically configured to:
[0083] The training data is sliced according to a first preset secret slice algorithm to obtain first sliced training data and second sliced training data.
[0084] Optionally, the third processing module is specifically configured to:
[0085] The cloud performs random sharding on the second feature vector to obtain a first shard feature vector and a second shard feature vector.
[0086] Optionally, the third processing module is specifically configured to:
[0087] The cloud performs sharding on the second feature vector according to a second preset secret sharding algorithm to obtain a first sharding feature vector and a second sharding feature vector.
[0088] Optionally, the head adapter and tail adapter of the trained large model are deployed on the local client, and the model body is deployed on the cloud.
[0089] Optionally, the above device further includes an inference prediction module, configured to:
[0090] The local client obtains a piece of data to be predicted; the local client inputs the data to be predicted into the head adapter to output a first prediction vector; the local client sends the first prediction vector to the cloud; the cloud inputs the first prediction vector into the model body to output a second prediction vector; the cloud sends the second prediction vector to the local client; the local client inputs the second prediction vector into the tail adapter to output a prediction result of the data to be predicted.
[0091] Optionally, the data format of the first prediction vector is an encrypted format.
[0092] In a third aspect, the present application provides a large model training device, comprising: at least one processor and a memory;
[0093] The memory stores computer-executable instructions;
[0094] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the large model training method described in the first aspect and various possible designs of the first aspect.
[0095] In a fourth aspect, the present invention provides a computer-readable storage medium, which stores computer-executable instructions. When a processor executes the computer-executable instructions, it implements the training method of the large model described in the first aspect and various possible designs of the first aspect.
[0096] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which, when executed by a processor, implements the large model training method described in the first aspect and various possible designs of the first aspect.
[0097] The present application provides a training method, apparatus, equipment and storage medium for a large model, wherein the method uses industry-privatized data from the client as training data for the large model. After the data is sliced and entered, it is entered into the cloud and the local client for the first joint training. After the first training, the first eigenvector in the form of a eigenvector is obtained, and then input into the cloud for plaintext training of all the training data. The output of the cloud is then sliced and processed for a second joint training in the cloud and the local client to obtain the prediction results of the training data. Based on the prediction results of the training data, a trained large model can be obtained. Based on the above training method, during the collaborative reasoning operation of the large model and the small model, neither the model nor the data leaves the local machine. The cloud can only obtain part of the data after sharding, and it is difficult to restore the feature vector of the original input, which protects privacy and improves data security. In addition, only the head and tail Adaptors are distributed to the cloud and the client, and the encrypted client data is used for the Adaptor model training. The main structure of the model is still located in the cloud, and the Cloud computing power is used for training and reasoning, which ensures the computing power performance. At the same time, the Adaptor fine-tuning mechanism is effectively utilized. The number of Adaptor parameters only accounts for a few percent or a few thousandths of the entire original large model, which can achieve almost the same effect as the fine-tuning of all parameters of the full model, realizing the effective training of large models under the premise of safety and full utilization of computing power. BRIEF DESCRIPTION OF THE DRAWINGS
[0098] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0099] FIG1 is a schematic diagram of a cloud-based and local client joint model structure provided by an embodiment of the present application;
[0100] FIG2 is a schematic diagram of a large model structure based on an Adaptor method provided in an embodiment of the present application;
[0101] FIG3 is a schematic diagram of a model structure of a training process of a large model provided in an embodiment of the present application;
[0102] FIG4 is a flow chart of a large model training method provided in an embodiment of the present application;
[0103] FIG5 is a schematic diagram of the basic operation logic of an ABY protocol provided in an embodiment of the present application;
[0104] FIG6 is a schematic diagram of a parameter training process provided in an embodiment of the present application;
[0105] FIG7 is a schematic diagram of the structure of a trained large model provided in an embodiment of the present application;
[0106] FIG8 is a flow chart of another large model training method provided in an embodiment of the present application;
[0107] FIG9 is a schematic structural diagram of a large-model training device provided in an embodiment of the present application.
[0108] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0109] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0110] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0111] A general-purpose, pre-trained large model typically contains billions or tens of billions of parameters, requiring computing power and private data for fine-tuning. Small and medium-sized enterprises often have localized data that can be used to fine-tune large models, resulting in customized models. However, the current situation or difficulty lies in the fact that model and data owners want to collaborate on a large model, but are reluctant to disclose their respective content (model and data) to each other.
[0112] Currently, there are three approaches to training large models: Approach 1 proposes a privacy-preserving computing method and system based on distributed collaboration. This technical solution primarily consists of a software development kit (SDK), a controller, and multiple privacy-preserving computing appliances. The controller is deployed in the edge cloud, and the appliances are deployed in a private cloud. In the collaborative privacy-preserving computing process, the SDK first requests access to a dataset from n privacy-preserving appliances through the controller. Data element holders can register their datasets with the controller through the privacy-preserving appliances. This information includes, but is not limited to, data characteristics, data sources, data quantity, data usage rights pricing, and data privacy rules. After the SDK receives data from multiple privacy-preserving appliances, developers can develop privacy-preserving applications within the SDK. Upon completion, these applications are sent to the controller, which decomposes the privacy-preserving applications and sends the resulting computational tasks to each of the n privacy-preserving appliances. Each privacy-preserving appliance then computes the computational task based on its stored dataset, and the controller transmits the results to the SDK. Method 2 proposes a federated learning method and system, a first privacy-preserving computing platform, and a second privacy-preserving computing platform. This technical solution enables collaborative optimization of a federated learning model by exchanging model-related information through encryption, without sharing protected private data or transmitting proprietary data externally. The two privacy-preserving computing platforms adhere to different protocols. Specifically, a first interactive operation is performed with a first data party based on a first parameter ciphertext held by the first data party, resulting in first data to be aggregated. The first parameter ciphertext is obtained by the first data party training locally based on its own dataset and encrypted according to a first encryption protocol. The first data to be aggregated conforms to a second encryption protocol supported by the second privacy-preserving computing platform. The first data to be aggregated is forwarded to the second privacy-preserving computing platform via a routing node, so that the second privacy-preserving computing platform performs a first aggregation calculation using the first and second data to be aggregated to obtain aggregation parameters. The second data to be aggregated is calculated based on the second parameter ciphertexts of each second data party on the second privacy-preserving computing platform, and the second data to be aggregated conforms to a second encryption protocol. The aggregation parameters are returned by the second privacy-preserving computing platform and forwarded by the routing node, and the next round of iterative calculations is performed using the aggregation parameters. Method three proposes a skyline query method and system for privacy protection of sensitive data. This technical solution uploads sensitive data information to two non-colluding first and second servers through additive secret sharing. The two servers generate a skyline graph through joint privacy calculation, and each has a corresponding share graph; at the user end, user information is uploaded through additive secret sharing. Each server jointly retrieves the similar information share that the user expects to query on its own share graph through a private information retrieval method, and sends the similar information share to the user end; the user end recovers the complete query information to assist in decision-making.
[0113] However, all of the above approaches have drawbacks. The technical solution proposed in Approach 1 suffers from certain shortcomings, primarily due to factors such as data characteristics, data sources, and data volume being transferred out of the local private cloud during the collaborative privacy computing task, posing risks to data security. Furthermore, regarding computing power, the final privacy computing task is sent back to n privacy computing machines via the SDK controller for local execution. For the decentralized participants in privacy computing in federated scenarios, insufficient computing power is often a thorny issue. How to effectively leverage the abundant computing power of major cloud providers to efficiently collaborate on privacy computing tasks remains a research topic. Approach 2 primarily focuses solely on protocol conversion. While the private data of both parties can be kept locally, it fails to consider the impact on computational efficiency and the significant computational cost of transferring full parameters. Approach 3 primarily requires the decision service provider to upload its full historical data to two servers using additive secret sharing. This results in data being transferred out of the local cloud, making the "data available but not visible" model impossible. Furthermore, uploading full historical data to two servers, along with the continuous generation of massive amounts of user data, places significant strain on the communication link. Two servers perform grid-based information retrieval. After retrieving similar information that the user wishes to query, they send their respective shares of similar information to the user end. The user end restores the complete similar information to facilitate the user's query and provide auxiliary decision-making. Although this method isolates the querying user from the data and has a certain degree of privacy protection, it is essentially a traditional database query and is not close to the specific vertical field's actual application demands for large models (Large Language Model) to process massive data and implement model training and inference.
[0114] From the above, we can see that relevant technologies have technical problems such as low data security and insufficient utilization of computing power during the training of large models.
[0115] In order to solve the above problems, the embodiments of the present application provide a large model training method, device, equipment and medium. In this method, the cloud and the local client collaborate to jointly build a customized large model to achieve privacy protection and rights protection. The privacy includes the cloud model and the client's private data. During the cooperation process, the privacy is not exposed to the other party, and the formed model can still reflect the respective rights and interests during use.
[0116] Optionally, the embodiments of the present application can implement the following functions:
[0117] (1) Protecting data and model privacy through secret sharing: Various secret sharing protocols are used in the collaborative reasoning process between large and small models, so that neither the model nor the data is locally stored. Heterogeneous interoperable operators can also be used. Secure operators emphasize basic computing tools based on cryptographic construction and implemented using secure computing protocols, such as multi-party matrix multiplication, Euclidean distance, and size comparison calculations.
[0118] (2) Rationally utilize computing power to ensure overall performance: Only the first and last adapters are distributed to the cloud and the local client for adapter model training. The majority of the model structure remains in the cloud, using cloud computing power for training and inference to ensure performance.
[0119] (3) Effectively utilize the Adaptor fine-tuning mechanism: The Adaptor is generally a partially effective layer in the original large model, such as a low-rank matrix of parameters, or a parameter layer with a very small proportion embedded in each layer of the large model. The number of Adaptor parameters accounts for only a few percent or a few thousandths of the entire original large model, which can achieve almost the same effect as fine-tuning all parameters of the entire model. This feature is used to distribute some parameters of a very small part of the model (i.e., the Adaptor) to the client side, and jointly complete secure training / inference based on privacy protection / secret sharing protocols with the cloud side.
[0120] Optionally, Figure 1 is a schematic diagram of a joint model structure of the cloud and local client provided in an embodiment of the present application. As shown in Figure 1, the local client here is also called a client. The embodiment of the present application can obtain a trained large model by jointly training the original large model through the cloud and the local client.
[0121] Optionally, Figure 2 is a schematic diagram of a large model structure based on the Adaptor method provided in an embodiment of the present application. As shown in Figure 2, the model structure: the model consists of three parts, the middle model M0 and two Adaptor parts at the head and tail, including a head adapter (Adaptor Header, AH) and a tail adapter (Adaptor Tail, AT). The Adaptor is a small effective layer of the head and tail of the original large model, usually accounting for only a few percent or even a few thousandths of the parameters, and is specifically used to fine-tune the original model. Fine-tuning method: The training data Data is fed to the large model for fine-tuning training. During the training process, only the parameters of the Adaptor part are updated, and the parameters of the M0 part remain unchanged. Method features: This fine-tuning method can only fine-tune the parameters of the original large model by a few percent or even a few thousandths, and can achieve a model inference accuracy that is almost the same as fine-tuning the entire original model.
[0122] As shown in Figure 2, during pre-training, the large model M = AH + M0 + AT. After fine-tuning, that is, training is complete, the trained large model M^* = AH^* + M0 + AT^*. Only the parameters of the adapter are updated, while the parameters of the M0 component remain unchanged. It should be understood that the "+" here does not represent a mathematical calculation, but rather represents the combination of the model M0 and the two adapter components at the beginning and end.
[0123] It is understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the training system architecture of the large model. In other feasible implementations of the present application, the above architecture may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The specific configuration can be determined according to the actual application scenario and is not limited here. The components shown in Figures 1 and 2 can be implemented in hardware, software, or a combination of software and hardware.
[0124] In a specific implementation process, the cloud and local client include processors or processing devices.
[0125] It should be understood that the above-mentioned processing device can be implemented by a processor reading instructions in a memory and executing the instructions, or it can be implemented by a chip circuit.
[0126] In addition, the network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field can know that with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0127] The technical solution of this application is described in detail below with reference to specific embodiments:
[0128] Optionally, Figure 3 is a schematic diagram of the model structure of the training process of a large model provided in an embodiment of the present application. As shown in Figure 3, the large model of the training process includes a head adapter (the first cloud part and the first local part constitute the head adapter), a model body M0 and a tail adapter (the second cloud part and the second local part constitute the tail adapter); wherein the head adapter includes the first cloud part AH1 and the first local part AH2, wherein the tail adapter includes the second cloud part AT1 and the second local part AT2; in the process of training the large model, the first cloud part, the model body and the second cloud part are deployed on the cloud, and the first local part and the second local part are deployed on the local client.
[0129] During the training process, the data Data is split into two parts D1 and D2.
[0130] An adaptor is typically a valid layer in the original large model, such as a low-rank matrix of parameters, or a parameter layer with a very small percentage embedded in each layer of the large model. The adaptor consists of two parts: the adaptor header and the adaptor tail, denoted as AH and AT, respectively. Part of each part is distributed on the cloud side, while the other part is on the client side. The remaining parameters of the large model remain on the cloud side.
[0131] As shown in Figure 3, the cloud part and the local part can achieve joint training through multi-party computing (MPC) operators.
[0132] As shown in Figure 3, the collaborative training process is as follows:
[0133] Step 1: The original training data is the industry-private data from the client, which is sharded and entered into the next step of the training process based on secret sharing calculation.
[0134] Through step one, the client input data is protected.
[0135] Step 2: The Adapter Header is divided into two halves, one in the Cloud and the other in the Client. Both parties conduct the first joint training based on the secret sharing protocol.
[0136] Through step 2, some parameters of the Adaptor are dispersed.
[0137] Step 3: Output after Adaptor Header training in plain text.
[0138] At this point, the output data of the middle layer is already a feature vector, and it is difficult to restore the original input.
[0139] Step 4: Perform plaintext training on all training data on the Cloud side.
[0140] The M0 computing part on the cloud side can prevent the large model from being leaked while making full use of the computing power on the cloud side.
[0141] Step 5: The output of M0 is again secret-shared and split into two halves. The Adaptor Tail is also split into two halves, one in the Cloud and the other in the Client. Both parties conduct a second joint training based on the secret-sharing protocol.
[0142] Some parameters of the Adaptor continue to be dispersed.
[0143] Optionally, FIG4 is a flow chart of a large model training method provided in an embodiment of the present application, which is used to train the large model in FIG3. The execution subject of the embodiment of the present application can be the cloud-based and local client joint model in FIG1, and the specific execution subject can be determined according to the actual application scenario. As shown in FIG4, the method includes the following steps:
[0144] S401: The local client obtains training data and performs sharding processing on the training data to obtain first sharded training data and second sharded training data.
[0145] Optionally, any training data may be obtained, and sharding may be performed on the training data to obtain first sharded training data and second sharded training data.
[0146] Optionally, sharding the training data to obtain first sharded training data and second sharded training data includes:
[0147] The training data is randomly sharded to obtain first sharded training data and second sharded training data.
[0148] Among them, the embodiment of the present application can adopt a random sharding method when sharding the training data. Through this method, the cloud cannot restore the original training data, thereby fully protecting the data security of the local client.
[0149] Optionally, sharding the training data to obtain first sharded training data and second sharded training data includes:
[0150] The training data is sliced according to a first preset secret slicing algorithm to obtain first sliced training data and second sliced training data.
[0151] It is understandable that the first preset secret sharding algorithm can be determined according to actual conditions, and the embodiment of the present application does not impose any specific restrictions on this.
[0152] Among them, when sharding the training data, the embodiment of the present application can adopt a first preset secret sharding algorithm. Through this method, the cloud cannot restore the original training data, thereby fully protecting the data security of the local client.
[0153] S402: The local client sends the first shard training data to the cloud.
[0154] S403: The cloud inputs the first segmented training data into the first cloud part for calculation, and the local client inputs the second segmented training data into the first local part for calculation, so as to output a first feature vector and send it to the cloud.
[0155] Optionally, the cloud inputs the first shard training data into the first cloud part for calculation, and the local client inputs the second shard training data into the first local part for calculation, to output a first feature vector and send it to the cloud, including:
[0156] The cloud inputs the first shard training data into the first cloud part for calculation, and the local client inputs the second shard training data into the first local part for calculation. During the calculation process of the first cloud part and the first local part, an encrypted calculation method of multi-party secure computing is used to output the first feature vector through the calculation of the first cloud part and the first local part and send it to the cloud.
[0157] Among them, the embodiment of the present application can share computing parameters based on multi-party secure computing, thereby realizing joint training of the first cloud part and the first local part based on a secret sharing protocol, and converting the original data into a difficult-to-restore feature vector through multi-party secure computing, further improving the security and feasibility of large-scale model training.
[0158] Optionally, the multi-party secure computation includes an ABY hybrid protocol or a Secret Sharing (SS) protocol. The ABY protocol is a two-party dedicated secure computation framework that is a hybrid of three protocols: A represents arithmetic secret sharing, B represents Boolean secret sharing, and Y represents Yao's garbled circuits.
[0159] The client's training data is secretly sharded and distributed to the Cloud and Client ends. At the same time, the network parameters of the AH part are trained based on secret sharing protocols (such as ABY, ss, etc.).
[0160] Taking the ABY protocol as an example, the training process is explained in detail:
[0161] The basic operation logic of the ABY protocol is shown in Figure 5. For example, the client has a fine-tuned dataset for a certain industry:
[0162] "If the price level (i.e., CPI) rises, then the ability of the same amount of money to purchase the same goods and services will decrease, that is, the purchasing power of money will decrease. Conversely, if the price level falls, then the ability of the same amount of money to purchase the same goods and services will increase, that is, the purchasing power of money will increase."
[0163] At this point, the result of the dataset token is [If the price,level,(i.e., C,P,I,),rises, then, similarly, the amount,of,currency,that,purchases,goods,and,services,ability,will,fall,and,purchasing power,decreases, whereas,it,increases].,N=27 is a list of all words. Next, the word list is encoded and vector embedded. Taking the embedding of some tokens into 768-dimensional vectors as an example, Figure 6 is a schematic diagram of a parameter training process provided by an embodiment of the present application. As shown in Figure 6, in this example, the input data we obtain is a 27*768 matrix, recorded as the input data matrix D. Let AH and AT be m*n dimensional matrices (m and n are any positive integers). In the sharding, we put m / 2*n dimensional matrices on the Cloud side and the Client side respectively. Next, the matrix D is cut according to the Aby protocol, and random triples are generated for both parties. The Aby secret sharing protocol blinds the calculation data on both sides through triples, and the two parties cannot reversely obtain the other party's data during the calculation process.
[0164] S404: The cloud inputs the first feature vector into the model body to output a second feature vector.
[0165] The first eigenvector is the plaintext of the secret sharing form data.
[0166] After obtaining the decrypted secret shared form data plaintext, we are ready to enter the other parameters of the large model on the Cloud side for training: After the AH part of the operation, we get the sliced multiplication form D1*D2 of the original input data. All the secrets are placed on the Cloud side and enter the fixed part M0 for training.
[0167] The data is trained on other parameters of the large model on the Cloud side, making full use of the cloud computing power to obtain the plaintext output of the secret sharing data, and is ready to be sharded again and enter AT to participate in another round of secret sharing training.
[0168] S405: The cloud performs sharding processing on the second feature vector to obtain a first sharding feature vector and a second sharding feature vector, and sends the second sharding feature vector to the client.
[0169] Optionally, the cloud performs sharding processing on the second feature vector to obtain a first shard feature vector and a second shard feature vector, including:
[0170] The cloud performs random sharding on the second feature vector to obtain a first shard feature vector and a second shard feature vector.
[0171] Optionally, the cloud performs sharding processing on the second feature vector to obtain a first shard feature vector and a second shard feature vector, including:
[0172] The cloud performs sharding on the second feature vector according to a second preset secret sharding algorithm to obtain a first sharding feature vector and a second sharding feature vector.
[0173] Here, in the embodiment of the present application, the cloud can slice the second eigenvector through random or preset algorithms, and further split the data to achieve safe and reliable joint training of the cloud and local client, further improving the data security and data privacy of large model training.
[0174] S406: The cloud inputs the first shard feature vector to the second cloud part for calculation, and the local client inputs the second shard feature vector to the second local part for calculation to output a prediction result of the training data.
[0175] Optionally, the data is distributed to the Cloud and Client, and the network parameters of the AT part are trained based on a secret sharing protocol (such as aby, ss, etc.), and the calculation logic of the AT part is the same as that in step S403.
[0176] Optionally, the cloud inputs the first shard feature vector to the second cloud part for calculation, and the local client inputs the second shard feature vector to the second local part for calculation, to output a prediction result of the training data, including:
[0177] The cloud inputs the first shard feature vector to the second cloud part for calculation, and the local client inputs the second shard feature vector to the second local part for calculation. During the calculation process of the second cloud part and the second local part, the encryption calculation method of multi-party secure computing is used to output the prediction result of the training data through the calculation of the second cloud part and the second local part.
[0178] Among them, the operation of the tail adapter in the embodiment of the present application is also based on multi-party secure computing to share operation parameters, thereby realizing joint training of the second cloud part and the second local part based on the secret sharing protocol, further improving the security and feasibility of large model training.
[0179] S407: The cloud and the local client iteratively adjust the large model according to the prediction results of a preset amount of training data until the model converges.
[0180] Optionally, the cloud and the local client iteratively adjust the large model according to the prediction results of a preset amount of training data until the model converges, including:
[0181] The cloud obtains the loss parameter based on the preset labels corresponding to the prediction results and the training data; the cloud adjusts the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter; the local client adjusts the model parameters of the first local part and the second local part of the large model according to the loss parameter; if the local client determines that the prediction error of the large model is greater than the preset threshold, the step of "local client obtains training data" is re-executed to continue training the large model. If it is determined that the prediction error of the large model is less than or equal to the preset threshold, the iterative training is stopped.
[0182] It is understandable that the preset threshold here can be determined according to actual conditions, and the embodiments of the present application do not impose specific limitations on this.
[0183] Optionally, the training output is obtained, and the loss is calculated with the label, which is then fed back to the entire model network for model convergence calculation. Specifically, the masks of the training data tokens are predicted and the loss function is calculated. Here, the general multi-class cross-entropy loss function is used for illustration. The output of the AT is the logits value calculated by the classification layer, which is used to calculate the loss with the true label value. Based on the above steps, the model is iteratively trained until the model converges to a certain accuracy.
[0184] Optionally, the cloud obtains loss parameters based on the prediction results and preset labels corresponding to the training data, including:
[0185] The cloud inputs the prediction results and preset labels into the loss function to output the loss parameters.
[0186] Optionally, the loss function is calculated as:
[0187] Among them, L represents the loss function, M represents the number of categories, N represents the number of samples, and y ic is a sign function (takes 0 or 1, if the true category of sample i is equal to c, it takes 1, otherwise it takes 0), indicating the probability that the i-th sample belongs to the c-th category, p ic It represents the probability that the model predicts that the i-th sample belongs to the c-th category, where i and N are any positive integers.
[0188] Here, after the embodiment of the present application obtains the prediction results of the training data, it calculates the loss with the predicted label and feeds back the entire model network to perform model convergence calculation, thereby adjusting the model parameters of the large model to adjust the large model until the requirements are met, thereby realizing the training of the large model.
[0189] Optionally, before obtaining a loss parameter on the cloud according to the preset labels corresponding to the prediction results and the training data, and adjusting the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter, the method further includes:
[0190] The local client encrypts the preset labels corresponding to the training data according to the preset encryption algorithm to obtain encrypted labels; the local client sends the encrypted labels to the cloud.
[0191] Here, in order to further ensure data security during the large model training process, when the local client of the embodiment of the present application sends the preset labels corresponding to the training data to the cloud, the preset labels are first encrypted. The cloud cannot obtain the original preset labels, which further improves the security of large model training.
[0192] Optionally, the cloud obtains a loss parameter based on the prediction result and the preset label corresponding to the training data, and adjusts the model parameters of the first cloud part and the second cloud part of the large model based on the loss parameter, including:
[0193] The cloud encrypts the prediction result according to a preset encryption algorithm to obtain an encrypted preset result; the cloud obtains a loss parameter based on the encrypted prediction result and the encrypted label, and adjusts the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter.
[0194] Optionally, the preset encryption algorithm is a homomorphic encryption algorithm.
[0195] Here, the cloud encrypts the prediction results of the training data according to the preset encryption algorithm of the local client for the preset labels, so that the encrypted prediction results can be processed with the encrypted labels to obtain the loss parameters, and then the model parameters can be adjusted under the premise of safety and reliability.
[0196] Optionally, the trained AH and AT in the above steps are merged and placed on the client to obtain the final trained large model. The head adapter and tail adapter of the trained large model are deployed on the local client, and the main model is deployed on the cloud.
[0197] Exemplarily, FIG7 is a structural diagram of a trained large model provided in an embodiment of the present application. Through the trained large model in FIG7 , data inference and prediction can be realized.
[0198] In the process of training the large model, the embodiment of the present application splits the large model into three parts, namely the middle model body M0 and two adapter parts, namely the head adapter Adaptor Header and the tail adapter Adaptor Tail. The head adapter includes a first cloud part AH1 and a first local part AH2, and the tail adapter includes a second cloud part AT1 and a second local part AT2. Each adapter is divided into two parts, half of which is located in the cloud Cloud and half is located in the local client Client. The training data for the large model is the industry privatized data from the Client. After it is sliced and entered, it enters the cloud and the local client respectively for the first joint training. After the first training, the first eigenvector in the form of a eigenvector is obtained, and then input into the cloud for plaintext training of all the training data. The output of the cloud is sliced again and processed for a second joint training on the cloud and the local client respectively to obtain the prediction result of the training data. According to the prediction result of the training data, a trained large model can be obtained. Based on the above training method, during the collaborative reasoning operation of the large model and the small model, neither the model nor the data leaves the local machine. The cloud can only obtain part of the data after sharding, and it is difficult to restore the feature vector of the original input, which protects privacy and improves data security. In addition, only the head and tail Adaptors are distributed to the cloud and the client, and the encrypted client data is used for the Adaptor model training. The main structure of the model is still located in the cloud, and the Cloud computing power is used for training and reasoning, which ensures the computing power performance. At the same time, the Adaptor fine-tuning mechanism is effectively utilized. The number of Adaptor parameters only accounts for a few percent or a few thousandths of the entire original large model, which can achieve almost the same effect as the fine-tuning of all parameters of the full model, realizing the effective training of large models under the premise of safety and full utilization of computing power.
[0199] Optionally, the embodiment of the present application can implement data inference training through a trained large model. Accordingly, FIG8 is a flow chart of another large model training method provided by the embodiment of the present application. As shown in FIG8 , the method includes:
[0200] S801: The local client obtains training data and performs sharding processing on the training data to obtain first sharded training data and second sharded training data.
[0201] S802: The local client sends the first shard training data to the cloud.
[0202] S803: The cloud inputs the first segmented training data into the first cloud part for calculation, and the local client inputs the second segmented training data into the first local part for calculation, so as to output a first feature vector and send it to the cloud.
[0203] S804: The cloud inputs the first feature vector into the model body to output a second feature vector.
[0204] S805: The cloud performs sharding processing on the second feature vector to obtain a first shard feature vector and a second shard feature vector, and sends the second shard feature vector to the client.
[0205] S806: The cloud inputs the first shard feature vector to the second cloud part for calculation, and the local client inputs the second shard feature vector to the second local part for calculation to output a prediction result of the training data.
[0206] S807: The cloud and the local client iteratively adjust the large model according to the prediction results of a preset amount of training data until the model converges.
[0207] The implementation of steps S801-S807 is the same as that of steps S401-S407, and will not be described in detail here.
[0208] S808: The local client obtains a piece of data to be predicted.
[0209] S809: The local client inputs the data to be predicted into the header adapter to output a first prediction vector.
[0210] The data format of the first prediction vector is an encrypted format.
[0211] Among them, the first prediction vector is in an encrypted format for the cloud, and the cloud cannot obtain specific data, which improves the security of data inference and prediction.
[0212] First, the inference data passes through the AH part on the client side and is output as a scrambled form of the original plaintext inference data, which cannot be reversed, thereby ensuring the privacy of the inference data. Next, this form of inference data is passed to the remaining parameters of the large model on the Cloud side to participate in inference.
[0213] S810: The local client sends the first prediction vector to the cloud.
[0214] S811: The cloud inputs the first prediction vector to the model body to output a second prediction vector.
[0215] The data in the previous step is inferred and calculated on the remaining parameters of the model to obtain the calculation output, which is the second prediction vector.
[0216] S812: The cloud sends the second prediction vector to the local client.
[0217] S813: The local client inputs the second prediction vector to the tail adapter to output a prediction result of the data to be predicted.
[0218] The calculation output of the previous step is passed to the Client side, enters the AT part for inference calculation, and obtains the model inference result output.
[0219] This embodiment of the application achieves privacy protection. Neither the large model and training data before collaboration nor the incremental model and inference data after collaboration are exposed to the other party. This also protects rights and interests. Both parties collaborate to form a joint large model, and the inference phase also requires cooperation; neither party can complete inference independently. This ensures the data rights and interests of the client, and the model and computing power rights of the cloud are protected.
[0220] The embodiment of the present application can perform inference and prediction based on a trained large model. For the data to be predicted on the local client, the head adapter of the local client is first used to convert the data to be predicted into a first prediction vector encrypted relative to the cloud. Then, the computing power of the cloud is used to fully infer and predict the data to be predicted, and then the prediction result of the data to be predicted is output through the tail adapter of the local client, thereby realizing safe and efficient data inference and prediction.
[0221] The embodiment of the present application also provides a large-model training device, and the device of the embodiment of the present application includes: a first processing module, a first sending module, a second processing module, a first input module, a third processing module, a fourth processing module, and a fifth processing module. The large-model training device here can be the processing device of the cloud or local client, the processor itself, or a chip or integrated circuit that implements the function of the processor. It should be noted here that the division of the first processing module, the first sending module, the second processing module, the first input module, the third processing module, the fourth processing module, and the fifth processing module is only a division of logical functions. Physically, the two can be integrated or independent.
[0222] The first processing module is used for the local client to obtain training data and perform sharding processing on the training data to obtain first sharded training data and second sharded training data;
[0223] A first sending module, configured for the local client to send the first shard training data to the cloud;
[0224] A second processing module is configured to input the first shard training data into the first cloud part for calculation on the cloud side, and to input the second shard training data into the first local part for calculation on the local client side, so as to output a first feature vector and send it to the cloud side;
[0225] A first input module is used in the cloud to input the first feature vector into the model body to output a second feature vector;
[0226] A third processing module is configured to perform sharding processing on the second feature vector in the cloud to obtain a first sharding feature vector and a second sharding feature vector, and send the second sharding feature vector to the client;
[0227] A fourth processing module is configured to input the first shard feature vector to the second cloud portion for calculation on the cloud side, and to input the second shard feature vector to the second local portion for calculation on the local client side, so as to output a prediction result of the training data;
[0228] The fifth processing module is used for the cloud and the local client to iteratively adjust the large model according to the prediction results of a preset amount of training data until the model converges.
[0229] Optionally, the second processing module is specifically configured to:
[0230] The cloud inputs the first shard training data into the first cloud part for calculation, and the local client inputs the second shard training data into the first local part for calculation. During the calculation process of the first cloud part and the first local part, an encrypted calculation method of multi-party secure computing is used to output the first feature vector through the calculation of the first cloud part and the first local part and send it to the cloud.
[0231] Optionally, the fourth processing module is specifically configured to:
[0232] The cloud inputs the first shard feature vector to the second cloud part for calculation, and the local client inputs the second shard feature vector to the second local part for calculation. During the calculation process of the second cloud part and the second local part, the encryption calculation method of multi-party secure computing is used to output the prediction result of the training data through the calculation of the second cloud part and the second local part.
[0233] Optionally, the multi-party secure computation includes an ABY mixing protocol or a secret sharing protocol.
[0234] Optionally, the fifth processing module is specifically configured to:
[0235] The cloud obtains the loss parameter based on the preset labels corresponding to the prediction results and the training data; the cloud adjusts the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter; the local client adjusts the model parameters of the first local part and the second local part of the large model according to the loss parameter; if the local client determines that the prediction error of the large model is greater than the preset threshold, the step of "local client obtains training data" is re-executed to continue training the large model. If it is determined that the prediction error of the large model is less than or equal to the preset threshold, the iterative training is stopped.
[0236] Optionally, the fifth processing module is further specifically configured to: input the prediction result and the preset label into the loss function on the cloud side to output the loss parameter.
[0237] Optionally, the loss function is calculated as:
[0238] Among them, L represents the loss function, M represents the number of categories, N represents the number of samples, and y ic Is a symbolic function that represents the probability that the i-th sample belongs to the c-th category, p ic It represents the probability that the model predicts that the i-th sample belongs to the c-th category, where i and N are any positive integers.
[0239] Optionally, before the fifth processing module is used in the cloud to obtain a loss parameter based on the prediction result and the preset label corresponding to the training data, and to adjust the model parameters of the first cloud part and the second cloud part of the large model based on the loss parameter, the apparatus further includes an encryption processing module configured to:
[0240] The local client encrypts the preset labels corresponding to the training data according to the preset encryption algorithm to obtain encrypted labels; the local client sends the encrypted labels to the cloud.
[0241] Optionally, the fifth processing module is specifically configured to:
[0242] The cloud encrypts the prediction result according to a preset encryption algorithm to obtain an encrypted preset result; the cloud obtains a loss parameter based on the encrypted prediction result and the encrypted label, and adjusts the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter.
[0243] Optionally, the preset encryption algorithm is a homomorphic encryption algorithm.
[0244] Optionally, the first processing module is specifically configured to:
[0245] The training data is randomly sharded to obtain first sharded training data and second sharded training data.
[0246] Optionally, the first processing module is specifically configured to:
[0247] The training data is sliced according to a first preset secret slicing algorithm to obtain first sliced training data and second sliced training data.
[0248] Optionally, the third processing module is specifically configured to:
[0249] The cloud performs random sharding on the second feature vector to obtain a first shard feature vector and a second shard feature vector.
[0250] Optionally, the third processing module is specifically configured to:
[0251] The cloud performs sharding on the second feature vector according to a second preset secret sharding algorithm to obtain a first sharding feature vector and a second sharding feature vector.
[0252] Optionally, the head adapter and tail adapter of the trained large model are deployed on the local client, and the main body of the model is deployed on the cloud.
[0253] Optionally, the above device further includes an inference prediction module, configured to:
[0254] The local client obtains a piece of data to be predicted; the local client inputs the data to be predicted into the head adapter to output a first prediction vector; the local client sends the first prediction vector to the cloud; the cloud inputs the first prediction vector into the model body to output a second prediction vector; the cloud sends the second prediction vector to the local client; the local client inputs the second prediction vector into the tail adapter to output the prediction result of the data to be predicted.
[0255] Optionally, the data format of the first prediction vector is an encrypted format.
[0256] Referring to FIG9 , a schematic diagram of a large-scale model training device suitable for implementing an embodiment of the present disclosure is shown. The large-scale model training device 900 may be a terminal device or a server. The terminal device may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (PMPs), vehicle-mounted terminals (e.g., vehicle-mounted navigation terminals), and fixed terminals such as digital TVs and desktop computers. The large-scale model training device shown in FIG9 is merely an example and should not limit the functionality and scope of use of the embodiments of the present disclosure.
[0257] As shown in Figure 9, the training device 900 of the large model may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to the program stored in the read-only memory (Read Only Memory, referred to as ROM) 902 or the program loaded from the storage device 908 to the random access memory (Random Access Memory, referred to as RAM) 903. In RAM 903, various programs and data required for the operation of the training device 900 of the large model are also stored. The processing device 901, ROM 902 and RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0258] Typically, the following devices can be connected to the I / O interface 905: input devices 906 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 907 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 908 including, for example, a magnetic tape, hard disk, etc.; and communication devices 909. The communication devices 909 can allow the large-scale training device 900 to communicate with other devices wirelessly or by wire to exchange data. Although FIG9 shows a large-scale training device 900 with various devices, it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.
[0259] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network via the communication device 909, or installed from the storage device 908, or installed from the ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0260] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0261] The computer-readable medium may be included in the training device of the large model; or it may exist independently without being assembled into the training device of the large model.
[0262] The computer-readable medium carries one or more programs. When the one or more programs are executed by the large model training device, the large model training device executes the method shown in the above embodiment.
[0263] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0264] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0265] The units involved in the embodiments described in this disclosure may be implemented in software or hardware. In some cases, the name of a unit does not limit the unit itself. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses."
[0266] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0267] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0268] The large model training device of the embodiment of the present application can be used to execute the technical solutions in the above-mentioned method embodiments of the present application. Its implementation principles and technical effects are similar and will not be repeated here.
[0269] An embodiment of the present application also provides a computer-readable storage medium, which stores computer execution instructions. When the computer execution instructions are executed by a processor, they are used to implement any of the above-mentioned large model training methods.
[0270] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, is used to implement any of the above-mentioned large model training methods.
[0271] In the several embodiments provided in this 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 merely schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. 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 interface, device or unit, which can be electrical, mechanical or other forms.
[0272] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0273] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0274] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for processing a large model, characterized in that: The large model includes a head adapter, a model body, and a tail adapter; the head adapter includes a first cloud part and a first local part, and the tail adapter includes a second cloud part and a second local part; during the training of the large model, the first cloud part, the model body, and the second cloud part are deployed in the cloud, and the first local part and the second local part are deployed on a local client; The method comprises: The local client obtains the training data and performs sharding processing on the training data to obtain first sharded training data and second sharded training data; The local client sends the first shard training data to the cloud; The cloud inputs the first segmented training data into the first cloud part for calculation, and the local client inputs the second segmented training data into the first local part for calculation, so as to output a first feature vector and send it to the cloud; The cloud inputs the first feature vector into the model body to output a second feature vector; The cloud performs sharding processing on the second feature vector to obtain a first shard feature vector and a second shard feature vector, and sends the second shard feature vector to the client; The cloud inputs the first shard feature vector to the second cloud part for calculation, and the local client inputs the second shard feature vector to the second local part for calculation, so as to output a prediction result of the training data; The cloud and local clients iteratively adjust the large model according to the prediction results of a preset amount of training data until the model converges.
2. The method according to claim 1, characterized in that The cloud inputs the first segmented training data into the first cloud part for calculation, and the local client inputs the second segmented training data into the first local part for calculation, so as to output a first feature vector and send it to the cloud, including: The cloud inputs the first shard training data into the first cloud part for calculation, and the local client inputs the second shard training data into the first local part for calculation. During the calculation process of the first cloud part and the first local part, an encrypted calculation method of multi-party secure computing is used to output the first feature vector after the calculation of the first cloud part and the first local part and send it to the cloud.
3. The method according to claim 1, characterized in that The cloud inputs the first shard feature vector to the second cloud part for calculation, and the local client inputs the second shard feature vector to the second local part for calculation, to output a prediction result of the training data, including: The cloud inputs the first shard feature vector into the second cloud part for calculation, and the local client inputs the second shard feature vector into the second local part for calculation. During the calculation process of the second cloud part and the second local part, an encrypted calculation method of multi-party secure computing is used to output the prediction result of the training data through the calculation of the second cloud part and the second local part.
4. The method according to claim 2 or 3, characterized in that The multi-party secure computation is an ABY hybrid protocol or a secret sharing protocol.
5. The method according to claim 1, wherein The cloud and local clients iteratively adjust the large model according to the prediction results of a preset amount of training data until the model converges, including: The cloud obtains loss parameters based on the prediction results and the preset labels corresponding to the training data; The cloud adjusts the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter; The local client adjusts model parameters of the first local part and the second local part of the large model according to the loss parameter; If the local client determines that the prediction error of the large model is greater than the preset threshold, the step of "local client obtains training data" is re-executed to continue training the large model. If it is determined that the prediction error of the large model is less than or equal to the preset threshold, the iterative training is stopped.
6. The method according to claim 5, characterized in that The cloud obtains a loss parameter based on the prediction result and the preset label corresponding to the training data, including: The cloud inputs the prediction result and the preset label into the loss function to output the loss parameter.
7. The method according to claim 6, characterized in that The calculation formula of the loss function is: Among them, L represents the loss function, M represents the number of categories, N represents the number of samples, and y ic Is a symbolic function that represents the probability that the i-th sample belongs to the c-th category, p ic It represents the probability that the model predicts that the i-th sample belongs to the c-th category, where i and N are any positive integers.
8. The method according to claim 5, characterized in that Before obtaining, on the cloud side, a loss parameter based on the prediction result and the preset label corresponding to the training data, and adjusting the model parameters of the first cloud side part and the second cloud side part of the large model based on the loss parameter, the method further includes: The local client encrypts the preset label corresponding to the training data according to a preset encryption algorithm to obtain an encrypted label; The local client sends the encrypted tag to the cloud.
9. The method according to claim 8, characterized in that The cloud obtains a loss parameter based on the prediction result and the preset label corresponding to the training data, and adjusts the model parameters of the first cloud part and the second cloud part of the large model based on the loss parameter, including: The cloud encrypts the prediction result according to the preset encryption algorithm to obtain an encrypted preset result; The cloud obtains a loss parameter according to the encrypted prediction result and the encrypted label, and adjusts the model parameters of the first cloud part and the second cloud part of the large model according to the loss parameter.
10. The method according to claim 8 or 9, characterized in that The preset encryption algorithm is a homomorphic encryption algorithm.
11. The method according to any one of claims 1 to 3, characterized in that The sharding of the training data to obtain first sharded training data and second sharded training data includes: The training data is randomly fragmented to obtain first fragmented training data and second fragmented training data.
12. The method according to any one of claims 1 to 3, characterized in that The sharding of the training data to obtain first sharded training data and second sharded training data includes: The training data is sliced according to a first preset secret slice algorithm to obtain first sliced training data and second sliced training data.
13. The method according to any one of claims 1 to 3, characterized in that The cloud performs sharding processing on the second feature vector to obtain a first shard feature vector and a second shard feature vector, including: The cloud performs random sharding on the second feature vector to obtain a first shard feature vector and a second shard feature vector.
14. The method according to any one of claims 1 to 3, characterized in that The cloud performs sharding processing on the second feature vector to obtain a first shard feature vector and a second shard feature vector, including: The cloud performs sharding on the second feature vector according to a second preset secret sharding algorithm to obtain a first sharding feature vector and a second sharding feature vector.
15. The method according to any one of claims 1 to 3, characterized in that The head adapter and tail adapter of the trained large model are deployed on the local client, and the model body is deployed on the cloud.
16. The method according to claim 15, characterized in that Also includes: The local client obtains a piece of data to be predicted; The local client inputs the data to be predicted into the head adapter to output a first prediction vector; The local client sends the first prediction vector to the cloud; The cloud inputs the first prediction vector into the model body to output a second prediction vector; The cloud sends the second prediction vector to the local client; The local client inputs the second prediction vector to the tail adapter to output a prediction result of the data to be predicted.
17. The method according to claim 16, characterized in that The data format of the first prediction vector is an encrypted format.
18. A large model training device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 17.
19. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 17 when executed by a processor.