Task model generation method, electronic device, storage medium and program product

By using quantization processing and embedding low-rank adapters and quantization error compensators, the problem of high cost in fine-tuning task models is solved, achieving efficient and accurate model parameter adjustment, which is suitable for a variety of application scenarios.

CN121052286BActive Publication Date: 2026-05-19INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INSPUR SUZHOU INTELLIGENT TECH CO LTD
Filing Date
2025-10-31
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing task models are inefficient due to the long and costly parameter adjustment time during fine-tuning.

Method used

An initial low-rank adapter and an initial quantization error compensator are used to quantize the pre-trained task model. An adapter is then embedded after the quantized model structure layer. The model parameters are adjusted using the training dataset, thereby reducing the number of model parameters that need to be adjusted.

Benefits of technology

It reduces the cost of fine-tuning, improves the efficiency of adjustment, and reduces the consumption of video memory resources while ensuring accuracy, thus adapting to the needs of different application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121052286B_ABST
    Figure CN121052286B_ABST
Patent Text Reader

Abstract

The application discloses a task model generation method, an electronic device, a storage medium and a program product, relates to the technical field of artificial intelligence, and comprises the following steps: acquiring an initial low-rank adapter, an initial quantization error compensator, a pre-trained task model and a training data set. After the pre-trained task model is subjected to quantization processing, a quantized task model is obtained. The initial low-rank adapter is embedded behind a target structure layer of the quantized task model to obtain a first task model. A second task model is constructed based on the first task model and the initial quantization error compensator. After the training data set is used to adjust model parameters of the initial low-rank adapter and the initial quantization error compensator included in the second task model, a target task model is obtained. In this way, only the model parameters in the initial low-rank adapter and the initial quantization error compensator are adjusted, the number of adjusted model parameters is greatly reduced, and the fine-tuning cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to methods for generating task models, electronic devices, storage media, and program products. Background Technology

[0002] With the rapid iteration of artificial intelligence technology, task models have become a core technological support for fields such as natural language processing, computer vision, and speech recognition. For example, task models can be large-scale task models based on the "Transformer architecture" or multimodal large models. These models achieve powerful general feature extraction and task adaptation capabilities with billions to hundreds of billions of parameters. However, large pre-trained models need to be adapted to specific downstream tasks through fine-tuning, such as industrial defect detection, intelligent customer service speech transcription, and multimodal courseware understanding in the education field.

[0003] Generally, fine-tuning requires updating a large number of core model parameters, such as fully connected layers and attention layers. The large number of model parameters that need to be adjusted results in a long fine-tuning process and high costs. Summary of the Invention

[0004] This application provides a method, apparatus, electronic device, storage medium, and program product for generating task models to address the problem of high cost of fine-tuning operations.

[0005] This application provides a method for generating a task model, including:

[0006] Obtain the initial low-rank adapter, the initial quantization error compensator, the pre-trained task model, and the training dataset corresponding to the target inference task. The total number of model parameters included in the initial low-rank adapter and the initial quantization error compensator is less than the number of model parameters included in the pre-trained task model.

[0007] After quantizing the pre-trained task model, the quantized task model is obtained.

[0008] An initial low-rank adapter is embedded after the target structure layer of the quantized task model to obtain the first task model.

[0009] Based on the first task model and the initial quantization error compensator, a second task model is constructed.

[0010] Using the training dataset, the model parameters of the initial low-rank adapter and the initial quantization error compensator included in the second task model are adjusted to obtain the target task model, which is used to perform the target inference task.

[0011] This application also provides a task model generation apparatus, comprising:

[0012] The acquisition module is used to acquire the initial low-rank adapter, the initial quantization error compensator, the pre-trained task model, and the training dataset corresponding to the target inference task. The total number of model parameters included in the initial low-rank adapter and the initial quantization error compensator is less than the number of model parameters included in the pre-trained task model.

[0013] The quantization module is used to quantize the pre-trained task model to obtain the quantized task model.

[0014] A building module is used to embed an initial low-rank adapter after the target structure layer of the quantized task model to obtain the first task model; and a second task model is built based on the first task model and the initial quantization error compensator.

[0015] The adjustment module is used to adjust the model parameters of the initial low-rank adapter and the initial quantization error compensator included in the second task model using the training dataset, so as to obtain the target task model for performing the target inference task.

[0016] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of generating any of the above-described task models.

[0017] This application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of the method for generating any of the above-described task models.

[0018] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of generating any of the above-described task models.

[0019] This application first obtains an initial low-rank adapter, an initial quantization error compensator, a pre-trained task model, and a training dataset corresponding to the target inference task. Then, to conserve GPU memory, the pre-trained task model can be quantized to obtain a quantized task model. Further, the initial low-rank adapter can be embedded after the target structure layer of the quantized task model to obtain a first task model. Based on the first task model and the initial quantization error compensator, a second task model is constructed. During model parameter tuning, the training dataset can be used to adjust the model parameters of the initial low-rank adapter and the initial quantization error compensator included in the second task model, resulting in the target task model. Thus, this approach only adjusts the model parameters in the initial low-rank adapter and the initial quantization error compensator during parameter tuning. Since the total number of model parameters in the initial low-rank adapter and the initial quantization error compensator is much smaller than the number of model parameters in the pre-trained task model, the number of model parameters adjusted is significantly reduced, lowering fine-tuning costs and improving tuning efficiency. This allows for rapid response to the needs of different application scenarios and possesses greater practical value. Meanwhile, the quantized task model can greatly reduce the occupation of video memory resources, and the initial quantization error compensator can compensate for the quantization error caused by quantization processing. In other words, this solution reduces the cost of fine-tuning while ensuring the accuracy of the adjustment operation and the accuracy of the subsequent execution of the target inference task. Attached Figure Description

[0020] To more clearly illustrate the embodiments of this application, the accompanying 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.

[0021] Figure 1 A flowchart illustrating a method for generating a task model provided in an embodiment of this application;

[0022] Figure 2 A schematic diagram of a model preparation stage provided for an embodiment of this application;

[0023] Figure 3 This is a schematic diagram illustrating the parallel execution of multiple branches during the generation process of a task model provided in an embodiment of this application.

