Model training method and device based on dynamic rank adjustment, and electronic device
By dynamically adjusting the rank of the pre-trained weight matrix and reweighting the singular value spectrum, the problem of limited expressive power and low training efficiency caused by the static fixation of rank configuration in the fine-tuning of pre-trained large models in downstream tasks is solved, thus achieving efficient training and improved generalization performance of the model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA UNICOM SMART CONNECTION TECH LTD
- Filing Date
- 2026-04-03
- Publication Date
- 2026-06-05
Smart Images

Figure CN122154767A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large models, and specifically to a model training method, apparatus, and electronic device based on dynamic rank adjustment. Background Technology
[0002] In fine-tuning of pre-trained large models for downstream tasks, LoRA (Low-Rank Adaptation) significantly reduces parameter update costs by injecting trainable low-rank matrices, becoming a commonly used method for efficient parameter fine-tuning. However, traditional LoRA uses a fixed rank configuration, uniformly setting the same rank value across all layers and tasks. This "one-size-fits-all" design ignores the differences in parameter sensitivity among different network layers and the diverse demands of different tasks on model expressive power. This leads to over-parameterization and overfitting due to excessively high rank in simple tasks, while underfitting may occur due to insufficient rank in complex tasks, limiting the balance between model performance and training efficiency. Existing improvements mostly focus on reducing activation memory or partial parameter updates, but none of them fundamentally solve the adaptation problem caused by the static fixation of rank configuration. Summary of the Invention
[0003] In view of this, this application provides a model training method, apparatus and electronic device based on dynamic rank adjustment, which helps to solve the problems of limited model expressive ability, low training efficiency and easy overfitting or underfitting caused by the static fixation of rank configuration in the prior art.
[0004] In a first aspect, embodiments of this application provide a model training method based on dynamic rank adjustment, comprising: The rank of the weight adapter injected into the pre-trained weight matrix is dynamically adjusted according to the model training process. In the early stage of training, a first rank value is used, and in the later stage of training, a second rank value higher than the first rank value is used. The singular value spectrum is dynamically reweighted using a task-aware network, and the matrix parameters of the weight adapter are initialized using the reweighted singular value spectrum, wherein the singular value spectrum is obtained by singular value decomposition of the pre-trained weight matrix.
[0005] In an optional embodiment, the method further includes: During training, singular value decomposition is performed on the gradient matrix of the current layer to obtain the corresponding singular value sequence; Calculate the effective rank percentage of the singular value sequence, whereby the effective rank percentage indicates the proportion of the sum of squares of the top-preset proportion of singular values in the singular value sequence to the total sum of squares. When the effective rank percentage is lower than the first threshold, the current rank value of the weight adapter is reduced; when the effective rank percentage is higher than the second threshold, the current rank value of the weight adapter is increased.
[0006] In an optional embodiment, the method further includes: During training, monitor the model's training loss and validation loss; When the verification loss is greater than a first multiple of the training loss, the current rank value of the weight adapter is decreased; when the training loss is greater than a preset loss threshold, the current rank value of the weight adapter is increased.
[0007] In one optional embodiment, dynamically adjusting the rank of the weight adapter injected into the pre-trained weight matrix according to the model training process includes: A time-step-dependent rank function is used to linearly adjust the current rank value between a preset minimum rank value and a preset maximum rank value, based on the ratio of the current diffusion time step to the total diffusion time step.
[0008] In one optional embodiment, the step of dynamically reweighting the singular value spectrum through a task-aware network and initializing the matrix parameters of the weight adapter using the reweighted singular value spectrum includes: The pre-trained weight matrix is subjected to singular value decomposition to obtain a left singular matrix, a right singular matrix, and a singular value spectrum composed of singular values arranged in descending order. The feature representation of the downstream task sample is input into the task perception network, and the output is a reweighted vector with the same dimension as the singular value spectrum. The reweighted vector is multiplied element-by-element by the corresponding singular value in the singular value spectrum to obtain the reweighted singular value spectrum. The matrix parameters of the weight adapter are initialized based on the left singular matrix, the right singular matrix, and the reweighted singular value spectrum.
[0009] In one optional embodiment, the matrix parameters of the weight adapter are initialized based on the left singular matrix, the right singular matrix, and the reweighted singular value spectrum, including: The first preset number of columns of the left singular matrix is used as the initial value of the first matrix of the weight adapter; The first preset number of rows of the product of the reweighted singular value spectrum and the right singular matrix is used as the initial value of the second matrix of the weight adapter.
[0010] In one optional embodiment, the first threshold is 30% and the second threshold is 70%.
[0011] Secondly, embodiments of this application provide a model training apparatus based on dynamic rank adjustment, comprising: The adjustment module is used to dynamically adjust the rank of the weight adapter injected into the pre-trained weight matrix according to the progress of model training. In the early stage of training, a first rank configuration is used, and in the later stage of training, a second rank configuration higher than the first rank configuration is used. The processing module is used to dynamically reweight the singular value spectrum through a task-aware network and initialize the matrix parameters of the weight adapter using the reweighted singular value spectrum, wherein the singular value spectrum is obtained by singular value decomposition of the pre-trained weight matrix.
[0012] Thirdly, embodiments of this application provide an electronic device, including a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute the method described in any of the first aspects above.
[0013] Fourthly, embodiments of this application provide a computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to perform the method described in any of the first aspects.
[0014] Fifthly, embodiments of this application provide a computer program product comprising executable instructions that, when executed on a computer, cause the computer to perform the method described in any of the first aspects.
[0015] The scheme provided in this application dynamically adjusts the rank of the weight adapter injected into the pre-trained weight matrix according to the model training progress. A first rank is used in the early stages of training, and a second rank, higher than the first rank, is used in the later stages. The singular value spectrum is dynamically reweighted through a task-aware network, and the matrix parameters of the weight adapter are initialized using the reweighted singular value spectrum. The singular value spectrum is obtained by singular value decomposition of the pre-trained weight matrix. This application, through a combination of dynamic rank control, task-aware initialization, and rank-adaptive training, enables the model to dynamically adjust its rank based on the training stage, task characteristics, and real-time learning state during fine-tuning. This achieves an optimal balance between suppressing overfitting and alleviating underfitting, thereby significantly improving training efficiency and model generalization performance. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A flowchart illustrating a model training method based on dynamic rank adjustment provided in this application embodiment; Figure 2 A flowchart illustrating another model training method based on dynamic rank adjustment provided in this application embodiment; Figure 3 A flowchart illustrating another model training method based on dynamic rank adjustment provided in this application embodiment; Figure 4 A schematic diagram of a model training device based on dynamic rank adjustment provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0018] To better understand the technical solution of this application, the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0019] It should be understood that the described embodiments are merely some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0020] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0021] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0022] The method described in this application embodiment can be applied to an electronic device, which may include a processor, a memory, and a computer program stored in the memory and executable on the processor. Figure 1 A flowchart illustrating a model training method based on dynamic rank adjustment provided in this application embodiment is shown below. Figure 1 As shown, the method may include: Step 101: Dynamically adjust the rank of the weight adapter injected into the pre-trained weight matrix according to the progress of model training. In the early stage of training, a first rank configuration is used, and in the later stage of training, a second rank configuration higher than the first rank configuration is used.
[0023] Specifically, in this embodiment, the weight adapter adopts a low-rank adaptation structure, where the rank value r determines the number of parameters and expressive power of the adapter. A first rank value is preset before model training begins. Second rank ,in In the early stages of training, the model has not yet learned effective task-related features, and the gradient information is relatively chaotic. A low first rank value (e.g., r=4 or r=8) is used to limit the expressive power of the adapter, allowing it to learn only the most robust general features, thereby effectively suppressing overfitting. As the training progresses, the model gradually grasps the core rules of the task. At this point, the rank value is gradually increased, and a higher second rank value (e.g., r=32 or r=64) is used in the later stages of training to release the expressive power of the adapter, enabling it to capture the task-specific fine features and avoid underfitting.
[0024] In one optional embodiment, the dynamic adjustment of the rank value can be achieved using a time-step-dependent rank function. Based on the ratio of the current diffusion time step to the total diffusion time steps, the current rank value is linearly adjusted between a preset minimum rank value and a preset maximum rank value, allowing the rank value to change smoothly with the training process. Specifically, refer to the following formula:
[0025] r(t) is the rank, T is the total time step, and t is the current time step. In the early stages of training (corresponding to high time step and high noise scenarios), a value close to 1 is used. The low-rank configuration effectively suppresses overfitting; in the later stages of training (corresponding to low time steps and low noise scenarios), a near-rank configuration is used. The high-rank configuration enhances the model's ability to capture details.
[0026] Step 102: Dynamically reweight the singular value spectrum through the task-aware network, and initialize the matrix parameters of the weight adapter using the reweighted singular value spectrum, wherein the singular value spectrum is obtained by singular value decomposition of the pre-trained weight matrix.
[0027] In this embodiment of the application, before initializing the weight adapter, singular value decomposition (SVD) is first performed on the pre-trained weight matrix W to obtain the left singular matrix U and the right singular matrix U. And the singular value spectrum, which consists of singular values arranged in descending order. The singular value spectrum reflects the energy distribution of the pre-trained weight matrix across various feature directions, with larger singular values corresponding to more important feature directions.
[0028] Then, a lightweight task-aware network is constructed. The network represents the characteristics of a small number of samples from downstream tasks. As input, output a reweighted vector with the same dimension as the singular value spectrum. In one specific implementation, the task-aware network employs a channel attention mechanism. First, it performs global average pooling on the features of downstream task samples to obtain a global feature vector with the same dimension as the singular value spectrum. Then, it performs a nonlinear transformation through a two-layer perceptron with a bottleneck structure. Finally, it outputs a reweighted vector w with values ranging from (0, γ) using a sigmoid function and a learnable scaling parameter γ. Each element in this reweighted vector... Used to indicate the corresponding singular value The importance of the characteristic orientation to the current task.
[0029] The reweighted vector is multiplied element-wise with the corresponding singular values in the original singular value spectrum to obtain the reweighted singular value spectrum. This operation adaptively amplifies the feature directions that are highly discriminative for the current task, while effectively suppressing redundant or interfering directions.
[0030] Finally, using the left singular matrix U and the right singular matrix... and the reweighted singular value spectrum Initialize the matrix parameters of the weight adapter. In one specific implementation, the first r columns of the left singular matrix U are used as the initial values of the first matrix B of the weight adapter, and the product of the reweighted singular value spectrum and the right singular matrix is... The first r rows are used as the initial values of the second matrix A of the weight adapter, thus completing the adapter initialization. This initialization method allows the adapter to focus on the feature subspace most relevant to the downstream task from the beginning of training, significantly improving convergence speed and fine-tuning performance.
[0031] Through steps 101 and 102 described above, this embodiment of the application achieves dynamic configuration of rank values and task-aware adapter initialization, laying a solid foundation for subsequent model fine-tuning. Optionally, the execution order of steps 101 and 102 is not strictly limited. In practical applications, step 102 can be executed first to complete adapter initialization, followed by step 101 for dynamic rank configuration. The two steps can also be executed in parallel, as long as the technical effect of this application can be achieved.
[0032] This application's embodiments can also introduce a gradient sensitivity analysis mechanism during model training to achieve online optimization of the rank value. For example... Figure 2 As shown, the method may include the following steps: Step 201: During the training process, singular value decomposition is performed on the gradient matrix of the current layer to obtain the corresponding singular value sequence.
[0033] Specifically, in each iteration of model training or at a preset monitoring interval, the gradient matrix G of the loss function with respect to the current layer's weight adapter parameters (e.g., the first matrix B or the second matrix A) is obtained. This gradient matrix G has the same dimension as the adapter matrix, and its elements reflect the degree of influence of each parameter on the loss function. Singular value decomposition is then performed on the gradient matrix G to obtain... ,in Given a diagonal matrix, the elements σ1, σ2, ..., σr on the diagonal are the sequence of singular values, arranged in descending order: σ1 ≥ σ2 ≥ ... ≥ σr > 0. The squares of the singular values... This represents the "energy" of the gradient matrix in the i-th feature direction, reflecting the degree to which that direction contributes to the current learning.
[0034] Step 202: Calculate the effective rank ratio of the singular value sequence. The effective rank ratio is used to indicate the proportion of the sum of squares of the first preset proportion of singular values in the singular value sequence to the total sum of squares.
[0035] In one specific implementation, the preset ratio can be the first half, i.e., k = [r / 2], where r is the current rank value. The sum of squares of the first k largest singular values is calculated. and the sum of squares of all singular values The effective rank proportion η is defined as: The ratio η reflects the degree to which gradient energy is concentrated in the main directions. When η is high, it means that most of the energy is concentrated in the first half of the feature directions, and the model is making full use of a few core directions for learning; when η is low, it means that the energy is distributed in a large number of directions, and there may be redundant parameter dimensions.
[0036] Step 203: When the effective rank percentage is lower than the first threshold, decrease the current rank value of the weight adapter; when the effective rank percentage is higher than the second threshold, increase the current rank value of the weight adapter.
[0037] In this embodiment, the electronic device pre-sets a first threshold θ1 and a second threshold θ2, where θ1 < θ2. In a preferred embodiment, the first threshold can be set to 30%, and the second threshold can be set to 70%.
[0038] (1) Rank reduction condition: When the effective rank ratio η < 30%, it indicates that the gradient energy is highly dispersed, with the first half of the direction contributing less than 30% of the energy, indicating that there are a large number of redundant parameters in the second half of the direction, which contribute very little to the learning. At this time, the electronic device triggers a rank reduction operation, reducing the current rank value (e.g., from 32 to 24, or directly halving it). Rank reduction can eliminate redundant dimensions, simplify the model, reduce computational overhead, and help suppress overfitting.
[0039] (2) Rank increase condition: When the effective rank ratio η > 70%, it indicates that the gradient energy is highly concentrated in the first half of the direction, and the contribution of the second half of the direction is less than 30%. This indicates that the current rank may not be sufficient to cover all important feature directions, and the model's expressive power is limited. At this time, the electronic device triggers a rank increase operation, increasing the current rank value (e.g., from 16 to 24). Rank increase can add more feature dimensions, enabling the model to capture richer information and avoid underfitting.
[0040] When 30% ≤ η ≤ 70%, it indicates that the current rank configuration is reasonable and the energy distribution is moderate, requiring no adjustment. Optionally, the rank value can be adjusted in a stepwise manner: the step size for each rank increase or decrease can be preset to a fixed value (e.g., 4 or 8), or it can be adaptively determined based on the difference between the current rank value and the preset minimum / maximum rank value. The adjusted rank value must be constrained within the preset rank value range. Inside.
[0041] Through the gradient sensitivity analysis mechanism described above, this application embodiment realizes online dynamic optimization of the adapter rank value. It can automatically determine whether the current rank is redundant or insufficient based on the real-time learning status and make corresponding adjustments, thereby avoiding parameter waste while maintaining the model's expressive power and significantly improving training efficiency and generalization performance.
[0042] In one optional embodiment, the electronic device may further introduce a loss-aware control mechanism during model training. By monitoring the changing trends of training loss and validation loss, it can determine the current fitting state of the model and dynamically adjust the rank value of the weight adapter accordingly. (See also...) Figure 3 The method may include the following steps: Step 301: During the training process, monitor the training loss and validation loss of the model.
[0043] Specifically, after each training cycle or after a preset number of iterations, the electronic device calculates the average loss value of the model on the current training set. and the average loss value on the validation set. Training loss reflects how well the model fits the training data, while validation loss reflects the model's generalization ability. By monitoring the changes in these two loss values in real time, it is possible to determine whether the model is overfitting or underfitting.
[0044] Step 302: When the validation loss is greater than a first multiple of the training loss, decrease the current rank value of the weight adapter.
[0045] When a model overfits, a common manifestation is that the validation loss is significantly higher than the training loss; that is, the model performs well on the training set but poorly on the unseen validation set. In this embodiment, a first multiple β is set, and when the following condition is met... If the validation loss exceeds 1.2 times the training loss, it is considered overfitting. In a preferred embodiment, the first factor β = 1.2, meaning that when the validation loss exceeds 1.2 times the training loss, the model is considered to have overfitted noise or irrelevant details in the training data, and the model's capacity needs to be reduced to improve generalization ability. At this time, the electronic device triggers a rank reduction operation, decreasing the current rank value (e.g., from 32 to 24, or directly halving it). The rank reduction operation forces the model to discard some unnecessary parameter dimensions, making it unable to remember the details in the training set, thereby shifting the learning focus back to the truly task-relevant features.
[0046] The specific value of the first factor can be adjusted according to the task type and dataset size. For datasets with high noise, the first factor can be appropriately reduced (e.g., 1.1) to intervene earlier in suppressing overfitting. For relatively clean datasets, the first factor can be increased (e.g., 1.3) to avoid premature rank reduction leading to underfitting.
[0047] Step 303: When the training loss is greater than the preset loss threshold, increase the current rank value of the weight adapter.
[0048] When a model exhibits underfitting, it typically manifests as high training loss, indicating that the model struggles to learn effective patterns from the training data. This application's embodiment sets a preset loss threshold. When satisfied If the condition is deemed underfit, a preset loss threshold is set. The value of is related to the specific task and the type of loss function.
[0049] Model underfitting indicates that the current weight adapter's rank (i.e., model capacity) is insufficient to fit the complexity of the training data, requiring an increase in the model's expressive power. In this case, the electronic device triggers a rank-raising operation, increasing the current rank (e.g., from 16 to 24). The rank-raising operation adds more feature dimensions to the model, enabling it to learn more complex patterns and finer decision boundaries, thereby reducing training loss.
[0050] Through the aforementioned loss-aware control mechanism, the embodiments of this application can promptly identify overfitting and underfitting states based on the dynamic changes in training loss and validation loss, and adaptively adjust the rank of the adapter, thereby achieving a dynamic balance between suppressing overfitting and enhancing expressive power, significantly improving the robustness of the fine-tuning process and the generalization performance of the final model.
[0051] Figure 4 This is a schematic diagram of a model training device based on dynamic rank adjustment, provided as an embodiment of this application. Figure 4 As shown, the device may include: The adjustment module 410 is used to dynamically adjust the rank of the weight adapter injected into the pre-trained weight matrix according to the progress of model training. In the early stage of training, a first rank configuration is used, and in the later stage of training, a second rank configuration higher than the first rank configuration is used.
[0052] The processing module is used to dynamically reweight the singular value spectrum through the task-aware network and initialize the matrix parameters of the weight adapter using the reweighted singular value spectrum, wherein the singular value spectrum is obtained by singular value decomposition of the pre-trained weight matrix.
[0053] Corresponding to the above embodiments, this application also provides an electronic device. Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 500 may include a processor 501, a memory 502, and a communication unit 503. These components communicate through one or more buses. Those skilled in the art will understand that the structure of the electronic device shown in the figure does not constitute a limitation on the embodiment of this application. It may be a bus topology or a star topology, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0054] The communication unit 503 is used to establish a communication channel, enabling the electronic device to communicate with other devices. It receives user data from other devices or sends user data to other devices.
[0055] The processor 501 serves as the control center of the electronic device, connecting various parts of the device via various interfaces and lines. It executes software programs, instructions, and / or modules stored in the memory 502, and calls data stored in the memory to perform various functions and / or process data. The processor may be composed of integrated circuits (ICs), such as a single packaged IC or multiple packaged ICs with the same or different functions connected together. For example, the processor 501 may consist only of a central processing unit (CPU). In this embodiment, the CPU may have a single processing core or include multiple processing cores.
[0056] The memory 502 is used to store the execution instructions of the processor 501. The memory 502 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0057] When the execution instructions in memory 502 are executed by processor 501, the electronic device 500 is able to perform some or all of the steps in the above embodiments.
[0058] In a specific implementation, this application also provides a computer storage medium, wherein the computer storage medium may store a program, which, when executed, may include some or all of the steps of the various embodiments of the model training method based on dynamic rank adjustment provided in this application. The storage medium may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0059] In a specific implementation, this application also provides a computer program product, wherein the computer program product includes executable instructions, which, when executed on a computer, cause the computer to perform some or all of the steps in various embodiments of the model training method based on dynamic rank adjustment provided in this application.
[0060] This application also provides a non-transitory computer-readable storage medium that stores computer instructions that cause the computer to execute the model training method based on dynamic rank adjustment provided in this application.
[0061] The aforementioned non-transitory computer-readable storage medium may be any combination of one or more computer-readable media. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or flash memory, optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in connection with an instruction execution system, apparatus, or device.
[0062] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including—but not limited to—electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0063] The program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0064] Those skilled in the art will clearly understand that the techniques in the embodiments of this application can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application or some parts of the embodiments.
[0065] The same or similar parts between the various embodiments in this specification can be referred to mutually. In particular, the device embodiments and terminal embodiments are basically similar to the method embodiments, so the description is relatively simple, and the relevant parts can be referred to the description in the method embodiments.
Claims
1. A model training method based on dynamic rank adjustment, characterized in that, include: The rank of the weight adapter injected into the pre-trained weight matrix is dynamically adjusted according to the model training process. In the early stage of training, a first rank value is used, and in the later stage of training, a second rank value higher than the first rank value is used. The singular value spectrum is dynamically reweighted using a task-aware network, and the matrix parameters of the weight adapter are initialized using the reweighted singular value spectrum, wherein the singular value spectrum is obtained by singular value decomposition of the pre-trained weight matrix.
2. The method according to claim 1, characterized in that, The method further includes: During training, singular value decomposition is performed on the gradient matrix of the current layer to obtain the corresponding singular value sequence; Calculate the effective rank percentage of the singular value sequence, whereby the effective rank percentage indicates the proportion of the sum of squares of the top-preset proportion of singular values in the singular value sequence to the total sum of squares. When the effective rank percentage is lower than the first threshold, the current rank value of the weight adapter is reduced; when the effective rank percentage is higher than the second threshold, the current rank value of the weight adapter is increased.
3. The method according to claim 1, characterized in that, The method further includes: During training, monitor the model's training loss and validation loss; When the verification loss is greater than a first multiple of the training loss, the current rank value of the weight adapter is decreased; when the training loss is greater than a preset loss threshold, the current rank value of the weight adapter is increased.
4. The method according to claim 1, characterized in that, The step of dynamically adjusting the rank of the weight adapter injected into the pre-trained weight matrix according to the model training process includes: A time-step-dependent rank function is used to linearly adjust the current rank value between a preset minimum rank value and a preset maximum rank value, based on the ratio of the current diffusion time step to the total diffusion time step.
5. The method according to claim 1, characterized in that, The step of dynamically reweighting the singular value spectrum through a task-aware network and initializing the matrix parameters of the weight adapter using the reweighted singular value spectrum includes: The pre-trained weight matrix is subjected to singular value decomposition to obtain a left singular matrix, a right singular matrix, and a singular value spectrum composed of singular values arranged in descending order. The feature representation of the downstream task sample is input into the task perception network, and the output is a reweighted vector with the same dimension as the singular value spectrum. The reweighted vector is multiplied element-by-element by the corresponding singular value in the singular value spectrum to obtain the reweighted singular value spectrum. The matrix parameters of the weight adapter are initialized based on the left singular matrix, the right singular matrix, and the reweighted singular value spectrum.
6. The method according to claim 5, characterized in that, Based on the left singular matrix, the right singular matrix, and the reweighted singular value spectrum, initialize the matrix parameters of the weight adapter, including: The first preset number of columns of the left singular matrix is used as the initial value of the first matrix of the weight adapter; The first preset number of rows of the product of the reweighted singular value spectrum and the right singular matrix is used as the initial value of the second matrix of the weight adapter.
7. The method according to claim 2, characterized in that, The first threshold is 30%, and the second threshold is 70%.
8. A model training device based on dynamic rank adjustment, characterized in that, include: The adjustment module is used to dynamically adjust the rank of the weight adapter injected into the pre-trained weight matrix according to the progress of model training. In the early stage of training, a first rank configuration is used, and in the later stage of training, a second rank configuration higher than the first rank configuration is used. The processing module is used to dynamically reweight the singular value spectrum through a task-aware network and initialize the matrix parameters of the weight adapter using the reweighted singular value spectrum, wherein the singular value spectrum is obtained by singular value decomposition of the pre-trained weight matrix.
9. An electronic device, characterized in that, The device includes a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device performs the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1 to 7.