Big model training method and device based on federated learning, equipment and storage medium
By introducing adapters and simulators into federated learning for fine-tuning training and aggregation processing, it solves the problems of data privacy and model upgrade difficulties in traditional federated learning, and achieves efficient training of large models and improved generalization capabilities.
Patent Information
- Application Number
- CN202410829043.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-01
AI Technical Summary
On the premise of protecting data privacy, traditional federated learning methods are difficult to effectively train large models, especially when local data on different offline devices cannot be shared and model upgrades are difficult, resulting in low model training efficiency and insufficient data security.
By importing adapters and simulators from the online server, fine-tuning training and aggregation processing, local data security and privacy protection on the offline device side can be achieved, while large model training costs can be reduced, and the difficulties of data sharing and model upgrades in traditional methods can be overcome.
While protecting the security and privacy of local data, it improves the generalization ability and training efficiency of the model, solves the problem that large models cannot be fine-tuned and trained on low-resource devices, and realizes incremental updates of large models on the online side and knowledge summary on the offline side. .
Smart Images

Figure CN118735006A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of model training technology, and in particular, to a large model training method, apparatus, device and storage medium based on federated learning. Background Art
[0002] Data is the foundation of AI. As people become more and more aware of the need to protect privacy data, how to train AI models while protecting data privacy is an important research topic. Federated learning has become a technology with great potential for AI applications. Federated learning is an important machine learning framework for privacy protection. It can train models collaboratively without collecting data, making data "available but invisible". It can then collaboratively train AI models on terminal devices without exchanging their original data, thereby protecting privacy information. The development of AI has entered the era of large models. The combination of federated learning and large models can play a very important role in some specific application scenarios. Therefore, the machine learning framework based on federated learning can protect privacy information, but for some special application scenarios (training on local data of different offline devices), this method cannot fully meet the requirements of data security or privacy.
[0003] In some training data collection methods, training data needs to be collected on the client device. Due to data security issues, it is currently not possible to support transferring it to the big data system for model training. Traditional federated learning requires data aggregation and training of deep models with data center servers as the core. The client device obtains the global model from the cloud, completes local training, and then uploads and integrates the model parameters. This model is limited by the scalability of client device scale and transmission network congestion, making it difficult to guarantee the training efficiency of the model, and the security and privacy of the client data when sharing is difficult to guarantee. Since there is a problem that client training data cannot be shared, and it is hoped that the data analysis model of the big data system can continuously obtain new information for iterative upgrades, how to train the text model based on the local data in different clients under the premise of ensuring the security of training data exchange has become an urgent problem to be solved. Summary of the invention
[0004] In view of this, in order to solve the above-mentioned technical problems or part of the technical problems, an embodiment of the present invention provides a large model training method, device, equipment and storage medium based on federated learning.
[0005] In a first aspect, an embodiment of the present invention provides a large model training method based on federated learning, which is applied to an offline device, including:
[0006] Importing an adapter and a simulator in a stacking layer of a first target model from an online server, wherein the adapter and the simulator are constructed in the online server, and the first target model is a model in the offline device;
[0007] Fine-tune the adapter according to the simulator and the local data of the offline device to obtain a new adapter;
[0008] The new adapter is exported to the second target model in the online server, so that the new adapter and the second target model are aggregated.
[0009] In a possible implementation manner, the adapter is constructed by the online server in the following manner:
[0010] determining a preset number of top layers adjacent to an output layer of the target model as a first adapter module;
[0011] determining a preset number of bottom layers adjacent to an input layer of the target model as second adapter modules;
[0012] The adapter is constructed from the first adapter module and the second adapter module.
[0013] In a possible implementation, the simulator is constructed by the online server in the following manner:
[0014] Determine other layers in the stacked layers except the top layer and the bottom layer;
[0015] The other layers are pruned and compressed to obtain the simulator.
[0016] In a possible implementation, fine-tuning the adapter according to the simulator and the local data of the offline device includes:
[0017] Preprocess and enhance the local data to obtain the processed target data;
[0018] Freezing all parameters in the simulator;
[0019] Inputting the target data into the target model for training, so as to calculate the loss during model training through the simulator;
[0020] Weight parameters in the adapter are updated according to the loss to minimize the loss.
[0021] In a second aspect, an embodiment of the present invention provides a large model training method based on federated learning, which is applied to the online server described in the first aspect, including:
[0022] constructing adapters and simulators in the stacked layers of the second target model;
[0023] Exporting the adapter and the simulator to a first target model of an offline device, so that the first target model fine-tunes the adapter according to local data of the simulator and the offline device to obtain a new adapter;
[0024] When the new adapter is imported into the online server, the new adapter and the second target model are aggregated.
[0025] In a possible implementation, exporting the adapter and the simulator to a first target model of an offline device includes:
[0026] The adapter and the simulator are downloaded to a target device that is communicatively connected to the online server, so that the target device copies the adapter and the simulator to a storage carrier corresponding to the target device, and imports the adapter and the simulator into the first target model of the offline device through the storage carrier.
[0027] In a possible implementation manner, the aggregating the new adapter and the second target model includes:
[0028] Obtaining information about the number of layers corresponding to the new adapter in the first target model;
[0029] The layer corresponding to the layer number information in the stacked layers of the second target model is updated to the new adapter.
[0030] In a third aspect, an embodiment of the present invention provides a model training device, comprising:
[0031] An import module, used for importing the adapter and the simulator in the stacking layer of the first target model from the online server, the adapter and the simulator are constructed in the online server, and the first target model is a model in the offline device;
[0032] A training module, used for fine-tuning the adapter according to the local data of the simulator and the offline device to obtain a new adapter;
[0033] The export module is used to export the new adapter to the second target model in the online server so that the new adapter and the second target model are aggregated.
[0034] In a fourth aspect, an embodiment of the present invention provides a device comprising: a processor and a memory, wherein the processor is used to execute a model training program stored in the memory to implement the large model training method based on federated learning as described in any one of the first aspect or the second aspect.
[0035] In a fifth aspect, an embodiment of the present invention provides a storage medium storing one or more programs, which can be executed by one or more processors to implement the large model training method based on federated learning as described in any one of the first aspect or the second aspect.
[0036] The large model training scheme based on federated learning provided in the embodiment of the present invention imports the adapter and the simulator in the stacking layer of the first target model from the online server, the adapter and the simulator are constructed in the online server, and the first target model is the model in the offline device; the adapter is fine-tuned and trained according to the local data of the simulator and the offline device to obtain a new adapter; the new adapter is exported to the second target model in the online server, so that the new adapter and the second target model are aggregated. Thus, it can be realized that after fine-tuning and training the adapter according to the local data on the offline device side, it is aggregated with the model in the online server. Fine-tuning and training locally protects the security and privacy of local data and reduces the cost of large model training. It breaks through the traditional problem of model upgrade difficulties caused by the inability to share local data of different offline devices. Compared with the single-task learning method, the model training method combining offline and online ends can aggregate the data of users of all different offline devices, realize the incremental update of offline knowledge by the large model on the online end, protect the security of offline data, and improve the generalization ability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A flowchart of a first large model training method based on federated learning provided in an embodiment of the present invention;
[0038] Figure 2 A flowchart of a second large model training method based on federated learning provided in an embodiment of the present invention;
[0039] Figure 3 A schematic diagram of a flow chart of a third large model training method based on federated learning provided in an embodiment of the present invention;
[0040] Figure 4 A schematic diagram of the structure of a large model training device based on federated learning provided in an embodiment of the present invention;
[0041] Figure 5A schematic diagram of the structure of another large model training device based on federated learning provided in an embodiment of the present invention;
[0042] Figure 6 A schematic diagram of the structure of a device provided by an embodiment of the present invention;
[0043] Figure 7 A schematic diagram of the model structure of a large model training method based on federated learning provided by the present invention;
[0044] Figure 8 A schematic diagram of the model structure of another large model training method based on federated learning provided in an embodiment of the present invention;
[0045] Fig. 9 A schematic diagram of a model structure of another large model training method based on federated learning provided in an embodiment of the present invention;
[0046] Fig.10 A flowchart of a fourth large model training method based on federated learning provided in an embodiment of the present invention;
[0047] Fig.11 A flowchart of a fifth large model training method based on federated learning provided in an embodiment of the present invention;
[0048] Fig.12 A schematic diagram of a flow chart of a model pre-training method provided in an embodiment of the present invention;
[0049] Fig.13 A flowchart of another model pre-training method provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] To facilitate understanding of the embodiments of the present invention, specific embodiments will be further explained below in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present invention.
[0052] Figure 1 A flowchart of a first large model training method based on federated learning provided in an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method specifically includes:
[0053] S11. Importing an adapter and a simulator in a stacking layer of a first target model from an online server, wherein the adapter and the simulator are constructed in the online server, and the first target model is a model in the offline device.
[0054] The large model training method based on federated learning provided in an embodiment of the present invention is applied to an offline device. The offline device may be a client, and local data is stored in the client. Specifically, the adapter and simulator in the model may be obtained from the online server, and the adapter in the model on the offline device may be fine-tuned and trained according to the local data and then aggregated with the model on the online server.
[0055] In this embodiment, the target model can be a large text model of federated learning, the first target model is a model in an offline device, and the corresponding second target model is in the online server. The first target model and the second target model have the same structure, and both the first target model and the second target model include: an input layer (including a word embedding layer), a transformer module stacking layer (for example, stacking 24 layers, 48 layers, etc.), and an output layer (mapped according to the size of the vocabulary), wherein the input layer is used to convert the text string into a tokenid, and at the same time, it is converted into a two-dimensional matrix through the embedding layer, and each token has a corresponding semantic vector. For example: "What's the weather like today?"-----converted into tokenid array---->[2,33,333,432,,444]---after embedding layer----->[[0.444,0.3333,0.4444],[.....],[.....],[.....]], transformer stacking layer, mainly used to realize deep learning of complex feature representation and semantics by stacking multiple layers of encoders and decoders, output layer: used to convert the output of the stacking layer into the probability distribution of each word.
[0056] The adapter and emulator in the stacking layer are pre-built in the second target model of the online server. The construction method can be to use multiple preset target layers in the stacking layer as adapters (for example, when stacking 24 layers, determine the two layers of the stacking layer close to the output layer as Top-2, determine the two layers of the stacking layer close to the input layer as Bottom-2, and finally combine Top-2 and Bottom-2 into an adapter), and use the layers in the stacking layer except the target layer as emulators. After the offline device obtains the adapter and emulator built by the online server, it imports the two into the corresponding positions in the stacking layer of the first target model.
[0057] S12: fine-tune the adapter according to the simulator and the local data of the offline device to obtain a new adapter.
[0058] In this embodiment, local data of the offline device is obtained and preprocessed and data augmentation and expansion operations are performed to obtain processed local data, hyperparameters such as learning rate, number of training rounds, and batch size are configured for the first target model, the processed local data is input into the first target model and the adapter is fine-tuned. During the training process, the simulator is only used to calculate the loss of the fine-tuning training and guide the parameter update of the adapter.
[0059] Specifically, the weight parameters of the simulator need to be frozen. The role of the simulator is to perform forward calculations and calculate the loss gradient direction of the overall model to guide the update of the learnable weight parameters of the adapter to minimize the loss. Fine-tuning training is to retrain the adapter module to obtain a new adapter after updating the weight parameters.
[0060] S13: Export the new adapter to the second target model in the online server, so that the new adapter and the second target model are aggregated.
[0061] The trained new adapter is exported to the online server, and the new adapter is aggregated with the second target model in the online server. The layer of the second target model corresponding to the new adapter in the first target model is replaced with the weight parameters of the trained new adapter to realize the update training of the second target model according to the local data of the offline device.
[0062] The large model training method based on federated learning provided in the embodiment of the present invention is to import the adapter and simulator in the stacking layer of the first target model from the online server, the adapter and the simulator are constructed in the online server, and the first target model is the model in the offline device; the adapter is fine-tuned and trained according to the local data of the simulator and the offline device to obtain a new adapter; the new adapter is exported to the second target model in the server, so that the new adapter and the second target model are aggregated. Thus, it can be realized that after fine-tuning and training the adapter according to the local data on the offline device side, it is aggregated with the model in the server. Fine-tuning and training locally protects the security and privacy of local data and reduces the cost of large model training. It breaks through the traditional problem of model upgrade difficulties caused by the inability to share local data of different offline devices. Compared with the single-task learning method, the model training method combining offline and online ends can aggregate the data of users of all different offline devices, realize the incremental update of offline knowledge by the large model on the online end, protect the security of offline data, and improve the generalization ability of the model.
[0063] Figure 2A flowchart of a second large model training method based on federated learning provided in an embodiment of the present invention is shown in FIG. Figure 2 As shown, the method specifically includes:
[0064] S21. Pre-train the second target model and the first target model.
[0065] In this embodiment, the first target model and the second target model are both large text models. Online pre-training requires larger GPU memory and memory, and larger data for training, so pre-training needs to be performed on the server. Online pre-training is full-parameter training of large models, which requires high-memory and high-memory server support. Fig.12 The figure shows a flow chart of a model pre-training method provided by an embodiment of the present invention. The specific pre-training steps include: 1. Upload training data, 2. Pre-process the data, including cleaning data, expanding data, automatic labeling, etc., 3. Initialize the model, which can be initialized randomly or using the pre-trained model weights, 4. Start full parameter training of the model, 5. End model training according to the number of training rounds and early stopping mechanism, and save the model. Get the second target model in the server.
[0066] As an example, Fig.13 As shown, it is a flow chart of another model pre-training method provided by an embodiment of the present invention. In order to solve the problem that the offline terminal can have the ability to dynamically update the analysis model at the same time, a set of offline training client software is provided. The software can be used in conjunction with the online learning subsystem of the natural language task management system. The federated learning module trained by the online learning subsystem can be imported into the offline device through the CD to update the basic model capabilities of the offline device. The model is pre-trained according to multiple user requests as training data, and after the model is configured, the model is aggregated to the pre-trained model weights and accelerated reasoning is performed before returning the result.
[0067] S22. Import the adapter and simulator in the stacking layer of the first target model from the online server.
[0068] In this embodiment, the role of the large text model is to generate answers based on questions. However, the existing large model does not fully answer the knowledge in the new field and needs to be fine-tuned. However, due to data security and insufficient video memory of the offline GPU device, the large model cannot be directly fine-tuned on the low-end offline device. This requires splitting the large model and only fine-tuning the adapter.
[0069] Specifically, the adapter and simulator are pre-built in the online server. The adapter is a learnable module for offline fine-tuning training. The adapter is built in the following way:
[0070] Determine a preset number of top layers adjacent to the output layer of the target model from the stacked layers as the first adapter module; determine a preset number of bottom layers adjacent to the input layer of the target model as the second adapter module; and construct an adapter based on the first adapter module and the second adapter module.
[0071] The simulator is built in the following way:
[0072] Determine the other layers in the stack except the top and bottom layers; prune and compress the other layers to obtain a simulator. Pruning and compression is to enable fine-tuning training on low-end video memory devices. (For example, a 7B (7 billion) large model is difficult to load directly into a GPU video memory of only 16G. This requires pruning and compressing the large model to reduce the model to 4B so that it can be loaded into the video memory).
[0073] Among them, the specific number of the top layer, the bottom layer and other layers can be set according to needs, and is not specifically limited in this embodiment (for example, the current test takes two layers each for the top and bottom, and the effect is better. You can also take three or four layers each, a 48-layer stacked layer, take 4 layers each for the top and bottom as the top layer and the bottom layer, and the other layers are transformer-40 layers).
[0074] Furthermore, the constructed adapter and simulator are imported into the offline device through a CD or a hard disk.
[0075] As an example, Figure 7 FIG. 1 is a schematic diagram of a model structure of a large model training method based on federated learning provided by the present invention. Figure 8 FIG. 4 is a schematic diagram of a model structure of another large model training method based on federated learning provided by an embodiment of the present invention. Fig. 9 FIG. 4 is a schematic diagram of a model structure of another large model training method based on federated learning provided in an embodiment of the present invention. Figure 7 The large model shown includes: input layer, stacking layer and output layer. Since large models can be large or small (for example, models with different parameter amounts such as 1.5B and 4B), the larger the model, the more transformer layers are stacked, including 24 layers and 48 layers. If the GPU memory of the offline device is very small, only a small model can be used. Taking the Transformer stacking layer as an example with 24 layers, Top-2 is the two layers of the Transformer stacking layer close to the output layer, and Bottom-2 is the two layers of the Transformer stacking layer close to the input layer. Figure 8As shown, Top-2 and Bottom-2 are combined into an adapter (Adapter, including Adapter-top and Adapter-Bottom), and the adapter can update the weight parameters during training. The two adapter network structures are similar, but the selected positions are different, one at the top end and the other at the bottom end.
[0076] like Fig. 9 As shown in the figure, the remaining middle layer Transformer-20 is pruned and compressed as a simulator. During training, the simulator's parameter updates are frozen, and only the fine-tuning training loss is calculated to guide the adapter's parameter updates.
[0077] S23. Preprocess and enhance the local data to obtain processed target data; freeze all parameters in the simulator; input the target data into the target model for training to calculate the loss during model training through the simulator; update the weight parameters in the adapter according to the loss to minimize the loss.
[0078] In this embodiment, it is applied to offline devices, and local data of offline devices is obtained before preprocessing and data enhancement. Data preprocessing refers to a series of processing operations performed on the data before model training, mainly cleaning, converting and integrating the original data to improve the quality and reliability of the data. It may include: removing incomplete, erroneous, duplicate or inconsistent data. Converting the original local data into a form more suitable for analysis or modeling. Data enhancement aims to improve the generalization and robustness of the model by increasing the diversity and number of training samples. It can be enhanced by synonym replacement, random insertion, deletion or exchange of words. And configure the learning rate, number of training rounds, and set the training parameters before training. You can use experience or default values.
[0079] The weight parameters in the simulator and adapter represent a learnable matrix of network nodes in deep learning. The data in this learnable matrix is the parameters. The adapter parameters include the learnable weight parameters in top and bottom (for example, y=w*x+b, this simple linear transformation is a node in the network model, and w is the weight parameter).
[0080] Fine-tune the training according to the processed target data. First, freeze all learnable weight parameters of the simulator. The simulator does not participate in parameter update training, that is, the weights in the simulator are no longer updated during training. It only provides inference guidance during training and calculates the loss. The loss measures the difference between the model's prediction results and the true label, that is, the model's prediction error. By minimizing the loss function, the model can be trained to enable it to make more accurate predictions.
[0081] The neural network in the simulator only performs forward reasoning. When fine-tuning training, loss needs to be calculated. The data needs to pass through the input layer, stacking layer (transformer layer) and output layer, and finally calculate the loss with the real label data. Finally, the weight parameters in the adapter are updated according to the loss to minimize the loss value. However, the network parameters in the simulator have been set to be non-updatable. The simulator is used to "simulate" the reasoning calculation of the uncompressed large model. Local data is generally in the format of one question and one answer. The question is input into the model to get the output of the model, and then the loss is calculated with the real answer. Finally, back propagation is performed to update the weight parameters in the adapter.
[0082] Among them, the loss can be calculated by measuring the difference between the model prediction and the true label through the loss function. The gradient is the partial derivative of the loss function with respect to the model parameters, which indicates the rate of change of the loss function at each parameter point. Use calculus or automatic differentiation tools (for example, deep learning frameworks such as TensorFlow and PyTorch) to calculate the gradient of the loss function with respect to the model weights.
[0083] As an example, Fig.10 As shown, it is a flow chart of the fourth large model training method based on federated learning provided by an embodiment of the present invention. After loading the local data for data preprocessing, the imported adapters (the top Adapter-top module and the bottom Adapter-bottom module are loaded respectively) and the simulator are loaded respectively, the weights of the simulator are frozen, the Adapter-top module, the Adapter-bottom module and the simulator perform forward calculations respectively, logits = the forward output of the overall model, the loss loss is calculated, and the adapter weight parameters are updated. When the loss is minimized, the training is completed to obtain a new adapter.
[0084] S24: Export the new adapter to the second target model in the online server, so that the new adapter and the second target model are aggregated.
[0085] In this embodiment, similar to step S14, the details can be referred to Figure 1 For the sake of brevity, the relevant content will not be repeated here.
[0086] The large model training method based on federated learning provided in the embodiment of the present invention can solve the problem that the large model cannot be fine-tuned and trained on low-resource devices through a model training method that combines offline devices and online servers. It can simulate the gradient direction of the adapter module during fine-tuning training of the large model and guide the parameter update of the adapter. The large model on the online side incrementally updates the offline knowledge and protects the data security on the offline side. In terms of model upgrades on the big data platform, a breakthrough is made in the traditional difficulty of model upgrades caused by the inability to share system user data, and a multi-party data security fusion training method based on the federated learning model is established. Compared with the single-task learning method, it can aggregate the data of all users and improve the generalization ability of the model.
[0087] Figure 3 A flowchart of a third large model training method based on federated learning provided in an embodiment of the present invention is shown in FIG. Figure 3 As shown, the method specifically includes:
[0088] S31. Construct an adapter and a simulator in the stacking layer of the second target model.
[0089] In this embodiment, the method for constructing the adapter and the simulator is the same as that in step S22. Figure 2 For the sake of brevity, the relevant content will not be repeated here.
[0090] S32, exporting the adapter and the simulator to the first target model of the offline device, so that the first target model fine-tunes the adapter according to the local data of the simulator and the offline device to obtain a new adapter.
[0091] In this embodiment, exporting the adapter and the simulator to the first target model of the offline device includes:
[0092] The adapter and the simulator are downloaded to the target device in communication with the online server, so that the target device copies the adapter and the simulator to the storage carrier corresponding to the target device, and imports the adapter and the simulator into the first target model of the offline device through the storage carrier.
[0093] Specifically, download the adapter and simulator from the online server to a designated computer (target device) with a CD-ROM drive, insert the CD-ROM (storage medium), and copy the adapter and simulator files to the CD-ROM. Finally, load the CD-ROM to the offline device. If there is no CD-ROM drive or CD-ROM, a mechanical hard disk can also be used.
[0094] Further, the process of fine-tuning the adapter according to the local data of the simulator and the offline device is similar to step S12 and step S23, and can be specifically referred to Figure 1 and 2For the sake of brevity, the relevant content will not be repeated here.
[0095] S33. When the new adapter is imported into the online server, the new adapter and the second target model are aggregated.
[0096] In this embodiment, the layer number information corresponding to the new adapter in the first target model is obtained; and the layer corresponding to the layer number information in the stacked layers of the second target model is updated to the new adapter.
[0097] Specifically, after fine-tuning training is completed, the new adapter can be imported into the online server through a storage carrier and aggregated. Aggregation is to replace the layers at the same position of the second target model with the new adapter to achieve reasoning by loading the adapter in the second target model. After aggregation, offline data knowledge can be expanded to achieve incremental learning of large models.
[0098] As an example, Fig.11 As shown, it is a flowchart of the fifth large model training method based on federated learning provided by an embodiment of the present invention, including an offline end (offline device) and an online end (online server). The offline end preprocesses local data, configures training parameters, imports the adapter and simulator built on the online end through a CD, and exports the new adapter to the online end after fine-tuning the adapter. The online end builds an adapter and a simulator through pruning compression, and then imports the adapter and simulator to the offline end. When a new adapter is received, the new adapter is loaded in the model.
[0099] The large model training method based on federated learning provided in the embodiment of the present invention is applied to an online server. After building an adapter and a simulator in the online server and importing them into an offline device for fine-tuning training, the trained new adapters are aggregated, thereby solving the problem that large models cannot be fine-tuned on low-resource devices. The data of all users can be aggregated, thereby improving the generalization ability of the model.
[0100] Figure 4 A schematic diagram of the structure of a large model training device based on federated learning provided by an embodiment of the present invention, such as Figure 4 As shown, the device specifically includes:
[0101] A first import module 41 is used to import the adapter and the simulator in the stacking layer of the first target model from the online server, the adapter and the simulator are constructed in the online server, and the first target model is a model in the offline device;
[0102] A training module 42, configured to perform fine-tuning training on the adapter according to the simulator and the local data of the offline device to obtain a new adapter;
[0103] The first export module 43 is used to export the new adapter to the second target model in the online server, so that the new adapter and the second target model are aggregated.
[0104] In a possible implementation, the training module is specifically used to perform preprocessing and data enhancement processing on the local data to obtain processed target data;
[0105] Freezing all parameters in the simulator;
[0106] Inputting the target data into the target model for training, so as to calculate the loss during model training through the simulator;
[0107] Weight parameters in the adapter are updated according to the loss to minimize the loss.
[0108] The large model training device based on federated learning provided in this embodiment can be as follows Figure 4 The device shown in FIG. 1 can perform the following steps: Figure 1-2 All steps of the large model training method based on federated learning are implemented Figure 1-2 The technical effect of the large model training method based on federated learning is shown in the figure. For details, please refer to Figure 1-2 For the sake of brevity, the relevant description is not repeated here.
[0109] Figure 5 A structural diagram of another large model training device based on federated learning provided in an embodiment of the present invention, such as Figure 5 As shown, the device specifically includes:
[0110] A construction module 51, for constructing an adapter and a simulator in a stacking layer of a second target model;
[0111] A second export module 52 is used to export the adapter and the simulator to a first target model of an offline device, so that the first target model fine-tunes the adapter according to the local data of the simulator and the offline device to obtain a new adapter;
[0112] The aggregation module 53 is used to aggregate the new adapter and the second target model when the new adapter is imported into the online server.
[0113] In one possible implementation, the second export module is specifically used to download the adapter and the simulator to a target device that is communicatively connected to the online server, so that the target device copies the adapter and the simulator to a storage carrier corresponding to the target device, so as to import the adapter and the simulator into the first target model of the offline device through the storage carrier.
[0114] In a possible implementation manner, the aggregation module is specifically used to obtain the layer number information corresponding to the new adapter in the first target model;
[0115] The layer corresponding to the layer number information in the stacked layers of the second target model is updated to the new adapter.
[0116] The large model training device based on federated learning provided in this embodiment can be as follows Figure 5 The device shown in FIG. 1 can perform the following steps: Figure 3 All steps of the large model training method based on federated learning are implemented Figure 3 The technical effect of the large model training method based on federated learning is shown in the figure. For details, please refer to Figure 3 For the sake of brevity, the relevant description is not repeated here.
[0117] Figure 6 A schematic diagram of a device provided in an embodiment of the present invention is provided. Figure 6 The device 600 shown includes: at least one processor 601, a memory 602, at least one network interface 604 and other user interfaces 603. The various components in the device 600 are coupled together via a bus system 605. It is understood that the bus system 605 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 605 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 605 is not shown in FIG. Figure 6 Various buses are labeled as bus system 605 .
[0118] The user interface 603 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen).
[0119] It can be understood that the memory 602 in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DRRAM). The memory 602 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0120] In some implementations, the memory 602 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 6021 and an application 6022 .
[0121] The operating system 6021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 6022 includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present invention can be included in the application 6022.
[0122] In the embodiment of the present invention, by calling the program or instruction stored in the memory 602, specifically, the program or instruction stored in the application 6022, the processor 601 is used to execute the method steps provided by each method embodiment, for example, including:
[0123] When applied to offline devices, it includes:
[0124] Importing an adapter and a simulator in a stacking layer of a first target model from an online server, wherein the adapter and the simulator are constructed in the online server, and the first target model is a model in the offline device;
[0125] Fine-tune the adapter according to the simulator and the local data of the offline device to obtain a new adapter;
[0126] The new adapter is exported to the second target model in the online server, so that the new adapter and the second target model are aggregated.
[0127] When applied to online servers, it includes:
[0128] constructing adapters and simulators in the stacked layers of the second target model;
[0129] Exporting the adapter and the simulator to a first target model of an offline device, so that the first target model fine-tunes the adapter according to local data of the simulator and the offline device to obtain a new adapter;
[0130] When the new adapter is imported into the online server, the new adapter and the second target model are aggregated.
[0131] The method disclosed in the above embodiment of the present invention can be applied to the processor 601, or implemented by the processor 601. The processor 601 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 601 or the instruction in the form of software. The above processor 601 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 602, and the processor 601 reads the information in the memory 602 and completes the steps of the above method in combination with its hardware.
[0132] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPDevice, DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.
[0133] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0134] The device provided in this embodiment can be Figure 6 The device shown in , can be executed as Figure 1-3 All steps of the large model training method based on federated learning are implemented Figure 1-3 The technical effect of the large model training method based on federated learning is shown in the figure. For details, please refer to Figure 1-3 For the sake of brevity, the relevant description is not repeated here.
[0135] The embodiment of the present invention also provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.
[0136] When one or more programs in the storage medium can be executed by one or more processors, the above-mentioned large model training method based on federated learning executed on the device side can be implemented.
[0137] The processor is used to execute the model training program stored in the memory to implement the following steps of the large model training method based on federated learning performed on the device side:
[0138] When applied to offline devices, it includes:
[0139] Importing an adapter and a simulator in a stacking layer of a first target model from an online server, wherein the adapter and the simulator are constructed in the online server, and the first target model is a model in the offline device;
[0140] Fine-tune the adapter according to the simulator and the local data of the offline device to obtain a new adapter;
[0141] The new adapter is exported to the second target model in the online server, so that the new adapter and the second target model are aggregated.
[0142] When applied to online servers, it includes:
[0143] constructing adapters and simulators in the stacked layers of the second target model;
[0144] Exporting the adapter and the simulator to a first target model of an offline device, so that the first target model fine-tunes the adapter according to local data of the simulator and the offline device to obtain a new adapter;
[0145] When the new adapter is imported into the online server, the new adapter and the second target model are aggregated.
[0146] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0147] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0148] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A large model training method based on federated learning, It is characterized in that Applicable to offline devices, including: Importing an adapter and a simulator in a stacking layer of a first target model from an online server, wherein the adapter and the simulator are constructed in the online server, and the first target model is a model in the offline device; Fine-tune the adapter according to the simulator and the local data of the offline device to obtain a new adapter; The new adapter is exported to the second target model in the online server, so that the new adapter and the second target model are aggregated.
2. The method according to claim 1, It is characterized in that The adapter is constructed by the online server in the following manner: determining a preset number of top layers adjacent to an output layer of the target model as a first adapter module; determining a preset number of bottom layers adjacent to an input layer of the target model as second adapter modules; The adapter is constructed from the first adapter module and the second adapter module.
3. The method according to claim 2, It is characterized in that The simulator is constructed by the online server in the following manner: Determine other layers in the stacked layers except the top layer and the bottom layer; The other layers are pruned and compressed to obtain the simulator.
4. The method according to claim 1, It is characterized in that The fine-tuning training of the adapter according to the simulator and the local data of the offline device comprises: Preprocess and enhance the local data to obtain the processed target data; Freezing all parameters in the simulator; Inputting the target data into the target model for training, so as to calculate the loss during model training through the simulator; Weight parameters in the adapter are updated according to the loss to minimize the loss.
5. A large model training method based on federated learning, It is characterized in that The online server as claimed in claim 1 comprises: constructing adapters and simulators in the stacked layers of the second target model; Exporting the adapter and the simulator to a first target model of an offline device, so that the first target model fine-tunes the adapter according to local data of the simulator and the offline device to obtain a new adapter; When the new adapter is imported into the online server, the new adapter and the second target model are aggregated.
6. The method according to claim 5, It is characterized in that The exporting of the adapter and the simulator to a first target model of an offline device comprises: The adapter and the simulator are downloaded to a target device that is communicatively connected to the online server, so that the target device copies the adapter and the simulator to a storage carrier corresponding to the target device, and imports the adapter and the simulator into the first target model of the offline device through the storage carrier.
7. The method according to claim 5, It is characterized in that The aggregating the new adapter and the second target model comprises: Obtaining information about the number of layers corresponding to the new adapter in the first target model; The layer corresponding to the layer number information in the stacked layers of the second target model is updated to the new adapter.
8. A model training device, It is characterized in that include: A first import module, used for importing an adapter and a simulator in a stacking layer of a first target model from an online server, wherein the adapter and the simulator are constructed in the online server, and the first target model is a model in an offline device; A training module, used for fine-tuning the adapter according to the local data of the simulator and the offline device to obtain a new adapter; The first export module is used to export the new adapter to the second target model in the online server, so that the new adapter and the second target model are aggregated.
9. A device, It is characterized in that include: A processor and a memory, wherein the processor is used to execute a model training program stored in the memory to implement the large model training method based on federated learning as described in any one of claims 1 to 4 or 5 to 7.
10. A storage medium, It is characterized in that The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the large model training method based on federated learning as described in any one of claims 1 to 4 or 5 to 7.
Citation Information
Cited By
Big language model data processing method and device based on federal learning
CN120597970A
Data processing method and device for federated learning-based large language model
CN120597970B
Federal large model robust fine tuning method and system for remote sensing task heterogeneous scene
CN121459104A