[0024] Figure 4 A flowchart illustrating a fine-tuning operation provided in an embodiment of this application;

[0025] Figure 5 A flowchart illustrating a task model generation apparatus provided in an embodiment of this application;

[0026] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0027] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0028] It should be noted that, in the description of this application, 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. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0029] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0030] Embodiments of this application provide a method for generating a task model, which can be executed by a computer device (e.g., a server, etc.). Figure 1 As shown, the specific processing steps of the task model generation method may include:

[0031] Step S101: Obtain the initial low-rank adapter, the initial quantization error compensator, the pre-trained task model, and the training dataset corresponding to the target inference task.

[0032] The initial low-rank adapter and the initial quantization error compensator contain fewer model parameters than the pre-trained task model.

[0033] Pre-trained task models can be large models used to perform various inference tasks, such as industrial defect detection, intelligent customer service speech transcription, multimodal courseware understanding in education, text generation, image understanding, and speech recognition. Large models refer to artificial intelligence models with billions to hundreds of billions of parameters.

[0034] The type of target reasoning task can be determined by the actual application scenario. The application scenario can usually be determined by multiple dimensions such as model type dimension, data feature dimension, and hardware dimension. For example, the model type can be a visual model, language model, multimodal model, etc., the data features can be image pixels, speech frames, text sequences, etc., and the hardware can be a graphics processing unit (GPU), a microcontroller unit (MCU), a central processing unit (CPU), etc.

[0035] The training dataset can include multiple input data points and their corresponding ground truth labels. For example, in an industrial defect detection scenario, the input data could be equipment operation data, and the ground truth labels could be specific defect types.

[0036] Specifically, technicians can upload the initial low-rank adapter, the initial quantization error compensator, the pre-trained task model, and the training dataset corresponding to the target inference task to the computer device in advance. In this way, the computer device can obtain the initial low-rank adapter, the initial quantization error compensator, the pre-trained task model, and the training dataset corresponding to the target inference task.

[0037] Step S102: After quantizing the pre-trained task model, the quantized task model is obtained.

[0038] Specifically, the model parameters of the pre-trained task model have high precision, which will consume a lot of GPU memory resources during the execution of inference tasks, and the process of adjusting model parameters is relatively complex. Therefore, in order to reduce the consumption of GPU memory resources and improve the efficiency of adjusting model parameters, this solution can first quantize the pre-trained task model, and then reduce the precision of the model parameters in the pre-trained task model to a specified precision to obtain the quantized task model.

[0039] For example, the precision of the pre-trained task model can be 32-bit or 16-bit floating-point numbers, and the quantization range can be... The integer range is defined accordingly, and after quantization, the model parameters in the pre-trained task model can be converted into 4-bit integers for storage.

[0040] Step S103: Embed an initial low-rank adapter after the target structure layer of the quantized task model to obtain the first task model.

[0041] Specifically, the quantized task model can include multiple structural layers. The computer device can directly embed the initial low-rank adapter after the target structural layer following the multiple structural layers included in the quantized task model to obtain the first task model.

[0042] Step S104: Based on the first task model and the initial quantization error compensator, construct the second task model.

[0043] Specifically, the computer device can combine the first task model and the initial quantization error compensator into a second task model, for example, by directly connecting the initial quantization error compensator to the second task model generated in step S103.

[0044] Step S105: Using the training dataset, the model parameters of the initial low-rank adapter and the initial quantization error compensator included in the second task model are adjusted to obtain the target task model.

[0045] Specifically, the task model is a general model. To adapt it to the target application scenario (i.e., the application scenario of the target inference task), the model parameters can be adjusted using a training dataset specific to the target application scenario. Furthermore, after quantization, the inference accuracy of the quantized task model may be lower than that of the pre-trained task model, resulting in quantization error. Additionally, the task model may include multiple weight matrices, which contain a large number of matrix elements (i.e., model parameters). Therefore, considering the existence of quantization error and the large number of model parameters in the quantized task model, this solution introduces an additional initial low-rank adapter and an initial quantization error compensator. During model parameter adjustment, the computer can input the input data from the training dataset into the second task model, performing one or more adjustments on the model parameters in the initial low-rank adapter and the initial quantization error compensator to obtain the final target task model. In this way, the target task model can be used to perform the target inference task.

[0046] The task model generation method of this application first obtains an initial low-rank adapter, an initial quantization error compensator, a pre-trained task model, and a training dataset corresponding to the target inference task. Then, to save GPU memory resources, the pre-trained task model can be quantized to obtain a quantized task model. Further, an initial low-rank adapter can be embedded after the target structure layer of the quantized task model to obtain a first task model. Based on the first task model and the initial quantization error compensator, a second task model is constructed. During the adjustment of model parameters, the training dataset can be used to adjust the model parameters of the initial low-rank adapter and the initial quantization error compensator included in the second task model to obtain the target task model. Thus, during the adjustment of model parameters, this solution only adjusts the model parameters in the initial low-rank adapter and the initial quantization error compensator. Since the total number of model parameters in the initial low-rank adapter and the initial quantization error compensator is much smaller than the number of model parameters in the pre-trained task model, the number of model parameters adjusted is greatly reduced, the fine-tuning cost is lowered, and the adjustment efficiency is improved. This allows for rapid response to the needs of different application scenarios and has stronger practical value. Meanwhile, the quantized task model can greatly reduce the occupation of video memory resources, and the initial quantization error compensator can compensate for the quantization error caused by quantization processing. In other words, this solution reduces the cost of fine-tuning while ensuring the accuracy of the adjustment operation and the accuracy of the subsequent execution of the target inference task.

[0047] In some alternative implementations, after step S104 described above, the computer device may set a gradient mask for the model parameters in the quantized task model included in the second task model.

[0048] Gradient masks can be used to indicate model parameters in a task model that is not adjusted after quantization.

[0049] Specifically, in order to avoid adjusting the model parameters in the quantized task model, the computer device can pre-set a gradient mask for the model parameters in the quantized task model included in the second task model before performing subsequent model parameter adjustment operations.

[0050] In this way, by setting gradient masks for the model parameters in the quantized task model in advance, it is possible to avoid updating a large number of model parameters and reduce the cost of fine-tuning.

