Lightweight continuous fine tuning method based on sparse matrix

Through a lightweight continuous fine-tuning method based on sparse matrix, the matrix low-rank decomposition of the fine-tuning weights of the large model is carried out, and the shared and professional weight matrix is ​​constructed, which solves the problem of fine-tuning of the large model on multiple data sets, and realizes the efficient application of the model in specific fields and the maintenance of generalization capabilities.

CN119782814AInactive Publication Date: 2025-04-08PEKING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411836817.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-04-08
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing fine-tuning techniques for large models are difficult to achieve continuous fine-tuning on multiple data sets, resulting in poor application of models in specific fields and prone to loss of generalization and universality.

Method used

A lightweight continuous fine-tuning method based on sparse matrix is ​​adopted, and the matrix low-rank decomposition is carried out on the fine-tuning weights, and a shared weight matrix is ​​constructed and a continuous learning professional weight matrix are realized to achieve fine-tuning training on multiple downstream data sets.

Benefits of technology

This method can complete the fine-tuning of the large model on multiple data sets at very low parameters, balance the universality and professionalism between multiple data sets, and improve the accuracy of the model on downstream data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782814A_ABST
    Figure CN119782814A_ABST
Patent Text Reader

Abstract

The invention discloses a lightweight continuous fine tuning method based on a sparse matrix, and belongs to the technical field of computer vision. According to the method, a sparse matrix and a matrix decomposition technology are used, low-rank decomposition is carried out on a sparse matrix required by fine tuning, a shared weight matrix and a continuous learning professional weight matrix are constructed, and then fine tuning training of a plurality of downstream data sets is completed. According to the method, the performance of various universal large models on a downstream data set can be improved, the method has universality, does not depend on a specific network architecture, is suitable for all current visual, language and multi-modal large models, is simple and convenient, and can effectively improve the precision on downstream data on the basis of retaining generalization and universality of the large models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer vision technology, and relates to a lightweight continuous fine-tuning method for a neural network model using computer vision and deep learning technology, and in particular to a lightweight continuous fine-tuning method based on a sparse matrix, which can solve fine-tuning problems in various fields. Background Art

[0002] In recent years, the research and application of machine learning has achieved rapid development. In this field, deep learning methods have achieved major breakthroughs in many application fields such as computer vision, speech processing and machine translation. With the rapid development of deep learning technology and hardware computing power, the parameter scale and training data volume of deep neural network models have continued to expand. Researchers have found that by expanding the number of model parameters and increasing training data, the performance and generalization of neural network models can be enhanced, and even "emergence" phenomena can occur, greatly improving performance in some tasks.

[0003] Compared with traditional artificial intelligence technologies such as deep learning, this type of large model shows good generalization and versatility. However, in specific fields, such as medicine and oil and gas, this type of large model does not work well. Therefore, in order to adapt to these fields, the large model needs to be fine-tuned.

[0004] During the fine-tuning process, if all parameters of the entire model are trained directly, the cost is high and the model is likely to lose its original good generalization and versatility. To solve this problem, researchers have proposed many lightweight fine-tuning methods, such as using prompt words or sparse matrices. However, the existing fine-tuning methods can only be used for a single downstream dataset, and cannot continuously fine-tune multiple datasets, which limits their application in real scenarios.

[0005] Therefore, there are still certain bottlenecks in the existing fine-tuning technology for large models, and the actual application potential is not high and the effect is poor. Summary of the invention

[0006] In order to overcome the above-mentioned deficiencies of the prior art, the present invention provides a lightweight continuous fine-tuning method based on sparse matrices, which completes the fine-tuning of large models on multiple data sets with extremely low parameter counts, while balancing the universality and specialization among multiple data sets.

[0007] The technical solution of the present invention is:

[0008] A lightweight continuous fine-tuning method based on a sparse matrix, the steps of which include:

[0009] S1. Set a new fine-tuning weight A for each layer weight of a given large model;

[0010] S2. Perform matrix low-rank decomposition on each fine-tuning weight A to obtain three low-rank sparse matrices:

[0011] A=G 1 ×G 2 ×G 3

[0012] Among them, G 1 , G 2 , G 3 They are all low-rank matrices, and their matrix dimensions are C 1 × 1 , r 1 ×C 2 × 2 and r 2 ×N,C 1 is the input dimension of each layer weight of the original model, C 2 is the output dimension of each layer weight of the original model, r 1 and r 2 They are respectively represented as the rank of the low-rank matrix, and N represents the number of professional datasets;

