Large model continuous learning method, electronic equipment, medium and product
By setting local model parameters in the large model and building an orthogonal projection matrix, the catastrophic forgetting problem and large computing resource occupancy in continuous learning are solved, and the effect of resource saving and learning continuity is achieved.
Patent Information
- Application Number
- CN202411570728.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-02-11
AI Technical Summary
The prior art has the flaw of large-scale computer resource occupancy when solving the catastrophic forgetting problem of large models when learning multiple tasks continuously.
By setting local model parameters in the overall model parameters of the large model, including the first low-rank matrix and the second low-rank matrix obtained by low-rank decomposition, the current orthogonal projection matrix is constructed, and the model update gradient is projected using this matrix. to update the first low rank matrix.
Without further decomposition of the low-rank matrix, the catastrophic forgetting problem in the continuous learning process is avoided, the calculation process is simplified, the computing resources are saved, and the problem of excessive computer resource occupation is avoided.
Smart Images

Figure CN119416912A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a large-model continuous learning method, electronic equipment, medium and product. Background Art
[0002] At present, the industry usually adopts solutions based on rearrangement, regularization, and architecture to solve the catastrophic forgetting problem when large models continuously learn multiple tasks. Most of these methods will introduce additional computing and storage overheads. For example, in the existing LoRA (Low-Rank Approximation) architecture solution, the low-rank matrix needs to be further QR decomposition (QR Decomposition, Q is an orthogonal matrix, R is an upper triangular matrix) to complicate the model parameters. Therefore, the existing solutions have the defect of large computer resource usage when solving the catastrophic forgetting problem.
[0003] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of this application is to provide a large-model continuous learning method, electronic device, medium and product, aiming to solve the technical problem that existing solutions occupy a large amount of computer resources when solving the catastrophic forgetting problem.
[0005] To achieve the above object, the present application proposes a large model continuous learning method, wherein the overall model parameters of the large model are provided with local model parameters for updating, and the local model parameters include a first low-rank matrix and a second low-rank matrix obtained by low-rank decomposition, and the large model continuous learning method comprises the following steps:
[0006] For any learning task of the large model in the continuous learning process, when the current training round of the learning task is within the trust region corresponding to the learning task, construct a current orthogonal projection matrix based on the second low-rank matrix, the model input in the training sample corresponding to the current training round, and the orthogonal projection matrix of the previous training round;
[0007] Calculating the model update gradient of the large model based on the training sample, projecting the model update gradient using the current orthogonal projection matrix to obtain a gradient projection result, and updating the first low-rank matrix by using the gradient projection result;
[0008] Enter the next training round of the learning task until the large model reaches the preset training condition of the learning task.
[0009] Optionally, the step of constructing a current orthogonal projection matrix based on the second low-rank matrix, the model input amount in the training sample corresponding to the learning task, and the orthogonal projection matrix of the previous training step includes:
[0010] Taking the product of the second low-rank matrix and the model input as an intermediate matrix;
[0011] An update matrix is calculated based on the intermediate matrix, the preset disturbance matrix and the orthogonal projection matrix of the previous training step;
[0012] The orthogonal projection matrix of the previous training step is subtracted from the update amount matrix to obtain the current orthogonal projection matrix.
[0013] Optionally, the large model continuous learning method further includes:
[0014] When the current training round of the learning task is not within the trust region corresponding to the learning task, the orthogonal projection matrix of the previous training round is used as the current orthogonal projection matrix.
[0015] Optionally, the large model continuous learning method further includes:
[0016] By presetting an initial trust region and the learning order of the learning task in each learning task of the large model, the trust region range corresponding to the learning task is calculated, wherein the trust region range corresponding to the learning task increases and decreases as the learning order increases.
[0017] Optionally, the step of calculating the model update gradient of the large model based on the training sample includes:
[0018] Inputting the model input of the training sample into the large model to obtain the model output;
[0019] Based on the loss function of the learning task and the difference between the model output and the sample labels in the training samples, the model update gradient of the large model is calculated.
[0020] Optionally, the step of using the current orthogonal projection matrix to project the model update gradient to obtain a gradient projection result, and updating the first low-rank matrix by using the gradient projection result includes:
[0021] Multiplying the model update gradient by the current orthogonal projection matrix to obtain the gradient projection result;
[0022] The gradient projection result is subtracted from the first low-rank matrix to obtain a new first low-rank matrix.
[0023] Optionally, when the large model is a semantic recognition model, the learning tasks of the large model continuous learning include semantic recognition tasks for different languages; when the large model is a face recognition model, the learning tasks of the large model continuous learning include face recognition tasks for different skin colors.
[0024] In addition, to achieve the above-mentioned purpose, the present application also proposes a large model continuous learning device, wherein the overall model parameters of the large model are provided with local model parameters for updating, and the local model parameters include a first low-rank matrix and a second low-rank matrix obtained by low-rank decomposition, and the large model continuous learning device includes:
[0025] A construction module, for constructing a current orthogonal projection matrix for any learning task of the large model in the continuous learning process, based on the second low-rank matrix, the model input amount in the training sample corresponding to the current training round, and the orthogonal projection matrix of the previous training round, when the current training round of the learning task is within the trust region corresponding to the learning task;
[0026] An updating module, configured to calculate a model update gradient of the large model based on the training sample, project the model update gradient using the current orthogonal projection matrix to obtain a gradient projection result, and update the first low-rank matrix using the gradient projection result;
[0027] A jump module is used to enter the next training round of the learning task until the large model reaches the preset training condition of the learning task.
[0028] In addition, to achieve the above-mentioned purpose, the present application also proposes an electronic device, which includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the computer program is configured to implement the steps of the large model continuous learning method as described above.
[0029] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the large model continuous learning method described above are implemented.
[0030] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the large model continuous learning method described above.
[0031] One or more technical solutions proposed in this application have at least the following technical effects:
[0032] In an embodiment of the present application, local model parameters for updating are set in the overall model parameters of the large model, and the local model parameters include a first low-rank matrix and a second low-rank matrix obtained by low-rank decomposition. For any learning task of the large model in the continuous learning process, when the current training round of the learning task is within the trust domain corresponding to the learning task, a current orthogonal projection matrix is constructed based on the second low-rank matrix, the model input in the training sample corresponding to the current training round, and the orthogonal projection matrix of the previous training round; the model update gradient of the large model is calculated based on the training sample, the model update gradient is projected using the current orthogonal projection matrix to obtain a gradient projection result, and the first low-rank matrix is updated by the gradient projection result; and the next training round of the learning task is entered until the large model reaches the preset training condition of the learning task. That is, compared to the existing solution that the update of the orthogonal projection matrix mainly depends on the model input, the embodiment of the present application will combine the second low-rank matrix, the model input and the orthogonal projection matrix of the previous training round to construct the current orthogonal projection matrix. Since the second low-rank matrix has a low rank property, it can be used to constrain the dimension of the model input in the training sample corresponding to the current training round, so as to avoid the problem that the dimension of the current orthogonal projection matrix constructed at the end is too large, causing the calculation complexity and causing excessive consumption of computing resources. And the orthogonal projection matrix is equivalent to being integrated into the entire framework, without further QR decomposition, so it can simplify the calculation process while retaining more original information, saving computing resources. At the same time, during the training process, the current positive projection matrix is used to constrain the calculated model update gradient, and the changes in the parameters related to the historical tasks in the model update gradient are removed, so as to avoid forgetting the knowledge learned in the past in the process of performing new learning tasks, thereby causing catastrophic forgetting problems in the continuous learning process. Therefore, in summary, the present application avoids the problem of catastrophic forgetting in the continuous learning process without further decomposing the low-rank matrix, and makes up for the defect that the existing solution needs to occupy a large amount of computer resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0035] Figure 1This is a flow chart of the first embodiment of the large model continuous learning method of the present application;
[0036] Figure 2 This is a flow chart of the second embodiment of the large model continuous learning method of the present application;
[0037] Figure 3 This is a schematic diagram of the model framework involved in the large-model continuous learning method of this application;
[0038] Figure 4 This is a schematic diagram of the structure corresponding to the large-model continuous learning device of this application;
[0039] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the large model continuous learning method in the embodiment of the present application.
[0040] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0041] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0042] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0043] At present, the industry usually adopts solutions based on rearrangement, regularization, and architecture to solve the catastrophic forgetting problem when large models continuously learn multiple tasks. Most of these methods will introduce additional computing and storage overheads. For example, in the existing LoRA (Low-Rank Approximation) architecture solution, the low-rank matrix needs to be further QR decomposition (QR Decomposition, Q is an orthogonal matrix, R is an upper triangular matrix) to complicate the model parameters. Therefore, the existing solutions have the defect of large computer resource usage when solving the catastrophic forgetting problem.
[0044] The main solution of the embodiment of the present application is: for any learning task of the large model in the continuous learning process, when the current training round of the learning task is within the trust domain corresponding to the learning task, construct a current orthogonal projection matrix based on the second low-rank matrix, the model input in the training sample corresponding to the current training round, and the orthogonal projection matrix of the previous training round; calculate the model update gradient of the large model based on the training sample, use the current orthogonal projection matrix to project the model update gradient to obtain a gradient projection result, and update the first low-rank matrix through the gradient projection result; enter the next training round of the learning task until the large model reaches the preset training condition of the learning task.
[0045] Compared with the existing solution that the update of the orthogonal projection matrix mainly depends on the model input, the embodiment of the present application will combine the second low-rank matrix, the model input and the orthogonal projection matrix of the previous training round to construct the current orthogonal projection matrix. Since the second low-rank matrix has low rank, it can be used to constrain the dimension of the model input in the training sample corresponding to the current training round, so as to avoid the problem that the dimension of the current orthogonal projection matrix constructed at the end is too large, causing the calculation complexity and causing excessive consumption of computing resources. And the orthogonal projection matrix is equivalent to being integrated into the entire framework, without further QR decomposition, so it can simplify the calculation process while retaining more original information, saving computing resources. At the same time, during the training process, the current positive projection matrix is used to constrain the calculated model update gradient, and the changes in the parameters related to the historical tasks in the model update gradient are removed, so as to avoid forgetting the knowledge learned in the past in the process of performing new learning tasks, thereby causing catastrophic forgetting problems in the continuous learning process. Therefore, in summary, the present application avoids the problem of catastrophic forgetting in the continuous learning process without further decomposing the low-rank matrix, and makes up for the defect that the existing solution needs to occupy a large amount of computer resources.
[0046] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a cloud platform, a computer, a mobile phone, etc., or an electronic device that can realize the above functions.
[0047] Based on this, the present application embodiment provides a large model continuous learning method, referring to Figure 1 , which is a flow chart of the first embodiment of the large model continuous learning method of the present application.
[0048] In this embodiment, the overall model parameters of the large model are provided with local model parameters for updating, and the local model parameters include a first low-rank matrix and a second low-rank matrix obtained by low-rank decomposition. The large model continuous learning method includes steps S10 to S30:
[0049] Step S10, for any learning task of the large model in the continuous learning process, when the current training round of the learning task is within the trust region corresponding to the learning task, construct a current orthogonal projection matrix based on the second low-rank matrix, the model input in the training sample corresponding to the current training round, and the orthogonal projection matrix of the previous training round;
[0050] It should be noted that a "large model" generally refers to an artificial intelligence model with a large number of parameters, a large amount of training data, and a complex model structure. If the model parameters of the entire large model are to be trained and updated, very large computing resources are required. In this embodiment, local model parameters are set in the overall model parameters of the large model, and the local model parameters are used to update the parameters in the continuous learning process of the large model. That is, in this embodiment, when the large model is continuously learned, the overall model parameters of the large model are not updated, and only the model parameters in the local model parameters are updated, thereby reducing the amount of model parameter updates, reducing the complexity of training, and saving computing resources. At the same time, the local model parameters include the first low-rank matrix and the second low-rank matrix obtained by low-rank decomposition. For example, the original weight matrix W of the large model is assumed to be init ∈R d×k , that is, the original model parameters of the large model, and then set a ΔW for the original model parameters for updating during training, and perform low-rank decomposition on ΔW, that is: W init +ΔW=W init +AB, where W init +AB are the overall model parameters, A is the first low-rank matrix obtained by low-rank decomposition of ΔW, and B is the second low-rank matrix obtained by low-rank decomposition of ΔW, where A∈R d×r ,B∈R r×k , the dimensions of d×r and r×k matrices, and r<<min(d,k). In addition, W init During training, it remains fixed, while A and B contain trainable parameters. Based on the above, the forward propagation process of the large model is: h = W init x+ΔWx=W init x+ABx, where x is the input of the large model and h is the output or intermediate output of the large model.
[0051] It is worth noting that the training process of each learning task in the continuous learning process of the large model is basically the same, so in this embodiment, one of the learning tasks will be used as an example for explanation. Exemplarily, for any learning task of the large model in the continuous learning process, the training sample of the learning task will be used to iteratively train the large model, and the training rounds under the learning task will be recorded. If the current training round of the learning task is within the trust domain corresponding to the learning task, the current orthogonal projection matrix used in the current round is constructed according to the second lowest matrix, the model input in the training sample corresponding to the current training round, and the orthogonal projection matrix used in the above training round.
[0052] Among them, the above-mentioned trust domain range can be characterized by a trust domain radius, and the trust domain radius can be a preset training round set for the learning task. If the current training round is less than the trust domain radius (i.e., the preset training round), it is deemed not to be within the trust domain range corresponding to the learning task. On the contrary, if the current training round is greater than or equal to the trust domain radius, it is deemed to be within the trust domain range corresponding to the learning task. It should be noted that the amount of knowledge learned in the early stage of training for the above-mentioned learning task (i.e., not within the trust domain range corresponding to the learning task) is relatively small, so the orthogonal projection matrix may not be updated temporarily. However, in the later stage of training for the above-mentioned learning task (i.e., within the trust domain range corresponding to the learning task), the amount of knowledge learned is relatively large, and the current orthogonal projection matrix may be updated to retain the historically learned knowledge.
[0053] Among them, the second low-rank matrix can be used to constrain the dimension of the model input in the training sample corresponding to the current training round due to its low rank property, so as to avoid the problem that the dimension of the current orthogonal projection matrix constructed at last is too large, resulting in complex calculation and excessive consumption of computing resources. In the existing scheme, the update of the orthogonal projection matrix mainly depends on the model input, that is, the dimension of the orthogonal projection matrix in the existing scheme will increase with the increase of the dimension of the model input. Therefore, when the dimension of the model input is large, the dimension of the orthogonal projection matrix will be too large.
[0054] In addition, since the current orthogonal projection matrix in the present application is constructed based on the second low-rank matrix, the model input in the training sample corresponding to the current training round, and the orthogonal projection matrix of the previous training round, it is equivalent to the present application integrating the orthogonal projection matrix in the LoRA (Low-Rank Approximation) framework and using it for gradient update, avoiding the need for further QR decomposition of the low-rank matrix in the LoRA scheme, and can simplify the calculation process while retaining more original information, saving computing resources.
[0055] Step S20, calculating the model update gradient of the large model based on the training sample, using the current orthogonal projection matrix to project the model update gradient to obtain a gradient projection result, and updating the first low-rank matrix by the gradient projection result;
[0056] Exemplarily, after obtaining the current orthogonal projection matrix, the model update gradient of the above-mentioned large model is calculated based on the above-mentioned training samples. For example, the model input in the training sample is input into the large model to obtain the model output result of the large model, and then the model update gradient is calculated based on the difference between the label of the training sample and the output result of the model. It is worth noting that the model update gradient is not directly used for updating, but the model update gradient is first multiplied by the current orthogonal projection matrix (i.e., projected) to constrain the model update gradient to obtain the gradient projection result, thereby removing the changes in the parameters related to the historical tasks in the model update gradient, so as to avoid forgetting the knowledge learned in the past during the new learning task. Finally, the gradient projection result is used to update the above-mentioned first low-rank matrix. Specifically, the update algorithm can be selected by the technician, and will not be repeated here.
[0057] Step S30, entering the next training round of the learning task until the large model reaches the preset training condition of the learning task.
[0058] Exemplarily, after the first low-rank matrix is updated, it is equivalent to completing the current round of training. At this point, the next training round of the learning task can be entered until the large model reaches the preset training condition of the learning task. For example, the preset training condition can be a preset end training round. If the training round of the large model under the learning task reaches the preset end training round of the learning task, the above learning task can be ended, and then the training of the next learning task can be entered.
[0059] It can be understood that in this embodiment, local model parameters for updating are set in the overall model parameters of the large model, and the local model parameters include a first low-rank matrix and a second low-rank matrix obtained by low-rank decomposition. For any learning task of the large model in the continuous learning process, when the current training round of the learning task is within the trust domain corresponding to the learning task, a current orthogonal projection matrix is constructed based on the second low-rank matrix, the model input in the training sample corresponding to the current training round, and the orthogonal projection matrix of the previous training round; the model update gradient of the large model is calculated based on the training sample, the model update gradient is projected using the current orthogonal projection matrix to obtain a gradient projection result, and the first low-rank matrix is updated by the gradient projection result; and the next training round of the learning task is entered until the large model reaches the preset training condition of the learning task. That is, compared to the existing solution that the update of the orthogonal projection matrix mainly depends on the model input, the embodiment of the present application will combine the second low-rank matrix, the model input and the orthogonal projection matrix of the previous training round to construct the current orthogonal projection matrix. Since the second low-rank matrix has a low rank property, it can be used to constrain the dimension of the model input in the training sample corresponding to the current training round, so as to avoid the problem that the dimension of the current orthogonal projection matrix constructed at the end is too large, causing the calculation complexity and causing excessive consumption of computing resources. And the orthogonal projection matrix is equivalent to being integrated into the entire framework, without further QR decomposition, so it can simplify the calculation process while retaining more original information, saving computing resources. At the same time, during the training process, the current positive projection matrix is used to constrain the calculated model update gradient, and the changes in the parameters related to the historical tasks in the model update gradient are removed, so as to avoid forgetting the knowledge learned in the past in the process of performing new learning tasks, thereby causing catastrophic forgetting problems in the continuous learning process. Therefore, in summary, the present application avoids the problem of catastrophic forgetting in the continuous learning process without further decomposing the low-rank matrix, and makes up for the defect that the existing solution needs to occupy a large amount of computer resources.
[0060] In a feasible real-time manner, the step of constructing a current orthogonal projection matrix based on the second low-rank matrix, the model input in the training sample corresponding to the learning task, and the orthogonal projection matrix of the previous training step includes steps S11 to S13:
[0061] Step S11, taking the product of the second low-rank matrix and the model input as an intermediate matrix;
[0062] Step S12, calculating an update matrix based on the intermediate matrix, the preset disturbance matrix and the orthogonal projection matrix of the previous training step;
[0063] Step S13, subtracting the update amount matrix from the orthogonal projection matrix of the previous training step to obtain the current orthogonal projection matrix.
[0064] Exemplarily, the product of the second low-rank matrix and the model input is used as an intermediate matrix, and then the actual intermediate matrix, the preset perturbation matrix and the orthogonal projection matrix of the training step are used to calculate the update matrix, and finally the text projection matrix of the previous training step is subtracted from the update matrix to obtain the current orthogonal projection matrix. Exemplarily, the update formula for updating the current orthogonal projection matrix by updating the previous training step is as follows:
[0065] P=P pre -P pre C(αI+C T P pre C)C T P pre
[0066] Where P is the current projection matrix, P pre is the orthogonal projection matrix of the previous training step, C is the above intermediate matrix and C = Bx, B∈R r×k , B is the second low-rank matrix mentioned above, x is the model input, αI is the preset disturbance matrix, which can be set by the technician according to the needs, and T represents the transpose of the matrix.
[0067] In a feasible implementation, the large language model may have multiple functions, such as a semantic recognition model and a face recognition model. When the large model is a semantic recognition model, the learning tasks of the large model continuous learning include semantic recognition tasks for different languages; when the large model is a face recognition model, the learning tasks of the large model continuous learning include face recognition tasks for different skin colors.
[0068] Exemplarily, if the above-mentioned large model is a semantic recognition model, the learning tasks of the large language model during continuous learning may include semantic recognition tasks for different languages, such as Chinese semantic recognition tasks and English semantic recognition tasks. By continuously learning the semantic recognition tasks of these two different languages, the trained large model can integrate the semantic recognition functions of different languages and ensure the accuracy of semantic recognition. If the above-mentioned large language model is a face recognition model, the learning tasks of the large language model during continuous learning may include semantic recognition tasks for different languages, such as yellow skin face recognition tasks, black skin face recognition tasks, and white skin face recognition tasks. By continuously learning the semantic recognition tasks of different skin colors, the trained large model can integrate the face recognition functions of different skin colors, thereby further improving the versatility of the face recognition model.
[0069] In a feasible implementation manner, the step of calculating the model update gradient of the large model based on the training sample includes steps S211 to S212:
[0070] Step S211, inputting the model input of the training sample into the large model to obtain the model output;
[0071] Step S212, based on the loss function of the learning task and the difference between the model output and the sample label in the training sample, calculate the model update gradient of the large model.
[0072] Exemplarily, in this embodiment, the training process of the above-mentioned semantic recognition and face recognition will be taken as an example for explanation. For example, in the case where the large model is a semantic recognition model, in different continuous learning tasks, the above-mentioned training samples can be natural language texts in different languages. Inputting the natural language text into the large model can perform context prediction based on part of the text in the natural language text to obtain the context prediction result, that is, the output of the above-mentioned model. The sample label of the training sample is the real context of the part of the text in the natural language text. The context prediction result and the real context are substituted into the loss function of the learning task to calculate the model update gradient of the large model. It is worth noting that the difference between the context prediction result and the real context is usually calculated in the loss function, and the specific loss function can be set by the technician according to actual needs, which will not be repeated here.
[0073] If the large model is a face recognition model, in different continuous learning tasks, the training samples can be labeled face images of different skin colors. Accordingly, the face images in the training samples are input into the large model, and the large model performs recognition based on the face images to obtain the recognition results (i.e., the output of the model, such as outputting a certain user). Similarly, the recognition results and sample labels are substituted into the loss function of the learning task, and the model update gradient of the large model is calculated through the loss function.
[0074] In a feasible implementation manner, the step of using the current orthogonal projection matrix to project the model update gradient to obtain a gradient projection result, and updating the first low-rank matrix by the gradient projection result includes steps S221 to S222:
[0075] Step S221, multiplying the model update gradient by the current orthogonal projection matrix to obtain the gradient projection result;
[0076] Step S222: subtract the gradient projection result from the first low-rank matrix to obtain a new first low-rank matrix.
[0077] It should be noted that the model update gradient obtained in the above process is an abstract regular feature learned based on the training samples in a specific scenario, so this embodiment will not take a specific application scenario as an example.
[0078] Exemplarily, the model update gradient is multiplied by the current orthogonal projection matrix to obtain a gradient projection result, and then the gradient projection result is subtracted from the first low-rank matrix to obtain a new first low-rank matrix, or the gradient projection result is multiplied by a preset learning rate, and then the first low-rank matrix is subtracted from the result of multiplying the gradient projection result by the preset learning rate to obtain a new first low-rank matrix, thereby completing the update of the first low-rank matrix. Exemplarily, the update formula of the first low-rank matrix is as follows:
[0079]
[0080] Where A is the new first low-rank matrix, A pre is the first low-rank matrix, λ is the learning rate, Update the gradient for the above model, where P is the current orthographic projection matrix.
[0081] Reference Figure 2 , which is a flow chart of the second embodiment of the present application proposed based on the first embodiment of the present application. In this embodiment, the same or similar contents as those in the above embodiment can be referred to the above introduction, and will not be repeated later. The large model continuous learning method also includes step S100, step S20 and step S30:
[0082] Step S100, when the current training round of the learning task is not within the trust region corresponding to the learning task, using the orthogonal projection matrix of the previous training round as the current orthogonal projection matrix;
[0083] Step S200, calculating the model update gradient of the large model based on the training sample, using the current orthogonal projection matrix to project the model update gradient to obtain a gradient projection result, and updating the first low-rank matrix by the gradient projection result;
[0084] Step S300, entering the next training round of the learning task until the large model reaches the preset training condition of the learning task.
[0085] Exemplarily, for another situation in the present application, when the training samples of the learning task are used to iteratively train the large model, if the current training round of the learning task is not within the trust domain corresponding to the learning task, that is, when the current training round is less than the trust domain radius, it is deemed not to be within the trust domain corresponding to the learning task. It can be understood that this situation is equivalent to being in the early stage of model training under the learning task, and the amount of knowledge learned is small, so the orthogonal projection matrix can be temporarily not updated. Correspondingly, the orthogonal projection matrix of the above training rounds can be used as the current orthogonal projection matrix. In addition, the contents of step S200 and step S300 are the same as those of step S20 and step S30, so the description of the above embodiment can be referred to and will not be repeated here.
[0086] In a feasible implementation manner, the large model continuous learning method further includes step S01:
[0087] Step S01, by presetting an initial trust region and the learning order of the learning task in each learning task of the large model, calculate the trust region range corresponding to the learning task, wherein the trust region range corresponding to the learning task increases and decreases with the learning order.
[0088] Exemplarily, the trust region range corresponding to the above learning task can be calculated by presetting the initial trust region and the learning order of the learning task in each learning task of the above large model (i.e., the order of learning). And the calculated trust region range corresponding to the learning task is proportional to the learning order, that is, the later the learning order of the learning task, the smaller the trust region range corresponding to the learning task (i.e., the larger the trust region radius of the trust region range). Exemplarily, the calculation formula for the trust region range corresponding to the trust region radius is as follows:
[0089] R j =Re j / τ
[0090] In the formula, R j To calculate the trust region radius of the trust region range of the jth learning task, R is the initial trust region radius, τ is the temperature hyperparameter, and j is the current training round in the current learning task.
[0091] It is understandable that in this embodiment, the trust region radius can be adaptively adjusted according to the learning order of the current learning task in each learning task, thereby avoiding the problem of information loss caused by using a fixed trust region radius. At the same time, the adaptive adjustment formula of the trust region radius is simple to calculate and does not require excessive computing resources.
[0092] In addition, combining the two situations of the current training round mentioned above, the orthogonal projection matrix update formula is as follows:
[0093] Where P is the current projection matrix, P pre is the orthogonal projection matrix of the previous training step, C is the above intermediate matrix and C = Bx, B∈R r×k , B is the second low-rank matrix, x is the model input, αI is the preset disturbance matrix, which can be set by technicians according to needs, T represents the transpose of the matrix, N j represents the total number of training rounds for the jth learning task, R j represents the trust region radius of the jth learning task, and i represents the i-th round in the current learning task. In addition, the initial projection matrix is P 0 =I 0 / β, where β is a hyperparameter, I 0 ∈R r×r is the identity matrix.
[0094] In order to clearly explain the scope of the trust region in the embodiment of the present application, a specific example is used for explanation. It is assumed that the real mapping law of the current task is φ(φ∈F, the function space), that is, φ is the model parameter under the ideal state, and the knowledge actually learned by the model is recorded as Obviously, the more reliable the knowledge learned by the model, the The closer the distance to φ is. For any mapping function φ, the trust region with radius r is the set of the following functions:
[0095]
[0096] The above norm ||a|| * Characterizing the bi-norm:
[0097]
[0098] Among them, that is, ||a|| * is the Euclidean norm, D is the set of current learning tasks, is the output of the large model with respect to the input x.
[0099] In practical applications, the actual mapping φ of the model is usually unknown. In order to describe the trust region more realistically, an approximate value is used instead of φ to give a posterior estimation method. Assume that the neural network is trained for a total of N stages in the current task, and the actual mapping learned in each training stage is recorded as make: The trust region representation is approximated by the following set:
[0100]
[0101] In the formula, the ideal mapping law φ is finally learned by the mapping To simplify the calculation, the distance It is further approximated by the absolute value of the difference in the training phase, where the positive integer R c As a hyperparameter, we can adjust the radius of the trust region. In practical applications, the radius R c Adaptive adjustment is possible. A simple way is to introduce formula R c =R j =Re j / τ , where R represents the initial trust region radius, j represents the jth learning task, and τ is a temperature hyperparameter.
[0102] In order to clearly illustrate the updating formula of the orthogonal projection matrix in the embodiment of the present application, a specific example will be given below for explanation.
[0103] Assume that in the first training round of a large model (such as DNNS, Deep Neural Network Structure), the input vector (i.e., the input amount of the large model) is composed of Ignoring the activation function of the large model, the goal of feedforward neural network training in the large model is to find a set of weight structures that approximately satisfy the following equation:
[0104]
[0105] In the formula, C 1 is the input of the first round of the model, is the label corresponding to the model input in the current learning task, the superscript 1 indicates the first round of training, and W i (i=0,1,…,L) is the weight of each layer of the network, L is the number of layers of the feedforward neural network, and the above equation only involves matrix multiplication. Generally speaking, the above equation is an underdetermined system of equations and there is no unique solution. Therefore, the purpose of feedforward neural network training is to find a set of weights W i (i=0,1,…,L)(In this embodiment of the application, W i The resultant force is denoted as W (1) ,) makes Reach the minimum. Assume that a small disturbance αI is added to it m (m represents the dimension of the model input), that is: At this point, we can get the ideal result: According to the Sherman-Morrison-Woodbury formula, we can get Right now:
[0106]
[0107] When the large model is trained in the next round (i.e. the second training round), new data is introduced C 2 is the input of the second round of the model, The label for the second round needs to be
[0108]
[0109] To achieve the minimum, let:
[0110]
[0111] According to the above derivation, we can get:
[0112]
[0113] Where W (2) is a set of ideal weights found in the second round of training, and Expands into the following form:
[0114]
[0115] Will Substitute the expanded result into the above W (2) From the approximate equation we can get:
[0116]
[0117] Applying the Sherman-Morrison-Woodbury formula again yields:
[0118]
[0119] To obtain the recursive form of the orthogonal projection matrix, let P 0 =I m ,Will Written in the following form:
[0120]
[0121] Among them, Then Substitute the above In the equation, we get:
[0122]
[0123] in,
[0124] According to the above derivation, this paper can obtain the recursive formula for calculating the orthogonal projection matrix:
[0125]
[0126] In which, assuming that P pre =P k ,C=C k+1 ,I=I m , then the above formula can be simplified into the following form:
[0127] P=P pre -P pre C(αI+C T P pre C)C T P pre
[0128] The above formula is also the orthogonal matrix update formula in the embodiment of the present application when it is within the trust region.
[0129] Reference Figure 3 , is a schematic diagram of the model framework in this application. As shown in the figure, Figure 3 Where x is the input of the model, and the output h will be obtained by passing through the original weight matrix Winit and the AB matrix. In the process of model training, the parameters in the matrix A are mainly updated, such as Figure 3 As shown, it includes low errors of task A and low errors of task B. When the parameters of matrix A are in the low error of task A, it means that good results can be achieved in task A. When they are in the low error of task B, it means that good results can be achieved in task B. Now we conduct continuous learning for task A and task B. We first conduct continuous learning for task A, so that the model parameters of matrix A are In the figure Represents the direction of the model gradient during the update process of task A. Now learn based on task B. If no constraints are imposed, the model parameters of matrix A are Will be updated to Figure 3 In If constraints are imposed (i.e., the orthogonal projection in this application), the model parameters Update to Therefore, the model parameters of the final matrix A will fall into the overlapping area of the low error of task A and the low error of task B, so that the model has good effects on both tasks A and B.
[0130] The present application also provides a large model continuous learning device, wherein the overall model parameters of the large model are provided with local model parameters for updating, wherein the local model parameters include a first low-rank matrix and a second low-rank matrix obtained by low-rank decomposition, and the reference Figure 4 , the large model continuous learning device comprises:
[0131] A construction module 10 is used to construct a current orthogonal projection matrix for any learning task of the large model in the continuous learning process, based on the second low-rank matrix, the model input in the training sample corresponding to the current training round, and the orthogonal projection matrix of the previous training round, when the current training round of the learning task is within the trust region corresponding to the learning task;
[0132] An updating module 20, configured to calculate a model update gradient of the large model based on the training sample, project the model update gradient using the current orthogonal projection matrix to obtain a gradient projection result, and update the first low-rank matrix using the gradient projection result;
[0133] The jump module 30 is used to enter the next training round of the learning task until the large model reaches the preset training condition of the learning task.
[0134] Optionally, the building module 10 is further used for:
[0135] Taking the product of the second low-rank matrix and the model input as an intermediate matrix;
[0136] An update matrix is calculated based on the intermediate matrix, the preset disturbance matrix and the orthogonal projection matrix of the previous training step;
[0137] The orthogonal projection matrix of the previous training step is subtracted from the update amount matrix to obtain the current orthogonal projection matrix.
[0138] Optionally, the building module 10 is further used for:
[0139] When the current training round of the learning task is not within the trust region corresponding to the learning task, the orthogonal projection matrix of the previous training round is used as the current orthogonal projection matrix.
[0140] Optionally, the large model continuous learning device further includes an adaptive module 40, and the adaptive module 40 is further used for:
[0141] By presetting an initial trust region and the learning order of the learning task in each learning task of the large model, the trust region range corresponding to the learning task is calculated, wherein the trust region range corresponding to the learning task increases and decreases as the learning order increases.
[0142] Optionally, the updating module 20 is further configured to:
[0143] Inputting the model input of the training sample into the large model to obtain the model output;
[0144] Based on the loss function of the learning task and the difference between the model output and the sample labels in the training samples, the model update gradient of the large model is calculated.
[0145] Optionally, the updating module 20 is further configured to:
[0146] Multiplying the model update gradient by the current orthogonal projection matrix to obtain the gradient projection result;
[0147] The gradient projection result is subtracted from the first low-rank matrix to obtain a new first low-rank matrix.
[0148] Optionally, when the large model is a semantic recognition model, the learning tasks of the large model continuous learning include semantic recognition tasks for different languages; when the large model is a face recognition model, the learning tasks of the large model continuous learning include face recognition tasks for different skin colors.
[0149] The large-model continuous learning device provided by the present application adopts the large-model continuous learning method in the above-mentioned embodiment, which can solve the technical problem that the existing solution has large computer resource occupation when solving the catastrophic forgetting problem. Compared with the prior art, the beneficial effects of the large-model continuous learning device provided by the present application are the same as the beneficial effects of the large-model continuous learning method provided by the above-mentioned embodiment, and the other technical features in the large-model continuous learning device are the same as the features disclosed in the above-mentioned embodiment method, which will not be repeated here.
[0150] The present application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the large model continuous learning method in the above-mentioned embodiment one.
[0151] Reference below Figure 5 , which shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to mobile terminals such as computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), and fixed terminals such as computers. Figure 5 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0152] like Figure 5 As shown, the electronic device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the electronic device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an electronic device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0153] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0154] The electronic device provided by the present application adopts the large model continuous learning method in the above embodiment, which can solve the technical problem that the existing solution has large computer resource occupation when solving the catastrophic forgetting problem. Compared with the prior art, the beneficial effects of the electronic device provided by the present application are the same as the beneficial effects of the large model continuous learning method provided by the above embodiment, and the other technical features in the electronic device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0155] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0156] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0157] The present application provides a computer-readable storage medium having computer-readable program instructions (i.e., computer programs) stored thereon, and the computer-readable program instructions are used to execute the large model continuous learning method in the above-mentioned embodiment.
[0158] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0159] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0160] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by an electronic device, the electronic device:
[0161] For any learning task of the large model in the continuous learning process, when the current training round of the learning task is within the trust region corresponding to the learning task, construct a current orthogonal projection matrix based on the second low-rank matrix, the model input in the training sample corresponding to the current training round, and the orthogonal projection matrix of the previous training round;
[0162] Calculating the model update gradient of the large model based on the training sample, projecting the model update gradient using the current orthogonal projection matrix to obtain a gradient projection result, and updating the first low-rank matrix by using the gradient projection result;
[0163] Enter the next training round of the learning task until the large model reaches the preset training condition of the learning task.
[0164] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0165] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0166] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0167] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned large-model continuous learning method, and can solve the technical problem that the existing solutions occupy large computer resources when solving the catastrophic forgetting problem. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the large-model continuous learning method provided in the above-mentioned embodiment, and will not be repeated here.
[0168] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the large model continuous learning method as described above.
[0169] The computer program product provided in this application can solve the technical problem of large model continuous learning. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the large model continuous learning method provided in the above embodiment, which will not be repeated here.
[0170] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A large model continuous learning method, characterized in that: The overall model parameters of the large model are provided with local model parameters for updating, wherein the local model parameters include a first low-rank matrix and a second low-rank matrix obtained by low-rank decomposition, and the large model continuous learning method includes the following steps: For any learning task of the large model in the continuous learning process, when the current training round of the learning task is within the trust region corresponding to the learning task, construct a current orthogonal projection matrix based on the second low-rank matrix, the model input in the training sample corresponding to the current training round, and the orthogonal projection matrix of the previous training round; Calculating the model update gradient of the large model based on the training sample, projecting the model update gradient using the current orthogonal projection matrix to obtain a gradient projection result, and updating the first low-rank matrix by using the gradient projection result; Enter the next training round of the learning task until the large model reaches the preset training condition of the learning task.
2. The large model continuous learning method according to claim 1, characterized in that: The step of constructing a current orthogonal projection matrix based on the second low-rank matrix, the model input in the training sample corresponding to the learning task, and the orthogonal projection matrix of the previous training step includes: Taking the product of the second low-rank matrix and the model input as an intermediate matrix; An update matrix is calculated based on the intermediate matrix, the preset disturbance matrix and the orthogonal projection matrix of the previous training step; The orthogonal projection matrix of the previous training step is subtracted from the update amount matrix to obtain the current orthogonal projection matrix.
3. The large model continuous learning method according to claim 1, characterized in that: The large model continuous learning method also includes: When the current training round of the learning task is not within the trust region corresponding to the learning task, the orthogonal projection matrix of the previous training round is used as the current orthogonal projection matrix.
4. The large model continuous learning method according to claim 1, characterized in that: The large model continuous learning method also includes: By presetting an initial trust region and the learning order of the learning task in each learning task of the large model, the trust region range corresponding to the learning task is calculated, wherein the trust region range corresponding to the learning task increases and decreases as the learning order increases.
5. The large model continuous learning method according to claim 1, characterized in that: The step of calculating the model update gradient of the large model based on the training sample comprises: Inputting the model input of the training sample into the large model to obtain the model output; Based on the loss function of the learning task and the difference between the model output and the sample labels in the training samples, the model update gradient of the large model is calculated.
6. The large model continuous learning method according to claim 1, characterized in that: The step of using the current orthogonal projection matrix to project the model update gradient to obtain a gradient projection result, and updating the first low-rank matrix by using the gradient projection result comprises: Multiplying the model update gradient by the current orthogonal projection matrix to obtain the gradient projection result; The gradient projection result is subtracted from the first low-rank matrix to obtain a new first low-rank matrix.
7. The large model continuous learning method according to claim 1, characterized in that: When the large model is a semantic recognition model, the learning tasks of the large model continuous learning include semantic recognition tasks for different languages; when the large model is a face recognition model, the learning tasks of the large model continuous learning include face recognition tasks for different skin colors.
8. An electronic device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of large model continuous learning as described in any one of claims 1 to 7.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of continuous learning of a large model as described in any one of claims 1 to 7 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of large model continuous learning according to any one of claims 1 to 7 are implemented.