[0051] In some optional implementations, the target structural layer may be a target network layer. In step one of step S103 above, the computer device may construct the first task model according to the following specific steps:

[0052] Step 1: Obtain target location information.

[0053] Step 2: Based on the target location information, determine the target network layer corresponding to the target location information in the quantized task model.

[0054] Step 3: Embed the initial low-rank adapter after the target network layer.

[0055] Specifically, the quantized task model can include multiple structural layers, such as embedding layers, attention layers, and network layers. Since the network layer has a large number of model parameters, a target network layer can be selected based on fine-tuning requirements for subsequent processing of its output data. Correspondingly, fine-tuning requirements can be reflected in the target network layer's target location information. After acquiring this information, the computer device can determine the target network layer within the quantized task model and embed the initial low-rank adapter into it, thus obtaining the first initial model.

[0056] This approach divides the functionality of the task model into different modules, facilitating problem identification and allowing for adjustments to the structure of each part based on the specific scenario. The low-rank adapter learns the knowledge required for the target inference task, while the quantization error compensator corrects performance losses caused by quantization. Furthermore, the low-rank adapter, quantization error compensator, and the quantized task model can execute tasks in parallel, avoiding additional latency caused by sequential execution and ensuring efficient fine-tuning. Additionally, this solution is applicable to various application scenarios without requiring changes to the quantization range, low-rank adapter structure, or quantization error compensation logic, making it more convenient and addressing the issue of reducing fine-tuning costs across various fields. For example, adding dialects to in-vehicle voice commands requires adjusting numerous model parameters in related technologies, while this solution only requires adjusting a small number of model parameters within the task model.

[0057] In some alternative implementations, in step S105 above, the computer device may perform the model parameter adjustment process according to the following specific steps:

[0058] Step 1: In the current round, select a sub-training dataset from the training dataset that corresponds to the current round.

[0059] Step 2: Obtain the quantization error corresponding to the current round.

[0060] Step 3: Based on the sub-training dataset and quantization error corresponding to the current round, adjust the model parameters of the low-rank adapter and quantization error compensator included in the task model to be adjusted corresponding to the current round to obtain the adjusted task model corresponding to the current round.

[0061] Specifically, if the current round is the first round, the task model to be adjusted is the second task model; or if the current round is not the first round, the task model to be adjusted is the adjusted task model corresponding to the previous round before the current round.

[0062] Step 4: After determining that the adjusted task model corresponding to the current round meets the preset stopping conditions, the adjusted task model corresponding to the current round is determined as the target task model.

[0063] Alternatively, in step five, after determining that the adjusted task model corresponding to the current round does not meet the preset stopping conditions, proceed to the next round until a task model that meets the preset stopping conditions is determined, then stop adjusting and determine the task model that meets the preset stopping conditions as the target task model.

[0064] Specifically, since the adjustment of model parameters is an iterative process, the computer device can perform corresponding adjustment operations in each iteration until a target task model that meets preset stopping conditions is determined. For example, preset stopping conditions may include model parameter convergence and / or the accuracy of performing the target inference task reaching a preset accuracy condition (which could be a loss value less than a preset threshold). The adjustment process can specifically be as follows:

[0065] In step one, the computer device can randomly select a batch of input data from the training dataset as the sub-training dataset for the current round.

[0066] In step two, as the model parameters in the quantization error compensator are continuously adjusted, the quantization error compensator can eliminate some of the quantization error. That is, the quantization error changes continuously with the adjustment process. Accordingly, in the current round, the computer device can first obtain the quantization error of the current round so that it can be used as a reference for subsequent adjustment steps.

[0067] In step three, if the current round is the first round, the computer device can directly use the second task model as the task model to be adjusted for the current round. If the current round is not the first round, the computer device can use the adjusted task model obtained after the adjustment operation in the previous round as the task model to be adjusted for the current round. Furthermore, the computer device can adjust the model parameters in the low-rank adapter and quantization error compensator of the task model to be adjusted corresponding to the current round based on the sub-training dataset and quantization error corresponding to the current round, thus obtaining the task model corresponding to the current round.

[0068] In steps four and five, the computer device can determine whether the model parameters in the low-rank adapter and quantization error compensator of the task model in the current round have converged, and whether the accuracy of performing the target inference task has reached the preset accuracy condition. If both judgments are yes, the task model corresponding to the current round is determined as the target task model. Alternatively, if one of the judgments is no, the next round can be entered, and so on, until a task model that meets the preset stopping condition is determined, and then the adjustment operation stops. Using "parameter convergence" and "performance achievement" as dual termination conditions ensures the sufficiency of model fine-tuning while avoiding the time waste caused by excessive iteration. Alternatively, the computer device can also determine the task model of the current round as the target task model if at least one judgment result is "yes".

[0069] In this way, by introducing quantization error and using the corresponding quantization error in different iteration rounds, the task model can learn more effectively how to maintain or recover the original performance of the task model under the information loss caused by quantization, thereby significantly reducing the accuracy decline caused by quantization and improving the accuracy of the final model (i.e., the target task model).

[0070] In some optional implementations, the pre-trained task model includes a weight matrix that can be called the original weight matrix. That is, the pre-trained task model can include multiple original weight matrices. Accordingly, in step two above, the computer device can determine the quantization error of the current round according to the type of the current round, using a method corresponding to the type of the current round. Specifically, this can include the following two cases:

[0071] Scenario 1: The current round is the first round.

[0072] Step 1: Determine the maximum and minimum weight values ​​in the target original weight matrix.

[0073] The target original weight matrix can be any one of multiple original weight matrices.

[0074] Step 2: Obtain the quantization range corresponding to the quantization process.

[0075] Step 3: Based on the maximum weight value, minimum weight value, quantization range, and the target quantization weight matrix corresponding to the target original weight matrix, determine the target inverse quantization weight matrix corresponding to the target original weight matrix.

[0076] Step 4: After determining the inverse quantization weight matrices corresponding to the multiple original weight matrices, determine the quantization error corresponding to the current round based on the multiple original weight matrices and their corresponding inverse quantization weight matrices.