[0013] S3. Given the input x and annotation y of a general dataset, the large model encodes the input using each layer’s weights and three low-rank sparse matrices to obtain the output:

[0014] y ′ =f(W 0 +A,x)

[0015] Where f(·) represents the large model, y′ represents the obtained model output, and W 0 Represents the original weight parameters of the large model;

[0016] S4, by calculating the loss between the output y′ of the large model and the labeled y, the model is trained using gradient back propagation to update three low-rank sparse matrices;

[0017] S5. Given the input x of the i-th professional dataset i With label y i , load the three updated low-rank sparse matrices in S4, freeze G 1 , G 2 The parameters of G remain unchanged and only G is adjusted 3 Parameters, use each layer weight and 3 low-rank sparse matrices to encode the input and get the output:

[0018] y i ′ =f(W 0 +A i ,x i )

[0019] Among them, Ai Represents G 3 The i-th dimension of

[0020] S6. By calculating the output y of the large model i ′ and label y i The loss between them is used to train the large model on the i-th professional dataset using gradient back propagation; the low-rank sparse matrix G is updated 3 ;

[0021] S7. Given more professional data sets, repeat S5-S6 until all professional data sets are trained.

[0022] Furthermore, the architecture of the given large model adopts ResNet, EfficientNet, SwinTransformer, VoVNetV2, ConvNeXt or ViT series.

[0023] Furthermore, during the training process, 1 and r 2 It is adjusted as a hyperparameter.

[0024] Furthermore, the loss function in steps S4 and S6 adopts the loss function when the large model is trained on large-scale data.

[0025] Furthermore, in steps S4 and S6, the gradient back-propagation algorithm adopts SGD or Adam series.

[0026] Compared with the prior art, the present invention has the following beneficial effects:

[0027] The present invention provides a lightweight continuous fine-tuning method based on sparse matrices, and proposes the use of sparse matrices and matrix decomposition technology to perform low-rank decomposition on the sparse matrices required for fine-tuning, construct shared weight matrices and continuously learn professional weight matrices, and then complete fine-tuning training on multiple downstream data sets. The present invention can improve the performance of various general large models on downstream data sets. The lightweight continuous fine-tuning method based on sparse matrices of the present invention is universal, does not rely on a specific network architecture, and is applicable to all current visual, language and multimodal large models. The method is simple and convenient, and can effectively improve the accuracy on downstream data while retaining the generalization and general capabilities of the large model. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 This is a lightweight continuous fine-tuning flow chart based on sparse matrix proposed in the present invention.

[0029] Figure 2 It is a schematic diagram of the sparse matrix and matrix decomposition proposed by the present invention. DETAILED DESCRIPTION

[0030] The present invention proposes a lightweight continuous fine-tuning method based on a sparse matrix. The present invention is further described below through embodiments in conjunction with the accompanying drawings, but the scope of the present invention is not limited in any way.

[0031] The present invention is based on a lightweight continuous fine-tuning method of sparse matrix, such as Figure 1 As shown, the following steps are included:

[0032] S1. Given a large model, set a new fine-tuning weight A for each layer of the large model. The architecture of the large model can generally adopt but is not limited to ResNet, EfficientNet, SwinTransformer, VoVNetV2, ConvNeXt, ViT and other series with a certain depth level.

[0033] S2, such as Figure 2 As shown, a matrix low-rank decomposition is performed on each fine-tuning weight A to obtain three low-rank sparse matrices:

[0034] A=G 1 ×G ′ ×G 3

[0035] Among them, G 1 , G 2 , G 3 They are all low-rank matrices, and their matrix dimensions are C 1 × 1 , r 1 ×C 2 × 2 and r 2 ×N,C 1 is the input dimension of each layer weight of the original model, C 2 is the output dimension of each layer weight of the original model, r 1 and r 2 They are respectively represented as the ranks of the low-rank matrices, which can be adjusted as hyperparameters during the training process. N represents the number of datasets in the process of continuous fine-tuning of professional datasets. The above three low-rank sparse matrices are the shared weight matrices G 1 、N 2 and the continuous learning professional weight matrix G 3 .

