Efficient fine-tuning method for language model parameters based on block toeplitz matrix
By introducing a weight update method based on a block Toplitz matrix into the pre-trained model, the limitations of low-rank and sparse structure methods in terms of expressive power and efficiency are overcome, achieving high-rank and dense weight updates and improving the model's adaptability and overall performance in complex tasks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INST OF COMPUTING TECH CHINESE ACAD OF SCI
- Filing Date
- 2026-04-10
- Publication Date
- 2026-06-05
AI Technical Summary
Existing efficient parameter fine-tuning methods for low-rank and sparse structures struggle to balance expressive power and parameter efficiency, exhibiting performance bottlenecks, especially in complex tasks. Furthermore, different tasks have varying requirements for parameter distribution and update patterns, making it difficult to cater to diverse application scenarios.
We employ an efficient parameter fine-tuning method based on block Toplitz matrices. By introducing multiple Toplitz structure sub-blocks into the weight update of the pre-trained model, we achieve high-rank, dense weight updates, thereby improving the model's expressive and adaptive capabilities.
It significantly improves the model's performance across a variety of downstream tasks, such as accuracy and generalization, under the same parameter budget, including mathematical reasoning, natural language understanding, and code generation.
Smart Images

Figure CN122154808A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of efficient parameter fine-tuning technology for large models and natural language understanding technology, and particularly to a method, apparatus, electronic device, computer-readable storage medium, and computer program product for efficient parameter fine-tuning of language models based on block Toplitz matrices. Background Technology
[0002] In recent decades, with the rapid development of deep learning and pre-training technologies, large-scale pre-trained models have made significant progress in natural language processing, computer vision, and multimodal understanding, demonstrating strong generalization capabilities in tasks such as intelligent question answering, text generation, image generation, and cross-modal reasoning. However, these models typically have billions or even tens of billions of parameters, making full parameter fine-tuning in downstream tasks extremely computationally and incurring high storage costs, severely limiting their practical application in resource-constrained scenarios.
[0003] To alleviate the aforementioned problems, researchers have proposed several Parameter-Efficient Fine-Tuning (PEFT) methods. The core idea is to introduce only a small number of trainable parameters while freezing the main parameters of the pre-trained model to achieve task adaptation. Among these, low-rank reparameterization methods (such as LoRA and its variants) reduce the number of parameters and training costs to some extent by imposing low-rank constraints on weight updates; while sparse structure reparameterization methods (such as OFT, BOFT, etc.) attempt to improve parameter utilization efficiency by utilizing specific matrix structures. These methods have achieved good results on multiple tasks and have become an important technical approach for fine-tuning large models.
[0004] However, existing fine-tuning methods based on low-rank structures have inherent limitations in terms of expressive power. Since weight updates are confined to a low-rank subspace, the representable variations are relatively limited, making it difficult to characterize the high-rank parameter transformations required in complex tasks, thus exhibiting performance bottlenecks at certain task or model scales. Especially in scenarios requiring significant adjustments to the model's internal representation, the low-rank assumption may be insufficient to support high-quality task adaptation. On the other hand, while fine-tuning methods based on sparse structures alleviate the parameter scale problem to some extent, they typically rely on fixed or predefined sparse patterns, making it difficult to fully utilize the global correlations between parameters. This structural constraint, while improving parameter utilization efficiency, may also limit the model's ability to model complex feature interactions, thereby affecting the overall performance of downstream tasks. Furthermore, different tasks have different requirements for parameter distribution and update patterns, and a uniform sparse structure often fails to accommodate diverse application scenarios. Summary of the Invention
[0005] While researching efficient fine-tuning techniques for large-scale pre-trained models, the inventors noted that existing low-rank and sparse structure methods still face a challenge in balancing parameter efficiency and expressive power. Therefore, how to maintain parameter efficiency while effectively modeling updates of high-rank, dense weights, thereby improving the model's adaptability to complex tasks, remains a key technical problem that urgently needs to be solved in the field of efficient fine-tuning of large model parameters.
[0006] In the downstream task adaptation process of large-scale pre-trained models, while full parameter fine-tuning has strong expressive power, its computational and storage costs are extremely high, making it difficult to deploy in resource-constrained scenarios. Therefore, existing efficient parameter fine-tuning methods typically reduce the number of trainable parameters by introducing low-rank or sparse structures. However, low-rank structure methods inherently limit the rank of weight updates, making it difficult to characterize the high-rank parameter updates required for complex tasks; while sparse structure methods rely on predefined structural constraints, making it difficult to fully model the global correlations between parameters, thus affecting the model's adaptation performance.
[0007] Therefore, the objective of this invention is to overcome the limitations of low-rank and sparse structures on expressive power while maintaining parameter efficiency, and to design an efficient parameter fine-tuning method that can achieve high-rank, dense weight updates and is applicable to large-scale pre-trained models, thereby improving the model's adaptability and overall performance in various downstream tasks. To achieve the above technical effects, the core technical point of this invention is to propose an efficient parameter fine-tuning method based on a block-based Toeplitz structure. By introducing multiple Toeplitz structure sub-blocks into the weight updates of the pre-trained model, a structured modeling of the weight update space is achieved. This method, with a controlled number of parameters, can generate a high-rank, dense weight update matrix, thereby significantly improving the expressive power of the fine-tuning method.
[0008] Specifically, such as Figure 1 As shown, this invention proposes an efficient fine-tuning method for language model parameters based on a block Toplitz matrix, which includes:
[0009] The initial step is to obtain a large language model and initialize its parameters. In the large language model, each Transformer layer contains an attention module, into which block adapters are inserted into the query and value projection layers. For each linear layer into which an adapter is inserted, t block Toplitz matrices are introduced to form a parameter set. ;
[0010] Each of them Let the i-th block Toeplitz matrix be represented by... It consists of 10 sub-blocks, each sub-block being 1000 units in size. ;
[0011] Constructing the effective weights of this linear layer for: ;
[0012] Initialization parameter set ,in Initialize as a zero matrix, the rest ( The initial model is obtained by random initialization using a Gaussian distribution;
[0013] The processing steps involve dividing the question-and-answer training set S into multiple batches to obtain the current batch. : ;
[0014] in This indicates that the question text input is correct. This represents the corresponding target output sequence;
[0015] The forward propagation step will move the current batch... Input is fed into the initial model; for each input sample in the current batch B The following calculations are performed in each layer of the initial model:
[0016] Obtain the input representation of this layer ;
[0017] Based on effective weights Calculate the output of this layer : ;
[0018] Output Passed to the next layer as input;
[0019] After calculations by all Transformer layers, the model output for the current batch is obtained. : ;
[0020] in For input The corresponding prediction results;
[0021] Loss calculation steps, based on model output With real labels : ;
[0022] Calculate the loss of the current batch. : ;
[0023] in Model a loss function for the language;
[0024] Gradient calculation steps, based on loss For parameter set Perform backpropagation to obtain the gradient: ;
[0025] The gradient g is output by the model. The loss function is obtained through backpropagation and then passed to the Toeplitz matrix of each block. ;
[0026] The parameter update step, based on the gradient g, updates the parameter set. Update: ;
[0027] With the updated parameter set replace ;
[0028] The process involves repeating the processing steps up to the parameter update step, until all batches of the question-answering training set S are processed sequentially. This process is repeated a preset number of times to obtain the final parameter set. ;
[0029] Model output steps, with the final parameter set Construct the final model weights of this large language model. : ;
[0030] The parameters of this large language model are set as the weights of the final model. The final model is obtained by inputting the question text into the final model, and the answer to the question text is obtained.
[0031] The method for efficient fine-tuning of language model parameters based on block Toplitz matrices, wherein the question-answering training set S includes mathematical application problems described in words. And the standard answer to the mathematical application problem. .
[0032] The method for efficient fine-tuning of language model parameters based on a block Toplitz matrix is described above, wherein the number of blocks t is 64 or 256.
[0033] This invention proposes an efficient fine-tuning device for language model parameters based on a block Toplitz matrix, comprising:
[0034] The initial module is used to obtain the large language model, and the parameters of the large language model are initialized as follows: In the large language model, each Transformer layer contains an attention module, into which block adapters are inserted into the query and value projection layers. For each linear layer into which an adapter is inserted, t block Toplitz matrices are introduced to form a parameter set. ;
[0035] Each of them Let the i-th block Toeplitz matrix be represented by... It consists of 10 sub-blocks, each sub-block being 1000 units in size. ;
[0036] Constructing the effective weights of this linear layer for: ;
[0037] Initialization parameter set ,in Initialize as a zero matrix, the rest ( The initial model is obtained by random initialization using a Gaussian distribution;
[0038] The processing module is used to divide the question-answering training set S into multiple batches and obtain the current batch. : ;
[0039] in This indicates that the question text input is correct. This represents the corresponding target output sequence;
[0040] The forward propagation module will pass the current batch Input is fed into the initial model; for each input sample in the current batch B The following calculations are performed in each layer of the initial model:
[0041] Obtain the input representation of this layer ;
[0042] Based on effective weights Calculate the output of this layer : ;
[0043] Output Passed to the next layer as input;
[0044] After calculations by all Transformer layers, the model output for the current batch is obtained. : ;
[0045] in For input The corresponding prediction results;
[0046] The loss calculation module is based on the model output. With real labels : ;
[0047] Calculate the loss of the current batch. : ;
[0048] in Model a loss function for the language;
[0049] The gradient calculation module is used for loss-based calculations. For parameter set Perform backpropagation to obtain the gradient: ;
[0050] The gradient g is output by the model. The loss function is obtained through backpropagation and then passed to the Toeplitz matrix of each block. ;
[0051] The parameter update module, based on gradient g, updates the parameter set. Update: ;
[0052] With the updated parameter set replace ;
[0053] The loop module repeatedly executes the processing module up to the parameter update module until all batches of the question-answering training set S are processed sequentially, and the above process is repeated for a preset number of rounds to obtain the final parameter set. ;
[0054] The model output module is used to output the final parameter set. Construct the final model weights of this large language model. : ;
[0055] The parameters of this large language model are set as the weights of the final model. The final model is obtained by inputting the question text into the final model, and the answer to the question text is obtained.
[0056] The aforementioned efficient fine-tuning device for language model parameters based on a block Toplitz matrix, wherein the question-answering training set S includes mathematical application problems described in words. And the standard answer to the mathematical application problem. .
[0057] The method for efficient fine-tuning of language model parameters based on a block Toplitz matrix is described above, wherein the number of blocks t is 64 or 256.
[0058] The present invention also proposes a client for implementing any of the language model parameter fine-tuning devices based on block Toplitz matrices.
[0059] The present invention also proposes an electronic device, including the aforementioned efficient fine-tuning device for language model parameters based on a block Toplitz matrix. This electronic device may be connected to an information display device, which is used to display the answer result with user-set display parameters, attributes, or through an artificial intelligence model.
[0060] The present invention also proposes a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the method for efficient fine-tuning of language model parameters based on a block Topletz matrix.
[0061] The present invention also proposes a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, it implements the steps of the method for efficient fine-tuning of language model parameters based on a block Topletz matrix.
[0062] As can be seen from the above solutions, the advantages of the present invention are:
[0063] Compared to existing efficient parameter fine-tuning methods based on low-rank or sparse structures, the proposed fine-tuning method based on a block Toeplitz structure achieves high-rank, dense weight updates under similar parameter scales, thereby significantly improving the model's expressive power and task adaptability. Furthermore, through structured design and an identity residual mechanism, this method ensures training stability while balancing parameter efficiency and performance, making it suitable for pre-trained models of various sizes and complex downstream tasks.
[0064] Specifically, under the same parameter budget conditions, the method of this invention achieves stable performance improvements in multiple typical tasks. For example, in mathematical reasoning tasks (such as GSM8K), it achieves an accuracy improvement of approximately 2%–4% compared to the LoRA method under the same parameter budget; in natural language understanding tasks (such as the GLUE benchmark), it achieves an average performance improvement of approximately 0.7% compared to LoRA under the same parameter scale settings; in code generation and reasoning tasks (such as HumanEval), this method also delivers a performance improvement of approximately 1%–3% compared to LoRA under the same parameter budget, demonstrating more stable generalization ability and indicating its expressive advantages in various complex downstream tasks. Attached Figure Description
[0065] Figure 1This is a flowchart of the method of the present invention;
[0066] Figure 2 This is a schematic diagram of the structure of the first electronic device of the present invention;
[0067] Figure 3 This is a schematic diagram of the application environment structure of the first electronic device of the present invention;
[0068] Figure 4 This is a schematic diagram of the structure of the second electronic device of the present invention.
[0069] Figure label:
[0070] A - First electronic device;
[0071] B-Efficient fine-tuning device for language model parameters based on block Toplitz matrix;
[0072] C-Data acquisition equipment;
[0073] D-Information display device;
[0074] 1000 - Second electronic device;
[0075] Ⅰ-Computational Unit;
[0076] II-ROM;
[0077] III-RAM;
[0078] N-bus;
[0079] V-Interface;
[0080] VI - Input Unit;
[0081] VII - Output Unit;
[0082] VIII - Storage medium;
[0083] IX - Communication Unit. Detailed Implementation
[0084] It should be noted that, in this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus.
[0085] Without further restrictions, an element defined by the phrase "comprising a..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0086] The processor described in this invention is the control center of an electronic device. It can be a single processor or a collective term for multiple processing elements. For example, it can be one or more central processing units (CPUs), application-specific integrated circuits (ASICs), or one or more integrated circuits configured to implement embodiments of this invention, such as one or more digital signal processors (DSPs), or one or more field-programmable gate arrays (FPGAs).
[0087] Alternatively, the processor can perform various functions of the electronic device by running or executing software programs stored in memory, and by calling data stored in memory.
[0088] In a specific implementation, as one example, the processor may include one or more CPUs. Each of these processors may be a single-core processor or a multi-core processor. Here, "processor" can refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions). Electronic devices may include servers, desktop computers, laptops, smartphones, tablets, embedded computers, etc., where the embedded computer includes vehicles and robots, etc.
[0089] The memory is used to store the software program that executes the solution of the present invention, and the execution is controlled by the processor. For specific implementation methods, please refer to the above method embodiments, which will not be repeated here.
[0090] It should be noted that the structure of the electronic device shown in the accompanying drawings of this invention does not constitute a limitation thereof. The actual knowledge structure recognition device may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0091] The above embodiments can be implemented, in whole or in part, by software, hardware (such as circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.
[0092] It should also be understood that the term "and / or" 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, and B existing alone. A and B can be singular or plural. Additionally, the character " / " in this article generally indicates an "or" relationship between the preceding and following related objects, but it can also represent an "and / or" relationship. Please refer to the context for a more accurate understanding.
[0093] In this invention, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of a single item or a plurality of items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be a single item or multiple items.
[0094] It should also be understood that, in various embodiments of the present invention, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0095] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0096] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0097] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0098] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0099] To make the above-mentioned features and effects of the present invention clearer and easier to understand, specific embodiments are described below in conjunction with the accompanying drawings. This specification discloses one or more embodiments incorporating the features of the present invention. The disclosed embodiments are merely illustrative. The scope of protection of the present invention is not limited to the disclosed embodiments, but is defined by the appended claims.
[0100] This invention proposes a novel two-level knowledge base completion method, comprising the following steps:
[0101] First, we present the parameterization settings for the model layers. Let the pre-training weights of a certain linear layer in the pre-trained model to be fine-tuned be... The present invention is in freezing Under this premise, a learnable structured transformation matrix is introduced. The pre-trained weights are modulated using right multiplication to obtain the fine-tuned weights: ;
[0102] In the ToPA framework, the stated It is composed of the block Toeplitz matrix and the identity residual term, i.e. ;
[0103] in Indicates the chain length. It is the identity matrix. This identity residual structure makes the model output naturally contain... The original mapping is used to stabilize the fine-tuning process around the pre-training initialization. Each chain factor Defined as a block Toeplitz matrix. Specifically, the matrix is divided into... A small block, ;
[0104] Each sub-block All are independent Toeplitz matrices. Therefore, the... Each block Toeplitz factor A vector can be defined by a set of Toeplitz vectors. The diagonal parameters of each of its sub-blocks are uniquely determined.
[0105] Based on the above parameterization method, this invention explicitly defines the weight update term as: ;
[0106] Therefore, the fine-tuned weights can be equivalently written as ;
[0107] in Generated by a block Toeplitz transformation chain, it typically presents as a high-rank and dense update form.
[0108] To ensure that the behavior of the pre-trained network is not disrupted during the initial training phase, this invention employs an asymmetric initialization strategy, ensuring that the output of the learnable module is zero at the start of training. ;
[0109] The specific implementation method is as follows: the Toeplitz factor of the first block (more precisely, the Toeplitz definition vector of each sub-block) is initialized to zero, while the remaining factors are initialized to Gaussian distributed random values: ;
[0110] in Indicates the first In the nth block Toeplitz matrix The Toeplitz definition vector for each sub-block.
[0111] During the training phase, this invention freezes the pre-trained weights. Only for all The parameters are backpropagated and updated.
[0112] Example: A fine-tuning method for mathematical inference tasks based on a block-based Toeplitz parameterized adapter
[0113] Using the Meta-MathQA mathematical reasoning dataset or a natural language understanding task as training data, and taking the pre-trained language model LLaMA-3-8B as the base model as an example, the learning rate is set to η, the number of training epochs to E, the training set representation to S, the batch size to b, and the number of blocks to be... The Toeplitz chain has a length of t.
[0114] It's important to note that the data in the mathematical reasoning dataset does not consist of mathematical calculations, but rather word problems described in words, such as the "chicken and rabbit in the same cage" problem. Essentially, it's still natural language understanding data; the language model needs to understand the word-described "chicken and rabbit in the same cage" problem to provide the appropriate answer. In the LLaMA-3-8B model, each Transformer layer contains an attention module. In this embodiment, a block-based Toeplitz adapter is inserted into the Query and Value projection layers within the attention module.
[0115] Step 1: Model Initialization
[0116] Initialize the pre-trained model parameters as follows And freeze all original parameters;
[0117] For each linear layer of the inserted adapter, t block Toeplitz parameter matrices are introduced to form a parameter set: ;
[0118] Each of them Let the i-th block Toeplitz matrix be represented by... It consists of 10 sub-blocks, each sub-block being 1000 units in size. The number of blocks is a hyperparameter, typically set to 8² or 16². More blocks mean more training parameters per matrix, resulting in stronger expressive power and generally better training performance, but also higher training costs. Without blocks, the number of parameters per matrix is too low, leading to unstable training.
[0119] Based on the above parameters, the effective weights of this linear layer are constructed as follows: ;
[0120] Among them, weight As the computational basis for forward propagation in step 3, It is an identity matrix, that is, a matrix in which the elements on the diagonal are 1s and the elements in other positions are 0s;
[0121] Initialization parameter set ,in Initialize as a zero matrix, the rest ( The system is initialized using a Gaussian distribution.
[0122] Step 2: Data Processing and Batch Building
[0123] Shuffle the training set S and divide it into multiple batches to obtain the current batch: ;
[0124] in This indicates that the question text input is correct. This represents the target output sequence (real labels) corresponding to the question text.
[0125] The batch B serves as the input data for the model's forward propagation in step 3.
[0126] Step 3: Output of the forward propagation calculation model
[0127] Input the batch B obtained in step 2 into the model constructed in step 1;
[0128] For each input sample in batch B The following calculations are performed in each layer of the model:
[0129] 1) Obtain the input representation of this layer ;
[0130] 2) Based on the weights constructed in step 1 (Depend on and (Together determined) Calculate the output of this layer: ;
[0131] 3) Output Passed to the next layer as input;
[0132] After computation through all Transformer layers, the model output for the current batch is obtained: ;
[0133] in For input The corresponding prediction results;
[0134] The model output As input for the loss function calculation in step 4.
[0135] Step 4: Loss Function Calculation
[0136] Based on the model output obtained in step 3 Compared to the actual labels in step 2: ;
[0137] Calculate the loss function for the current batch: ;
[0138] in Modeling loss functions for autoregressive languages (token-level cross-entropy loss);
[0139] The loss function As input for gradient calculation in step 5.
[0140] Step 5: Gradient Calculation
[0141] Based on the loss function obtained in step 4 For the parameter set in step 1 Perform backpropagation to obtain the gradient: ;
[0142] The gradient g is output by the model. The loss function is obtained through backpropagation and then passed layer by layer along the multiplication chain structure in step 3 to the Toeplitz parameters of each block. ;
[0143] The gradient g is used as the input for parameter updating in step 6.
[0144] Step 6: Parameter Update
[0145] Based on the gradient g obtained in step 5, the parameter set... Update: ;
[0146] Get the updated parameter set ;
[0147] The Replace the step 1 in the next batch of training. And used for forward propagation calculation in step 3.
[0148] Step 7: Circuit Training
[0149] Repeat steps 2 through 6, processing all batches of the training set S sequentially, and looping the above process for E rounds to obtain the final parameter set: ;
[0150] Step 8: Model Output and Inference
[0151] Based on the parameters after training Construct the final model weights: ;
[0152] In the inference phase, the mathematical problem to be solved is input into the model, and calculations are performed according to the forward propagation process in step 3, outputting the prediction results. .
[0153] The following are system embodiments corresponding to the above method embodiments. This embodiment can be implemented in conjunction with the above embodiments. The relevant technical details mentioned in the above embodiments are still valid in this embodiment, and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the above embodiments.
[0154] This invention proposes an efficient fine-tuning device for language model parameters based on a block Toplitz matrix, comprising:
[0155] The initial module is used to obtain the large language model, and the parameters of the large language model are initialized as follows: In the large language model, each Transformer layer contains an attention module, into which block adapters are inserted into the query and value projection layers. For each linear layer into which an adapter is inserted, t block Toplitz matrices are introduced to form a parameter set. ;
[0156] Each of them Let the i-th block Toeplitz matrix be represented by... It consists of 10 sub-blocks, each sub-block being 1000 units in size. ;
[0157] Constructing the effective weights of this linear layer for: ;
[0158] Initialization parameter set ,in Initialize as a zero matrix, the rest ( The initial model is obtained by random initialization using a Gaussian distribution;
[0159] The processing module is used to divide the question-answering training set S into multiple batches and obtain the current batch. : ;
[0160] in This indicates that the question text input is correct. This represents the corresponding target output sequence;
[0161] The forward propagation module will pass the current batch Input is fed into the initial model; for each input sample in the current batch B In each layer of this initial model, the following calculations are performed: The input representation of that layer is obtained. ;
[0162] Based on effective weights Calculate the output of this layer : ;
[0163] Output Passed to the next layer as input;
[0164] After calculations by all Transformer layers, the model output for the current batch is obtained. : ;
[0165] in For input The corresponding prediction results;
[0166] The loss calculation module is based on the model output. With real labels : ;
[0167] Calculate the loss of the current batch. : ;
[0168] in Model a loss function for the language;
[0169] The gradient calculation module is used for loss-based calculations. For parameter set Perform backpropagation to obtain the gradient: ;
[0170] The gradient g is output by the model. The loss function is obtained through backpropagation and then passed to the Toeplitz matrix of each block. ;
[0171] The parameter update module, based on gradient g, updates the parameter set. Update: ;
[0172] With the updated parameter set replace ;
[0173] The loop module repeatedly executes the processing module up to the parameter update module until all batches of the question-answering training set S are processed sequentially, and the above process is repeated for a preset number of rounds to obtain the final parameter set. ;
[0174] The model output module is used to output the final parameter set. Construct the final model weights of this large language model. : ;
[0175] The parameters of this large language model are set as the weights of the final model. The final model is obtained by inputting the question text into the final model, and the answer to the question text is obtained.
[0176] The aforementioned efficient fine-tuning device for language model parameters based on a block Toplitz matrix, wherein the question-answering training set S includes mathematical application problems described in words. And the standard answer to the mathematical application problem. .
[0177] The method for efficient fine-tuning of language model parameters based on a block Toplitz matrix is described above, wherein the number of blocks t is 64 or 256.
[0178] The present invention also proposes a client for implementing any of the language model parameter fine-tuning devices based on block Toplitz matrices.
[0179] like Figure 2 As shown, in another embodiment of the present invention, a first electronic device A is proposed, including the aforementioned efficient fine-tuning device B for language model parameters based on a block Topulitz matrix.
[0180] like Figure 3 As shown, the first electronic device A can also be connected to the data acquisition device C and the information display device D through wired or wireless information transmission schemes. The data acquisition device C is used to collect natural text, such as the chicken and rabbit problem described in the embodiment of the present invention. The information display device D is used to display the answer results obtained by the analysis of the present invention.
[0181] The information display device D can process and organize the data output by the first electronic device A based on an information display mechanism to improve the readability of the data. This information display mechanism can be manually preset, for example, visualizing the data output by the first electronic device A. It can present the user with the specified key information based on user-defined display parameters and / or attributes, such as the data range and font, color, and scrolling options. Users can access this information more quickly without needing to navigate to secondary pages or scroll through pages, saving them time and effort. Alternatively, the information display mechanism can be an artificial intelligence (AI) display model that learns the user's key information interests based on past usage habits, such as viewing time, click count, and edit count, and automatically presents rich and necessary key information.
[0182] The present invention also provides a computer program product, which includes a computer program that can be stored on a readable storage medium. When the computer program is executed by a processor, the computer is able to execute the efficient fine-tuning method for language model parameters based on the block Toplitz matrix provided by the above methods.
[0183] In another embodiment, the present invention also proposes a storage medium VIII for storing a computer program that executes the efficient fine-tuning method for language model parameters based on the block Topulitz matrix. It should be understood that the storage medium in the embodiments of the present invention can be volatile memory or non-volatile memory, or may include both. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0184] Figure 4 A schematic block diagram of a second electronic device 1000 that can be used to implement embodiments of the present invention is shown. The second electronic device 1000 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The second electronic device 1000 can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein. The second electronic device 1000 may be the same as or different from the first electronic device A.
[0185] The second electronic device 1000 includes a computing unit I, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory II (ROM) or a computer program loaded from storage medium VIII into random access memory (RAM) III. The RAM III may also store various programs and data required for the operation of the device 1000. The computing unit I, ROM II, and RAM III are interconnected via bus IV. An input / output (I / O) interface V is also connected to bus IV.
[0186] Multiple components in the second electronic device 1000 are connected to I / O interface V, including: input unit VI, such as a keyboard, mouse, etc.; output unit VII, such as various types of displays, speakers, etc.; storage medium VIII, such as a disk, optical disk, etc.; and communication unit IX, such as a network card, modem, wireless transceiver, etc. Communication unit IX allows the second electronic device 1000 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0187] The computing unit I can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of computing unit I include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit I performs the various methods and processes described above, such as method steps S1-S8. For example, in some embodiments, the methods can be implemented as computer software programs tangibly contained in a machine-readable medium, such as storage medium VIII. In some embodiments, part or all of the computer program can be loaded and / or installed on device 1000 via ROM II and / or communication unit IX. When the computer program is loaded into RAM III and executed by computing unit I, one or more steps of the methods described above can be performed. Alternatively, in other embodiments, computing unit I can be configured to perform methods by any other suitable means (e.g., by means of firmware).
[0188] Although embodiments of the present invention have been disclosed above, they are not limited to the applications listed in the specification and embodiments. They can be applied to various fields suitable for the present invention. For those skilled in the art, other modifications can be easily made. Therefore, without departing from the general concept defined by the claims and their equivalents, the present invention is not limited to the specific details and illustrations shown and described herein.
Claims
1. A method for efficient fine-tuning of language model parameters based on a block Toplitz matrix, characterized in that, include: The initial step is to obtain a large language model and initialize its parameters. In the large language model, each Transformer layer contains an attention module, into which block adapters are inserted into the query and value projection layers. For each linear layer into which an adapter is inserted, t block Toplitz matrices are introduced to form a parameter set. ; Each of them Let the i-th block Toeplitz matrix be represented by... It consists of 10 sub-blocks, each sub-block being 1000 units in size. ; Constructing the effective weights of this linear layer for: ; Initialization parameter set ,in Initialize as a zero matrix, the rest ( The initial model is obtained by random initialization using a Gaussian distribution; The processing steps involve dividing the question-and-answer training set S into multiple batches to obtain the current batch. : ; in This indicates that the question text is input. This represents the corresponding target output sequence; The forward propagation step will move the current batch... Input is fed into the initial model; for each input sample in the current batch B The following calculations are performed in each layer of the initial model: Obtain the input representation of this layer ; Based on effective weights Calculate the output of this layer : ; Output Passed to the next layer as input; After calculations by all Transformer layers, the model output for the current batch is obtained. : ; in For input The corresponding prediction results; Loss calculation steps, based on model output With real labels : ; Calculate the loss of the current batch. : ; in Model a loss function for the language; Gradient calculation steps, based on loss For parameter set Perform backpropagation to obtain the gradient: ; The gradient g is output by the model. The loss function is obtained through backpropagation and then passed to the Toeplitz matrix of each block. ; The parameter update step, based on the gradient g, updates the parameter set. Update: ; With the updated parameter set replace ; The process involves repeating the processing steps up to the parameter update step, until all batches of the question-answering training set S are processed sequentially. This process is repeated a preset number of times to obtain the final parameter set. ; Model output steps, with the final parameter set Construct the final model weights of this large language model. : ; The parameters of this large language model are set as the weights of the final model. The final model is obtained by inputting the question text into the final model, and the answer to the question text is obtained.
2. The efficient fine-tuning method for language model parameters based on block Toplitz matrices as described in claim 1, characterized in that, The question-and-answer training set S includes mathematical application problems described in words. And the standard answer to the mathematical application problem. .
3. The efficient fine-tuning method for language model parameters based on block Toplitz matrices as described in claim 1, characterized in that, The number of blocks, t, is 64 or 256.
4. A highly efficient fine-tuning device for language model parameters based on a block Toplitz matrix, characterized in that, include: The initial module is used to obtain the large language model, and the parameters of the large language model are initialized as follows: In the large language model, each Transformer layer contains an attention module, into which block adapters are inserted into the query and value projection layers. For each linear layer into which an adapter is inserted, t block Toplitz matrices are introduced to form a parameter set. ; Each of them Let the i-th block Toeplitz matrix be represented by... It consists of 10 sub-blocks, each sub-block being 1000 units in size. ; Constructing the effective weights of this linear layer for: ; Initialization parameter set ,in Initialize as a zero matrix, the rest ( The initial model is obtained by random initialization using a Gaussian distribution; The processing module is used to divide the question-answering training set S into multiple batches and obtain the current batch. : ; in This indicates that the question text is input. This represents the corresponding target output sequence; The forward propagation module will pass the current batch Input is fed into the initial model; for each input sample in the current batch B The following calculations are performed in each layer of the initial model: Obtain the input representation of this layer ; Based on effective weights Calculate the output of this layer : ; Output Passed to the next layer as input; After calculations by all Transformer layers, the model output for the current batch is obtained. : ; in For input The corresponding prediction results; The loss calculation module is based on the model output. With real labels : ; Calculate the loss of the current batch. : ; in Model a loss function for the language; The gradient calculation module is used for loss-based calculations. For parameter set Perform backpropagation to obtain the gradient: ; The gradient g is output by the model. The loss function is obtained through backpropagation and then passed to the Toeplitz matrix of each block. ; The parameter update module, based on gradient g, updates the parameter set. Update: ; With the updated parameter set replace ; The loop module repeatedly executes the processing module up to the parameter update module until all batches of the question-answering training set S are processed sequentially, and the above process is repeated for a preset number of rounds to obtain the final parameter set. ; The model output module is used to output the final parameter set. Construct the final model weights of this large language model. : ; The parameters of this large language model are set as the weights of the final model. The final model is obtained by inputting the question text into the final model, and the answer to the question text is obtained.
5. The efficient fine-tuning device for language model parameters based on a block Toplitz matrix as described in claim 1, characterized in that, The question-and-answer training set S includes mathematical application problems described in words. And the standard answer to the mathematical application problem. .
6. The efficient fine-tuning method for language model parameters based on a block Toplitz matrix as described in claim 1, characterized in that, The number of blocks, t, is 64 or 256.
7. A client for implementing any of the language model parameter fine-tuning devices based on block Toplitz matrices as described in claims 4-6.
8. An electronic device, characterized in that, The device includes a language model parameter fine-tuning device based on a block Toplitz matrix as described in claims 4-6. The electronic device may be connected to an information display device, which is used to display the answer result with user-set display parameters, attributes, or through an artificial intelligence model.
9. A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for efficient fine-tuning of language model parameters based on a block Toplitz matrix as described in any one of claims 1-3.
10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the efficient fine-tuning method for language model parameters based on block Topulitz matrices as described in any of claims 1-3.