[0077] Specifically, in step 1, taking the target original weight matrix as an example, the computer device can identify the maximum and minimum weight values ​​among the weight values ​​included in the target original weight matrix. The maximum and minimum weight values ​​constitute the weight value range of the target original weight matrix.

[0078] In step 2, during the aforementioned quantization process, the precision of the original target weight matrix can be reduced to the quantization range. In this step, the computer device can directly obtain the quantization range corresponding to the quantization process.

[0079] In step 3, the weight value range and quantization range of the original weight matrix can reflect the scaling ratio between the original weight matrix and the quantized weight matrix. Therefore, for the target original weight matrix, the computer device can use the maximum weight value, minimum weight value, and quantization range to perform dequantization operation on the target original weight matrix to determine the target dequantized weight matrix corresponding to the target original weight matrix.

[0080] In step 4, since the inverse quantization weight matrix obtained after the inverse quantization operation still differs from the original weight matrix, this difference can reflect the quantization error. Accordingly, after determining the inverse quantization weight matrices corresponding to the multiple original weight matrices, the computer device can determine the quantization error reflecting the overall situation based on the multiple original weight matrices and the inverse quantization weight matrices corresponding to the multiple original weight matrices, that is, determine the quantization error corresponding to the current round.

[0081] For example, in step 4, for each original weight matrix, the computer device can first calculate the quantization error of each original weight matrix, and then average the quantization errors of all original weight matrices to obtain the quantization error of the current round. Since each weight matrix includes multiple matrix elements, the mean squared error (MSE) can be used to calculate the quantization error of the original weight matrix. Taking the target original weight matrix as an example, the quantization error corresponding to the target original weight matrix can be calculated using the following expression:

[0082] (1)

[0083] in, The quantization error of the target original weight matrix, The target is the original weight matrix. The target is the dequantized weight matrix.

[0084] Scenario 2: The current round is not the first round.

[0085] Step 1: Obtain the number of model parameter adjustment operations performed before the current round.

[0086] Step 2: Whenever the number of adjustment operations is identified as an integer multiple of the preset number of adjustment operations, the input data from the previous round of sub-training dataset is input into the pre-trained task model to obtain the original output data corresponding to the input data from the previous round of sub-training dataset.

[0087] Step 3: Determine the quantization error corresponding to the current round based on the final output data corresponding to the input data in the sub-training dataset of the previous round, the original output data corresponding to the input data in the sub-training dataset of the previous round, and the dimension of the final output data.

[0088] Specifically, to reduce the computational overhead of updating quantization errors and balance timeliness, a quantization error update operation can be performed every preset number of training steps (e.g., 100). Accordingly, the computer device first obtains the number of model parameter adjustment operations performed before the current round (i.e., the number of rounds completed). If the number of adjustment operations is determined to be an integer multiple of the preset number of adjustment operations (e.g., 0 times, 100 times, i.e., the aforementioned preset number), then the number of quantization error update operations required can be determined. If the number of adjustment operations is not an integer multiple of the preset number of adjustment operations, the quantization error from the previous round can be reused. Then, the computer device can input the input data from the sub-training dataset of the previous round into the pre-trained task model. The pre-trained task model can then perform the target inference task on the input data, obtaining the original output data corresponding to the input data from the sub-training dataset of the previous round, as output by the pre-trained task model. Finally, the computer device can determine the quantization error corresponding to the current round based on the final output data corresponding to the input data in the previous round's sub-training dataset, the original output data corresponding to the input data in the previous round's sub-training dataset, and the dimension of the final output data.

[0089] Thus, if an update operation is performed in every round during the process of updating the quantization error, it will result in a large amount of computation, consume a lot of resources, and affect the fine-tuning efficiency. If no update operation is performed, it may lead to inaccurate fine-tuning, affecting the convergence speed of model parameters and the fine-tuning efficiency. Therefore, this scheme chooses to perform a model parameter update operation after a certain number of adjustment operations, which can avoid the aforementioned problems and achieve the dual purpose of reducing computational overhead and ensuring model accuracy.

[0090] In some optional implementations, before updating the quantization error of the current round, the computer device can determine the trend information of the quantization error (including the order of each round and its corresponding quantization error) based on the quantization error of the current round and the quantization errors of historical rounds before the current round. It can then extract trend features from this trend information and compare the similarity between these trend features and preset trend features. If the similarity is greater than a preset similarity threshold, the computer device will then perform the update operation for the quantization error of the current round. Since the preset trend features are used to indicate that the quantization error maintains a downward trend, when the similarity is greater than the preset similarity threshold, it indicates that the quantization error calculation for the current round is correct and can be used as a reference. This can more accurately guide the adjustment process of model parameters and improve fine-tuning efficiency.

[0091] In some alternative implementations, in step 3 of the above-described scenario one, the computer device may specifically determine the target inverse quantization weight matrix using the following steps:

[0092] Step a: Determine the target proportional coefficient based on the maximum weight value, the minimum weight value, and the quantization range.

[0093] Step b: Determine the zero-point coefficient based on the minimum weight value, the quantization range, and the target scaling factor.

[0094] Step c: Determine the target dequantization weight matrix based on the target scaling factor, zero-point factor, and target quantization weight matrix.

[0095] Specifically, the computer device can first calculate the first difference between the maximum and minimum weight values, and the second difference between the maximum and minimum values ​​included in the quantization range. Then, the ratio between the first and second differences can be determined as the target scaling factor, which reflects the scaling ratio of the quantization process. Next, the computer device can calculate the third difference between the minimum weight values ​​and the minimum value, and use this third difference and the target scaling factor to determine the zero-point coefficient. The zero-point coefficient can be used to align the starting points of the two precision ranges. Finally, based on the target scaling factor and the zero-point coefficient, the computer device can perform precision adjustment on the target quantization weight matrix to obtain a target inverse quantization weight matrix with the same precision as the original target weight matrix.

[0096] For example, step c can be expressed as follows:

[0097] (2)

[0098] in, For the target dequantized weight matrix, Quantize the weight matrix for the target. The target proportionality coefficient, It is the zero-point coefficient.

[0099] In some alternative implementations, in step 3 of scenario two above, the computer device may specifically determine the quantization error corresponding to the current round using the following steps:

