Model parameter adjustment methods, apparatus, equipment and computer-readable storage media
By adjusting the parameter adjustment vector, the complexity of fine-tuning the parameters of the pre-trained language model is reduced, the problem of excessive GPU memory and disk space consumption is solved, and the efficiency of model parameter adjustment and prediction performance are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-14
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies result in excessive GPU and disk space consumption when fine-tuning parameters of pre-trained language models, making it difficult to effectively train and save model parameters.
By obtaining the pre-trained model and parameter adjustment vector, the parameter adjustment vector is further trained using the target task and the trained first network model to determine the adjustment value of the parameter to be adjusted. Only the number of parameters in the parameter adjustment vector is less than the number of parameters to be adjusted, thus reducing the adjustment complexity.
It improves the efficiency of model parameter adjustment, reduces the use of video memory and disk space, and at the same time ensures the model's prediction performance.
Smart Images

Figure CN116644791B_ABST
Abstract
Description
Technical Field
[0001] This application relates to artificial intelligence technology, and more particularly to a method, apparatus, device, and computer-readable storage medium for adjusting model parameters. Background Technology
[0002] In recent years, deep learning technology has been widely applied in various fields, and deep learning-based preprocessing models have ushered in a new era for natural language processing. Since the introduction of the Transformer model architecture, pre-trained language models have achieved great success in various natural language processing tasks. Pre-trained language models can effectively capture the syntax and semantics of text to generate information representations for downstream natural language processing (NLP) tasks, thus adapting well to various downstream tasks through transfer learning with a small number of samples.
[0003] In the process of transfer learning for a downstream task, traditional methods require fine-tuning all the parameters of the model and saving the parameters. However, for huge models, this puts pressure on GPU memory and hard disk storage. In other words, on the one hand, it will consume a lot of GPU memory during training, making training difficult; on the other hand, the saved model parameters will occupy a lot of disk space. Summary of the Invention
[0004] This application provides a model parameter adjustment method, apparatus, and computer-readable storage medium, which can improve parameter adjustment efficiency.
[0005] The technical solution of this application embodiment is implemented as follows:
[0006] This application provides a method for adjusting model parameters, including:
[0007] Obtain the trained pre-trained model and the first parameter dimension of the parameters to be adjusted in the trained pre-trained model;
[0008] Obtain a trained first network model and a pre-trained parameter adjustment vector; wherein, the second parameter dimension of the trained first network model is determined based on the third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension, and the number of parameters in the parameter adjustment vector is less than the number of parameters in the parameter to be adjusted;
[0009] Based on the target task and the trained first network model, the pre-trained parameter adjustment vector is further trained to obtain the trained parameter adjustment vector.
[0010] The adjustment value of the parameter to be adjusted is determined based on the trained first network model and the trained parameter adjustment vector;
[0011] The parameters of the pre-trained model are adjusted based on the adjustment values of the parameters to be adjusted, thereby obtaining the trained target model corresponding to the target task.
[0012] This application provides a model parameter adjustment device, including:
[0013] The first acquisition module is used to acquire the trained pre-trained model and the first parameter dimension of the parameters to be adjusted of the trained pre-trained model.
[0014] The second acquisition module is used to acquire the trained first network model and the pre-trained parameter adjustment vector; wherein, the second parameter dimension of the trained first network model is determined based on the third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension, and the number of parameters in the parameter adjustment vector is less than the number of parameters in the parameter to be adjusted;
[0015] The first training module is used to continue training the pre-trained parameter adjustment vector based on the target task and the trained first network model to obtain the trained parameter adjustment vector.
[0016] The first determining module is used to determine the adjustment value of the parameter to be adjusted based on the trained first network model and the trained parameter adjustment vector;
[0017] The parameter adjustment module is used to adjust the parameters of the pre-trained model based on the adjustment value of the parameter to be adjusted, so as to obtain the trained target model corresponding to the target task.
[0018] In some embodiments, the device further includes:
[0019] The third acquisition module is used to acquire the parameter fine-tuning algorithm used for the trained pre-trained model;
[0020] The second determining module is used to determine the parameters to be adjusted of the trained pre-trained model and the first parameter dimension of the parameters to be adjusted based on the parameter fine-tuning algorithm. The first parameter dimension is M*N, where M and N are positive integers.
[0021] In some embodiments, the device further includes:
[0022] The fourth acquisition module is used to acquire a preset parameter adjustment vector, wherein the third parameter dimension of the parameter adjustment vector is an R-dimensional vector, R is a positive integer, R is less than M and R is less than N;
[0023] The third determining module is used to determine the second parameter dimension based on the first parameter dimension and the third parameter dimension, wherein the second parameter dimension is M*N*R.
[0024] In some embodiments, the device further includes:
[0025] The model building module is used to build a first network model based on the second parameter dimension;
[0026] The fifth acquisition module is used to acquire the source task and acquire the first training data and the first loss function corresponding to the source task;
[0027] The second training module is used to train the first network model and parameter adjustment vector using the first training data and the first loss function to obtain the trained first network model and the pre-trained parameter adjustment vector.
[0028] In some embodiments, the first training module is further configured to:
[0029] Obtain the target task, and obtain the second training data and the second loss function corresponding to the target task;
[0030] Keeping the parameters in the trained first network model unchanged, the pre-trained parameter adjustment vector is further trained using the second training data and the second loss function to obtain the trained parameter adjustment vector.
[0031] In some embodiments, the first determining module is further configured to:
[0032] Obtain the first parameter information of the trained first network model, and obtain the second parameter information of the trained parameter adjustment vector, wherein the first parameter information is an M*N*R matrix parameter value; and the second parameter information is an R-dimensional vector parameter value.
[0033] The adjustment value of the parameter to be adjusted is obtained by multiplying the first parameter information and the second parameter information.
[0034] In some embodiments, the parameter adjustment module is further configured to:
[0035] Obtain the current parameter values of each parameter to be adjusted in the trained pre-trained model;
[0036] Based on the current parameter value and the adjustment value of each parameter to be adjusted, the updated parameter value of each parameter to be adjusted is determined.
[0037] Based on the updated parameter values of each parameter to be adjusted and the current parameter values of the other parameters of the pre-trained model (excluding the parameters to be adjusted), the pre-trained target model corresponding to the target task is determined.
[0038] In some embodiments, the device further includes:
[0039] The sixth acquisition module is used to acquire test data corresponding to the target model. The test data includes multiple test texts and label information corresponding to each test text.
[0040] The first prediction module is used to perform prediction processing on each test text using the target model to obtain prediction information corresponding to each test text.
[0041] The fourth determining module is used to determine the evaluation information of the target model based on the label information and prediction information corresponding to each test text;
[0042] The first adjustment module is used to continue adjusting the parameters of the parameter adjustment vector until the evaluation information of the target model reaches the evaluation threshold when it is determined that the evaluation information has not reached the preset evaluation threshold.
[0043] In some embodiments, the device further includes:
[0044] The seventh acquisition module is used to acquire the predicted text corresponding to the target task;
[0045] The second prediction module is used to perform prediction processing on the predicted text using the trained target model to obtain the prediction result of the predicted text.
[0046] The result output module is used to output the prediction result of the predicted text.
[0047] This application provides a computer device, including:
[0048] Memory, used to store executable instructions;
[0049] A processor, when executing executable instructions stored in the memory, implements the method provided in the embodiments of this application.
[0050] This application provides a computer-readable storage medium storing executable instructions for inducing a processor to execute and implement the method provided in this application.
[0051] This application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the method provided in this application.
[0052] The embodiments of this application have the following beneficial effects:
[0053] In the model parameter adjustment method provided in this application embodiment, the following steps are taken: First, a pre-trained model and a first parameter dimension of the pre-trained model's parameters to be adjusted are obtained. Then, a first-trained network model and a pre-trained parameter adjustment vector are obtained. The second parameter dimension of the pre-trained first network model is determined based on the third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension, and the number of parameters in the parameter adjustment vector is less than the number of parameters of the parameters to be adjusted. Next, the pre-trained parameter adjustment vector is trained further based on the target task and the pre-trained first network model to obtain a trained parameter adjustment vector. Then, the adjustment value of the parameters to be adjusted is determined based on the pre-trained first network model and the trained parameter adjustment vector. Finally, the parameters of the pre-trained model are adjusted based on the adjustment value of the parameters to be adjusted to obtain the trained target model corresponding to the target task. In other words, in this application embodiment, the adjustment of the parameters to be adjusted in the pre-trained model is achieved by adjusting the parameter adjustment vector. Since the number of parameters in the parameter adjustment vector is less than the number of parameters of the parameters to be adjusted, the adjustment complexity is reduced, thereby improving the efficiency of model parameter adjustment. Attached Figure Description
[0054] Figure 1 This is a schematic diagram of the architecture of the model parameter adjustment system 100 provided in an embodiment of this application;
[0055] Figure 2 This is a schematic diagram of the structure of the server 400 provided in an embodiment of this application;
[0056] Figure 3 A schematic diagram illustrating an implementation flow of the model parameter adjustment method provided in this application embodiment;
[0057] Figure 4 A schematic diagram illustrating the implementation process of creating a first network model provided in an embodiment of this application;
[0058] Figure 5 A schematic diagram illustrating another implementation flow of the model parameter adjustment method provided in this application embodiment;
[0059] Figure 6 This is a schematic diagram illustrating another implementation of the model parameter adjustment method provided in the embodiments of this application. Detailed Implementation
[0060] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0061] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0062] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0064] In the implementation of this application, the collection and processing of relevant data should strictly comply with the requirements of relevant laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.
[0065] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.
[0066] 1) Pre-training refers to either training a model in advance or the process of training a model in advance;
[0067] 2) Pre-trained model refers to a model obtained through pre-training;
[0068] 3) Parameter fine-tuning refers to the process of applying a pre-trained model to one's own dataset and adapting the parameters to the dataset.
[0069] To better understand the model parameter adjustment method provided in the embodiments of this application, the model parameter adjustment method for fine-tuning a pre-trained model in related technologies will be explained first.
[0070] In related technologies, model parameter tuning methods based on few-parameter fine-tuning can be implemented in the following ways:
[0071] The first implementation method involves selecting a small subset of parameters and fixing the remaining parameters, such as the BitFit algorithm.
[0072] The second implementation method is to perform low-rank decomposition on the changes in the original parameters, thereby introducing fewer training parameters, such as the LoRA algorithm.
[0073] The third approach is to introduce parameters outside the model into the input, such as the Prompt Tuning algorithm.
[0074] While the above methods reduce the number of parameters to be fine-tuned to some extent, the number of parameters that need to be fine-tuned and saved is still very large. For example, for the GPT-3 model, traditional parameter tuning methods require 175,255.8M parameters, the BitFit algorithm requires 14.2M parameters, the Prompt Tuning algorithm requires 3.2M parameters, and the LoRA algorithm requires 4.7M parameters.
[0075] Based on this, this application provides a model parameter adjustment method that can be combined with any of the related technologies’ low-parameter fine-tuning methods (such as BitFit and LoRA) to further reduce the number of parameters that need to be fine-tuned by a thousand times without losing performance. It can also be adapted to a variety of downstream tasks of natural language processing, which can not only improve the execution efficiency of model parameter adjustment, but also ensure the prediction effect of the model.
[0076] The following describes exemplary applications of the computer device provided in the embodiments of this application. The computer device provided in the embodiments of this application can be implemented as various types of user terminals such as laptops, tablets, desktop computers, set-top boxes, and mobile devices (e.g., mobile phones, portable music players, personal digital assistants, dedicated messaging devices, portable gaming devices), or as a server. The following will describe exemplary applications when the device is implemented as a server.
[0077] See Figure 1 , Figure 1 This is a schematic diagram of the architecture of the model parameter adjustment system 100 provided in this application embodiment, as shown below. Figure 1 As shown, the system includes a terminal 200, a network 300, and a server 400. The terminal 200 is connected to the server 400 through the network 300, which can be a wide area network, a local area network, or a combination of both.
[0078] Terminal 200 can send a parameter adjustment request to server 400 via network 300. This request carries target task information. Upon receiving the request, server 400 obtains the target task information, a pre-trained model, and the first parameter dimension of the pre-trained model's parameters to be adjusted. It also obtains a pre-trained first network model and a pre-trained parameter adjustment vector. The second parameter dimension of the pre-trained first network model is determined based on the third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension. The number of parameters in the parameter adjustment vector is less than the number of parameters to be adjusted. Based on the target task and the pre-trained first network model, the pre-trained parameter adjustment vector is further trained to obtain a trained parameter adjustment vector. The adjustment value of the parameter to be adjusted is determined based on the pre-trained first network model and the trained parameter adjustment vector. The parameters of the pre-trained model are adjusted based on the adjustment value of the parameter to be adjusted to obtain the trained target model corresponding to the target task. Server 400 sends the trained target model to terminal 200. Terminal 200 uses the trained target model to perform prediction processing on the test data corresponding to the target task and obtain the processing result.
[0079] In some embodiments, server 200 may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Terminal 400 may be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, in-vehicle smart terminal, etc., but is not limited to these. Terminals and servers can be directly or indirectly connected via wired or wireless communication, which is not limited in this embodiment.
[0080] See Figure 2 , Figure 2 This is a schematic diagram of the structure of the server 400 provided in an embodiment of this application. Figure 2 The server 400 shown includes at least one processor 410, at least one network interface 420, a bus system 430, and memory 440. The various components in the server 400 are coupled together via the bus system 430. It is understood that the bus system 430 is used to implement communication between these components. In addition to a data bus, the bus system 430 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 2 The general labeled all buses as Bus System 430.
[0081] Processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0082] The memory 440 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state storage, hard disk drives, optical disk drives, etc. The memory 440 may optionally include one or more storage devices physically located away from the processor 410.
[0083] The memory 440 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 440 described in this application embodiment is intended to include any suitable type of memory.
[0084] In some embodiments, memory 440 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.
[0085] Operating system 441 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks;
[0086] The network communication module 442 is used to reach other computing devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 including: Bluetooth, WiFi, and Universal Serial Bus (USB), etc.
[0087] In some embodiments, the apparatus provided in this application can be implemented in software. Figure 2 A model parameter adjustment device 443 stored in memory 440 is shown. This device can be software in the form of programs or plug-ins, and includes the following software modules: a first acquisition module 4431, a second acquisition module 4432, a first training module 4433, a first determination module 4434, and a parameter adjustment module 4435. These modules are logically connected and can therefore be arbitrarily combined or further separated according to their implemented functions. The functions of each module will be described below.
[0088] In other embodiments, the apparatus provided in this application can be implemented in hardware. As an example, the apparatus provided in this application can be a processor in the form of a hardware decoding processor, which is programmed to execute the model parameter adjustment method provided in this application. For example, the processor in the form of a hardware decoding processor can be one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.
[0089] The model parameter adjustment method provided in this application will be described in conjunction with exemplary applications and implementations of the terminal provided in the embodiments of this application.
[0090] This application provides a model parameter adjustment method applied to a computer device, which can be a terminal or a server. In this application embodiment, the computer device is described as a server. Figure 3 This is a schematic diagram illustrating an implementation flow of the model parameter adjustment method provided in this application embodiment, which will be combined with... Figure 3 The steps shown are explained.
[0091] Step S101: Obtain the first parameter dimension of the pre-trained model and the parameters to be adjusted of the pre-trained model.
[0092] Pre-trained models are an application of transfer learning that utilizes virtually unlimited text to learn context-dependent representations of each word in an input sentence, implicitly learning general syntactic and semantic knowledge. Pre-trained models can transfer knowledge learned from open-domain tasks to downstream tasks, improving low-resource tasks and proving highly beneficial for low-resource language processing. When applying pre-trained models to actual downstream tasks, only fine-tuning of the pre-trained model's parameters based on the specific downstream task is required. Therefore, the combination of pre-trained models and fine-tuning mechanisms offers excellent scalability; to support a new task, only fine-tuning using the labeled data for that task is needed.
[0093] In practical implementation, the parameters to be adjusted in the pre-trained model can be all the parameters of the pre-trained model or only a portion of the parameters. The model parameter adjustment method provided in this embodiment can be superimposed on the few-parameter fine-tuning method in related technologies. In this case, the parameters to be adjusted in this step are a small portion of the parameters of the pre-trained model; that is, the first parameter dimension of the parameters to be adjusted is smaller than the total parameter dimension of the pre-trained model, and the first parameter dimension is determined by the selected few-parameter fine-tuning method.
[0094] Step S102: Obtain the trained first network model and the pre-trained parameter adjustment vector.
[0095] In this embodiment, the first network model can be a supernetwork. A supernetwork is a method used to accelerate model training. The supernetwork is not a specific network architecture, but rather a collection of multiple models of the same type but different parameters. By training the supernetwork in its initial state, the parameters of each model within the supernetwork can be adjusted. The trained supernetwork also includes the aforementioned multiple models, but with the model parameters adjusted, thus achieving the training of the supernetwork model (i.e., the first network model).
[0096] The trained first network model and the pre-trained parameter adjustment vector are obtained using the training data from the source task. The source task needs to have a certain similarity to the target task, such as both belonging to text classification tasks or sentiment analysis tasks. The difference between the source task and the target task lies in their application domains. The second parameter dimension of the trained first network model is determined based on the third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension, satisfying formula (1-1) in actual implementation:
[0097] W 0= W h * I r (1-1);
[0098] in, W h Here is the parameter matrix of the first network model. I r Adjust the vector for the parameters. W 0 represents the parameter adjustment matrix for the parameter to be adjusted. Furthermore, the number of parameters in the parameter adjustment vector is less than the number of parameters in the parameter to be adjusted; in fact, the number of parameters in the parameter adjustment vector is much smaller than the number of parameters in the parameter to be adjusted. For example, the parameter to be adjusted may have 20,000 parameters, while the parameter adjustment vector may only have 8 or 16 parameters.
[0099] Step S103: Based on the target task and the trained first network model, continue training the pre-trained parameter adjustment vector to obtain the trained parameter adjustment vector.
[0100] In this step, the parameters of the pre-trained first network model and the pre-trained model are fixed. Second training data corresponding to the target task is obtained. Using this second training data, the pre-trained parameter adjustment vector is further trained to obtain a trained parameter adjustment vector. Continuing to train the pre-trained parameter adjustment vector involves adjusting each vector value within it. A preset second loss function is used to determine when the training termination condition is met, resulting in the final trained parameter adjustment vector.
[0101] Step S104: Determine the adjustment value of the parameter to be adjusted based on the trained first network model and the trained parameter adjustment vector.
[0102] In this embodiment, since the parameter matrix and parameter adjustment vector of the first network model, as well as the parameter adjustment matrix of the parameter to be adjusted, satisfy formula (1-1), after obtaining the trained first network model and the trained parameter adjustment vector, the parameter matrix and parameter adjustment vector of the trained first network model can be obtained, and then the adjustment value of the parameter to be adjusted can be determined by formula (1-1). That is to say, in this embodiment, when determining the adjustment value of the parameter to be adjusted in the pre-trained model, it is only necessary to adjust the vector value of the parameter adjustment vector. Since the number of parameters in the parameter adjustment vector is much smaller than the number of parameters to be adjusted, the parameter adjustment efficiency can be greatly improved.
[0103] Step S105: Adjust the parameters of the pre-trained model based on the adjustment values of the parameters to be adjusted to obtain the trained target model corresponding to the target task.
[0104] In this step, the current parameter values of each parameter to be adjusted in the pre-trained model are first obtained; then, based on the current parameter values and the adjustment values of each parameter to be adjusted, the updated parameter values of each parameter to be adjusted are determined; and finally, based on the updated parameter values and the current parameter values of other parameters of the pre-trained model besides the parameters to be adjusted, the trained target model corresponding to the target task is determined.
[0105] In the model parameter adjustment method provided in this application embodiment, the following steps are taken: First, a pre-trained model and a first parameter dimension of the pre-trained model's parameters to be adjusted are obtained. Then, a first-trained network model and a pre-trained parameter adjustment vector are obtained. The second parameter dimension of the pre-trained first network model is determined based on the third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension, and the number of parameters in the parameter adjustment vector is less than the number of parameters of the parameters to be adjusted. Next, the pre-trained parameter adjustment vector is trained further based on the target task and the pre-trained first network model to obtain a trained parameter adjustment vector. Then, the adjustment value of the parameters to be adjusted is determined based on the pre-trained first network model and the trained parameter adjustment vector. Finally, the parameters of the pre-trained model are adjusted based on the adjustment value of the parameters to be adjusted to obtain the trained target model corresponding to the target task. In other words, in this application embodiment, the adjustment of the parameters to be adjusted in the pre-trained model is achieved by adjusting the parameter adjustment vector. Since the number of parameters in the parameter adjustment vector is less than the number of parameters of the parameters to be adjusted, the adjustment complexity is reduced, thereby improving the efficiency of model parameter adjustment.
[0106] In some embodiments, prior to step S101, the parameters to be adjusted in the pre-trained model and the first parameter dimension of the parameters to be adjusted can be determined through the following steps:
[0107] Step S001: Obtain the parameter fine-tuning algorithm used for the trained pre-trained model.
[0108] The algorithm for fine-tuning this parameter can be LoRA, BitFit, or similar algorithms.
[0109] Step S002: Based on the parameter fine-tuning algorithm, determine the parameters to be adjusted of the trained pre-trained model and the first parameter dimension of the parameters to be adjusted.
[0110] After determining the parameter fine-tuning algorithm, the parameters to be adjusted in the pre-trained model and the first parameter dimension of the parameters to be adjusted can be determined based on the selected parameter fine-tuning algorithm. The first parameter dimension is M*N, where M and N are positive integers. For example, the first parameter dimension can be 200*100, that is, M is 200 and N is 100.
[0111] The parameter model adjustment method provided in this application embodiment can be used in conjunction with the parameter fine-tuning method provided in related technologies. That is, the model parameter adjustment method provided in this application embodiment can further reduce the parameter adjustment amount on the basis of the parameter fine-tuning method in related technologies, thereby further improving the parameter adjustment efficiency.
[0112] In some embodiments, prior to step S102, it can also be done by Figure 4 The steps described above create the first network model and train the first network model and parameter adjustment vectors. The following is a combination of... Figure 4 Each step is explained.
[0113] Step S201: Obtain the preset parameter adjustment vector.
[0114] The third parameter dimension of the parameter adjustment vector is an R-dimensional vector. R is a positive integer, R is less than M and R is less than N. For example, R can be 8 or 16. In actual implementation, R is much smaller than M and much smaller than N, so R is much smaller than M*N.
[0115] Step S202: Determine the second parameter dimension based on the first parameter dimension and the third parameter dimension.
[0116] The second parameter has a dimension of M*N*R.
[0117] Step S203: Construct the first network model based on the second parameter dimension.
[0118] The first network model can be a supernetwork.
[0119] Step S204: Obtain the source task, and obtain the first training data and the first loss function corresponding to the source task.
[0120] Once the source task is obtained, the actual task to be processed and its application domain can be determined. At this point, the corresponding first training data can be obtained based on the source task. The first training data includes multiple first training texts and first text labels corresponding to each first training text. These first text labels are related to the type of the source task. For example, if the source task is a sentiment analysis task for film reviews, then the first text label can be either positive or negative sentiment. Or, if the source task is a text classification task, then the first text label is the category of each first training text.
[0121] Step S205: Use the first training data and the first loss function to train the first network model and the parameter adjustment vector respectively, to obtain the trained first network model and the pre-trained parameter adjustment vector.
[0122] In this step, the initial adjustment values of the parameters to be adjusted in the pre-trained model are determined based on the model parameters and parameter adjustment vector of the first network model. Then, the parameter values of the parameters to be adjusted in the pre-trained model are adjusted based on the initial adjustment values to obtain the adjusted pre-trained model. After that, the adjusted pre-trained model is used to predict each first training text in the first training data to obtain the prediction information of each first training text. Based on the prediction information of each first training text, the label information of each first training text, and the first loss function, the loss value of the adjusted pre-trained model is calculated. The loss value is then backpropagated to the first network model and the parameter adjustment vector to adjust the model parameter values of the first network model and the vector values of the parameter adjustment vector, and finally, the trained first network model and the pre-trained parameter adjustment vector are obtained.
[0123] Through steps S201 to S205 described above, the first network model and parameter adjustment vector can be trained simultaneously using the first training data corresponding to the source task, according to the first loss function, while keeping the pre-trained model fixed. The first network model obtained after training can define an optimization eigenspace for a series of similar tasks represented by the source task, and the dimension of this optimization eigenspace is the same as the dimension of the parameter adjustment vector. Based on this, all similar tasks can be optimized and trained using the parameter adjustment vector within this eigenspace to obtain the target model corresponding to the target task, greatly reducing the amount of parameter adjustment and improving parameter adjustment efficiency.
[0124] In some embodiments, the above step S103, "Continue to train the pre-trained parameter adjustment vector based on the target task and the trained first network model to obtain the trained parameter adjustment vector," can be achieved through the following steps:
[0125] Step S1031: Obtain the target task, and obtain the second training data and the second loss function corresponding to the target task.
[0126] In this embodiment, obtaining the target task may involve obtaining the application domain and task type to be performed by the target task. The second loss function may be the same as or different from the first loss function. The target task and the source task may have similar or the same task types, but different application domains. For example, the source task may be in the field of film and television reviews, while the target task may be in the field of product reviews. Both the source task and the target task may be sentiment analysis tasks.
[0127] Step S1032: Keeping the parameters in the trained first network model unchanged, the pre-trained parameter adjustment vector is trained again using the second training data and the second loss function to obtain the trained parameter adjustment vector.
[0128] In this step, the parameters in the trained first network model are kept unchanged. Then, based on the model parameters and parameter adjustment vector of the trained first network model, intermediate adjustment values of the parameters to be adjusted in the pre-trained model are determined. Then, the parameter values of the parameters to be adjusted in the pre-trained model are adjusted based on the intermediate adjustment values to obtain the pre-trained model after adjustment. Then, the adjusted pre-trained model is used to predict each second training text in the second training data to obtain the prediction information of each second training text. Based on the prediction information, label information and second loss function of each second training text, the loss value of the pre-trained model after adjustment is calculated. The loss value is then backpropagated to the parameter adjustment vector to adjust the vector value of the parameter adjustment vector, and finally the trained parameter adjustment vector is obtained.
[0129] When it is necessary to determine the target model corresponding to the target task, since the first network model and parameter adjustment vector have been trained using the source task, an optimized intrinsic space of a series of similar tasks represented by the source task has been obtained. At this time, through the above steps S1031 to S1032, the parameter adjustment vector can be optimized and trained in this intrinsic space to obtain the trained parameter adjustment vector. Then, the parameters to be adjusted in the pre-trained model can be adjusted using the trained parameter adjustment vector and the trained first network model. In other words, the parameters to be adjusted in the pre-trained model can be adjusted simply by adjusting the parameter adjustment vector, thereby obtaining the target model corresponding to the target task, which can improve the efficiency of parameter adjustment.
[0130] In some embodiments, step S104, "determining the adjustment value of the parameter to be adjusted based on the trained first network model and the trained parameter adjustment vector," can be achieved through the following steps:
[0131] Step S1041: Obtain the first parameter information of the trained first network model and the second parameter information of the trained parameter adjustment vector.
[0132] The first parameter information is the parameter matrix of the first network model, which is an M*N*R matrix parameter value; the second parameter information is an R-dimensional vector parameter value.
[0133] Step S1042: Multiply the first parameter information and the second parameter information to obtain the adjustment value of the parameter to be adjusted.
[0134] This step involves multiplying the M*N*R matrix parameter values with the R-dimensional vector parameter values to obtain a parameter adjustment matrix. This matrix includes the adjustment values for M*N parameters to be adjusted. The adjustment values for the parameters to be adjusted can be positive or negative.
[0135] In some embodiments, step S105, "adjusting the parameters of the pre-trained model based on the adjustment value of the parameter to be adjusted to obtain the trained target model corresponding to the target task," can be achieved through the following steps:
[0136] Step S1051: Obtain the current parameter values of each parameter to be adjusted in the trained pre-trained model.
[0137] Step S1052: Based on the current parameter value and the adjustment value of each parameter to be adjusted, determine the updated parameter value of each parameter to be adjusted.
[0138] In implementation, the current parameter value of the parameter to be adjusted and the adjustment value of the parameter to be adjusted can be added together to obtain the updated parameter value of the parameter to be adjusted.
[0139] Step S1053: Based on the updated parameter values of each parameter to be adjusted and the current parameter values of the other parameters of the pre-trained model (excluding the parameters to be adjusted), determine the trained target model corresponding to the target task.
[0140] Through the above steps S1051 to S1053, after obtaining the adjustment values of the parameters to be adjusted, the updated parameter values of each parameter to be adjusted can be determined based on the current parameter values and corresponding adjustment values of each parameter to be adjusted in the pre-trained model. The parameter values of other parameters in the pre-trained model, except for the parameters to be adjusted, do not need to be adjusted. This way, the trained target model corresponding to the target task can be obtained, thereby improving the adjustment efficiency of the target model.
[0141] Based on the foregoing embodiments, this application provides a model parameter adjustment method, applied to... Figure 1 The network architecture shown is Figure 5 This is a schematic diagram illustrating another implementation flow of the model parameter adjustment method provided in the embodiments of this application, as follows: Figure 5 As shown, the process includes:
[0142] Step S301: The terminal obtains the target task information.
[0143] In the embodiments of this application, the target task information may include the type of task to be performed and the application field. In some embodiments, the target task information may also include the application platform corresponding to the application field. For example, when the target task is a sentiment analysis task for product reviews, the target task information may also include the actual product sales platform.
[0144] In step S302, the terminal sends a parameter adjustment request to the server.
[0145] The parameter adjustment request includes target task information.
[0146] Step S303: The server obtains the trained pre-trained model and the first parameter dimension of the parameters to be adjusted of the trained pre-trained model.
[0147] After receiving a parameter adjustment request, the server parses the request, obtains the target task information, retrieves the pre-trained model based on the task type in the target task information, and obtains the first parameter dimension of the pre-trained model's parameters to be adjusted. In actual implementation, the first parameter dimension of the parameters to be adjusted can be smaller than the total number of parameters in the pre-trained model. That is, the model parameter adjustment method provided in this application embodiment can be used in conjunction with related low-parameter model adjustment methods to further improve the efficiency of model parameter adjustment.
[0148] Step S304: The server obtains the trained first network model and the pre-trained parameter adjustment vector.
[0149] The second parameter dimension of the trained first network model is determined based on the third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension, and the number of parameters in the parameter adjustment vector is less than the number of parameters to be adjusted.
[0150] In step S305, the server continues to train the pre-trained parameter adjustment vector based on the target task and the trained first network model to obtain the trained parameter adjustment vector.
[0151] Step S306: The server determines the adjustment value of the parameter to be adjusted based on the trained first network model and the trained parameter adjustment vector.
[0152] In step S307, the server adjusts the parameters of the pre-trained model based on the adjustment values of the parameters to be adjusted, thereby obtaining the trained target model corresponding to the target task.
[0153] It should be noted that the implementation process of steps S303 to S307 is the same as that of steps S101 to S105. In actual implementation, the implementation process of steps S101 to S105 can be referred to.
[0154] Step S308: The server obtains the test data corresponding to the target model.
[0155] In implementation, the server can obtain the test data corresponding to the target model based on the target task. The test data includes multiple test texts and the label information corresponding to each test text.
[0156] In step S309, the server uses the target model to perform prediction processing on each test text to obtain the prediction information corresponding to each test text.
[0157] In implementation, each test text is input into the target model corresponding to the target task, thereby performing prediction processing on each test text to obtain the prediction information for each test text. For example, when the target task is sentiment analysis, the prediction information of the test text is the sentiment analysis prediction result.
[0158] In step S310, the server determines the evaluation information of the target model based on the label information and prediction information corresponding to each test text.
[0159] The evaluation information may include the value of at least one evaluation indicator, such as recall, precision, or AUC. In practice, each evaluation indicator corresponds to a preset evaluation threshold. After obtaining the evaluation information of the target model, it can be determined whether the evaluation information reaches the preset evaluation threshold. When the evaluation information includes the value of one evaluation indicator, it is only determined whether the indicator value reaches the corresponding evaluation threshold. If the indicator value reaches the corresponding evaluation threshold, proceed to step S312; if the indicator value does not reach the corresponding evaluation threshold, proceed to step S311. When the evaluation information includes the values of two or more evaluation indicators, it is necessary to determine whether each indicator value reaches the corresponding evaluation threshold sequentially. If all indicator values reach the corresponding evaluation threshold, proceed to step S312; if at least one indicator value does not reach the corresponding evaluation threshold, proceed to step S311.
[0160] Step S311: When the server determines that the evaluation information has not reached the preset evaluation threshold, it continues to adjust the parameters of the parameter adjustment vector until the evaluation information of the target model reaches the evaluation threshold.
[0161] In this step, it is necessary to obtain the second training data corresponding to the target task again, then keep the parameters in the trained first network model unchanged, and use the newly obtained second training data and the second loss function to train the pre-trained parameter adjustment vector again to obtain the retrained parameter adjustment vector. Then, obtain the first parameter information of the trained first network model, obtain the second parameter information of the retrained parameter adjustment vector, multiply the first parameter information and the second parameter information to obtain the adjustment value of the parameter to be adjusted, and use the adjustment value of the parameter to be adjusted to adjust the parameters of the trained pre-trained model to obtain the target model corresponding to the target task again.
[0162] Step S312: When it is determined that the evaluation information has reached the preset evaluation threshold, the server sends the target model corresponding to the target task to the terminal.
[0163] Step S313: The terminal obtains the predicted text corresponding to the target task.
[0164] When implementing this step, the corresponding predicted text can be obtained based on the application domain corresponding to the target task.
[0165] In step S314, the terminal uses the trained target model to perform prediction processing on the predicted text and obtain the prediction result of the predicted text.
[0166] Here, each predicted text can be input into a trained target model, and the trained target model can be used to perform prediction processing on the predicted text to obtain the prediction vector of the predicted text. Then, the prediction result corresponding to the predicted text can be determined based on the prediction vector.
[0167] Step S315: The terminal outputs the prediction result of the predicted text.
[0168] The prediction results of the predicted text output by the terminal can be presented on the terminal's display device.
[0169] In some embodiments, steps S313 to S315 above can also be implemented by the server. After the server obtains the target model corresponding to the target task, it can send a request to the terminal to obtain the prediction file. Based on the request, the terminal returns the prediction text to the server. The server uses the target model to perform prediction processing on the prediction text to obtain the prediction result of the prediction text. Then the server returns the prediction result to the terminal.
[0170] In the model parameter adjustment method provided in this application embodiment, after the terminal sends a parameter adjustment request carrying target task information to the server, the server responds to the parameter adjustment request by obtaining a trained pre-trained model and the first parameter dimension of the pre-trained model's parameters to be adjusted; and obtains a trained first network model and a pre-trained parameter adjustment vector; wherein, the second parameter dimension of the trained first network model is determined based on the third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension, and the number of parameters in the parameter adjustment vector is less than the number of parameters of the parameters to be adjusted; the pre-trained parameter adjustment vector is further trained based on the target task and the trained first network model to obtain a trained parameter adjustment vector; based on the trained first network model... A network model and the trained parameter adjustment vector determine the adjustment value of the parameter to be adjusted; based on the adjustment value of the parameter to be adjusted, the parameters of the trained pre-trained model are adjusted to obtain the trained target model corresponding to the target task. Then, test data is used to determine whether the target model meets the evaluation criteria. If it does not meet the criteria, the parameter adjustment vector is adjusted again to ensure that the final trained target model meets the evaluation criteria, thereby ensuring the accuracy of the prediction results of the final trained target model. The server sends the final trained target model to the terminal so that the terminal can use the final trained target model to perform prediction processing on the predicted text and obtain the prediction result. In this way, not only can the efficiency of model parameter adjustment be improved, but the accuracy of the final prediction result can also be guaranteed.
[0171] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario.
[0172] This application provides a model parameter method. Figure 6 This is a schematic diagram illustrating another implementation of the model parameter adjustment method provided in the embodiments of this application. The following is in conjunction with... Figure 6 The steps of this method are explained.
[0173] Step S601: Obtain the input and output of the pre-trained model and the loss function.
[0174] Step S602: Train the Hyper Network and Intrinsic Vector on the source task.
[0175] The hypernetwork here corresponds to the first network model in other embodiments, and the eigenvectors correspond to the parameter adjustment vectors in other embodiments.
[0176] Step S603: Based on the hypernetwork, only the eigenvectors are fine-tuned to solve the target problem corresponding to the target task.
[0177] The implementation process of each of the above steps is explained below.
[0178] The model parameter adjustment method provided in this application is adaptable to various pre-trained models, various few-parameter fine-tuning methods, and downstream tasks. Therefore, the actual pre-trained model (e.g., BART, T5), few-parameter fine-tuning method (e.g., BitFit, LoRA), and downstream task type (e.g., sentiment analysis) used can be freely selected. In this application embodiment, the T5 model is used as the basic model for illustration. Further, it is possible to use the parameters within the T5 model... The model consists of 12 Transformer layers, with a total of approximately 110M parameters. The input to this pre-trained model is a sequence of tokens. The output is a sequence of tokens. .
[0179] For example, in sentiment analysis It could be: "I really like this movie; the emotional tone of the above sentence is..." It could be: "positive emotions". After inputting into the pre-trained model, sequences can be continuously decoded. The loss function is defined as shown in equation (1-1):
[0180] (1-1);
[0181] By optimizing the loss function shown in formula (1-1) and changing the corresponding parameters (the parameters to be changed are determined by the selected fine-tuning method), the pre-trained model can learn to handle the corresponding downstream tasks (such as sentiment classification).
[0182] The model parameter adjustment method provided in this application includes two stages: the first stage selects a source task to learn a supernetwork and eigenvectors, and the second stage uses the supernetwork trained in the first stage to solve the target task.
[0183] In the first stage, to reduce the number of parameters to be fine-tuned when training the target task, a source task is first selected (the source task needs to have a certain similarity to the target task, such as both belonging to text classification tasks), and the hypernetwork and eigenvectors are trained on the source task. The model parameter adjustment method provided in this application embodiment can be a further simplification based on the few-parameter fine-tuning method in related technologies, so the appropriate few-parameter fine-tuning method can be freely chosen. Here, it is assumed that the few-parameter fine-tuning method requires fine-tuning a matrix. (This assumption applies to all existing efficient, few-parameter fine-tuning methods), its dimension is An eigenvector is defined as a vector with dimension 1. vector ,in much smaller and A hypernetwork is defined as a network with one dimension. matrix Applying a hypernetwork to the eigenvectors can generate the desired matrix. As shown in formula (1-2):
[0184] (1-2);
[0185] In the source task, according to the objective function Simultaneous training and And fix the pre-trained model and keep it stationary. The result after training... An optimal intrinsic space is defined, consisting of a series of similar tasks represented by the source task, and the dimension of this optimal intrinsic space is... Based on this, all similar tasks can be optimized within this eigenspace. Because this eigenspace has a very low dimension, the number of parameters required is also small.
[0186] In step S602, training is performed simultaneously on the source task. and This yields a series of tasks represented by the source task, with the dimension being... The second stage optimizes the intrinsic space. The target task is optimized only within this low-dimensional optimization space, allowing the pre-trained model to learn how to solve the target task. In implementation, only the training data from the first stage is retained. And maintain in the second phase Keeping the parameters of the pre-trained model constant, and only fine-tuning one dimension. The vector. According to formula (1-2), it can be obtained through a constantly changing vector. And a fixed Get the one that fits the current target task The loss function for training the target task in the second stage is the same as before. Compared to previous methods with fewer parameters, this new method requires fine-tuning during training. There are a total of There were 10 parameters, but now only minor adjustments are needed. One parameter, because much smaller and This greatly reduces the number of parameters that need to be fine-tuned.
[0187] In this embodiment, a model was pre-trained using a novel framework, and its performance was validated on several publicly available sentiment classification datasets (source task: SST-2, target tasks: Rotten Tomatoes / Yelp Polarity / AmazonPolarity). The results are shown in Table 1. Finetune is a traditional downstream task fine-tuning method, LoRA / BitFit are baseline few-parameter fine-tuning methods for comparison, and Intrinsic LoRA / Intrinsic BitFit are the few-parameter fine-tuning methods proposed in this embodiment (adapted to LoRA / BitFit respectively).
[0188] Table 1. Comparison of results from different parameter fine-tuning methods
[0189]
[0190] As shown in Table 1, the model parameter adjustment method provided in this application embodiment can fine-tune fewer parameters compared to traditional methods. It uses only 0.00364% of the parameters compared to LoRA and 0.0000909% compared to BitFit, achieving an accuracy comparable to traditional fine-tuning. This demonstrates that the model using the parameters provided in this application embodiment can train large pre-trained models more efficiently. Furthermore, it verifies that the model parameter adjustment method provided in this application embodiment is adaptable to both LoRA and BitFit methods, showcasing its broad applicability to various existing methods for fine-tuning pre-trained models with fewer parameters.
[0191] It is understood that in the embodiments of this application, the content involving user information, such as training text in the first training data and the second training data, requires user permission or consent when the embodiments of this application are applied to specific products or technologies, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0192] The following description continues to illustrate the exemplary structure of the model parameter adjustment device 443 provided in the embodiments of this application as a software module. In some embodiments, such as Figure 2 As shown, the software module stored in the model parameter adjustment device 443 in the memory 440 may include:
[0193] The first acquisition module 4431 is used to acquire the trained pre-trained model and the first parameter dimension of the parameters to be adjusted of the trained pre-trained model;
[0194] The second acquisition module 4432 is used to acquire the trained first network model and the pre-trained parameter adjustment vector; wherein, the second parameter dimension of the trained first network model is determined based on the third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension, and the number of parameters in the parameter adjustment vector is less than the number of parameters in the parameter to be adjusted;
[0195] The first training module 4433 is used to continue training the pre-trained parameter adjustment vector based on the target task and the trained first network model to obtain the trained parameter adjustment vector.
[0196] The first determining module 4434 is used to determine the adjustment value of the parameter to be adjusted based on the trained first network model and the trained parameter adjustment vector;
[0197] The parameter adjustment module 4435 is used to adjust the parameters of the pre-trained model based on the adjustment value of the parameter to be adjusted, so as to obtain the trained target model corresponding to the target task.
[0198] In some embodiments, the device further includes:
[0199] The third acquisition module is used to acquire the parameter fine-tuning algorithm used for the trained pre-trained model;
[0200] The second determining module is used to determine the parameters to be adjusted of the trained pre-trained model and the first parameter dimension of the parameters to be adjusted based on the parameter fine-tuning algorithm. The first parameter dimension is M*N, where M and N are positive integers.
[0201] In some embodiments, the device further includes:
[0202] The fourth acquisition module is used to acquire a preset parameter adjustment vector, wherein the third parameter dimension of the parameter adjustment vector is an R-dimensional vector, R is a positive integer, R is less than M and R is less than N;
[0203] The third determining module is used to determine the second parameter dimension based on the first parameter dimension and the third parameter dimension, wherein the second parameter dimension is M*N*R.
[0204] In some embodiments, the device further includes:
[0205] The model building module is used to build a first network model based on the second parameter dimension;
[0206] The fifth acquisition module is used to acquire the source task and acquire the first training data and the first loss function corresponding to the source task;
[0207] The second training module is used to train the first network model and parameter adjustment vector using the first training data and the first loss function to obtain the trained first network model and the pre-trained parameter adjustment vector.
[0208] In some embodiments, the first training module 4433 is further configured to:
[0209] Obtain the target task, and obtain the second training data and the second loss function corresponding to the target task;
[0210] Keeping the parameters in the trained first network model unchanged, the pre-trained parameter adjustment vector is further trained using the second training data and the second loss function to obtain the trained parameter adjustment vector.
[0211] In some embodiments, the first determining module 4434 is further configured to:
[0212] Obtain the first parameter information of the trained first network model, and obtain the second parameter information of the trained parameter adjustment vector, wherein the first parameter information is an M*N*R matrix parameter value; and the second parameter information is an R-dimensional vector parameter value.
[0213] The adjustment value of the parameter to be adjusted is obtained by multiplying the first parameter information and the second parameter information.
[0214] In some embodiments, the parameter adjustment module 4435 is further configured to:
[0215] Obtain the current parameter values of each parameter to be adjusted in the trained pre-trained model;
[0216] Based on the current parameter value and the adjustment value of each parameter to be adjusted, the updated parameter value of each parameter to be adjusted is determined.
[0217] Based on the updated parameter values of each parameter to be adjusted and the current parameter values of the other parameters of the pre-trained model (excluding the parameters to be adjusted), the pre-trained target model corresponding to the target task is determined.
[0218] In some embodiments, the device further includes:
[0219] The sixth acquisition module is used to acquire test data corresponding to the target model. The test data includes multiple test texts and label information corresponding to each test text.
[0220] The first prediction module is used to perform prediction processing on each test text using the target model to obtain prediction information corresponding to each test text.
[0221] The fourth determining module is used to determine the evaluation information of the target model based on the label information and prediction information corresponding to each test text;
[0222] The first adjustment module is used to continue adjusting the parameters of the parameter adjustment vector until the evaluation information of the target model reaches the evaluation threshold when it is determined that the evaluation information has not reached the preset evaluation threshold.
[0223] In some embodiments, the device further includes:
[0224] The seventh acquisition module is used to acquire the predicted text corresponding to the target task;
[0225] The second prediction module is used to perform prediction processing on the predicted text using the trained target model to obtain the prediction result of the predicted text.
[0226] The result output module is used to output the prediction result of the predicted text.
[0227] It should be noted that the description of the model parameter adjustment device in this application is similar to the description of the method embodiment described above, and has similar beneficial effects. For technical details not disclosed in this device embodiment, please refer to the description of the method embodiment of this application for understanding.
[0228] This application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the model parameter adjustment method described above in this application.
[0229] This application provides a computer-readable storage medium storing executable instructions. When these executable instructions are executed by a processor, they cause the processor to execute the model parameter adjustment method provided in this application. For example, ... Figure 3 , Figure 4 as well as Figure 5 The model parameter adjustment method is shown.
[0230] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.
[0231] In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0232] As an example, executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborating files (e.g., a file that stores one or more modules, subroutines, or code sections).
[0233] As an example, executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.
[0234] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.
Claims
1. A model parameter adjustment method, characterized by, The method comprises: obtaining a pre-trained model trained for a source task in the field of natural language processing, and a first parameter dimension of to-be-adjusted parameters of the trained pre-trained model, the pre-trained model being used to learn general grammar semantic knowledge according to context-related representations of each word in each sentence in input text; obtaining a trained first network model and a pre-trained parameter adjustment vector; wherein a second parameter dimension of the trained first network model is determined based on a third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension, and a parameter quantity of the parameter adjustment vector is less than a parameter quantity of the to-be-adjusted parameters; continuing training the pre-trained partial parameter adjustment vector based on a target task in the field of natural language processing and the trained first network model, to obtain a trained parameter adjustment vector adapted to the target task, wherein the target task is a task similar to the source task in the field of natural language processing; determining an adjustment value of the to-be-adjusted parameters based on the trained first network model and the trained parameter adjustment vector; adjusting parameters of the trained pre-trained model based on the adjustment value of the to-be-adjusted parameters, to obtain a trained target model corresponding to the target task.
2. The method of claim 1, wherein, The method further comprises: obtaining a parameter fine-tuning algorithm used by the trained pre-trained model; determining the to-be-adjusted parameters of the trained pre-trained model and a first parameter dimension of the to-be-adjusted parameters based on the parameter fine-tuning algorithm, the first parameter dimension being M*N, M and N being positive integers.
3. The method of claim 2, wherein, The method further comprises: obtaining a pre-set parameter adjustment vector, wherein a third parameter dimension of the parameter adjustment vector is an R-dimensional vector, R being a positive integer, R being less than M and R being less than N; determining the second parameter dimension based on the first parameter dimension and the third parameter dimension, the second parameter dimension being M*N*R.
4. The method of claim 3, wherein, The method further comprises: constructing a first network model based on the second parameter dimension; obtaining a source task, and obtaining first training data and a first loss function corresponding to the source task; training the first network model and the parameter adjustment vector using the first training data and the first loss function, to obtain a trained first network model and a pre-trained parameter adjustment vector.
5. The method as claimed in claim 1, wherein, The continuing training of the pre-trained partial parameter adjustment vector based on the target task in the field of natural language processing and the trained first network model, to obtain a trained parameter adjustment vector adapted to the target task, comprises: obtaining the target task, and obtaining second training data and a second loss function corresponding to the target task; keeping parameters in the trained first network model unchanged, and continuing training the pre-trained parameter adjustment vector using the second training data and the second loss function, to obtain a trained parameter adjustment vector.
6. The method as claimed in claim 1, wherein, The determining of the adjustment value of the to-be-adjusted parameters based on the trained first network model and the trained parameter adjustment vector comprises: obtain first parameter information of the trained first network model and second parameter information of the trained parameter adjustment vector, wherein the first parameter information is a matrix parameter value of M*N*R; and the second parameter information is a vector parameter value of R dimensions; perform multiplication calculation on the first parameter information and the second parameter information to obtain an adjustment value of the to-be-adjusted parameter.
7. The method of claim 6, wherein, The adjusting the parameter of the trained pre-training model based on the adjustment value of the to-be-adjusted parameter to obtain the trained target model corresponding to the target task comprises: obtaining a current parameter value of each to-be-adjusted parameter in the trained pre-training model; determining an updated parameter value of each to-be-adjusted parameter based on the current parameter value of each to-be-adjusted parameter and the adjustment value of each to-be-adjusted parameter; determining the trained target model corresponding to the target task based on the updated parameter value of each to-be-adjusted parameter and a current parameter value of other parameters of the trained pre-training model except the to-be-adjusted parameters.
8. The method according to any one of claims 1 to 7, characterized in that, The method further comprises: obtaining test data corresponding to the target model, wherein the test data comprises a plurality of test texts and label information corresponding to each test text; performing prediction processing on each test text by using the target model to obtain prediction information corresponding to each test text; determining evaluation information of the target model based on the label information and the prediction information corresponding to each test text; when it is determined that the evaluation information does not reach a preset evaluation threshold, adjusting the parameter of the parameter adjustment vector until the evaluation information of the target model reaches the evaluation threshold.
9. The method according to any one of claims 1 to 7, characterized in that, The method further comprises: obtaining a prediction text corresponding to the target task; performing prediction processing on the prediction text by using the trained target model to obtain a prediction result of the prediction text; and outputting the prediction result of the prediction text.
10. A parameter model adjustment apparatus characterized by comprising: The device comprises: a first obtaining module configured to obtain a pre-training model trained for a source task in a natural language processing field and a first parameter dimension of a to-be-adjusted parameter of the trained pre-training model, wherein the pre-training model is configured to learn general grammar and semantic knowledge according to a context-related representation of each word in each sentence in an input text; a second obtaining module configured to obtain a trained first network model and a pre-trained parameter adjustment vector, wherein a second parameter dimension of the trained first network model is determined based on a third parameter dimension of the pre-trained parameter adjustment vector and the first parameter dimension, and a number of parameters of the pre-trained parameter adjustment vector is less than a number of parameters of the to-be-adjusted parameter; a first training module configured to continue training the pre-trained partial parameter adjustment vector based on a target task in the natural language processing field and the trained first network model to obtain a trained parameter adjustment vector adapted to the target task, wherein the target task is a task similar to the source task in the natural language processing field; and a second training module configured to adjust the parameter of the trained pre-training model based on an adjustment value of the to-be-adjusted parameter to obtain the trained target model corresponding to the target task. The first determining module is configured to determine the adjustment value of the to-be-adjusted parameter based on the trained first network model and the trained parameter adjustment vector. The parameter adjustment module is configured to adjust the parameters of the trained pre-training model based on the adjustment value of the to-be-adjusted parameter, to obtain a trained target model corresponding to the target task.
11. The apparatus of claim 10, wherein, The apparatus further includes: The third obtaining module is configured to obtain a parameter fine-tuning algorithm used for the trained pre-training model. The second determining module is configured to determine the to-be-adjusted parameter of the trained pre-training model and a first parameter dimension of the to-be-adjusted parameter based on the parameter fine-tuning algorithm, the first parameter dimension being M*N, M and N being positive integers.
12. The apparatus of claim 11, wherein, The apparatus further includes: The fourth obtaining module is configured to obtain a preset parameter adjustment vector, wherein a third parameter dimension of the parameter adjustment vector is an R-dimensional vector, R being a positive integer, R being less than M and R being less than N. The third determining module is configured to determine the second parameter dimension based on the first parameter dimension and the third parameter dimension, the second parameter dimension being M*N*R.
13. A computer device, comprising: The computer device includes: The memory is configured to store executable instructions. The processor is configured to execute the executable instructions stored in the memory to implement the method in any one of claims 1 to 9.
14. A computer-readable storage medium storing executable instructions, the method comprising: The executable instructions, when executed by the processor, implement the method in any one of claims 1 to 9.
15. A computer program product comprising computer programs or instructions, characterized in that, The computer program or instructions, when executed by the processor, implement the method in any one of claims 1 to 9.
Citation Information
Patent Citations
Training method and device of multi-task pre-training model, electronic equipment and medium
CN113704388A
Model training method and device, text prediction method and device, electronic equipment and medium
CN113901799A