Federal learning-based model training method, device and equipment
By determining the target-dependent structure in federated learning and pruning, the problem of low training efficiency of large language models is solved, and the model structure simplification and training speed are improved.
Patent Information
- Application Number
- CN202510857656.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-25
- Publication Date
- 2025-07-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing large language model training method based on federated learning has the problem of huge model structure and low training efficiency.
By determining the set of dependency structures of the initial large language model and the predetermined pruning ratio, the pre-pruning model is sent to the computing node, the target dependency structure is determined based on the first and second performance deviations, and the initial large language model is pruned, and then the optimization training is performed to obtain the target large language model.
The structure of the large language model is accurately and reasonably simplified, the training speed is improved, and the accuracy of model training is ensured.
Smart Images

Figure CN120354906A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technologies, and particularly to a model training method, device, and equipment based on federated learning. Background Art
[0002] Federated Learning is a distributed learning technology that combines traditional cryptography and machine learning, aiming to establish a federated learning model based on distributed data sets for multiple data providers who are unwilling or unable to expose their plaintext data.
[0003] Large language models are deep learning models based on the Transformer architecture applied in the field of natural language processing, usually containing hundreds of billions (or more) of parameters trained on a large amount of text data, and their applications are very extensive, including machine translation, speech recognition, information retrieval, content generation, intelligent question answering, etc.
[0004] However, existing large language model training methods based on federated learning have problems such as a large model structure and low training efficiency. Summary of the Invention
[0005] In view of this, the present invention provides a model training method, device, and equipment based on federated learning, mainly aiming to solve the problems of a large current model structure and low training efficiency.
[0006] To solve the above problems, the present application provides a model training method based on federated learning, which is applied to a main computing node and includes: Determine pre-pruned models corresponding to each total pruning strategy based on the dependency structure set corresponding to the initial large language model and a predetermined pruning ratio, and send each pre-pruned model to each slave computing node; Determine the first performance deviation of each pre-pruned model based on a pre-constructed first training data set; Receive the second performance deviation of each pre-pruned model sent by each slave computing node; Determine a number of target dependency structures based on the first performance deviation of each pre-pruned model and the second performance deviation of each pre-pruned model, and perform pruning processing on the initial large language model based on each target dependency structure to obtain a pruned large language model; Perform optimization training on the pruned large language model based on a pre-constructed first optimization data set to obtain a target large language model.
[0007] To solve the above problems, the present application provides a model training method based on federated learning, which is applied to a slave computing node and includes: Receive each pre-pruned model of the initial large language model sent by the main computing node; Based on a pre-constructed second training dataset, determine the second performance deviation of each pre-pruning model; Send the second performance deviation to the main computing node for the main computing node to determine a number of target dependency structures based on the first performance deviation of each pre-pruning model and the received second performance deviations of each pre-pruning model, and perform pruning processing on the initial large language model based on each target dependency structure to obtain a pruned large language model; Receive the pruned large language model sent by the main computing node, and perform optimization training on the pruned large language model based on a pre-constructed second optimization dataset to obtain a target large language model.
[0008] To solve the above technical problems, the present application provides a model training device based on federated learning, including: A first sending module, configured to determine pre-pruning models corresponding to each total pruning strategy based on a set of dependency structures corresponding to an initial large language model and a predetermined pruning ratio, and send each pre-pruning model to each slave computing node; A first determining module, configured to determine the first performance deviation of each pre-pruning model based on a pre-constructed first training dataset; A first receiving module, configured to receive the second performance deviations of each pre-pruning model sent by each slave computing node; A pruning module, configured to determine a number of target dependency structures based on the first performance deviation of each pre-pruning model and the second performance deviations of each pre-pruning model, and perform pruning processing on the initial large language model based on each target dependency structure to obtain a pruned large language model; A first optimization module, configured to perform optimization training on the pruned large language model based on a pre-constructed first optimization dataset to obtain a target large language model.
[0009] To solve the above technical problems, the present application provides a model training device based on federated learning, including: A second receiving module, configured to receive each pre-pruning model of the initial large language model sent by the main computing node; A second determining module, configured to determine the second performance deviation of each pre-pruning model based on a pre-constructed second training dataset; A second sending module, configured to send the second performance deviation to the main computing node for the main computing node to determine a number of target dependency structures based on the first performance deviation of each pre-pruning model and the received second performance deviations of each pre-pruning model, and perform pruning processing on the initial large language model based on each target dependency structure to obtain a pruned large language model; A second optimization module, configured to receive the pruned large language model sent by the main computing node, and perform optimization training on the pruned large language model based on a pre-constructed second optimization dataset to obtain a target large language model.
[0010] To solve the above technical problems, the present application provides an electronic device, which at least includes a memory and a processor. A computer program is stored on the memory, and when the processor executes the computer program on the memory, the steps of the model training method based on federated learning described in any one of the above are implemented.
[0011] In the model training method, device and equipment based on federated learning in the present application, by determining pre-pruned models corresponding to each total pruning strategy, subsequent performance deviations between each pre-pruned model and the initial large language model can be used to accurately determine several target dependency structures with lower importance / impact degree from the dependency structures of each total pruning strategy. Subsequently, the initial large language model can be pruned based on these prunable target dependency structures, thereby accurately and reasonably obtaining a pruned large language model, simplifying the model structure of the large language model, improving the model training speed, and ensuring the accuracy of model training.
[0012] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the description. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the following specifically illustrates the specific embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of illustrating the preferred embodiments and are not considered to be a limitation of the present invention. And throughout the drawings, the same reference numerals are used to represent the same components. In the drawings: Figure 1 is a flowchart of a model training method based on federated learning according to an embodiment of the present application; Figure 2 is a flowchart of a model training method based on federated learning according to another embodiment of the present application; Figure 3 is a structural block diagram of a model training device based on federated learning according to another embodiment of the present application; Figure 4 is a structural block diagram of a model training device based on federated learning according to another embodiment of the present application; Figure 5 is a structural block diagram of an electronic device according to another embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0014] Reference is made herein to the various aspects and features of the present application with reference to the accompanying drawings.
[0015] It should be understood that various modifications can be made to the embodiments applied herein. Therefore, the above specification should not be regarded as restrictive, but only as an example of the embodiments. Those skilled in the art will think of other modifications within the scope and spirit of this application.
[0016] The accompanying drawings, which are included in and constitute a part of this specification, illustrate embodiments of the application and, together with the general description of the application given above and the detailed description of the embodiments given below, serve to explain the principles of the application.
[0017] These and other features of the application will become apparent from the following description of the preferred forms of the embodiments, given by way of non-limiting example with reference to the accompanying drawings.
[0018] It should also be understood that although the application has been described with reference to some specific examples, those skilled in the art can surely implement many other equivalent forms of the application.
[0019] When combined with the accompanying drawings, the above and other aspects, features and advantages of the application will become more apparent in view of the following detailed description.
[0020] Specific embodiments of the application will be described hereinafter with reference to the accompanying drawings; however, it should be understood that the embodiments applied are merely examples of the application and can be implemented in various ways. Well-known and / or repetitive functions and structures are not described in detail to avoid obscuring the application with unnecessary or redundant details. Therefore, the specific structural and functional details applied herein are not intended to be limiting, but are merely used as a basis for the claims and a representative basis for teaching those skilled in the art to use the application in substantially any suitable detailed structure in a variety of ways.
[0021] This specification may use the phrases "in one embodiment", "in another embodiment", "in yet another embodiment" or "in other embodiments", which may each refer to one or more of the same or different embodiments according to the application.
[0022] An embodiment of the application provides a model training method based on federated learning, which can be specifically applied to the main computing node / leading party of federated learning. Specifically, the main computing node can be a financial infrastructure. As Figure 1 shown, the method in this embodiment includes the following steps: Step S101, based on the set of dependency structures corresponding to the initial large language model and a predetermined pruning ratio, determine pre-pruned models corresponding to each total pruning strategy, and send each pre-pruned model to each slave computing node; In this step, a pruning ratio can be preset. For example, the pruning ratio is 50%. The main computing node can deploy components of the federated large language model collaboration network in the local data center in advance. The framework of the federated learning collaboration network in this application can be implemented using other software products with the same functions such as FATE, SecretFlow, PaddleFL, TensorFlow Federated, and Pysyft.
[0023] The main computing node can identify the dependency relationships of the initial large language model, so as to determine the inter-layer and intra-layer dependency relationships of the initial large language model, and regard the neural network nodes with dependency relationships as a dependency structure g n , so as to obtain a number of dependency structures, that is, obtain the dependency structure set G = {g1, g2, g3... g n}.
[0024] After determining the dependency structure set, several total pruning strategies can be determined according to the pruning ratio, and a strategy set G prun ={g1∪g2∪g3, g1∪g3∪g4,...} can be obtained, where g1∪g2∪g3 represents a total pruning strategy, and g1∪g3∪g4 represents another total pruning strategy.
[0025] After obtaining each total pruning strategy, the initial large language model M can be further pruned based on each total pruning strategy respectively, so as to obtain a pre-pruned model M pm corresponding to each total pruning strategy, and thus a pre-pruned model set M prun ={M p1 , M p2 ,... M pm} can be obtained. That is, each total pruning strategy corresponds to a pre-pruned model M pm .
[0026] Step S102, determine the first performance deviation of each pre-pruned model based on the pre-constructed first training dataset; In the specific implementation process of this step, the main computing node can adopt the K-fold cross-validation method to calculate the performance deviation between each pre-pruned model and the initial large language model respectively, so as to obtain the first performance deviation of each pre-pruned model.
[0027] Step S103, receive the second performance deviation sent by each slave computing node for each pre-pruned model; In this step, each slave computing node can use a K-fold cross-validation method based on each pre-pruned model sent by the master computing node to calculate the performance deviation between each pre-pruned model and the initial large language model to obtain a second performance deviation of each pre-pruned model, and send the second performance deviation to the master computing node, so that the master computing node can receive the second performance deviation for each pre-pruned model sent by each slave computing node.
[0028] Step S104, determining a plurality of target dependency structures based on the first performance deviations of the pre-pruned models and the second performance deviations of the pre-pruned models, and pruning the initial large language model based on the target dependency structures to obtain a pruned large language model; In this step, after receiving the second performance deviation of each pre-pruning model sent by each slave computing node, the master computing node can perform pm The first performance deviation and each second performance deviation determine the pre-pruning model M pm The target performance deviation is calculated to determine the influence of the total pruning strategy corresponding to the pre-pruning model, thereby obtaining the influence of each total pruning strategy.
[0029] In this step, the greater the performance deviation, the greater the impact, that is, the dependency structures in the total pruning strategy cannot be pruned. Then, the total pruning strategies can be sorted in descending order based on the impact, and a number of dependency structures in the top-ranked total pruning strategies are determined as non-target dependency structures that cannot be pruned (specifically, they can be determined based on the number of repetitions of the same dependency structure in the total pruning strategy), and finally the remaining dependency structures can be determined as target dependency structures.
[0030] After the target dependency structure is determined, the initial large language model can be pruned based on each target dependency structure to obtain a pruned large language model.
[0031] Step S105 , optimizing and training the pruned large language model based on the pre-constructed first optimization data set to obtain a target large language model.
[0032] In the specific implementation process of this step, the pruned large language model can be optimized / restored based on the first optimized dataset to obtain the initial first optimized parameters; receive the initial second optimized parameters obtained by each slave computing node for optimizing the pruned large language model; perform parameter aggregation processing based on the first optimized parameters and the second optimized parameters to obtain the initial aggregated parameters; send the initial aggregated parameters to each slave computing node for each slave computing node to perform the next round of model optimization / restoration based on the initial aggregated parameters, and receive the current second optimized parameters sent by each slave computing node. When the predetermined tuning condition is met, stop the model tuning, use the current aggregated parameters as the target aggregated parameters, and obtain the target large language model.
[0033] In the model training method based on federated learning in this embodiment, by determining the pre-pruned models corresponding to each total pruning strategy, subsequently, based on the performance deviation between each pre-pruned model and the initial large language model, several target dependency structures with relatively low importance / impact degree can be accurately determined from the dependency structures of each total pruning strategy. Subsequently, the initial large language model can be pruned based on these prunable target dependency structures, thereby accurately and reasonably obtaining the pruned large language model, simplifying the model structure of the large language model, improving the model training speed, and ensuring the accuracy of model training.
[0034] Based on the above embodiment, another embodiment of the present application provides a model training method based on federated learning, which is applied to the master computing node. The overall process of model training is as follows: Step S201, installation and initialization of the federated large language model; In this step, the financial infrastructure as the leading party serves as the master computing node, deploys the federated large language model collaboration network in its data center, and provides a distributed node deployment installation package to send to each participant (financial institution) / slave computing node of the federated learning. So that each participant / slave computing node deploys and installs the components of the federated large language model collaboration network and joins the collaboration network as a slave computing node. The framework of the federated learning collaboration network can be implemented using other software products with the same functions such as FATE, SecretFlow, PaddleFL, TensorFlow Federated, and Pysyft.
[0035] Step S202, data preprocessing; In this step, the main computing node connects to its local bond business database and prepares high-quality dialogue data within its own business domain to obtain a first initial dataset. This first initial dataset contains questions that may be asked in various financial operations and their answers, which are used as training data for the importance assessment and model recovery steps. Specifically, the dialogue data in the first initial dataset includes dialogue data of types such as zero-shot prompts, few-shot prompts, and knowledge base prompts.
[0036] 1. Zero-shot prompt: The institution does not provide demonstrations related to the task results and directly prompts the language model to give task-related answers.
[0037] 2. Few-shot prompt: The institution provides a small number of prompt examples, such as task descriptions.
[0038] 3. Knowledge base prompt: The institution provides a knowledge base related to questions and question keywords, and uses the context content of the knowledge base to form prompt words. After the main computing node performs text extraction and semantic understanding on the knowledge base, it calculates the relevance between the vectorized knowledge base document fragments and the input question using a vector distance measurement metric, and forms prompt words by combining the most similar several document fragments with the input question to obtain dialogue data. Among them, the vector distance measurement metric can be implemented by methods such as cosine similarity, dot product, Hamming distance, and other vector distance measurements.
[0039] In this step, in addition to the bond business dialogue data, the main computing node can prepare general Chinese dialogue data in advance to expand the first initial dataset. The data sources of the Chinese dialogue data include, but are not limited to, open-source instruction datasets such as Stanford Alpaca, self-instruct, GPT4-for-LLM, alpaca-chinese-dataset, BELLE, and COIG. For the non-Chinese dialogue data among them, models with the same functions such as NLLB-200 or Delta LM are used to identify the language and translate it into Chinese.
[0040] After the main computing node completes the preparation of the first initial dataset, a certain proportion of the data is randomly selected from it as the first training dataset for pruning processing and the first optimization dataset for model tuning. By default, 60% of the data is selected as the first training dataset D_eval center , and the other non-repeating 40% of the data is the first optimization dataset D_recover center . For the first training dataset D_eval center , in the way of K-fold cross-validation, K training data D_eval used in the importance assessment step / pruning step are generated 1…K center . For the first optimization dataset D_recovercenter In the way of K-fold cross-validation, generate K tuning data D_recover used in the model tuning step 1…K center . The default value of K is 5, which can be flexibly adjusted according to needs.
[0041] Step S203, identify the dependency structure of the initial large language model; In this step, based on the dependency relationships of each neuron in the initial large language model, a dependency structure set containing several dependency structures can be determined.
[0042] That is, for the purpose of performing structured pruning on the federated large language model, this step identifies the inter-layer and intra-layer dependency relationships of the initial large language model for the local dependency relationships between adjacent layers of the model, and regards the neural network nodes with dependencies as a dependency structure / dependency structure. That is, if a certain neuron N in the initial large language model network i only depends on another neuron N j , then when pruning N j , it is necessary to synchronously prune N i , from which a dependency structure / dependency structure containing N j and N i can be obtained.
[0043] In this step, the main computing node performs iterative dependency detection / identification on all neurons in the initial large language model M until there are no unrecognized neurons. According to the results of the dependency relationship analysis, the trainable variables of the initial large language model are divided into multiple sets G of the smallest deletable structures, that is, the dependency structure set G corresponding to the initial large language model, and this dependency structure set G contains all the dependency structures of the initial large language model.
[0044] Step S204, screen each dependency structure in the dependency structure set G to obtain the target dependency structure to be pruned; When performing the screening of the target dependency structure, it can specifically include the following steps: Step S2041, based on the dependency structure set corresponding to the initial large language model and a predetermined pruning ratio, determine the pre-pruned models corresponding to each total pruning strategy; In this step, based on the dependency structure set and the pruning ratio, several total pruning strategies can be determined; based on each total pruning strategy, determine the pre-pruned models corresponding to each total pruning strategy.
[0045] That is, the pruning quantity can be determined according to the pruning ratio. For example, the predetermined pruning ratio P is 50%. The main computing node then traverses to obtain all combinations in the dependency structure set G that meet the pruning ratio P, and generates a set of structures to be pruned, that is, generates the strategy set G prun={g1∪g2∪g3, g1∪g3∪g4, ……}, where g1∪g2∪g3 represents a total pruning strategy, and g1∪g3∪g4 represents another total pruning strategy. According to the total pruning strategies in the strategy set G prun prune the initial large language model, and pre-pruned models M pm corresponding to each total pruning strategy can be generated, thus obtaining a set of pre-pruned models M prun ={M p1 , M p2 , …… M pm}.
[0046] In this step, after obtaining the set of pre-pruned models, the master computing node can synchronize the set of pre-pruned models M prun to each slave computing node, which is convenient for the slave computing nodes to calculate the performance deviation between each pre-pruned model and the initial large language model.
[0047] Step S2042: Determine the first performance deviation of each pre-pruned model based on the pre-constructed first training dataset; In the specific implementation of this step, specifically, based on the first training dataset, the K-fold cross-validation method can be used to calculate the performance deviation between each pre-pruned model and the initial large language model respectively, so as to obtain the first performance deviation of each pre-pruned model. That is, the master computing node can perform K-fold cross-validation on the first training dataset D_eval center to generate K training data D_eval 1…K center used in the importance evaluation step / pruning step, where the default value of K is 5 and can be flexibly adjusted according to needs.
[0048] Then, the master computing node uses D_eval 1…K center to calculate the performance deviation between each pre-pruned model M pm and the initial large language model M in the way of K-fold cross-validation. That is, for the same pre-pruned model, the performance deviation between the pre-pruned model and the initial large language model is calculated respectively using K datasets, so as to obtain K performance deviations, and then the first performance deviation between the pre-pruned model and the initial large language model is comprehensively obtained based on the K performance deviations. For example, using the K performance deviations, by calculating the average value or taking the median value, etc., to determine the final first performance deviation. Among them, the performance deviation can specifically include the accuracy deviation of the model, the recall deviation of the model, etc.; that is, the deviation between the accuracy of the pre-pruned model and the accuracy of the initial large language model, or the deviation between the recall of the pre-pruned model and the recall of the initial large language model.
[0049] Step S2043: Receive the second performance deviations of each pre-pruned model sent by each slave computing node. In this step, after each slave computing node receives the set of pre-pruned models M sent by the master computing node prun , it can also use the same deviation performance determination method as the master computing node to determine the second performance deviation of each pre-pruned model. That is, the slave computing node is based on the local second training dataset D_eval nodei , and adopts the K-fold cross-validation method to calculate the performance deviation between each pre-pruned model and the initial large language model respectively, so as to obtain the second performance deviation of each pre-pruned model. That is, each slave computing node can perform K-fold cross-validation on the local second training dataset D_eval nodei in the form of K-fold cross-validation to generate K training data D_eval used in the importance evaluation step / pruning step 1…K nodei , and the default value of K is 5, which can be flexibly adjusted according to needs. Then, the slave computing node uses D_eval 1…K nodei , and calculates the performance deviation between each pre-pruned model M pm and the initial large language model M in the form of K-fold cross-validation. That is, for the same pre-pruned model, the performance deviation between the pre-pruned model and the initial large language model is calculated respectively using K datasets, so as to obtain K performance deviations, and then the second performance deviation between the pre-pruned model and the initial large language model is comprehensively obtained based on the K performance deviations. For example, using the K performance deviations, by calculating the average value or taking the median value, etc., to determine the final second performance deviation.
[0050] In this step, after the slave computing node determines the second performance deviation of each pre-pruned model, it can send the second performance deviation of each pre-pruned model to the master computing node.
[0051] Step S2044: Determine a number of target dependency structures based on the first performance deviations of each pre-pruned model and the second performance deviations of each pre-pruned model. In this step, when determining the target dependency structure, the specific process is as follows: Step 1: Determine the influence degree of each total pruning strategy based on the first performance deviations of each pre-pruned model and the second performance deviations of each pre-pruned model. That is, for the same pre-pruned model, the master computing node can adopt a predetermined federated aggregation strategy based on the first performance deviation and each second performance deviation to determine the target performance deviation between the pre-pruned model M pm and the initial large language model M. The predetermined federated aggregation strategies include but are not limited to summation, arithmetic mean, weighted mean, maximum value, etc.
[0052] After determining the target performance deviation of each pre-pruning model, the main computing node can determine the influence degree of the total pruning strategy corresponding to the pre-pruning model, and thus obtain the influence degree of each total pruning strategy. Among them, the greater the performance deviation, the greater the influence degree, that is, it is not possible to perform pruning processing on each dependent structure in the total pruning strategy.
[0053] Step 2: Based on the influence degree of each total pruning strategy and a predetermined non-prunable ratio, determine a number of non-target dependent structures that cannot be pruned from each total pruning strategy to obtain a number of target dependent structures that can be pruned.
[0054] In this step, the total pruning strategies can be sorted in descending order based on the influence degree, so as to determine that a number of dependent structures in the total pruning strategy with a higher ranking cannot be pruned as non-target dependent structures.
[0055] Specifically, it can be determined whether it is a non-target dependent structure based on the number of occurrences of the same dependent structure in each total pruning strategy. For example, for the top 10 total pruning strategies with a higher ranking, if the number of occurrences of a certain dependent structure in these 10 total pruning strategies is 9, it can be determined that this dependent structure is a non-target dependent structure that cannot be pruned. Thus, a non-target dependent structure with a predetermined quantity / a predetermined non-prunable ratio γ can be determined, that is, the non-target dependent structure set G_unprunable is obtained. Furthermore, the remaining dependent structures in the dependent structure set G can be determined as target dependent structures that can be pruned, that is, the target dependent structure set G_prunable is obtained.
[0056] Step S205: Prune the initial large language model based on each target dependent structure to obtain a pruned large language model; In this step, when pruning the initial large language model, the specific process is as follows: Based on each target dependent structure, an iterative pruning method is used to determine the current sub-pruning strategy corresponding to the current pruning round, and the current large language model is pruned based on the current sub-pruning strategy to obtain the pruned current large language model until a predetermined pruning condition is met to obtain the pruned large language model. Among them, the process of determining the current sub-pruning strategy is as follows: Step S2051: Determine the pruning quantity for each round based on the total pruning rounds and a predetermined pruning ratio; For example, if the pruning ratio of P = 50% is achieved through 10 iterations / pruning rounds, then each iteration / each round of pruning needs to subtract dependent structures accounting for 5% of the original model.
[0057] Step S2052: Based on the pruning quantity of the current pruning round and the remaining target dependency structures after the previous pruning process, determine several candidate sub-pruning strategies corresponding to the current round, and determine candidate pruning models corresponding to each candidate sub-pruning strategy. In this step, for example, it is determined that the set of target dependency structures G_prunable contains g2, g4, g7, g8, g9, g 10 ...... these target dependency structures. If the total number of dependency structures of the initial large language model is 100, then the number of dependency structures for 5% in each round is 5. Thus, for the current pruning round T = 1, the main computing node can arbitrarily select 5 dependency structures from each target dependency structure as candidate sub-pruning strategies, thereby obtaining several candidate sub-pruning strategies, and at the same time, can determine the corresponding candidate pruning models according to each candidate sub-pruning strategy.
[0058] In this step, the main computing node can also send each candidate pruning model to each slave computing node for the slave computing node to calculate the performance deviation between each candidate pruning model and the pruning model of the initial large language model based on each candidate pruning model.
[0059] Step S2053: Based on the first training dataset, determine the third performance deviation between each candidate pruning model and the historical pruning model obtained from the previous pruning process. In this step, when the pruning round T = 1, the historical pruning model obtained from the previous pruning process is the initial large language model. Thus, the main computing node can, based on the first training set, adopt the K-fold cross-validation method to calculate the third performance deviation between each candidate pruning model and the historical pruning model (initial large language model M) obtained from the previous pruning process.
[0060] In this step, the calculation principle of the third performance deviation is the same as that of the first performance deviation, and it also uses the training data D_eval 1…K center , and calculates the performance deviation between each candidate pruning model and the historical pruning model (initial large language model M) obtained from the previous pruning process in the K-fold cross-validation method. That is, for the same candidate pruning model, the performance deviation between this candidate pruning model and the historical pruning model (initial large language model M) obtained from the previous pruning process is calculated using K datasets respectively, so as to obtain K performance deviations, and then the third performance deviation of the candidate pruning model is comprehensively obtained based on the K performance deviations. The specific process is not elaborated here.
[0061] Step S2054: Receive the fourth performance deviation sent by each slave computing node for each candidate pruning model. In this step, the calculation principle of the fourth performance deviation is the same as that of the second performance deviation. When the pruning round number T = 1, the historical pruning model obtained from the previous pruning process is the initial large language model. After each computing node receives the candidate pruning models sent by the main computing node, it also uses the training data D_eval 1…K nodei , and calculates the performance deviation between each candidate pruning model and the historical pruning model (initial large language model M) obtained from the previous pruning process in the way of K-fold cross-validation. That is, for the same pre-pruned model, the performance deviation between the candidate pruning model and the historical pruning model (initial large language model M) obtained from the previous pruning process is calculated using K data sets respectively, so as to obtain K performance deviations, and then the fourth performance deviation of the candidate pruning model is comprehensively obtained based on the K performance deviations.
[0062] Step S2055, determine the influence degree of each candidate sub-pruning strategy based on the third performance deviation of each candidate pruning model and each fourth performance deviation of each candidate pruning model; In this step, the main computing node can aggregate the third performance deviation and each fourth performance deviation of the same candidate pruning model based on a predetermined aggregation strategy to obtain the target performance deviation, so as to obtain the influence degree of each candidate sub-pruning strategy. The predetermined aggregation strategies include but are not limited to summation, arithmetic mean, weighted mean, maximum value, etc., and the arithmetic mean is used by default, etc. In this step, the greater the performance deviation, the greater the influence degree, that is, the pruning process cannot be performed on each dependent structure in the candidate sub-pruning strategy.
[0063] Step S2056, determine the current sub-pruning strategy corresponding to the current round from each candidate sub-pruning strategy based on the influence degree of each candidate sub-pruning strategy.
[0064] In this step, the candidate sub-pruning strategy with the smallest influence degree can be specifically selected as the current sub-pruning strategy corresponding to the current round.
[0065] Step S2057, and perform pruning on the current large language model based on the current sub-pruning strategy to obtain the pruned current large language model until the predetermined pruning condition is met to obtain the pruned large language model.
[0066] In this step, pruning can be performed on the current large language model (when T = 1, the current large language model is the initial large language model) based on the current sub-pruning strategy to obtain the pruned current large language model, and the above steps S2052 to S2057 are repeated until the predetermined pruning round number is reached to obtain the pruned large language model M*.
[0067] In this step, in each pruning cycle / pruning round \(T = 1, 2,\cdots\), all computing nodes participate in the calculation. By gradually pruning the initial large language model through an iterative method, the final pruning result can be made more reasonable and accurate. That is, the main computing node selects the combination / candidate sub-pruning strategy with the lowest importance / lowest impact degree from the important group / the set \(G_{prunable}\) of target dependency structures to be pruned as the current sub-pruning strategy \(G_p\) for the current pruning round, and removes \(G_p\) from the important group / the set \(G_{prunable}\) of target dependency structures to be pruned. Perform gradient-based updates on the LoRA variables in the redundant group / the current sub-pruning strategy \(G_p\), and project the variables in the redundant group / the current sub-pruning strategy \(G_p\) onto the null space. During this entire process, the redundant group is gradually projected to zero, while the LoRA module absorbs knowledge to minimize the loss function.
[0068] In this step, by pruning the initial large language model in the above manner, redundant parameters with low contributions in the large language model can be removed to compress the memory occupancy of the federated large language model, reduce storage requirements, and improve memory and computing efficiency. During the pruning process, by determining the performance deviation and adopting a federated learning framework, multiple financial institutions are supported to use their local business data respectively to evaluate the parameter importance (performance deviation calculation) and iterative pruning of the federated large language model, improving the generalization ability of the model while compressing the scale of the federated large language model.
[0069] Step S206: Optimize and train the pruned large language model based on a pre-constructed first optimization dataset to obtain the target large language model.
[0070] In this step, the specific process of model optimization / model recovery is as follows: Step S2061: Optimize the pruned large language model \(M^*\) based on the first optimization dataset to obtain the initial first optimization parameters; In this step, the main computing node can specifically generate \(K\) tuning data \(D_{recover}\) used in the model tuning step in the form of \(K -\)fold cross-validation based on the first optimization dataset \(D_{recover}\) center in the form of \(K -\)fold cross-validation, and then use the \(K\) tuning data \(D_{recover}\) 1…K center to optimize the pruned large language model \(M^*\) and obtain the initial first optimization parameters. 1…K center
[0071] Step S2062: Receive the initial second optimization parameters obtained by optimizing the pruned large language model \(M^*\) sent by each slave computing node; In this step, after the main computing node obtains the pruned large language model M* through pruning, it can send the pruned large language model M* to each slave computing node, that is, the main computing node synchronizes the pruned variable x. p Both the pruned model M* and the pruned variable x are sent to all slave computing nodes. Thus, each slave computing node can also perform model tuning on the pruned large language model M* using the same model optimization method as the main computing node to obtain the second optimization parameter, and send the second optimization parameter to the main computing node.
[0072] Step S2063: Perform parameter aggregation processing based on the first optimization parameter and the second optimization parameter to obtain the initial aggregation parameter. In this step, the main computing node aggregates the parameter fine-tuning results of all computing nodes according to the federated aggregation strategy. The aggregation strategy includes, but is not limited to, summation, arithmetic mean, weighted average, maximum value, etc., and the arithmetic mean is used by default.
[0073] Step S2064: Send the initial aggregation parameter to each slave computing node for each slave computing node to perform the next round of model optimization based on the initial aggregation parameter, and receive the current second optimization parameter sent by each slave computing node. When the predetermined tuning condition is met, stop the model tuning, use the current aggregation parameter as the target aggregation parameter, and obtain the target large language model.
[0074] In this step, after obtaining the initial aggregation parameter, the main computing node determines the current large language model based on the initial aggregation parameter and sends the initial aggregation parameter to the slave computing nodes. At the same time, the main computing node determines whether the current large language model meets the predetermined tuning condition, that is, determines whether the current large language model converges. If the predetermined tuning condition is not met, the main computing node will perform the next round of model tuning based on the current large language model to obtain the current first optimization parameter, and receive the current second optimization parameter obtained by each slave computing node based on the next round of model tuning until the predetermined tuning condition is met, stop the model tuning, use the current aggregation parameter as the target aggregation parameter, and obtain the target large language model.
[0075] In this step, based on the federated learning framework, it supports multiple financial institutions to respectively use their local business data to restore the federated large language model after pruning, complete model restoration / model tuning after fewer rounds of fine-tuning training, improve the performance of the pruned model, and enable it to have the ability to understand different businesses in the bond field, rather than being limited to the data and business scope of a certain financial institution.
[0076] In the model training method based on federated learning in this embodiment, by determining the pre-pruned models corresponding to each overall pruning strategy, subsequently, based on the performance deviation between each pre-pruned model and the initial large language model, several target dependency structures with relatively low importance / impact degree can be accurately determined from the dependency structures of each overall pruning strategy. Subsequently, the initial large language model can be pruned based on these prunable target dependency structures, thereby accurately and reasonably obtaining the pruned large language model, simplifying the model structure of the large language model, improving the model training speed, and ensuring the accuracy of model training at the same time.
[0077] Another embodiment of this application provides a model training method based on federated learning, which can be specifically applied to each slave computing node / participant in federated learning. Specifically, the slave computing node can be a financial institution. As Figure 2 shown, the method in this embodiment includes the following steps: Step S301, receive each pre-pruned model for the initial large language model sent by the master computing node; In this step, the process of the master computing node determining each pre-pruned model M pm can refer to the above embodiment and will not be elaborated here.
[0078] Step S302, determine the second performance deviation of each pre-pruned model based on the pre-constructed second training dataset; In this step, each slave computing node can adopt the K-fold cross-validation method based on each pre-pruned model M p1 , M p2 , …… M pm sent by the master computing node to calculate the performance deviation between each pre-pruned model and the initial large language model respectively, so as to obtain the second performance deviation of each pre-pruned model.
[0079] Step S303, send the second performance deviation to the master computing node for the master computing node to determine several target dependency structures based on the first performance deviation of each pre-pruned model and the received second performance deviations of each pre-pruned model, and perform pruning processing on the initial large language model based on each target dependency structure to obtain the pruned large language model; In this step, each slave computing node can send the second performance deviation of each pre-pruned model to the master computing node, so that the master computing node can receive the second performance deviation for each pre-pruned model sent by each slave computing node.
[0080] Thus, the master computing node can determine the first performance deviation and each second performance deviation for the same pre-pruned model M pm to determine the pre-pruned model M pmThe target performance deviation is used to determine the influence degree of the total pruning strategy corresponding to the pre-pruned model, thereby obtaining the influence degree of each total pruning strategy. Subsequently, the main computing node can sort the total pruning strategies in descending order based on the influence degree, determine that a certain number of dependency structures in the total pruning strategies with higher rankings are non-target dependency structures that cannot be pruned, and finally determine the remaining dependency structures as target dependency structures, and prune the initial large language model based on the target dependency structures to obtain the pruned large language model M*. After obtaining the pruned large language model M*, the main computing node can send the pruned large language model M* to each slave computing node.
[0081] Step S304: Receive the pruned large language model sent by the main computing node, and optimize and train the pruned large language model based on the pre-constructed second optimization dataset to obtain the target large language model.
[0082] In this step, after receiving the pruned large language model M*, the slave computing node can use the local second optimization dataset to optimize and train / resume training the pruned large language model. That is, the slave computing node optimizes / resumes the model of the pruned large language model based on the second optimization dataset to obtain the initial second optimization parameters; sends the initial second optimization parameters to the main computing node for the main computing node to perform parameter aggregation processing based on the first optimization parameters and the second optimization parameters to obtain the initial aggregation parameters; receives the initial aggregation parameters sent by the main computing node, and performs the next round of model optimization / model recovery based on the initial aggregation parameters until the predetermined tuning condition is met, stops model tuning, and uses the received current aggregation parameters as the target aggregation parameters to obtain the target large language model.
[0083] In the model training method based on federated learning in this embodiment, by receiving the pre-pruned models sent by the main computing node, it is convenient for subsequent slave computing nodes to determine the second performance deviations of the pre-pruned models and the initial large language model, which provides a guarantee for the main computing node to accurately and quickly determine a number of target dependency structures based on the second performance deviations, making the pruning process of the main computing node based on the target dependency structures more reasonable and accurate, and laying a foundation for reasonably and accurately obtaining the pruned large language model. It provides a guarantee for subsequent fast and accurate model training.
[0084] Another embodiment of this application provides a model training method based on federated learning, which is applied to a slave computing node and specifically includes the following steps: Step S401: Installation and initialization of the federated large language model; In this step, each slave computing node will receive the installation package of the federated large language model collaboration network sent by the master computing node. Thus, each participant / slave computing node deploys and installs the components of the federated large language model collaboration network and joins the collaboration network as a slave computing node. The framework of the federated learning collaboration network can be implemented using other software products with the same functions such as FATE, SecretFlow, PaddleFL, TensorFlow Federated, and Pysyft.
[0085] Step S402, data preprocessing; In this step, the slave computing node connects to its local bond business database and prepares high-quality dialogue data within its own business domain to obtain a second initial dataset. This second initial dataset contains questions that may be asked in various financial operations and the answers to the questions, which are used as training data for the importance assessment and model recovery steps. Specifically, the dialogue data in the second initial dataset includes types of dialogue data such as zero-shot prompts, few-shot prompts, and knowledge base prompts.
[0086] 1. Zero-shot prompt: The institution does not provide demonstrations related to the task results and directly prompts the language model to give task-related answers.
[0087] 2. Few-shot prompt: The institution provides a small number of prompt examples, such as task descriptions.
[0088] 3. Knowledge base prompt: The institution provides a knowledge base related to the question and question keywords, and uses the context content of the knowledge base to form prompt words. After the master computing node performs text extraction and semantic understanding on the knowledge base, it calculates the relevance between the vectorized knowledge base document fragments and the input question using a vector distance measurement index, and forms prompt words by combining the most similar several document fragments with the input question to obtain dialogue data. Among them, the vector distance measurement index can be implemented by methods such as cosine similarity, dot product, Hamming distance, and other vector distance measurements.
[0089] After the slave computing node completes the preparation of the second initial dataset, a certain proportion of the data is randomly selected from it as the second training dataset for pruning processing and the second optimization dataset for model tuning. By default, 60% of the data is selected as the second training dataset D_eval nodei , and the other non-repeating 40% of the data is the second optimization dataset D_recover nodei . For the second training dataset D_eval nodei In the way of K-fold cross-validation, K training data D_eval used in the importance assessment step / pruning step are generated 1…K nodei . For the second optimization dataset D_recover nodeiGenerate the K tuning data D_recover used in the model tuning step in the manner of K-fold cross-validation 1…K nodei The default value of K is 5 and can be flexibly adjusted according to needs.
[0090] Step S403: Receive each pre-pruned model for the initial large language model sent by the master computing node; In this step, after determining each pre-pruned model, the master computing node will send each pre-pruned model to each slave computing node, and then each slave computing node will receive each pre-pruned model.
[0091] Step S404: Based on the second training dataset, adopt the K-fold cross-validation method to calculate the performance deviation between each pre-pruned model and the initial large language model respectively, so as to obtain the second performance deviation of each pre-pruned model; In the specific implementation process of this step, it can be based on the second training dataset D_eval nodei , adopt the K-fold cross-validation method to calculate the performance deviation between each pre-pruned model and the initial large language model respectively, so as to obtain the second performance deviation of each pre-pruned model. That is, the slave computing node can perform K-fold cross-validation on the second training dataset D_eval nodei Generate the K training data D_eval used in the importance evaluation step / pruning step in the manner of K-fold cross-validation 1…K nodei , the default value of K is 5 and can be flexibly adjusted according to needs. Then, the slave computing node uses D_eval 1…K cnodei , calculate the performance deviation between each pre-pruned model M pm and the initial large language model M in the manner of K-fold cross-validation. That is, for the same pre-pruned model, calculate the performance deviation between the pre-pruned model and the initial large language model respectively using K datasets, so as to obtain K performance deviations, and then comprehensively obtain the second performance deviation between the pre-pruned model and the initial large language model based on the K performance deviations. For example, use the K performance deviations, by calculating the average value or taking the median value, etc., to determine the final second performance deviation. Among them, the performance deviation can specifically include the accuracy deviation of the model, the recall deviation of the model, etc.; that is, the deviation between the accuracy of the pre-pruned model and the accuracy of the initial large language model, or the deviation between the recall of the pre-pruned model and the recall of the initial large language model.
[0092] Step S405: Send the second performance deviation to the master computing node for the master computing node to determine a number of target dependency structures based on the first performance deviation of each pre-pruned model and the received second performance deviations of each pre-pruned model; Step S406: Receive, from the master computing node, each candidate pruning model for the current pruning round sent by the master computing node. In this step, after receiving the second performance deviations of the pre-pruning models, the master computing node determines a number of target dependency structures that can be pruned from the dependency structure set G by combining the first performance deviations of the pre-pruning models, i.e., obtains the target dependency structure set G_prunable. The specific determination process of the target dependency structure can refer to any of the above embodiments and will not be elaborated here.
[0093] After determining the target dependency structures, the master computing node determines a number of candidate sub-pruning strategies from the target dependency structures for the current pruning round in combination with the pruning quantity, and can determine the corresponding candidate pruning models according to each candidate sub-pruning strategy, i.e., obtains a number of candidate pruning models, and then sends them to the slave computing nodes. Thus, the slave computing nodes will receive a number of candidate pruning models for the current pruning round.
[0094] Step S407: Based on the pre-constructed second training dataset, determine the fourth performance deviation between each candidate pruning model and the historical pruning model obtained in the previous pruning process. In this step, the calculation principle of the fourth performance deviation is the same as that of the second performance deviation. When the pruning round T = 1, the historical pruning model obtained in the previous pruning process is the initial large language model. After receiving the candidate pruning models sent by the master computing node, each slave computing node uses the training data D_eval 1…K nodei to calculate the performance deviation between each candidate pruning model and the historical pruning model (initial large language model M) obtained in the previous pruning process in a K-fold cross-validation manner. That is, for the same pre-pruning model, the performance deviation between the candidate pruning model and the historical pruning model (initial large language model M) is calculated using K datasets D_eval 1…K nodei respectively, so as to obtain K performance deviations, and then the fourth performance deviation of the candidate pruning model is comprehensively obtained based on the K performance deviations.
[0095] Step S408: Send the fourth performance deviation to the master computing node for the master computing node to determine the influence degree of each candidate sub-pruning strategy based on the third performance deviations of the candidate pruning models and the fourth performance deviations of the candidate pruning models. In this step, the greater the performance deviation, the greater the impact, that is, pruning cannot be performed on the various dependency structures in the candidate sub-pruning strategy. The main computing node can determine the current sub-pruning strategy corresponding to the current round from the candidate sub-pruning strategies according to the impact degree of each candidate sub-pruning strategy, and further perform pruning on the historical pruning model obtained from the previous round of pruning based on the current sub-pruning strategy to obtain the current pruned large language model, and send the current large language model to each slave computing node, so that the slave computing node can calculate the fourth performance deviation based on the current large language model and the candidate pruning models in the next round during the next round of pruning; until the predetermined number of pruning rounds is reached, the current pruned large language model is used as the pruned large language model M*.
[0096] Step S409: Receive the pruned large language model sent by the main computing node; Step S410: Optimize and train the pruned large language model based on the pre-constructed second optimization dataset to obtain the target large language model.
[0097] In this step, the specific process of model optimization / model recovery is as follows: Step S4101: Optimize the pruned large language model M* based on the second optimization dataset to obtain the initial second optimization parameters; In this step, the slave computing node can specifically generate K tuning data D_recover used in the model tuning step based on the second optimization dataset D_recover nodei in the form of K-fold cross-validation. 1…K nodei 。
[0098] Then, use the K tuning data D_recover 1…K nodei to optimize the pruned large language model M* to obtain the initial second optimization parameters.
[0099] Step S4102: Send the initial second optimization parameters to the main computing node for the main computing node to perform parameter aggregation processing based on the first optimization parameters and the second optimization parameters to obtain the initial aggregation parameters; In this step, after the slave computing node obtains the initial second optimization parameters, it can send the initial second optimization parameters to the main computing node. Thus, the main computing node aggregates the parameter fine-tuning results of all computing nodes according to the federated aggregation strategy to obtain the initial aggregation parameters.
[0100] Step S4103: Receive the initial aggregation parameters sent by the master computing node, perform the next round of model optimization based on the initial aggregation parameters, stop the model tuning until the predetermined tuning condition is met, use the received current aggregation parameters as the target aggregation parameters, and obtain the target large language model.
[0101] In this step, after obtaining the initial aggregation parameters, the master computing node determines the current large language model based on the initial aggregation parameters and sends the initial aggregation parameters / current large language model to the slave computing nodes. At the same time, the slave computing nodes determine whether the current large language model meets the predetermined tuning condition, that is, determine whether the current large language model converges. If the predetermined tuning condition is not met, the slave computing nodes perform the next round of model optimization based on the current large language model, obtain the current second optimization parameters, and send the current second optimization parameters to the master computing node until the predetermined tuning condition is met, stop the model tuning, and the slave computing nodes use the current aggregation parameters as the target aggregation parameters to obtain the target large language model.
[0102] In the model training method based on federated learning in this embodiment, by receiving the pre-pruned models sent by the master computing node, it is convenient for the subsequent slave computing nodes to determine the second performance deviations of the pre-pruned models for each pre-pruned model and the initial large language model, which provides a guarantee for the master computing node to accurately and quickly determine a number of target dependency structures based on the second performance deviations, making the pruning process of the master computing node based on the target dependency structures more reasonable and accurate, and laying a foundation for reasonably and accurately obtaining the pruned large language model. It provides a guarantee for subsequent fast and accurate model training.
[0103] Another embodiment of the present application provides a model training device based on federated learning, as Figure 3 shown, including: The first sending module 11 is used to determine pre-pruned models corresponding to each total pruning strategy based on the dependency structure set corresponding to the initial large language model and the predetermined pruning ratio, and send each pre-pruned model to each slave computing node; The first determining module 12 is used to determine the first performance deviation of each pre-pruned model based on the pre-constructed first training dataset; The first receiving module 13 is used to receive the second performance deviations of each pre-pruned model sent by each slave computing node; The pruning module 14 is used to determine a number of target dependency structures based on the first performance deviation of each pre-pruned model and the second performance deviations of each pre-pruned model, and perform pruning processing on the initial large language model based on each target dependency structure to obtain a pruned large language model; The first optimization module 15 is used to perform optimization training on the pruned large language model based on the pre-constructed first optimization dataset to obtain the target large language model.
[0104] In the specific implementation process of this embodiment, the first sending module specifically includes: An identification unit, configured to determine a set of dependency structures including a plurality of dependency structures based on the dependency relationships of each neuron in the initial large language model; A total pruning strategy determination unit, configured to determine a plurality of total pruning strategies based on the set of dependency structures and the pruning ratio; A pre-pruning model determination unit, configured to determine a pre-pruning model corresponding to each total pruning strategy based on each total pruning strategy.
[0105] In the specific implementation process of this embodiment, the first determination unit is specifically configured to: based on the first training data set, adopt the K-fold cross-validation method to calculate the performance deviation between each pre-pruning model and the initial large language model respectively, so as to obtain the first performance deviation of each pre-pruning model.
[0106] In the specific implementation process of this embodiment, the pruning module is specifically configured to: determine the influence degree of each total pruning strategy based on the first performance deviation of each pre-pruning model and the second performance deviation of each pre-pruning model; determine a plurality of non-target dependency structures that cannot be pruned from each total pruning strategy based on the influence degree of each total pruning strategy and a predetermined non-prunable ratio, so as to obtain a plurality of target dependency structures that can be pruned; based on each target dependency structure, adopt an iterative pruning method to determine the current sub-pruning strategy corresponding to the current pruning round, and perform pruning processing on the current large language model based on the current sub-pruning strategy to obtain the pruned current large language model until a predetermined pruning condition is met, so as to obtain the pruned large language model.
[0107] In the specific implementation process of this embodiment, the pruning module is specifically configured to: determine the pruning quantity of each round based on the total number of pruning rounds and a predetermined pruning ratio; determine a plurality of candidate sub-pruning strategies corresponding to the current round based on the pruning quantity of the current pruning round and the remaining target dependency structures after the previous pruning process, and determine candidate pruning models corresponding to each candidate sub-pruning strategy; determine the third performance deviation between each candidate pruning model and the historical pruning model obtained after the previous pruning process based on the first training data set; receive the fourth performance deviation of each candidate pruning model sent from each computing node; determine the influence degree of each candidate sub-pruning strategy based on the third performance deviation of each candidate pruning model and the fourth performance deviation of each candidate pruning model; determine the current sub-pruning strategy corresponding to the current round from each candidate sub-pruning strategy based on the influence degree of each candidate sub-pruning strategy.
[0108] In the specific implementation process of this embodiment, the first optimization module is specifically used for: optimizing the pruned large language model based on the first optimization data set to obtain initial first optimization parameters; receiving the initial second optimization parameters obtained by each slave computing node for optimizing the pruned large language model; performing parameter aggregation processing based on the first optimization parameters and the second optimization parameters to obtain initial aggregation parameters; sending the initial aggregation parameters to each slave computing node for each slave computing node to perform the next round of model optimization based on the initial aggregation parameters, and receiving the current second optimization parameters sent by each slave computing node, and stopping the model tuning until a predetermined tuning condition is met, taking the current aggregation parameters as the target aggregation parameters, and obtaining the target large language model.
[0109] In the model training device based on federated learning in this embodiment, by determining the pre-pruned models corresponding to each total pruning strategy, subsequent performance deviations between each pre-pruned model and the initial large language model can be used to accurately determine several target dependency structures with relatively low importance / impact degree from the dependency structures of each total pruning strategy. Subsequently, the initial large language model can be pruned based on these prunable target dependency structures, thereby accurately and reasonably obtaining the pruned large language model, simplifying the model structure of the large language model, improving the model training speed, and ensuring the accuracy of model training.
[0110] Another embodiment of this application provides a model training device based on federated learning, as Figure 4 shown, including: A second receiving module 21, configured to receive each pre-pruned model of the initial large language model sent by the master computing node; A second determination module 22, configured to determine the second performance deviation of each pre-pruned model based on a pre-constructed second training data set; A second sending module 23, configured to send the second performance deviation to the master computing node for the master computing node to determine several target dependency structures based on the first performance deviation of each pre-pruned model and the received second performance deviations of each pre-pruned model, and perform pruning processing on the initial large language model based on each target dependency structure to obtain a pruned large language model; A second optimization module 24, configured to receive the pruned large language model sent by the master computing node and perform optimization training on the pruned large language model based on a pre-constructed second optimization data set to obtain a target large language model.
[0111] In the specific implementation process of this embodiment, the second determination module is specifically used for: based on the second training data set, adopting the K-fold cross-validation method to calculate the performance deviations between each pre-pruned model and the initial large language model respectively to obtain the second performance deviations of each pre-pruned model.
[0112] In the specific implementation process of this embodiment, the second receiving module is further configured to: receive each candidate pruning model sent by the main computing node for the current pruning round; the second determining module is further configured to: based on the pre-constructed second training dataset, determine the fourth performance deviation between each candidate pruning model and the historical pruning model obtained by the previous pruning process; the second sending module is further configured to: send the fourth performance deviation to the main computing node, so that the main computing node can determine the influence degree of each candidate sub-pruning strategy based on the third performance deviation of each candidate pruning model and the fourth performance deviation of each candidate pruning model.
[0113] In the specific implementation process of this embodiment, the second optimization module is specifically configured to: optimize the pruning large language model based on the second optimization dataset to obtain the initial second optimization parameters; send the initial second optimization parameters to the main computing node, so that the main computing node can perform parameter aggregation processing based on the first optimization parameters and the second optimization parameters to obtain the initial aggregation parameters; receive the initial aggregation parameters sent by the main computing node, and perform the next round of model optimization based on the initial aggregation parameters until the predetermined tuning condition is met, stop the model tuning, use the received current aggregation parameters as the target aggregation parameters, and obtain the target large language model.
[0114] The model training device based on federated learning in this embodiment facilitates subsequent slave computing nodes to determine the second performance deviation of each pre-pruning model for each pre-pruning model and the initial large language model by receiving the pre-pruning models sent by the main computing node, which provides a guarantee for the main computing node to accurately and quickly determine a number of target dependency structures based on the second performance deviation, making the pruning process of the main computing node based on the target dependency structure more reasonable and accurate, and laying a foundation for reasonably and accurately obtaining the pruning large language model. It provides a guarantee for subsequent fast and accurate model training.
[0115] Another embodiment of this application provides an electronic device, as Figure 5 shown, at least including a memory 1 and a processor 2. A computer program is stored on the memory 1, and when the processor 2 executes the computer program on the memory 1, the following method steps are implemented: Step 1: Determine pre-pruning models corresponding to each total pruning strategy based on the dependency structure set corresponding to the initial large language model and a predetermined pruning ratio, and send each pre-pruning model to each slave computing node; Step 2: Determine the first performance deviation of each pre-pruning model based on the pre-constructed first training dataset; Step 3: Receive the second performance deviation of each pre-pruning model sent by each slave computing node; Step 4: Based on the first performance deviation of each pre-pruned model and each second performance deviation of each pre-pruned model, determine a number of target dependency structures, and based on each target dependency structure, perform pruning processing on the initial large language model to obtain a pruned large language model; Step 5: Optimize and train the pruned large language model based on the pre-constructed first optimization dataset to obtain a target large language model.
[0116] Alternatively, the following method steps are implemented: Step 1: Receive each pre-pruned model of the initial large language model sent by the main computing node; Step 2: Based on the pre-constructed second training dataset, determine the second performance deviation of each pre-pruned model; Step 3: Send the second performance deviation to the main computing node for the main computing node to determine a number of target dependency structures based on the first performance deviation of each pre-pruned model and the received second performance deviation of each pre-pruned model, and perform pruning processing on the initial large language model based on each target dependency structure to obtain a pruned large language model; Step 4: Receive the pruned large language model sent by the main computing node, and optimize and train the pruned large language model based on the pre-constructed second optimization dataset to obtain a target large language model.
[0117] For the specific implementation process of the above method steps, reference can be made to the embodiments of any of the above model training methods based on federated learning, and this embodiment will not be repeated here.
[0118] In the electronic device of this embodiment, by determining the pre-pruned models corresponding to each total pruning strategy, subsequent performance deviations between each pre-pruned model and the initial large language model can be used to accurately determine a number of target dependency structures with lower importance / impact degree from the dependency structures of each total pruning strategy. Subsequently, pruning processing can be performed on the initial large language model based on these target dependency structures that can be pruned, thereby accurately and reasonably obtaining a pruned large language model, simplifying the model structure of the large language model, improving the model training speed, and at the same time ensuring the accuracy of model training.
[0119] The above embodiments are only exemplary embodiments of the present application and are not used to limit the present application. The protection scope of the present application is defined by the claims. Those skilled in the art can make various modifications or equivalent replacements within the essence and protection scope of the present application, and such modifications or equivalent replacements should also be regarded as falling within the protection scope of the present application.
Claims
1. A model training method based on federated learning, applied to a main computing node, characterized in that, Including: Based on the set of dependency structures corresponding to the initial large language model and a predetermined pruning ratio, determine pre-pruned models corresponding to each overall pruning strategy, and send each pre-pruned model to each slave computing node; Based on the pre-constructed first training dataset, determine the first performance deviation of each pre-pruned model; Receive the second performance deviation of each pre-pruned model sent by each slave computing node; Based on the first performance deviation of each pre-pruned model and the second performance deviations of each pre-pruned model, determine a number of target dependency structures, and perform pruning processing on the initial large language model based on each target dependency structure to obtain a pruned large language model; Perform optimization training on the pruned large language model based on the pre-constructed first optimization dataset to obtain a target large language model.
2. The method according to claim 1, wherein The step of determining pre-pruned models corresponding to each overall pruning strategy based on the set of dependency structures corresponding to the initial large language model and a predetermined pruning ratio, and sending each pre-pruned model to each slave computing node specifically includes: Based on the dependency relationships of each neuron in the initial large language model, determine a set of dependency structures containing a number of dependency structures; Based on the set of dependency structures and the pruning ratio, determine a number of overall pruning strategies; Based on each overall pruning strategy, determine a pre-pruned model corresponding to each overall pruning strategy.
3. The method according to claim 1, characterized in that, The step of determining the first performance deviation of each pre-pruned model based on the pre-constructed first training dataset specifically includes: Based on the first training dataset, adopt the K-fold cross-validation method to calculate the performance deviation between each pre-pruned model and the initial large language model respectively, so as to obtain the first performance deviation of each pre-pruned model.
4. The method according to claim 1, wherein The step of determining a number of target dependency structures based on the first performance deviation of each pre-pruned model and the second performance deviations of each pre-pruned model, and performing pruning processing on the initial large language model based on each target dependency structure to obtain a pruned large language model specifically includes: Based on the first performance deviation of each pre-pruned model and the second performance deviations of each pre-pruned model, determine the influence degree of each overall pruning strategy; Based on the influence degree of each overall pruning strategy and a predetermined non-prunable ratio, determine a number of non-target dependency structures that cannot be pruned from each overall pruning strategy, so as to obtain a number of target dependency structures that can be pruned; Based on each target dependency structure, adopt an iterative pruning method to determine the current sub-pruning strategy corresponding to the current pruning round, and perform pruning processing on the current large language model based on the current sub-pruning strategy to obtain the pruned current large language model until a predetermined pruning condition is met to obtain a pruned large language model.
5. The method according to claim 4, characterized in that The step of adopting an iterative pruning method to determine the current sub-pruning strategy corresponding to the current pruning round based on each target dependency structure specifically includes: Based on the total number of pruning rounds and a predetermined pruning ratio, determine the number of prunings per round; Based on the number of prunings in the current pruning round and the remaining target dependency structures after the previous pruning process, determine a number of candidate sub-pruning strategies corresponding to the current round, and determine candidate pruned models corresponding to each candidate sub-pruning strategy; Based on the first training dataset, determine the third performance deviation between each candidate pruned model and the historical pruned model obtained from the previous pruning process; Receive the fourth performance deviation for each candidate pruning model sent by each slave computing node; Determine the influence degree of each candidate sub-pruning strategy based on the third performance deviation of each candidate pruning model and the fourth performance deviation of each candidate pruning model; Based on the influence degree of each candidate sub-pruning strategy, determine the current sub-pruning strategy corresponding to the current round from each candidate sub-pruning strategy.
6. The method according to claim 1, characterized in that The optimizing and training the pruning large language model based on the pre-constructed first optimization dataset to obtain the target large language model specifically includes: Performing model optimization on the pruning large language model based on the first optimization dataset to obtain the initial first optimization parameters; Receive the initial second optimization parameters obtained by each slave computing node for performing model optimization on the pruning large language model; Perform parameter aggregation processing based on the first optimization parameters and the second optimization parameters to obtain the initial aggregation parameters; Send the initial aggregation parameters to each slave computing node for each slave computing node to perform the next round of model optimization based on the initial aggregation parameters, and receive the current second optimization parameters sent by each slave computing node. When the predetermined tuning condition is met, stop model tuning, use the current aggregation parameters as the target aggregation parameters, and obtain the target large language model.
7. A model training method based on federated learning, applied to a computing node, characterized in that, Including: Receive each pre-pruning model for the initial large language model sent by the master computing node; Determine the second performance deviation of each pre-pruning model based on the pre-constructed second training dataset; Send the second performance deviation to the master computing node for the master computing node to determine a number of target dependency structures based on the first performance deviation of each pre-pruning model and the received second performance deviation of each pre-pruning model, and perform pruning processing on the initial large language model based on each target dependency structure to obtain the pruning large language model; Receive the pruning large language model sent by the master computing node and perform optimizing and training on the pruning large language model based on the pre-constructed second optimization dataset to obtain the target large language model.
8. A model training device based on federated learning, characterized in that, Including: The first sending module is used to determine the pre-pruning models corresponding to each total pruning strategy based on the dependency structure set corresponding to the initial large language model and a predetermined pruning ratio, and send each pre-pruning model to each slave computing node; The first determining module is used to determine the first performance deviation of each pre-pruning model based on the pre-constructed first training dataset; The first receiving module is used to receive the second performance deviation for each pre-pruning model sent by each slave computing node; The pruning module is used to determine a number of target dependency structures based on the first performance deviation of each pre-pruning model and the second performance deviation of each pre-pruning model, and perform pruning processing on the initial large language model based on each target dependency structure to obtain the pruning large language model; The first optimizing module is used to perform optimizing and training on the pruning large language model based on the pre-constructed first optimization dataset to obtain the target large language model.
9. A model training device based on federated learning, characterized in that, Including: The second receiving module is used to receive each pre-pruning model for the initial large language model sent by the master computing node; The second determining module is used to determine the second performance deviation of each pre-pruning model based on the pre-constructed second training dataset; The second sending module is used to send the second performance deviation to the main computing node, so that the main computing node can determine a number of target dependency structures based on the first performance deviations of the pre-pruned models and the received second performance deviations of the pre-pruned models, and perform pruning processing on the initial large language model based on the target dependency structures to obtain a pruned large language model; The second optimization module is used to receive the pruned large language model sent by the main computing node and perform optimization training on the pruned large language model based on a pre-constructed second optimization dataset to obtain a target large language model.
10. An electronic device, characterized in that, It at least includes a memory and a processor. A computer program is stored on the memory, and when the processor executes the computer program on the memory, the steps of the model training method based on federated learning described in any one of claims 1-6 or 7 above are implemented.