[0100] Step a: Determine the sub-quantization error corresponding to the second input data based on the final output data and the original output data corresponding to the second input data, as well as the dimension of the final output data.

[0101] The second input data is any input data from the sub-training dataset corresponding to the previous round. The dimension of the final output data is the number of elements included in the final output data.

[0102] Step b: After determining the sub-quantization errors corresponding to the input data in the sub-training dataset of the previous round, determine the quantization error corresponding to the current round based on the sub-quantization errors corresponding to the input data in the sub-training dataset of the previous round.

[0103] Specifically, taking the second input data as an example, the final output data corresponding to the second input data and the original output data can be vectors, including the same number of elements. Accordingly, the computer device can perform positional difference calculations based on the elements included in the original output data and the elements included in the final output data. For each bit, the difference can be squared, and all the squared values ​​are summed. Furthermore, the ratio of the sum to the dimension of the final output data can be determined as the sub-quantization error of the second input data. Finally, the computer device can average the sub-quantization errors corresponding to the input data in the previous round of sub-training dataset to obtain the quantization error corresponding to the current round.

[0104] For example, step a can be expressed as follows:

[0105] (3)

[0106] Where E is the sub-quantization error of the second input data, and M is the dimension of the final output data. The i-th element in the original output data of the second input data. It is the i-th element in the final output data corresponding to the second input data.

[0107] In some optional implementations, the sub-training dataset for the current round may include at least one input data point and at least one corresponding ground truth label. The task model to be adjusted corresponding to the current round includes multiple low-rank matrices, where each matrix element is a model parameter. Accordingly, in step three of step S105 above, the computer device may perform the model parameter adjustment operation according to the following specific steps:

[0108] Step 1: Input the first input data into the quantized task model to obtain the quantized output data of the quantized task model and the intermediate output data of the target structure layer.

[0109] The first input data is any one of at least one input data.

[0110] Step 2: Based on multiple low-rank matrices, the quantization error corresponding to the current round, the target weight matrix in the target structure layer, the quantization output data, and the intermediate output data, determine the final output data corresponding to the first input data.

[0111] Step 3: After determining the final output data corresponding to at least one input data, adjust the model parameters of the low-rank adapter and quantization error compensator of the task model to be adjusted corresponding to the current round based on the real label and final output data corresponding to at least one input data, to obtain the adjusted task model corresponding to the current round.

[0112] Specifically, in step 1, taking the first input data as an example, the computer device can input the first input data into the quantized task model. The quantized task model can process the first input data in accordance with the target reasoning task to obtain the quantized output data corresponding to the first input data output by the quantized task model, and the intermediate output data corresponding to the first input data output by the target structure layer.

[0113] In step 2, using a low-rank matrix reduces the number of updated models and adapts to the target inference task. Therefore, during the adjustment process, the low-rank matrix, intermediate output data, and target weight matrix can be used as references to perform the adjustment operation. Furthermore, the adjustment operation needs to eliminate quantization errors; therefore, the quantization error of the current round must also be considered during the adjustment process. In summary, the computer device can use a low-rank matrix, the quantization error of the current round, the target weight matrix, and intermediate output data to adjust the quantized output data, thus obtaining the final output data corresponding to the first input data.

[0114] In a similar manner, computer devices can determine the final output data corresponding to the input data in the sub-training dataset of the current round.

[0115] In step 3, the loss value is calculated based on the true label and final output data corresponding to at least one input data point, and a gradient is generated based on the loss value (the gradient indicates the direction and magnitude of the adjustment of each model parameter that needs to be adjusted). Then, the model parameters of the low-rank adapter and quantization error compensator in the task model to be adjusted corresponding to the current round are adjusted based on the gradient to obtain the adjusted task model corresponding to the current round.

[0116] In this way, the introduction of low-rank matrices can greatly reduce the number of model parameters that need to be adjusted, thereby reducing fine-tuning costs and improving fine-tuning efficiency.

[0117] In some optional implementations, in step 2 of step three in step S105, the computer device may perform the adjustment operation using the following specific steps to determine the final output data corresponding to the first input data:

[0118] Step a: Determine the total error compensation amount based on multiple low-rank matrices, the quantization error corresponding to the current round, the target weight matrix in the target structure layer, and the intermediate output data.

[0119] Step b: Determine the final output data corresponding to the first input data based on the quantized output data and the total error compensation.

[0120] Specifically, by using a low-rank matrix, the number of updated model parameters can be reduced, adapting to the target inference task. Furthermore, the adjustment operation needs to eliminate quantization errors. Therefore, during the adjustment process, the computer device can use the low-rank matrix, intermediate output data, and the target weight matrix to determine all the errors that need to be compensated, as well as the total error compensation. Then, the computer device can sum the quantized output data and the total error compensation to obtain the final output data corresponding to the first input data.

[0121] In some alternative implementations, in step a above, the computer device may determine the total error compensation amount using the following specific steps:

[0122] Step a1: Determine the first error compensation amount based on multiple low-rank matrices, the target weight matrix in the target network layer, and intermediate output data.

[0123] Step a2: Determine the total error compensation amount based on the quantization error corresponding to the current round and the first error compensation amount.

[0124] Specifically, the multiple low-rank matrices may include a first low-rank matrix and a second low-rank matrix. The computer device can multiply the first low-rank matrix and the second low-rank matrix to obtain a total low-rank matrix. Then, the computer device can add the target weight matrix and the total low-rank matrix digit by digit, and then multiply it with the intermediate output data to obtain the total error compensation. The second low-rank matrix has a first dimension (input feature dimension) of size D and a second dimension of size R. The first low-rank matrix has a first dimension of size R and a second dimension (output feature dimension) of size K. R is a preset low-rank parameter smaller than D and K, and R is much smaller than the dimension of the input data.

[0125] For example, step a1 can be expressed as follows:

[0126] (4)

[0127] in, This is the first error compensation amount. For the target weight matrix, , Let A be the total low-rank matrix, B be the first low-rank matrix among multiple low-rank matrices, and x be the intermediate output data.

[0128] In some alternative implementations, in step a2 above, the computer device may determine the total error compensation amount using the following specific steps:

