Model fine tuning method and device, electronic equipment and storage medium
By analyzing the base model and generating plug-in networks, combined with training, the problem of high training costs for large models is solved, the cost of model fine-tuning is reduced and the accuracy is improved, and it is suitable for a variety of models.
Patent Information
- Application Number
- CN202410830139.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-18
AI Technical Summary
Training large models is expensive, especially unfriendly to individual developers and small businesses, and requires a lot of computing power and capital investment.
By performing model analysis on the base model, a plug-in network is generated, and combined with the base model for training, a fine-tuned model is generated to realize plug-in network generation and combined training of the model, reducing the cost of model fine-tuning.
It reduces the cost of model fine-tuning and improves prediction accuracy. Through the reuse and combined training of plug-in networks, it can adapt to multiple models, reduce writing costs, and improve the versatility of the model.
Smart Images

Figure CN118798308A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning technology, and in particular to a model fine-tuning method, device, electronic device and storage medium. Background Art
[0002] With the development of large models and AI content generation technology, a large number of large model bases with different uses have been proposed. These large models are characterized by high cost, long training time, and high computing power. During the training of the base model, a GPU cluster of hundreds of GPUs is required with a training time of one week to one month. At the same time, due to the introduction of RLHF (Reinforcement Learning from Human Feedback) technology, a large amount of annotation also requires continuous investment of funds and personnel. It is difficult for individual developers and small businesses to follow up and use their own large models. Therefore, fine-tuning technology has become a new way to use large models with small resources.
[0003] At present, small businesses usually train models by adjusting parameters of large open source models. However, even for further training of large open source models, a large number of model parameters need to be trained, which requires a certain amount of computing power support. The cost of model training is high, which is not friendly to individual developers or small businesses.
[0004] Therefore, how to reduce the cost of training large models has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] The present invention provides a model fine-tuning method, device, electronic device and storage medium to solve the technical problem of high cost of large model training.
[0006] The present invention provides a model fine-tuning method, comprising: Performing model analysis on the base model to obtain parameter information of each layer network in the base model; Based on the configuration information and each of the parameter information, generate one or more plug-in networks; Initializing each of the plug-in networks; Combining the initialized plug-in network with the base model to obtain a combined model; The combined model is trained, and a fine-tuning model is determined based on the training result.
[0007] According to a model fine-tuning method provided by the present invention, the base model is parsed to obtain parameter information of each layer network in the base model, including: Inputting an empty string into the base model to simulate the reasoning process of the base model; During the simulation process, parameter information of each layer of the network in the base model is obtained through a preset script.
[0008] According to a model fine-tuning method provided by the present invention, the plug-in network includes an input layer plug-in network, an output layer plug-in network and an intermediate layer plug-in network; The input layer plug-in network is an embedding layer network with the same input dimension and output dimension; The output layer plug-in network is a dense layer network with the same input dimension and output dimension; The middle layer plug-in network is a network with the same input dimension and output dimension, and is used to form a side branch network.
[0009] According to a model fine-tuning method provided by the present invention, the configuration information includes input layer configuration information, output layer configuration information and intermediate layer configuration information, the input layer configuration information is the configuration information of the input layer plug-in network, the output layer configuration information is the configuration information of the output layer plug-in network, and the intermediate layer configuration information is the configuration information of the intermediate layer plug-in network; The middle layer configuration information includes at least one of first configuration information, second configuration information, third configuration information and fourth configuration information, the first configuration information is the configuration information of the plug-in network dimension, the second configuration information is the configuration information of the plug-in network quantization strategy, the third configuration information is the configuration information of the plug-in network size, and the fourth configuration information is the configuration information of the plug-in network custom network structure.
[0010] According to a model fine-tuning method provided by the present invention, the initialization of each plug-in network includes: for any plug-in network, if the plug-in network needs to be trained and fine-tuned, the plug-in network is initialized based on initialization configuration information, and the initialization configuration information includes an initialization method for the plug-in network; If the plug-in network does not need to be trained and fine-tuned, parameters of the plug-in network are loaded based on a configuration file to complete initialization, and the configuration file is generated based on the configuration information of the plug-in network.
[0011] According to a model fine-tuning method provided by the present invention, after training the combined model and determining the fine-tuning model based on the training result, the method further includes: Output each plug-in network in the fine-tuning model to the model library in one or more formats.
[0012] The present invention also provides a model fine-tuning device, comprising: The model parsing module is used to: perform model parsing on the base model to obtain parameter information of each layer network in the base model; the network generation module is used to: generate one or more plug-in networks based on the configuration information and each of the parameter information; An initialization module, used to: initialize each of the plug-in networks; A model combination module, used to: combine the initialized plug-in network with the base model to obtain a combined model; The model determination module is used to: train the combined model and determine the fine-tuning model based on the training results.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any one of the above-mentioned model fine-tuning methods is implemented.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the model fine-tuning method described in any one of the above is implemented.
[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the model fine-tuning method described above is implemented.
[0016] The model fine-tuning method, device, electronic device and storage medium provided by the present invention perform model analysis on the base model to obtain parameter information of each layer network in the base model, so as to subsequently generate a plug-in network adapted to the base model; based on the configuration information and each parameter information, one or more plug-in networks are generated, and the generated plug-in network is a module for fine-tuning. The plug-in network can not only be used for the base model, but also can be adapted to other models with the same parameter information, thereby realizing the generation of plug-in networks with universality, thereby reducing the writing cost of the fine-tuning module; each of the plug-in networks is initialized; the initialized plug-in network is combined with the base model to obtain a combined model; the combined model is trained, and the fine-tuning model is determined based on the training results, and the accuracy of the final model is improved by jointly training multiple plug-in networks with the base model. In summary, this scheme realizes the reuse of fine-tuning modules through plug-in networks, thereby reducing the cost investment of model fine-tuning, and combines multiple plug-in networks with the base model for training to improve the accuracy of model prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 This is one of the flow charts of the model fine-tuning method provided in an embodiment of the present invention.
[0019] Figure 2 This is the second flow chart of the model fine-tuning method provided in the embodiment of the present invention.
[0020] Figure 3 This is the third flow chart of the model fine-tuning method provided in the embodiment of the present invention.
[0021] Figure 4 It is a schematic diagram of a plug-in network provided by an embodiment of the present invention.
[0022] Figure 5 It is a structural schematic diagram of a model fine-tuning device provided in an embodiment of the present invention.
[0023] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution 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.
[0025] Figure 1 is one of the flow charts of the model fine-tuning method provided in an embodiment of the present invention, Figure 2 This is the second flow chart of the model fine-tuning method provided by the embodiment of the present invention. Figure 1 and Figure 2 , an embodiment of the present invention provides a model fine-tuning method, which may include: S110, performing model analysis on the base model to obtain parameter information of each layer network in the base model; S120, generating one or more plug-in networks based on the configuration information and each of the parameter information; S130, initializing each of the plug-in networks; S140, combining the initialized plug-in network with the base model to obtain a combined model; S150, training the combined model, and determining a fine-tuning model based on the training result.
[0026] In the embodiment of the present invention, the execution subject of the model fine-tuning method may be a model fine-tuning device, and the model fine-tuning device may include but is not limited to: a server, a desktop computer, a laptop computer, a tablet computer, etc. The execution subject of the model fine-tuning method may also be a model fine-tuning system, and the model fine-tuning system belongs to the model fine-tuning device. For ease of understanding, the following embodiments illustrate the model fine-tuning method provided by the present invention with the model fine-tuning system as the execution subject.
[0027] Here, the base model is a general model that needs to be fine-tuned. It can be selected from the model library or selected locally. If it is obtained from the model library, the corresponding network parameters will be downloaded through the network, and it is necessary to stay connected to the Internet. If the base model is selected locally, the base model file will be directly obtained from the local corresponding file directory, and the format of the base model file is not limited.
[0028] In S110, the base model is parsed to obtain parameter information of each network layer in the base model. The parameter information of a network layer may include information such as the matrix shape of the parameters in the network layer, parameter values, and input and output sizes of the network layer. By obtaining the parameter information of each network layer, the ability to construct an additional network for any layer is achieved without the need for specific model-specific configuration.
[0029] In S120, based on the parameter information of a layer of network, a plug-in network adapted to the layer of network is generated, and based on the configuration information, the size, structure, etc. of the plug-in network are configured. It should be understood that the corresponding plug-in network can be generated for each layer of network, or for some of the layers of network. Generating the plug-in network for some of the layers means setting the network of another part of the layers in the base model not to insert the plug-in network. For example, for a large model, there are multiple model parameter sizes, and the large model mainly reflects the difference through depth. The plug-in network performance and versatility can be improved by training the plug-in network layers that are adapted to the large model with a small parameter amount on the large model with a large parameter amount.
[0030] Optionally, in S120, an existing plug-in network is selected from the model library for loading, and there is no need to generate a new plug-in network. At this time, the plug-in network itself has good capabilities and does not need to be trained separately. In the subsequent training process, it can be configured as a frozen plug-in or as a plug-in that needs to be fine-tuned to meet the needs of the enterprise itself.
[0031] In S150, by loading multiple plug-in networks into the same base model at the same time, it is possible to achieve mixed fine-tuning and pre-training of multiple existing plug-in networks without changing the relevant parameters of the original base model. At the same time, for the same large model, the plug-in network has the same network structure and parameters and has the ability to be reused. For example, if the GLM large model is used as the base model, a knowledge plug-in network with professional knowledge can be completed through pre-training, and can be directly inserted into other GLM structure models to enable it to have the corresponding knowledge without fine-tuning or only a small amount of fine-tuning training.
[0032] The model fine-tuning method provided by the embodiment of the present invention performs model analysis on the base model to obtain parameter information of each layer network in the base model, so as to subsequently generate a plug-in network adapted to the base model; based on the configuration information and each parameter information, one or more plug-in networks are generated, and the generated plug-in network is a module for fine-tuning. The plug-in network can not only be used for the base model, but also can be adapted to other models with the same parameter information, thereby realizing the generation of plug-in networks with universality, thereby reducing the writing cost of the fine-tuning module; each of the plug-in networks is initialized; the initialized plug-in network is combined with the base model to obtain a combined model; the combined model is trained, and the fine-tuning model is determined based on the training results, and the accuracy of the final model is improved by jointly training multiple plug-in networks with the base model. In summary, this scheme realizes the reuse of fine-tuning modules through plug-in networks, thereby reducing the cost investment of model fine-tuning, and combines multiple plug-in networks with the base model for training to improve the prediction accuracy of the model.
[0033] In an optional embodiment, the performing of model parsing on the base model to obtain parameter information of each layer network in the base model includes: Inputting an empty string into the base model to simulate the reasoning process of the base model; During the simulation process, parameter information of each layer of the network in the base model is obtained through a preset script.
[0034] Specifically, by providing an empty string input, the preset model detection script is used to obtain relevant information about the model parameters of each layer, including the matrix shape and parameters of the parameters as well as the input and output sizes. Since the model structure is parsed through a simulated reasoning process, as long as the base model can perform reasoning normally, model parameter reasoning and parameter extraction can be completed without the need for a large model development company to support training services.
[0035] Furthermore, the plug-in network includes an input layer plug-in network, an output layer plug-in network and an intermediate layer plug-in network; the input layer plug-in network is an embedding layer network with the same input dimension and output dimension; The output layer plug-in network is a dense layer network with the same input dimension and output dimension; The middle layer plug-in network is a network with the same input dimension and output dimension, and is used to form a side branch network.
[0036] Figure 4 is a schematic diagram of a plug-in network provided by an embodiment of the present invention, such as Figure 4 As shown, specifically, the input layer can realize the input plug-in network by adding an embedding layer with the same input and output dimensions; the output layer can realize the output plug-in network by adding a dense layer with the same input and output dimensions; the middle layer automatically identifies the stacked modules with the same input and output dimensions, such as the transformer modules in most large natural language models. Compared with ordinary additional networks, the plug-in network is not only applicable to the transformer module, but also to any module with the same input and output dimensions. It can be arbitrarily connected to form an additional side network, freely configure the network form, and realize the plug-in network by adding a bypass network.
[0037] It should be understood that this solution uses modules with the same input and output dimensions as the plug-in network, so that the plug-in network is adaptable to any network module with the same input and output dimensions, further improving the versatility of the plug-in network.
[0038] In an optional embodiment, the configuration information includes input layer configuration information, output layer configuration information and middle layer configuration information, the input layer configuration information is the configuration information of the input layer plug-in network, the output layer configuration information is the configuration information of the output layer plug-in network, and the middle layer configuration information is the configuration information of the middle layer plug-in network; the middle layer configuration information includes at least one of first configuration information, second configuration information, third configuration information and fourth configuration information, the first configuration information is the configuration information of the plug-in network dimension, the second configuration information is the configuration information of the plug-in network quantization strategy, the third configuration information is the configuration information of the plug-in network size, and the fourth configuration information is the configuration information of the plug-in network custom network structure.
[0039] Specifically, after obtaining the location information where the plug-in network can be inserted through model analysis, the plug-in network is generated according to the configuration, wherein the input layer plug-in network and the output layer plug-in network can be directly configured to be present or not, that is, directly configure whether there is an input layer plug-in network and an output layer plug-in network; the configuration information of the intermediate layer plug-in network may include but is not limited to: The first configuration information is the configuration information of the plug-in network dimension. Specifically, the dimension size of the middle-layer plug-in network can be configured according to the first configuration information, such as Figure 4As shown, in the specific implementation process, the input can be transformed, that is, the dimension of the input is first reduced, and the dimension after dimensionality reduction is the same as the input and output dimension of the middle-layer plug-in network, and then fine-tuned through the middle-layer plug-in network, and then increased in dimension through the dimensionality increase matrix corresponding to the input transformation, so that the output and the input maintain the same dimension, and the dimensionality increase result is fused with the output of a layer network corresponding to the middle-layer plug-in network in the base model, such as adding, to achieve fine-tuning of the large model. Optionally, if the middle-layer plug-in network is versatile, it can be carried out using a more commonly used configuration to further improve its versatility.
[0040] The second configuration information, i.e., the configuration information of the plug-in network quantization strategy, specifically, the quantization level and quantization method of the middle-layer plug-in network can be configured according to the second configuration information. The quantization level can include but is not limited to 16-bit, 8-bit, and 4-bit levels of quantization. The quantization method can include but is not limited to quantization of quantization, double quantization, etc. In the specific implementation process, the quantization strategy can be configured for the middle-layer plug-in network as a whole and / or each module according to the second configuration information.
[0041] The third configuration information is the configuration information of the plug-in network size. Specifically, the size of the middle-layer plug-in network can be configured according to the third configuration information. Optionally, the minimum rank requirement of the plug-in network is obtained by performing singular value decomposition on the middle-layer plug-in network, and then the plug-in network size is self-configured.
[0042] The fourth configuration information is the configuration information of the custom network structure of the plug-in network. Specifically, according to the fourth configuration information, a custom network structure can be implemented to replace the original default network structure. For example, if you want to implement the LoCon (LoRA for Convolution Network) network yourself, confirm the characteristics of the plug-in network access output layer, generally by module category, layer shape, specific name for screening, and then complete the writing of the customized plug-in by writing the feedforward neural network module. The model fine-tuning system screens the access output layer through automatic screening conditions, and runs the custom feedforward neural network to replace the original default module.
[0043] Optionally, in addition to each plug-in network having its corresponding configuration information, the entire network model is also configured with corresponding first configuration information, second configuration information, third configuration information, and fourth configuration information.
[0044] It should be understood that the above configuration information can not only be the configuration of a plug-in network, but also can be for, through the first configuration information to adjust the dimension of the plug-in network, to achieve control of the amount of training parameters, thereby achieving control and limitation of training computing power and resource requirements; through the second configuration information to achieve quantitative control of the middle-layer plug-in network, further reducing the training computing power and resource requirements; through the third configuration information to achieve size control of the middle-layer plug-in network, to obtain the smallest possible plug-in network with less performance loss; through the fourth configuration information to customize the plug-in network of uncommon plug-ins, to improve the versatility of this solution.
[0045] Further, the initializing each of the plug-in networks includes: For any plug-in network, if the plug-in network needs to be trained and fine-tuned, the plug-in network is initialized based on the initialization configuration information, and the initialization configuration information includes the initialization method for the plug-in network; If the plug-in network does not need to be trained and fine-tuned, parameters of the plug-in network are loaded based on a configuration file to complete initialization, and the configuration file is generated based on the configuration information of the plug-in network.
[0046] Specifically, for the plug-in networks and pre-trained networks obtained through the model library, initialization can be completed by loading parameters according to the configuration file. For the plug-in networks that need training and fine-tuning, initialization is performed based on the initialization configuration information.
[0047] Here, the initialization method may include but is not limited to Xavier initialization, Kaiming initialization, Normal initialization, Uniform initialization, etc.
[0048] The model training method provided by the present invention is described below. Figure 3 FIG. 3 is a flow chart of the model fine-tuning method provided by an embodiment of the present invention. Figure 3 As shown, the model training process may include: (1) Environment configuration: For the existing computing environment, obtain the software and hardware environment configuration information of the entire environment and output it to the scheduler. The software and hardware environment configuration information may include but is not limited to CPU computing power, GPU computing power, memory, video memory, virtual technology support and other environments.
[0049] (2) Model configuration and plug-in configuration: The configurator obtains the configuration information of the base model and plug-in network and organizes it. At the same time, it arranges and combines it with the commonly used training configurations (learning rate, data set, plug-in combination, etc.) to form a variety of training configurations and outputs them to the scheduler.
[0050] (3) Evaluation module: All training configurations are evaluated based on preset evaluation indicators. The evaluation indicators may include but are not limited to loss function value, accuracy, recall rate, F1 score, etc. The evaluation module performs a comprehensive calculation on each evaluation indicator based on a preset calculation method to obtain a performance score for each training configuration. For example, each evaluation indicator is weighted based on a preset weight to obtain a performance score.
[0051] Optionally, after obtaining the performance scores of each training configuration, the evaluation module ranks them.
[0052] (4) Scheduler: Integrates computing resources and schedules training tasks according to the preset training strategy based on the training configuration generated by the configurator.
[0053] Optionally, the scheduler starts training tasks for different training configurations according to the computing power and queues, performs m rounds of training for all training configurations, calculates the performance score of each training configuration through the evaluation module and sorts them, screens out a preset number of training configurations, stops training for the screened out training configurations and generates a training report, performs n rounds of training for the screened out training configurations, calculates the performance score of each training configuration through the evaluation module and sorts them, screens out a preset number of training configurations, and so on, until the loss function values of all training configurations being trained are stable or the total number of training rounds reaches a preset threshold.
[0054] It should be noted that screening out a preset number of training configurations may be screening out the top few training configurations, that is, setting the screening number for each round of screening separately, for example, screening out the top 8 training configurations in the first round of screening, screening out the top 4 training configurations in the second round of screening, and screening out the top 2 training configurations in the third round of screening; screening out a preset number of training configurations may also be screening out training configurations ranked in a certain percentage, for example, screening out the top 50% of training configurations in each round.
[0055] Preferably, the number of training rounds of the training configuration increases with each round of screening, that is, n>m. For example, in a training task, all training configurations are initially trained for 2 rounds. After a preset number of training configurations are screened out, the screened training configurations are trained for 4 rounds. After a preset number of training configurations are screened out, the screened training configurations are trained for 8 rounds, and so on. Therefore, when the number of training configurations is large at the beginning, the training configurations with poor performance are screened out through coarse-precision training to reduce the computational complexity of model training. As more training configurations are screened out, the number of training rounds gradually increases, and the screened training configurations are further trained more finely, so as to accurately evaluate the performance of each training configuration, and then screen out the training configuration with the best performance.
[0056] (5) Training report: After completing the training task, the scheduler notifies the evaluation module to generate a training report. The training report contains graphical results and data tables of various parameters of all training configurations at all stages. It also saves the parameters of all intermediate plug-in networks according to the number of steps and sorts and compares them according to the selected parameters, so that users can select the required combination model and / or plug-in network to retain based on the training report.
[0057] In an optional embodiment, after training the combined model and determining the fine-tuning model based on the training result, the method further includes: Output each plug-in network in the fine-tuning model to the model library in one or more formats.
[0058] Here, the format of the plugin network may include but is not limited to pt, tensor, onnx, etc.
[0059] Preferably, the configuration information corresponding to each plug-in network is output to generate a configuration file, and the plug-in network and its corresponding configuration file are stored in the model library together for subsequent shared use, thereby improving the versatility of the plug-in network.
[0060] In summary, the model fine-tuning method provided by the present invention realizes the parameter detection of any large model and the generation of a plug-in network, decouples the large model from the plug-in network, realizes the construction of a plug-in network under a wider range of conditions, and realizes plug-and-play of large models, effectively reducing training costs and improving usage effects; by loading multiple plug-ins into the same model at the same time, mixed fine-tuning and pre-training of multiple existing plug-ins are achieved without changing the relevant parameters of the original model; fine-tuning is performed according to the pre-selected plug-ins, and the plug-in combination is automatically tried to obtain the performance effects of individual plug-ins and plug-in combinations, and the optimal method is automatically selected for model fine-tuning and training to achieve process automation.
[0061] The model fine-tuning device provided by the present invention is described below. The model fine-tuning device described below and the model fine-tuning method described above can be referred to each other.
[0062] Figure 5 is a schematic diagram of the structure of the model fine-tuning device provided in an embodiment of the present invention, such as Figure 5 As shown, the model fine-tuning device comprises: The model analysis module 510 is used to: perform model analysis on the base model to obtain parameter information of each layer network in the base model; The network generation module 520 is used to: generate one or more plug-in networks based on the configuration information and the parameter information; Initialization module 530, used to: initialize each of the plug-in networks; The model combination module 540 is used to combine the initialized plug-in network with the base model to obtain a combined model; the model determination module 550 is used to train the combined model and determine the fine-tuning model based on the training results.
[0063] Figure 6 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the computer program in the memory 630 to execute the steps of the model fine-tuning method, for example, including: performing model parsing on the base model to obtain parameter information of each layer network in the base model; generating one or more plug-in networks based on the configuration information and each of the parameter information; initializing each of the plug-in networks; combining the initialized plug-in network with the base model to obtain a combined model; training the combined model, and determining a fine-tuning model based on the training result.
[0064] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0065] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the model fine-tuning method provided by the above methods, which includes: performing model parsing on a base model to obtain parameter information of each layer of the network in the base model; generating one or more plug-in networks based on configuration information and each of the parameter information; initializing each of the plug-in networks; combining the initialized plug-in network with the base model to obtain a combined model; training the combined model, and determining a fine-tuning model based on the training results.
[0066] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the model fine-tuning method provided by the above-mentioned methods, the method comprising: performing model parsing on a base model to obtain parameter information of each layer network in the base model; generating one or more plug-in networks based on configuration information and each of the parameter information; initializing each of the plug-in networks; combining the initialized plug-in network with the base model to obtain a combined model; training the combined model, and determining a fine-tuning model based on the training results.
[0067] The non-transitory computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)), etc.
[0068] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0069] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0070] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A model fine-tuning method, characterized in that: include: Performing model analysis on the base model to obtain parameter information of each layer network in the base model; Based on the configuration information and each of the parameter information, generate one or more plug-in networks; Initializing each of the plug-in networks; Combining the initialized plug-in network with the base model to obtain a combined model; The combined model is trained, and a fine-tuning model is determined based on the training result.
2. The model fine-tuning method according to claim 1, characterized in that: The step of performing model analysis on the base model to obtain parameter information of each layer network in the base model includes: Inputting an empty string into the base model to simulate the reasoning process of the base model; During the simulation process, parameter information of each layer of the network in the base model is obtained through a preset script.
3. The model fine-tuning method according to claim 1, characterized in that: The plug-in network includes an input layer plug-in network, an output layer plug-in network and an intermediate layer plug-in network; The input layer plug-in network is an embedding layer network with the same input dimension and output dimension; The output layer plug-in network is a dense layer network with the same input dimension and output dimension; The middle layer plug-in network is a network with the same input dimension and output dimension, and is used to form a side branch network.
4. The model fine-tuning method according to claim 3, characterized in that: The configuration information includes input layer configuration information, output layer configuration information and middle layer configuration information, the input layer configuration information is the configuration information of the input layer plug-in network, the output layer configuration information is the configuration information of the output layer plug-in network, and the middle layer configuration information is the configuration information of the middle layer plug-in network; The middle layer configuration information includes at least one of first configuration information, second configuration information, third configuration information and fourth configuration information, the first configuration information is the configuration information of the plug-in network dimension, the second configuration information is the configuration information of the plug-in network quantization strategy, the third configuration information is the configuration information of the plug-in network size, and the fourth configuration information is the configuration information of the plug-in network custom network structure.
5. The model fine-tuning method according to claim 4, characterized in that: Initializing each of the plug-in networks includes: For any plug-in network, if the plug-in network needs to be trained and fine-tuned, the plug-in network is initialized based on the initialization configuration information, and the initialization configuration information includes the initialization method for the plug-in network; If the plug-in network does not need to be trained and fine-tuned, parameters of the plug-in network are loaded based on a configuration file to complete initialization, and the configuration file is generated based on the configuration information of the plug-in network.
6. The model fine-tuning method according to any one of claims 1 to 5, characterized in that: After training the combined model and determining the fine-tuning model based on the training result, the method further includes: Output each plug-in network in the fine-tuning model to the model library in one or more formats.
7. A model fine-tuning device, characterized in that: include: The model analysis module is used to: analyze the base model to obtain parameter information of each layer network in the base model; A network generation module, used to: generate one or more plug-in networks based on the configuration information and each of the parameter information; An initialization module, used to: initialize each of the plug-in networks; A model combination module, used to: combine the initialized plug-in network with the base model to obtain a combined model; The model determination module is used to: train the combined model and determine the fine-tuning model based on the training results.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the model fine-tuning method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the model fine-tuning method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the model fine-tuning method according to any one of claims 1 to 6 is implemented.