[0036] S3. Given the input x and annotation y of a general dataset, the large model encodes the input using each layer’s weights and three low-rank sparse matrices to obtain the output:

[0037] y ′ =f(W 0 +A,x)

[0038] Where f(·) represents the large model, y′ represents the obtained model output, and W 0 Represents the original weight parameters of the large model.

[0039] S4. By calculating the loss between the output y′ of the large model and the labeled y, the model is trained using gradient back propagation to update the three low-rank sparse matrices. The loss function can usually be used but not limited to the loss function of the large model when it is trained on large-scale data, and the gradient back propagation algorithm can usually be used but not limited to the SGD and Adam series.

[0040] S5. Given the input x of the i-th professional dataset i With label y i , load the three updated low-rank sparse matrices in S4, freeze G 1 , G 2 The parameters of G remain unchanged and only G is adjusted 3 Parameters, use each layer weight and 3 low-rank sparse matrices to encode the input and get the output:

[0041] y i ′ =f(W 0 +A i ,x i )

[0042] Among them, A i Represents G 3 The i-th dimension of .

[0043] S6. By calculating the output y of the large model i ′ and label y i The loss between , gradient back propagation is used to train the large model on the i-th professional dataset. Among them, the loss function can usually be used but not limited to the loss function when the large model is trained on large-scale data, and the gradient back propagation algorithm can usually be used but not limited to the SGD and Adam series.

[0044] S7. Given more professional data sets, repeat S5-S6 until all professional data sets are trained.

[0045] The above-mentioned lightweight continuous fine-tuning method can complete the fine-tuning of large models on multiple datasets with extremely low parameter count, while balancing the universality and specialization among multiple datasets.

[0046] It should be noted that the purpose of publishing the embodiments is to help further understand the present invention, but those skilled in the art can understand that various substitutions and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the present invention should not be limited to the contents disclosed in the embodiments, and the scope of protection claimed by the present invention shall be subject to the scope defined in the claims.

Claims

1. A lightweight continuous fine-tuning method based on sparse matrix, the steps of which include: S1. Set a new fine-tuning weight A for each layer weight of a given large model; S2. Perform matrix low-rank decomposition on each fine-tuning weight A to obtain three low-rank sparse matrices: A=G1×G2×G3 Among them, G1, G2, and G3 are all low-rank matrices, and their matrix dimensions are C1×r1, r1×C2×r2, and r2×N, respectively. C1 is the input dimension of the weight of each layer of the original large model, C2 is the output dimension of the weight of each layer of the original large model, and r1 and r2 represent the ranks of the low-rank matrices respectively; S3. Given the input x and annotation y of a general dataset, the large model encodes the input using each layer’s weights and three low-rank sparse matrices to obtain the output: y′=f(W0+A,x) Where f(·) represents the large model, y′ represents the obtained model output, and W0 represents the original weight parameter of the large model; S4, by calculating the loss between the output y′ of the large model and the labeled y, the model is trained using gradient back propagation to update three low-rank sparse matrices; S5. Given the input x of the i-th professional dataset i With label y i , load the three low-rank sparse matrices updated in S4, freeze the parameters of G1 and G2, keep them unchanged, only adjust the parameters of G3, use the weights of each layer and the three low-rank sparse matrices to encode the input, and get the output: and' i =f(W0+A i ,x i ) Among them, A i represents the i-th dimension of G3; S6. By calculating the output y of the large model i ′ and label y i The loss between them is used to train the large model on the i-th general dataset using gradient back propagation; the third low-rank sparse matrix is ​​updated; S7. Given more professional data sets, repeat S5-S6 until all professional data sets are trained.

2. The sparse matrix-based lightweight continuous fine-tuning method according to claim 1, characterized in that: The architecture of the given large model adopts ResNet, EfficientNet, SwinTransformer, VoVNetV2, ConvNeXt or ViT series.

3. The sparse matrix-based lightweight continuous fine-tuning method according to claim 1, characterized in that: During the training process, r1 and r2 are adjusted as hyperparameters.

4. The sparse matrix-based lightweight continuous fine-tuning method according to claim 1, characterized in that: The loss function in steps S4 and S6 adopts the loss function when the large model is trained on large-scale data.

5. The sparse matrix-based lightweight continuous fine-tuning method according to claim 1, characterized in that: In steps S4 and S6, the gradient back propagation algorithm adopts SGD or Adam series.