[0129] Step a21: After performing feature extraction on the quantization error corresponding to the current round, the quantization error features are obtained.

[0130] Step a22: Determine the second error compensation amount based on the pre-acquired scalar compensation coefficient and quantization error characteristics.

[0131] The scalar compensation coefficient is the model parameter in the quantization error compensator included in the task model to be adjusted corresponding to the current round.

[0132] Step a23: Add the second error compensation amount and the first error compensation amount together to obtain the total error compensation amount.

[0133] Specifically, the computer device can input the quantization error into a pre-built feature extractor, which can perform feature extraction operations (such as linear or nonlinear transformations) on the quantization error to obtain quantization error features (which can be a vector). Then, the computer device can adjust the quantization error features based on scalar compensation coefficients to obtain a second error compensation amount. Finally, the computer device can add the second error compensation amount and the first error compensation amount bit-for-bit to obtain the total error compensation amount.

[0134] For example, step a22 above can be expressed as follows:

[0135] (5)

[0136] in, This is the second error compensation amount. The scalar compensation coefficient is... This represents the quantization error characteristic.

[0137] Step a23 can be expressed as follows:

[0138] (6)

[0139] in, This is the total error compensation amount. This is the first error compensation amount. This is the second error compensation amount.

[0140] Accordingly, step b above can be expressed as follows:

[0141] (7)

[0142] in, The final output data corresponding to the first input data. The quantized output data corresponding to the first input data. This represents the total error compensation.

[0143] In some optional implementations, the quantization error compensator (the quantization error compensator included in the task model of the current round) may include a feature extractor, a compensation weight generator, and a signal fusion unit. Accordingly, in step a21 above, the computer device can use the feature extractor to perform feature extraction on the quantization error. In step a22 above, the scalar compensation coefficient can be a component of the compensation weight generator. The computer device can input the quantization error features into the compensation weight generator to obtain the second error compensation amount output by the compensation weight generator. In step a23 above, the computer device can input both the first and second error compensation amounts into the signal fusion unit, which can then perform a bitwise addition operation on the two to obtain the total error compensation amount.

[0144] refer to Figure 2In the preparation phase, the computer device can first load a pre-trained task model. The computer device can then quantize the pre-trained task model, including performing dynamic range statistics on the weight matrices and linearly mapping floating-point values ​​to a specified integer range, resulting in a quantized task model (where the weight matrices are stored as 4-bit signed integers). Additionally, the computer device can calculate the quantization error for the first round. This allows the computer device to release the GPU memory occupied by the pre-trained task model while retaining the quantized task model and the quantization error from the first round. Then, the computer device can embed an initial low-rank adapter after the target network layer to obtain the first task model. The low-rank adapter in any round can be used to calculate the first error compensation. Furthermore, the computer device can construct an initial quantization error compensator. In any round, a feature extractor can be used to extract quantization error features, and the feature extractor in the quantization compensator can be used to calculate the second error compensation. A signal fusion unit can be used to fuse the first and second error compensations to obtain the total error compensation, which is used for updating model parameters during subsequent fine-tuning.

[0145] In some alternative implementations, refer to Figure 3 Step 1 (step three of step S105) can be executed in parallel as branch one, step a1 as branch two, and the step of determining the quantization error corresponding to the current round in case two as branch three. This improves fine-tuning efficiency. After completing the operations of branch two and branch three, the computer device can input the quantization error of the current round into the quantization error compensator and calculate the second error compensation amount using the scalar compensation coefficient in the quantization error compensator. Furthermore, the quantization output data can be determined after completing the operation of branch one. Finally, the computer device can determine the total error compensation amount based on the first and second error compensation amounts, and determine the final output data based on the total error compensation amount and the quantization output data.

[0146] In some alternative implementations, the loss value calculation can be performed by a separate loss calculator, and the model parameter adjustment can be performed by a separate parameter updater. Accordingly, the quantization error compensator, low-rank adapter, quantized task model, loss calculator, and parameter updater can be configured as follows: Figure 4 The timing diagram shown is used for fine-tuning.

[0147] The quantization error compensator determines a second error compensation amount based on the quantization error of the current round. The low-rank adapter sends its calculated first error compensation amount to the quantization error compensator. The quantization error compensator adds the first and second error compensation amounts bit-for-bit to obtain the total error compensation amount, which is then sent to the loss calculator. The quantized task model processes the input data to obtain quantized output data and sends the quantized output data and the ground truth labels to the loss calculator. The loss calculator determines the final output data based on the total error compensation amount and the quantized output data, calculates the loss value based on the final output data and the ground truth labels, and sends it to the parameter updater. The parameter updater performs backpropagation, calculates the gradient based on the loss value, and updates the weight parameters in the low-rank matrices included in the low-rank adapter and the model parameters (e.g., scalar compensation coefficients) included in the quantization error compensator. Additionally, for the quantized task model, a gradient mask can be set for the included model parameters, effectively freezing the model parameters and preventing updates.

[0148] It should be noted that the computational quantities involved in the embodiments of this application are all dimensionless parameters.

[0149] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0150] Embodiments of this application also provide a task model generation apparatus, such as... Figure 5 As shown, it includes:

[0151] The acquisition module 510 is used to acquire the initial low-rank adapter, the initial quantization error compensator, the pre-trained task model, and the training dataset corresponding to the target inference task. The total number of model parameters included in the initial low-rank adapter and the initial quantization error compensator is less than the number of model parameters included in the pre-trained task model.

[0152] The quantization module 520 is used to quantize the pre-trained task model to obtain the quantized task model.

[0153] Module 530 is used to embed an initial low-rank adapter after the target structure layer of the quantized task model to obtain the first task model; and to construct the second task model based on the first task model and the initial quantization error compensator.

[0154] The adjustment module 540 is used to adjust the model parameters of the initial low-rank adapter and the initial quantization error compensator included in the second task model using the training dataset, so as to obtain the target task model for performing the target inference task.

[0155] In some alternative implementations, the adjustment module 540 is specifically used for:

[0156] In the current round, select a sub-training dataset corresponding to the current round from the training dataset;

[0157] Obtain the quantization error corresponding to the current round;

[0158] Based on the sub-training dataset and quantization error corresponding to the current round, the model parameters of the low-rank adapter and quantization error compensator included in the task model to be adjusted corresponding to the current round are adjusted to obtain the adjusted task model corresponding to the current round. Wherein, when the current round is the first round, the task model to be adjusted is the second task model, or when the current round is not the first round, the task model to be adjusted is the adjusted task model corresponding to the previous round before the current round.

[0159] Once it is determined that the adjusted task model corresponding to the current round meets the preset stopping conditions, the adjusted task model corresponding to the current round will be determined as the target task model.

[0160] Alternatively, if the adjusted task model corresponding to the current round does not meet the preset stopping condition, proceed to the next round until a task model that meets the preset stopping condition is identified, then stop adjusting and designate the task model that meets the preset stopping condition as the target task model.

[0161] In some optional implementations, the sub-training dataset includes at least one input data point and at least one corresponding ground truth label. The low-rank adapter in the task model to be adjusted corresponding to the current round includes multiple low-rank matrices, where the matrix elements of the multiple low-rank matrices are model parameters. The adjustment module 540 is specifically used for:

[0162] The first input data is input into the quantized task model to obtain the quantized output data of the quantized task model and the intermediate output data of the target structure layer. The first input data is any one of at least one input data.

[0163] Based on multiple low-rank matrices, the quantization error corresponding to the current round, the target weight matrix in the target structure layer, the quantization output data, and the intermediate output data, determine the final output data corresponding to the first input data;

[0164] After determining the final output data corresponding to at least one input data point, the model parameters of the low-rank adapter and quantization error compensator, which are included in the task model to be adjusted for the current round, are adjusted based on the real label and final output data corresponding to at least one input data point, so as to obtain the adjusted task model corresponding to the current round.

[0165] In some alternative implementations, the adjustment module 540 is specifically used for:

[0166] The total error compensation amount is determined based on multiple low-rank matrices, the quantization error corresponding to the current round, the target weight matrix in the target structure layer, and the intermediate output data.

[0167] Based on the quantized output data and the total error compensation, determine the final output data corresponding to the first input data.

[0168] In some alternative implementations, the adjustment module 540 is specifically used for:

[0169] The first error compensation amount is determined based on multiple low-rank matrices, the target weight matrix in the target structure layer, and intermediate output data.

[0170] The total error compensation is determined based on the quantization error and the first error compensation amount corresponding to the current round.

[0171] In some alternative implementations, the adjustment module 540 is specifically used for:

[0172] After performing feature extraction on the quantization error corresponding to the current round, the quantization error features are obtained;

[0173] Based on the pre-acquired scalar compensation coefficient and quantization error characteristics, the second error compensation amount is determined, wherein the scalar compensation coefficient is the model parameter in the quantization error compensator included in the task model to be adjusted corresponding to the current round;

[0174] The second error compensation amount and the first error compensation amount are added together to obtain the total error compensation amount.

[0175] In some optional implementations, the pre-trained task model includes multiple original weight matrices, and the quantized task model includes quantized weight matrices corresponding to the multiple original weight matrices respectively; the adjustment module 540 is specifically used for:

[0176] Determine the maximum and minimum weight values ​​in the target original weight matrix, where the target original weight matrix is ​​any one of multiple original weight matrices;

[0177] Obtain the quantization range corresponding to the quantization process;

[0178] Based on the maximum weight value, minimum weight value, quantization range, and the target quantization weight matrix corresponding to the target original weight matrix, determine the target inverse quantization weight matrix corresponding to the target original weight matrix;

[0179] After determining the inverse quantization weight matrices corresponding to the multiple original weight matrices, the quantization error corresponding to the current round is determined based on the multiple original weight matrices and their corresponding inverse quantization weight matrices. In some optional implementations, when the current round is not the first round, the adjustment module 540 is specifically used for:

[0180] Get the number of model parameter adjustment operations performed before the current round;

[0181] Whenever the number of adjustment operations is identified as an integer multiple of the preset number of adjustment operations, the input data from the previous round of sub-training dataset is input into the pre-trained task model, and the original output data corresponding to the input data from the previous round of sub-training dataset is obtained from the output of the pre-trained task model.

[0182] Based on the final output data corresponding to the input data in the previous round's sub-training dataset, the original output data corresponding to the input data in the previous round's sub-training dataset, and the dimension of the final output data, determine the quantization error corresponding to the current round.

[0183] In some alternative implementations, the adjustment module 540 is specifically used for:

[0184] Based on the final output data and original output data corresponding to the second input data, as well as the dimension of the final output data, the sub-quantization error corresponding to the second input data is determined, wherein the second input data is any input data in the sub-training dataset corresponding to the previous round;

[0185] Once the sub-quantization errors corresponding to the input data in the previous round's sub-training dataset are determined, the quantization error corresponding to the current round is determined based on the sub-quantization errors corresponding to the input data in the previous round's sub-training dataset.

[0186] For a description of the features in the embodiment corresponding to the task model generation device, please refer to the relevant description in the embodiment corresponding to the task model generation method, which will not be repeated here.

[0187] Embodiments of this application also provide an electronic device, such as... Figure 6 As shown, it includes a memory 10 and a processor 20. The memory 10 stores a computer program, and the processor 20 is configured to run the computer program to perform the steps in any of the above-described task model generation method embodiments.

[0188] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in the above-described embodiments of the task model generation method when running.

[0189] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0190] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described task model generation method embodiments.

[0191] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in the above-described task model generation method embodiments.

[0192] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0193] The foregoing has provided a detailed description of a task model generation method, apparatus, electronic device, storage medium, and program product provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.

Claims

1. A method for generating a task model, characterized in that, include: Obtain an initial low-rank adapter, an initial quantization error compensator, a pre-trained task model, and a training dataset corresponding to the target inference task. The total number of model parameters included in the initial low-rank adapter and the initial quantization error compensator is less than the number of model parameters included in the pre-trained task model. The target inference task is any one of the following: industrial defect detection, intelligent customer service speech transcription, multimodal courseware understanding in the education field, text generation, image understanding, speech recognition, etc. The training dataset includes one or more types of data, such as text data, image data, audio data, and video data. After quantizing the pre-trained task model, a quantized task model is obtained. The initial low-rank adapter is embedded after the target structure layer of the quantized task model to obtain the first task model; Based on the first task model and the initial quantization error compensator, a second task model is constructed; In the current round, a sub-training dataset corresponding to the current round is selected from the training dataset; Obtain the quantization error corresponding to the current round; Based on the sub-training dataset and quantization error corresponding to the current round, the model parameters of the low-rank adapter and quantization error compensator included in the task model to be adjusted corresponding to the current round are adjusted to obtain the adjusted task model corresponding to the current round. Wherein, when the current round is the first round, the task model to be adjusted is the second task model, or when the current round is not the first round, the task model to be adjusted is the adjusted task model corresponding to the previous round before the current round. After determining that the adjusted task model corresponding to the current round meets the preset stopping conditions, the adjusted task model corresponding to the current round is determined as the target task model for executing the target inference task.

2. The method for generating a task model according to claim 1, characterized in that, The method further includes: After determining that the adjusted task model corresponding to the current round does not meet the preset stopping condition, the process proceeds to the next round until a task model that meets the preset stopping condition is identified. Then, the adjustment stops, and the task model that meets the preset stopping condition is identified as the target task model.

3. The method for generating a task model according to claim 2, characterized in that, The sub-training dataset includes at least one input data and at least one true label corresponding to the input data. The low-rank adapter in the task model to be adjusted corresponding to the current round includes multiple low-rank matrices, and the matrix elements in the multiple low-rank matrices are model parameters. The step of adjusting the model parameters of the low-rank adapter and quantization error compensator in the task model to be adjusted corresponding to the current round based on the sub-training dataset and quantization error corresponding to the current round to obtain the adjusted task model corresponding to the current round includes: The first input data is input into the quantized task model to obtain the quantized output data of the quantized task model and the intermediate output data of the target structure layer, wherein the first input data is any one of at least one input data. Based on the multiple low-rank matrices, the quantization error corresponding to the current round, the target weight matrix in the target structure layer, the quantization output data, and the intermediate output data, determine the final output data corresponding to the first input data; After determining the final output data corresponding to at least one of the input data, the model parameters of the low-rank adapter and quantization error compensator included in the task model to be adjusted corresponding to the current round are adjusted according to the real label and final output data corresponding to at least one of the input data, so as to obtain the adjusted task model corresponding to the current round.

4. The method for generating a task model according to claim 3, characterized in that, The step of determining the final output data corresponding to the first input data based on the multiple low-rank matrices, the quantization error corresponding to the current round, the target weight matrix in the target structure layer, the quantization output data, and the intermediate output data includes: The total error compensation amount is determined based on the multiple low-rank matrices, the quantization error corresponding to the current round, the target weight matrix in the target structure layer, and the intermediate output data. Based on the quantized output data and the total error compensation, the final output data corresponding to the first input data is determined.

5. The method for generating a task model according to claim 4, characterized in that, The step of determining the total error compensation amount based on the multiple low-rank matrices, the quantization error corresponding to the current round, the target weight matrix in the target structure layer, and the intermediate output data includes: The first error compensation amount is determined based on the multiple low-rank matrices, the target weight matrix in the target structure layer, and the intermediate output data. The total error compensation amount is determined based on the quantization error corresponding to the current round and the first error compensation amount.

6. The method for generating a task model according to claim 5, characterized in that, The step of determining the total error compensation amount based on the quantization error corresponding to the current round and the first error compensation amount includes: After performing feature extraction on the quantization error corresponding to the current round, the quantization error features are obtained; Based on the pre-acquired scalar compensation coefficient and the quantization error characteristics, a second error compensation amount is determined, wherein the scalar compensation coefficient is the model parameter in the quantization error compensator included in the task model to be adjusted corresponding to the current round; The second error compensation amount and the first error compensation amount are added together to obtain the total error compensation amount.

7. The method for generating a task model according to any one of claims 2 to 6, characterized in that, The pre-trained task model includes multiple original weight matrices, and the quantized task model includes quantized weight matrices corresponding to the multiple original weight matrices respectively. When the current round is the first round, obtaining the quantization error corresponding to the current round includes: The maximum and minimum weight values ​​in the target original weight matrix are determined respectively, wherein the target original weight matrix is ​​any one of the multiple original weight matrices; Obtain the quantization range corresponding to the quantization process; Based on the maximum weight value, the minimum weight value, the quantization range, and the target quantization weight matrix corresponding to the target original weight matrix, determine the target inverse quantization weight matrix corresponding to the target original weight matrix; After determining the inverse quantization weight matrices corresponding to the multiple original weight matrices, the quantization error corresponding to the current round is determined based on the multiple original weight matrices and the inverse quantization weight matrices corresponding to the multiple original weight matrices.

8. The method for generating a task model according to any one of claims 2 to 5, characterized in that, When the current round is not the first round, obtaining the quantization error corresponding to the current round includes: Obtain the number of model parameter adjustment operations performed before the current round; Whenever the number of adjustment operations is detected to be an integer multiple of the preset number of adjustment operations, the input data from the previous round of sub-training dataset is input into the pre-trained task model to obtain the original output data corresponding to the input data from the previous round of sub-training dataset output by the pre-trained task model. The quantization error corresponding to the current round is determined based on the final output data corresponding to the input data in the previous round's sub-training dataset, the original output data corresponding to the input data in the previous round's sub-training dataset, and the dimension of the final output data.

9. The method for generating a task model according to claim 8, characterized in that, The step of determining the quantization error corresponding to the current round based on the final output data corresponding to the input data in the previous round's sub-training dataset, the original output data corresponding to the input data in the previous round's sub-training dataset, and the dimension of the final output data includes: Based on the final output data and original output data corresponding to the second input data, and the dimension of the final output data, the sub-quantization error corresponding to the second input data is determined, wherein the second input data is any input data in the sub-training dataset corresponding to the previous round; Once the sub-quantization errors corresponding to the input data in the sub-training dataset of the previous round are determined, the quantization error corresponding to the current round is determined based on the sub-quantization errors corresponding to the input data in the sub-training dataset of the previous round.

10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the method for generating the task model as described in any one of claims 1 to 9.