Model continuous training method, device and equipment based on joint metric selection
By calculating the cross-entropy loss value and the optimal transmission distance to screen the target data set, the small language model is continuously trained, which solves the problem of low quality of the training data set and improves prediction accuracy and resource utilization efficiency.
Patent Information
- Application Number
- CN202411782183.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-12-05
AI Technical Summary
In the existing technology, the training datasets used by small language models during the training phase are of low quality, resulting in low prediction accuracy and limiting their effective use in limited resource environments.
By determining the first cross-entropy loss value of the candidate dataset for the first small language model and the second cross-entropy loss value of the training dataset for the second small language model, calculating the difference and the optimal transmission distance, the target dataset is screened from the candidate dataset, and the small language model is continuously trained to improve data quality.
Improved prediction accuracy of small language models and enhanced their ability to be effectively utilized in resource-constrained environments.
Smart Images

Figure CN119719774B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of deep learning technology, and in particular to a method, apparatus and device for continuous model training based on joint metric selection. Background Art
[0002] Past research has highlighted the growing need to improve the reasoning capabilities of small language models. While several existing large-scale language models have demonstrated strong reasoning capabilities for complex tasks, their significant computational resource requirements have limited their widespread adoption in practical applications. Effectively leveraging the reasoning capabilities of language models in resource-constrained environments has become an emerging research topic.
[0003] Related technologies primarily use knowledge distillation to "distill" the reasoning capabilities of a large model into a smaller model. This approach typically relies on reasoning paths or data generated by a large teacher model, which is then used to fine-tune the smaller model. Alternatively, the large model can be used to generate synthetic data, which can then be used to fine-tune the smaller model. This approach is commonly used in scenarios requiring complex reasoning, such as arithmetic and logical reasoning.
[0004] However, in the above method, the quality of the training data set used in the training stage of the small model is low, resulting in low prediction accuracy of the trained small language model. Summary of the Invention
[0005] In view of the above problems, the embodiments of the present application provide a method, device, electronic device and readable storage medium for continuous model training based on joint metric selection to overcome the above problems or at least partially solve the above problems.
[0006] In a first aspect, an embodiment of the present application provides a method for continuous model training based on joint metric selection, the method comprising:
[0007] Determining a first cross-entropy loss value for a candidate dataset for a first small language model, and determining a second cross-entropy loss value for a training dataset for a second small language model; wherein the second small language model is a model obtained by adjusting model parameters of the first small language model; and the candidate dataset and the training dataset contain different sample text data;
[0008] Calculating a first difference between the first cross entropy loss value and the second cross entropy loss value;
[0009] determining a first target data set from the candidate data sets based on the first difference and a first optimal transmission distance between the candidate data set and the training data set;
[0010] Based on the first target dataset, the first small language model is continuously trained to obtain a target small language model.
[0011] Optionally, determining a first cross entropy loss value of the candidate dataset for the first small language model includes:
[0012] Inputting first sample text data in the candidate data set into a first small language model to obtain a first prediction vector output by the first small language model;
[0013] Based on the first prediction vector and the first annotation vector of the first sample text data, a first cross entropy loss value of the candidate dataset for the first small language model is determined.
[0014] Optionally, determining a second cross entropy loss value of the training dataset for the second small language model includes:
[0015] Inputting second sample text data in the training data set into a second small language model to obtain a second prediction vector output by the second small language model;
[0016] Based on the second prediction vector and the second labeled vector of the second sample text data, a second cross entropy loss value of the training dataset for the second small language model is determined.
[0017] Optionally, determining a first target data set from the candidate data sets based on the first difference and a first optimal transmission distance between the candidate data set and the training data set includes:
[0018] A first target data set is determined from the candidate data sets, wherein the first difference is greater than or equal to a first threshold, and a first optimal transmission distance between the candidate data set and the training data set is greater than or equal to a second threshold.
[0019] Optionally, determining a first target data set from the candidate data sets based on the first difference and a first optimal transmission distance between the candidate data set and the training data set includes:
[0020] Determine a first gradient of a first optimal transmission distance between the candidate data set and the training data set for each of the candidate data sets;
[0021] Calculating a first quality evaluation index of the candidate data set based on the first gradient, a regularization coefficient of the first gradient, and the first difference;
[0022] Determine a first target data set from the candidate data sets, in which the first quality evaluation indicator is greater than or equal to a third threshold.
[0023] Optionally, the continuously training the first small language model based on the first target dataset to obtain a target small language model includes:
[0024] Vectorizing the first sample text data contained in the first target data set to obtain a first sample text vector;
[0025] Inputting the first sample text vector into the first small language model to obtain a first sample prediction vector output by the first small language model;
[0026] Calculating a third cross entropy loss value between the first sample prediction vector and the sample annotation vector corresponding to the first sample text data;
[0027] Based on the third cross-entropy loss value, model parameters of the first small language model are adjusted to obtain a target small language model.
[0028] Optionally, adjusting the model parameters of the first small language model based on the third cross-entropy loss value to obtain a target small language model includes:
[0029] Adjusting model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model after parameter adjustment;
[0030] Calculating a second difference between the third cross entropy loss value and the second cross entropy loss value;
[0031] determining a second quality evaluation indicator of the first target data set based on the second difference, a regularization coefficient of the second difference, and a second optimal transmission distance between the first target data set and the training data set;
[0032] Determine, from the first target data set, a second target data set in which the second quality evaluation indicator is greater than or equal to a third threshold;
[0033] Vectorizing the second sample text data contained in the second target data set to obtain a second sample text vector;
[0034] Inputting the second sample text vector into the first small language model after parameter adjustment to obtain a second sample prediction vector output by the first small language model after parameter adjustment;
[0035] Calculating a fourth cross entropy loss value between the second sample prediction vector and the sample annotation vector corresponding to the second sample text data;
[0036] Calculate the second sample prediction vector and the second sample text based on the fourth cross entropy loss value, adjust the model parameters of the first small language model after the parameter adjustment, and obtain a fourth cross entropy loss value between the sample annotation vectors corresponding to the target small language model.
[0037] Optionally, adjusting the model parameters of the first small language model based on the third cross-entropy loss value to obtain a target small language model includes:
[0038] Adjusting model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model after parameter adjustment;
[0039] Re-performing the step of inputting the first sample text vector into the first small language model to obtain a first sample prediction vector output by the first small language model;
[0040] Counting the number of first consecutive occurrences of the third cross entropy loss value being less than or equal to a fourth threshold and the number of training cycles of the first small language model;
[0041] When the first number is greater than or equal to a fifth threshold, or the number of training cycles is greater than or equal to a sixth threshold, adjusting the model parameters of the first small language model is stopped to obtain a target small language model.
[0042] In a second aspect, an embodiment of the present application provides a model continuous training device based on joint metric selection, the device comprising:
[0043] a first determination module, configured to determine a first cross-entropy loss value for a candidate dataset for a first small language model, and to determine a second cross-entropy loss value for a training dataset for a second small language model; wherein the second small language model is a model obtained by adjusting model parameters of the first small language model; and the candidate dataset and the training dataset contain different sample text data;
[0044] A calculation module, configured to calculate a first difference between the first cross entropy loss value and the second cross entropy loss value;
[0045] a second determining module, configured to determine a first target data set from the candidate data sets based on the first difference and a first optimal transmission distance between the candidate data set and the training data set;
[0046] A continuous training module is used to continuously train the first small language model based on the first target data set to obtain a target small language model.
[0047] Optionally, the first determining module includes:
[0048] A first input-output submodule, configured to input first sample text data in the candidate data set into a first small language model to obtain a first prediction vector output by the first small language model;
[0049] The first determination submodule is configured to determine a first cross entropy loss value of the candidate dataset for the first small language model based on the first prediction vector and the first annotation vector of the first sample text data.
[0050] Optionally, the first determining module includes:
[0051] A second input-output submodule, configured to input second sample text data in the training data set into a second small language model to obtain a second prediction vector output by the second small language model;
[0052] The second determining submodule is configured to determine a second cross entropy loss value of the training dataset for the second small language model based on the second prediction vector and the second labeled vector of the second sample text data.
[0053] Optionally, the second determining module includes:
[0054] The third determining submodule is configured to determine, from the candidate data sets, a first target data set whose first difference is greater than or equal to a first threshold and whose first optimal transmission distance between the candidate data set and the training data set is greater than or equal to a second threshold.
[0055] Optionally, the second determining module includes:
[0056] A fourth determining submodule, configured to determine a first gradient of a first optimal transmission distance between the candidate dataset and the training dataset for each candidate dataset;
[0057] a first calculation submodule, configured to calculate a first quality evaluation index of the candidate data set based on the first gradient, a regularization coefficient of the first gradient, and the first difference;
[0058] The fifth determining submodule is configured to determine, from the candidate data sets, a first target data set whose first quality evaluation indicator is greater than or equal to a third threshold.
[0059] Optionally, the continuous training module includes:
[0060] a vectorization submodule, configured to vectorize the first sample text data contained in the first target data set to obtain a first sample text vector;
[0061] a third input-output submodule, configured to input the first sample text vector into the first small language model to obtain a first sample prediction vector output by the first small language model;
[0062] A second calculation submodule is used to calculate a third cross entropy loss value between the first sample prediction vector and the sample annotation vector corresponding to the first sample text data;
[0063] An adjustment submodule is configured to adjust model parameters of the first small language model based on the third cross-entropy loss value to obtain a target small language model.
[0064] Optionally, the adjustment submodule includes:
[0065] A first adjustment unit is configured to adjust model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model after parameter adjustment;
[0066] A first calculation unit is used to calculate a second difference between the third cross entropy loss value and the second cross entropy loss value;
[0067] a first determining unit, configured to determine a second quality evaluation indicator of the first target data set based on the second difference, a regularization coefficient of the second difference, and a second optimal transmission distance between the first target data set and the training data set;
[0068] a second determining unit, configured to determine, from the first target data set, a second target data set in which the second quality evaluation indicator is greater than or equal to a third threshold;
[0069] a vectorization unit, configured to vectorize the second sample text data contained in the second target data set to obtain a second sample text vector;
[0070] an input-output unit, configured to input the second sample text vector into the first small language model after parameter adjustment, and obtain a second sample prediction vector output by the first small language model after parameter adjustment;
[0071] A second calculation unit is used to calculate a fourth cross entropy loss value between the second sample prediction vector and the sample annotation vector corresponding to the second sample text data;
[0072] The second adjustment unit is used to calculate the fourth cross entropy loss value between the second sample prediction vector and the second sample text number, adjust the model parameters of the first small language model after the parameter adjustment, and obtain the fourth cross entropy loss value between the sample annotation vectors corresponding to the target small language model.
[0073] Optionally, the adjustment submodule includes:
[0074] a third adjusting unit, configured to adjust model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model after parameter adjustment;
[0075] an execution unit, configured to re-execute the step of inputting the first sample text vector into the first small language model to obtain a first sample prediction vector output by the first small language model;
[0076] a statistical unit, configured to count the number of first consecutive occurrences of the situation where the third cross entropy loss value is less than or equal to a fourth threshold and the number of training cycles of the first small language model;
[0077] The stopping module is configured to stop adjusting the model parameters of the first small language model to obtain a target small language model when the first number is greater than or equal to a fifth threshold, or when the number of training cycles is greater than or equal to a sixth threshold.
[0078] In a third aspect, an embodiment of the present application provides an electronic device comprising a memory, a processor, and a computer program stored on the memory, wherein the processor executes the computer program to implement the model continuous training method based on joint metric selection as described in any one of the above items.
[0079] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, a continuous model training method based on joint metric selection as described in any one of the above items is implemented.
[0080] The specific beneficial effects are:
[0081] In an embodiment of the present application, a first cross-entropy loss value for a candidate dataset with respect to a first small language model is determined, and a second cross-entropy loss value for a training dataset with respect to a second small language model is determined. The second small language model is a model obtained after adjusting model parameters of the first small language model. The candidate dataset and the training dataset contain different sample text data, and a first difference between the first cross-entropy loss value and the second cross-entropy loss value is calculated. Based on the first difference and a first optimal transmission distance between the candidate dataset and the training dataset, a first target dataset is determined from the candidate dataset. The first difference between the first cross-entropy loss value for the candidate dataset with respect to the first small language model and the second cross-entropy loss value for the training dataset with respect to the second small language model can be calculated. The first target dataset can then be screened from the candidate dataset based on the first difference and the first optimal transmission distance between the candidate dataset and the training dataset. The first target dataset can then be continuously trained on the first target dataset to obtain the target small language model. This improves the data quality of the first target dataset used for training the first small language model, thereby improving the prediction accuracy of the target small language model to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0083] Figure 1 This is a flowchart of a method for continuous model training based on joint metric selection provided by an embodiment of the present application;
[0084] Figure 2 This is a flowchart of another method for continuous model training based on joint metric selection provided by an embodiment of the present application;
[0085] Figure 3 This is a flowchart of a specific implementation method of a continuous model training method based on joint metric selection provided in an embodiment of the present application;
[0086] Figure 4 This is a logic block diagram of a model continuous training device based on joint metric selection provided by an embodiment of the present application;
[0087] Figure 5 This is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0088] The exemplary embodiments of the present application will be described in more detail below in conjunction with the accompanying drawings in the embodiments of the present application. Although the accompanying drawings show exemplary embodiments of the present application, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0089] Reference Figure 1 , Figure 1 A flowchart of a method for continuous model training based on joint metric selection provided in an embodiment of the present application is provided, wherein the method includes:
[0090] Step 101: Determine a first cross-entropy loss value for a candidate dataset for a first small language model, and determine a second cross-entropy loss value for a training dataset for a second small language model; wherein the second small language model is a model obtained by adjusting model parameters of the first small language model; and the candidate dataset and the training dataset contain different sample text data.
[0091] In the embodiments of the present application, Small Language Models (SLM) is a technology in the field of artificial intelligence, which refers to a model with a smaller scale and fewer parameters than a large language model. These models can usually achieve better performance at a lower computational cost when processing specific tasks or fields. The second small language model can be a model obtained after the model parameters of the first small language model are adjusted. The candidate data set may include multiple data sets, and the training data set may be a data set that has been determined to meet the data quality requirements, and the sample text data contained in the candidate data set and the training data set are different, that is, the training data set can be understood as a reference data set for the candidate data set. The cross entropy loss value in the embodiment of the present application can be defined as the form shown in Formula 1 below, as follows:
[0092] (Formula 1)
[0093] In the above formula 1, Represents the first cross entropy loss value or the second cross entropy loss value, represents the logarithmic sign, Indicates that the input data of the small language model is a dataset D Sample text data in x When , the output is label y The probability of x Corresponding output data With data labels The similarity between them is replaced. D Can be a candidate dataset or a training dataset.
[0094] In an embodiment of the present application, sample text data in a candidate dataset can be input into a first small language model to obtain predicted data output by the first small language model. Subsequently, a first cross-entropy loss value can be calculated based on the predicted data and the data labels in the candidate dataset, i.e., the first cross-entropy loss value of the candidate dataset for the first small language model. Similarly, sample text data in a training dataset can be input into a second small language model to obtain predicted data output by the second small language model. Subsequently, a second cross-entropy loss value can be calculated based on the predicted data and the data labels in the predicted dataset, i.e., the second cross-entropy loss value of the training dataset for the second small language model.
[0095] Step 102: Calculate a first difference between the first cross entropy loss value and the second cross entropy loss value.
[0096] In an embodiment of the present application, a first difference between the first cross entropy loss value and the second cross entropy loss value may be calculated as shown in the following formula 2:
[0097] (Equation 2)
[0098] In the above formula 2, represents the first difference, represents the first cross entropy loss value, Represents the second cross entropy loss value, and the symbol “||” represents the absolute value.
[0099] Step 103 : determining a first target data set from the candidate data sets based on the first difference and a first optimal transmission distance between the candidate data set and the training data set.
[0100] In an embodiment of the present application, the first target data set can be screened from the candidate data set based on the first difference and the first optimal transmission distance between the candidate data set and the training data set. Among them, the optimal transport distance is a measurement method for measuring the difference between two probability distributions. The core idea is to "convert" or "transport" one probability distribution to another probability distribution in some way so that the total cost of this conversion is minimized. First, both the candidate data set and the training data set can be vectorized to obtain the data distribution of the candidate data set and the data distribution of the training data set. After that, the first optimal transmission distance between the candidate data set and the training data set can be calculated based on the data distribution of the selected data set and the data distribution of the training data set. The detailed process of calculating the first optimal transmission distance can be implemented by some computer programs. For example, the POT toolbox in Python can be used to calculate the first optimal transmission distance.
[0101] Step 104: Continuously train the first small language model based on the first target dataset to obtain a target small language model.
[0102] In an embodiment of the present application, the first small language model can be continuously trained based on the first target data set to obtain a target small language model. Continuous training may mean that the termination condition of the first small language model training process is that the training cycle of the first small language model reaches a preset number of times. That is, after the training cycle of the first small language model reaches the preset number of times, the training process of the first small language model can be stopped, so that the first small language model finally obtained can be determined as the target small language model. The training process of the first small language model is the same as the training process of a common deep learning language model and will not be repeated here.
[0103] In an embodiment of the present application, a first cross-entropy loss value for a candidate dataset with respect to a first small language model is determined, and a second cross-entropy loss value for a training dataset with respect to a second small language model is determined; wherein the second small language model is a model obtained after adjusting the model parameters of the first small language model; the candidate dataset and the training dataset contain different sample text data, a first difference between the first cross-entropy loss value and the second cross-entropy loss value is calculated, and based on the first difference and a first optimal transmission distance between the candidate dataset and the training dataset, a first target dataset is determined from the candidate dataset, and the first cross-entropy loss value for the first small language model and the second cross-entropy loss value for the training dataset are continuously trained based on the first target dataset to obtain a target small language model. A first difference between the first cross-entropy loss value for the candidate dataset with respect to the first small language model and the second cross-entropy loss value for the training dataset with respect to the second small language model can be calculated, and the first target dataset can be screened from the candidate dataset based on the first difference and the first optimal transmission distance between the candidate dataset and the training dataset, so that the first small language model can be continuously trained based on the first target dataset to obtain the target small language model. This can improve the data quality of the first target dataset used for training the first small language model to a certain extent, thereby improving the prediction accuracy of the target small language model to a certain extent.
[0104] Reference Figure 2 , Figure 2 A flowchart of another method for continuous model training based on joint metric selection provided in an embodiment of the present application may include:
[0105] Step 201: Determine a first cross-entropy loss value for a candidate dataset for a first small language model, and determine a second cross-entropy loss value for a training dataset for a second small language model; wherein the second small language model is a model obtained by adjusting model parameters of the first small language model; and the candidate dataset and the training dataset contain different sample text data.
[0106] In the embodiment of the present application, the implementation content of this step can refer to the embodiment content of step 101 and will not be repeated here.
[0107] Optionally, step 201 may include the following sub-steps:
[0108] Sub-step 2011: inputting the first sample text data in the candidate data set into the first small language model to obtain a first prediction vector output by the first small language model.
[0109] In an embodiment of the present application, first sample text data in a candidate data set can be input into a first small language model, thereby obtaining a first prediction vector output by the first small language model. The first sample text data can be vectorized using an embedding module to obtain a first sample text vector, and then the first sample text vector is input into the first small language model as input data for the first small language model, thereby obtaining a first prediction vector output by the first small language model. Typically, the text information corresponding to the first prediction vector and the first sample text vector can constitute a conversation, which can include a question and an answer.
[0110] Sub-step 2012: determining a first cross-entropy loss value of the candidate dataset for the first small language model based on the first prediction vector and the first annotation vector of the first sample text data.
[0111] In an embodiment of the present application, a first cross entropy loss value of the candidate dataset for the first small language model can be calculated based on the first prediction vector and the first annotation vector of the first sample text data. The first annotation vector can be obtained by vectorizing the label of the first sample text data. The calculation method of the first cross entropy loss value can refer to Formula 1, where, The first sample text data can be used x The similarity between the corresponding first prediction vector and the first annotation vector is replaced.
[0112] In an embodiment of the present application, by inputting the first sample text data in the candidate data set into the first small language model, a first prediction vector output by the first small language model is obtained, and based on the first prediction vector and the first annotation vector of the first sample text data, a first cross-entropy loss value of the candidate data set for the first small language model is determined. The first small language model can be used, combined with calculation to obtain the first cross-entropy loss value corresponding to the candidate data set, thereby improving the accuracy of the first cross-entropy loss value to a certain extent.
[0113] Sub-step 2013: inputting the second sample text data in the training data set into the second small language model to obtain a second prediction vector output by the second small language model.
[0114] In an embodiment of the present application, second sample text data from a training dataset may be input into a second small language model, thereby obtaining a second prediction vector output by the second small language model. The second sample text data may be first vectorized using an embedding module to obtain a second sample text vector, and then the second sample text vector may be input into the second small language model as input data for the second small language model, thereby obtaining a second prediction vector output by the second small language model.
[0115] Sub-step 2014: determining a second cross-entropy loss value of the training dataset for the second small language model based on the second prediction vector and the second labeled vector of the second sample text data.
[0116] In an embodiment of the present application, a second cross entropy loss value of the training data set for the second small language model can be calculated based on the second prediction vector and the second annotation vector of the second sample text data. The second annotation vector can be obtained by vectorizing the label of the second sample text data. The calculation method of the second cross entropy loss value can refer to Formula 1, wherein, The second sample text data can be used x The similarity between the corresponding second predicted vector and the second labeled vector is used instead.
[0117] In an embodiment of the present application, by inputting the second sample text data in the training data set into the second small language model, a second prediction vector output by the second small language model is obtained, and based on the second prediction vector and the second annotation vector of the second sample text data, a second cross-entropy loss value of the training data set for the second small language model is determined. The second small language model can be used, combined with calculation to obtain the second cross-entropy loss value corresponding to the training data set, thereby improving the accuracy of the second cross-entropy loss value to a certain extent.
[0118] Step 202: Calculate a first difference between the first cross entropy loss value and the second cross entropy loss value.
[0119] In the embodiment of the present application, the implementation content of this step can refer to the embodiment content of step 102 and will not be repeated here.
[0120] Step 203 : determining a first target data set from the candidate data sets based on the first difference and a first optimal transmission distance between the candidate data set and the training data set.
[0121] In the embodiment of the present application, the implementation content of this step can refer to the embodiment content of step 103 and will not be repeated here.
[0122] Optionally, step 203 may include the following sub-steps:
[0123] Sub-step 2031 : determining, from the candidate datasets, a first target dataset in which the first difference is greater than or equal to a first threshold, and a first optimal transmission distance between the candidate dataset and the training dataset is greater than or equal to a second threshold.
[0124] In an embodiment of the present application, a candidate dataset among the candidate datasets whose first difference is greater than or equal to a first threshold and whose first optimal transmission distance between the candidate dataset and the training dataset is greater than or equal to a second threshold can be used as the first target dataset. There can be multiple candidate datasets.
[0125] In an embodiment of the present application, by determining from the candidate data sets a first target data set whose first difference is greater than or equal to a first threshold, and whose first optimal transmission distance between the candidate data set and the training data set is greater than or equal to a second threshold, the size relationship between the first threshold and the first difference, as well as the size relationship between the first optimal transmission distance between the candidate data set and the training data set and the second threshold, can be used to screen out the first target data set from the candidate data sets, thereby improving the data quality of the first target data set to a certain extent.
[0126] Sub-step 2032: determining a first gradient of a first optimal transmission distance between the candidate dataset and the training dataset for each candidate dataset.
[0127] In an embodiment of the present application, the first gradient of the first optimal transmission distance between the candidate dataset and the training dataset for each candidate dataset may be calculated, and the calculation method thereof is shown in the following formula 3:
[0128] (Formula 3)
[0129] In the above formula 3, Indicates the first optimal transmission distance The first gradient of each candidate data set, represents the candidate dataset i, and N is the number of candidate datasets.
[0130] Sub-step 2033: Calculate a first quality evaluation index of the candidate data set based on the first gradient, the regularization coefficient of the first gradient, and the first difference.
[0131] In an embodiment of the present application, the first gradient may have a corresponding regularization coefficient, and the first quality evaluation index of the candidate data set may be calculated by the first gradient, the regularization coefficient of the first gradient, and the first difference, as shown in the following formula 4:
[0132] (Formula 4)
[0133] In the above formula 4, represents the first quality evaluation indicator of the candidate dataset, represents the first difference, represents the first gradient, Represents the regularization coefficient of the first gradient, and its value range is usually (0, 1).
[0134] Sub-step 2034: determining a first target data set from the candidate data sets, wherein the first quality evaluation index is greater than or equal to a third threshold.
[0135] In an embodiment of the present application, the first quality evaluation index can be a joint metric for dataset quality composed of cross entropy loss and optimal transmission distance. Therefore, a candidate dataset whose first quality evaluation index is greater than or equal to the third threshold can be used as the first target dataset.
[0136] In an embodiment of the present application, by determining the first gradient of each candidate data set for the first optimal transmission distance between the candidate data set and the training data set, the first quality evaluation index of the candidate data set is calculated based on the first gradient, the regularization coefficient of the first gradient and the first difference, and the first target data set whose first quality evaluation index is greater than or equal to the third threshold is determined from the candidate data set. The first quality evaluation index of the candidate data set can be calculated based on the first gradient and the first difference, combined with the regularization coefficient, and the first target data set can be screened based on the first quality evaluation index, which improves the data quality of the first target data set to a certain extent. When the first target data set is used for training the first small language model, overfitting of the first small language model can be avoided, thereby improving the prediction accuracy of the target small language model finally obtained.
[0137] Step 204 : vectorize the first sample text data contained in the first target data set to obtain a first sample text vector.
[0138] In an embodiment of the present application, the first sample text data contained in the first target data set may be vectorized through an embedding module, thereby obtaining a first sample text vector.
[0139] Step 205: Input the first sample text vector into the first small language model to obtain a first sample prediction vector output by the first small language model.
[0140] In an embodiment of the present application, the first sample text vector may be input into the first small language model, thereby obtaining a first sample prediction vector output by the first small language model.
[0141] Step 206 : Calculate a third cross entropy loss value between the first sample prediction vector and the sample annotation vector corresponding to the first sample text data.
[0142] In an embodiment of the present application, a third cross entropy loss value can be calculated between the first sample prediction vector and the sample annotation vector corresponding to the first sample text data. The sample annotation vector can be obtained by vectorizing the annotation label corresponding to the first sample text data. The calculation method of the third cross entropy loss value can refer to Formula 1, where The first sample text data can be used x The similarity between the corresponding first sample prediction vector and the sample annotation vector is replaced.
[0143] Step 207: Adjust the model parameters of the first small language model based on the third cross-entropy loss value to obtain a target small language model.
[0144] Optionally, step 207 may include the following sub-steps:
[0145] Sub-step 20701: Adjust the model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model with adjusted parameters.
[0146] In an embodiment of the present application, model parameters of the first small language model can be adjusted according to the third cross-entropy loss value, thereby obtaining the first small language model after parameter adjustment. The model parameters can be adjusted in a direction that reduces the third cross-entropy loss value.
[0147] Sub-step 20702: Calculate a second difference between the third cross entropy loss value and the second cross entropy loss value.
[0148] In an embodiment of the present application, a second difference between the third cross entropy loss value and the second cross entropy loss value may be calculated. The calculation method thereof may refer to Formula 2 and will not be repeated here.
[0149] Sub-step 20703: Determine a second quality evaluation index of the first target data set based on the second difference, the regularization coefficient of the second difference, and the second optimal transmission distance between the first target data set and the training data set.
[0150] In an embodiment of the present application, a second quality evaluation index of the first target dataset can be calculated based on the second difference, the regularization coefficient of the second difference, and the second optimal transmission distance between the first target dataset and the training dataset. The calculation method of the second quality evaluation index is similar to that of the first quality evaluation index, and reference can be made to Equation 4, which is not further described here.
[0151] Sub-step 20704: determining, from the first target data set, a second target data set whose second quality evaluation index is greater than or equal to a third threshold.
[0152] In an embodiment of the present application, a second target dataset having a second quality evaluation index greater than or equal to a third threshold value can be obtained by screening the first target dataset. That is, the second target dataset is screened from the first target dataset using the second quality evaluation index greater than or equal to the third threshold value as a screening condition.
[0153] Sub-step 20705: vectorize the second sample text data contained in the second target data set to obtain a second sample text vector.
[0154] In an embodiment of the present application, the second sample text data contained in the second target data set may be vectorized through an embedding module, thereby obtaining a second sample text vector.
[0155] Sub-step 20706: input the second sample text vector into the first small language model after parameter adjustment to obtain a second sample prediction vector output by the first small language model after parameter adjustment.
[0156] In an embodiment of the present application, the second sample text vector may be input into the first small language model after parameter adjustment, thereby obtaining a second sample prediction vector output by the first small language model after parameter adjustment.
[0157] Sub-step 20707: Calculate a fourth cross entropy loss value between the second sample prediction vector and the sample annotation vector corresponding to the second sample text data.
[0158] In an embodiment of the present application, a fourth cross entropy loss value between the second sample prediction vector and the sample annotation vector corresponding to the second sample text data can be calculated. The specific calculation process can refer to Formula 1, where It can be replaced by the similarity between the second sample prediction vector and the sample annotation vector corresponding to the second sample text data x.
[0159] Sub-step 20708: Calculate the fourth cross-entropy loss value between the second sample prediction vector and the second sample text number, adjust the model parameters of the first small language model after the parameter adjustment, and obtain a fourth cross-entropy loss value between the sample annotation vectors corresponding to the target small language model.
[0160] In an embodiment of the present application, the model parameters of the first small language model after parameter adjustment can be adjusted again according to the fourth cross-entropy loss value, thereby obtaining a target small language model. The direction of adjusting the model parameters can be a direction that reduces the fourth cross-entropy loss value. Furthermore, steps 20701 to 20708 can be repeated multiple times to perform multiple model training on the first small language model, and the training of the first small language model can be stopped when the training process of the first small language model meets the convergence condition, so that the latest first small language model can be used as the target small language model.
[0161] In an embodiment of the present application, the model parameters of the first small language model are adjusted based on the third cross entropy loss value to obtain the first small language model after parameter adjustment, the second difference between the third cross entropy loss value and the second cross entropy loss value is calculated, and the second quality evaluation index of the first target data set is determined based on the second difference, the regularization coefficient of the second difference, and the second optimal transmission distance between the first target data set and the training data set. A second target data set whose second quality evaluation index is greater than or equal to the third threshold is determined from the first target data set, the second sample text data contained in the second target data set is vectorized to obtain a second sample text vector, and the second sample text vector is input into the first small language model after parameter adjustment. In the model, the second sample prediction vector output by the first small language model after parameter adjustment is obtained, the fourth cross-entropy loss value between the second sample prediction vector and the sample annotation vector corresponding to the second sample text data is calculated, and the second sample prediction vector and the second sample text data are calculated based on the fourth cross-entropy loss value. The model parameters of the first small language model after parameter adjustment are adjusted to obtain the fourth cross-entropy loss value between the sample annotation vectors corresponding to the target small language model. During the training process of the first small language model, the data set used for training can be continuously screened, the data quality of the screened data set can be improved, the convergence speed of the first small language model can be improved, and the training time of the first small language model can be shortened.
[0162] Sub-step 20709: Adjust the model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model with adjusted parameters.
[0163] In the embodiment of the present application, the implementation content of this step can refer to the embodiment content of step 20701 and will not be repeated here.
[0164] Sub-step 20710: re-execute the step of inputting the first sample text vector into the first small language model to obtain the first sample prediction vector output by the first small language model.
[0165] In an embodiment of the present application, after obtaining the first small language model after parameter adjustment, the step of inputting the first sample text vector into the first small language model to obtain the first sample prediction vector output by the first small language model can be re-executed to repeatedly train the first small language model.
[0166] Sub-step 20711: Count the number of consecutive occurrences of the third cross entropy loss value being less than or equal to a fourth threshold and the number of training cycles of the first small language model.
[0167] In an embodiment of the present application, the first number of consecutive occurrences of the third cross entropy loss value being less than or equal to the fourth threshold value can be counted, and the number of training cycles of the first small language model can be counted at the same time. The initial value of the first number is 0. When the third cross entropy loss value is less than or equal to the fourth threshold value for the first time, the first number can be increased by one. If the third cross entropy loss value is less than or equal to the fourth threshold value continues to occur, the first number is continuously accumulated. If the third cross entropy loss value is greater than the fourth threshold value once, the first number is reset to zero, and the detection of the third cross entropy loss value being less than or equal to the fourth threshold value is restarted. The fourth threshold value can be set manually.
[0168] Sub-step 20712: When the first number is greater than or equal to a fifth threshold, or the number of training cycles is greater than or equal to a sixth threshold, stop adjusting the model parameters of the first small language model to obtain a target small language model.
[0169] In an embodiment of the present application, if the first number is greater than or equal to the fifth threshold, or the number of training cycles of the first small language model is greater than or equal to the sixth threshold, it can be considered that the training of the first small language model meets the convergence condition. At this time, the adjustment of the model parameters of the first small language model can be stopped, and the first small language model obtained after the last model parameter adjustment is used as the target small language model.
[0170] In an embodiment of the present application, the model parameters of the first small language model are adjusted based on the third cross-entropy loss value to obtain the first small language model after parameter adjustment. The step of inputting the first sample text vector into the first small language model to obtain the first sample prediction vector output by the first small language model is re-executed. The first number of consecutive occurrences of the third cross-entropy loss value being less than or equal to the fourth threshold and the number of training cycles of the first small language model are counted. When the first number is greater than or equal to the fifth threshold, or the number of training cycles is greater than or equal to the sixth threshold, the adjustment of the model parameters of the first small language model is stopped to obtain a target small language model. The first small language model can be continuously trained to obtain the target small language model, which can avoid overfitting of the first small language model and improve the prediction accuracy of the target small language model to a certain extent.
[0171] In an embodiment of the present application, the first sample text data contained in the first target data set is vectorized to obtain a first sample text vector, the first sample text vector is input into the first small language model, and a first sample prediction vector output by the first small language model is obtained. A third cross-entropy loss value is calculated between the first sample prediction vector and the sample annotation vector corresponding to the first sample text data. Based on the third cross-entropy loss value, the model parameters of the first small language model are adjusted to obtain a target small language model. The first target data set can be used to train the first small language model to obtain the target small language model. This can avoid overfitting of the first small language model during the training process, and can improve the prediction accuracy of the target small language model to a certain extent.
[0172] Reference Figure 3 , Figure 3 It is a flowchart of a specific implementation method of a continuous model training method based on joint metric selection provided by an embodiment of the present application. In the figure, the implementation process of the method can be divided into two stages, namely the data screening stage and the continuous training stage. In the data screening stage, the training data set can be used as a reference data set, and the joint quality index composed of the difference in cross entropy loss values and the gradient of OT distance can be used to screen the candidate data set to obtain a first target data set. In the continuous training stage, the first target data set can be used to continuously train the small language model, and after the training is completed, the target small language model can be obtained. In addition, the training data of a specific task can be used to fine-tune the data of the target small language model so that the target small language model can better meet the needs of the specific task.
[0173] Reference Figure 4 , Figure 4A logical block diagram of a model continuous training device based on joint metric selection provided in an embodiment of the present application, wherein the device 400 may include:
[0174] A first determination module 401 is configured to determine a first cross-entropy loss value for a candidate dataset for a first small language model, and to determine a second cross-entropy loss value for a training dataset for a second small language model; wherein the second small language model is a model obtained by adjusting model parameters of the first small language model; and the candidate dataset and the training dataset contain different sample text data;
[0175] A calculation module 402 is configured to calculate a first difference between the first cross entropy loss value and the second cross entropy loss value;
[0176] A second determining module 403 is configured to determine a first target dataset from the candidate datasets based on the first difference and a first optimal transmission distance between the candidate dataset and the training dataset;
[0177] The continuous training module 404 is configured to continuously train the first small language model based on the first target dataset to obtain a target small language model.
[0178] Optionally, the first determining module 401 includes:
[0179] A first input-output submodule, configured to input first sample text data in the candidate data set into a first small language model to obtain a first prediction vector output by the first small language model;
[0180] The first determination submodule is configured to determine a first cross entropy loss value of the candidate dataset for the first small language model based on the first prediction vector and the first annotation vector of the first sample text data.
[0181] Optionally, the first determining module 401 includes:
[0182] A second input-output submodule, configured to input second sample text data in the training data set into a second small language model to obtain a second prediction vector output by the second small language model;
[0183] The second determining submodule is configured to determine a second cross entropy loss value of the training dataset for the second small language model based on the second prediction vector and the second labeled vector of the second sample text data.
[0184] Optionally, the second determining module 403 includes:
[0185] The third determining submodule is configured to determine, from the candidate data sets, a first target data set whose first difference is greater than or equal to a first threshold and whose first optimal transmission distance between the candidate data set and the training data set is greater than or equal to a second threshold.
[0186] Optionally, the second determining module 403 includes:
[0187] A fourth determining submodule, configured to determine a first gradient of a first optimal transmission distance between the candidate dataset and the training dataset for each candidate dataset;
[0188] a first calculation submodule, configured to calculate a first quality evaluation index of the candidate data set based on the first gradient, a regularization coefficient of the first gradient, and the first difference;
[0189] The fifth determining submodule is configured to determine, from the candidate data sets, a first target data set whose first quality evaluation indicator is greater than or equal to a third threshold.
[0190] Optionally, the continuous training module 404 includes:
[0191] a vectorization submodule, configured to vectorize the first sample text data contained in the first target data set to obtain a first sample text vector;
[0192] a third input-output submodule, configured to input the first sample text vector into the first small language model to obtain a first sample prediction vector output by the first small language model;
[0193] A second calculation submodule is used to calculate a third cross entropy loss value between the first sample prediction vector and the sample annotation vector corresponding to the first sample text data;
[0194] An adjustment submodule is configured to adjust model parameters of the first small language model based on the third cross-entropy loss value to obtain a target small language model.
[0195] Optionally, the adjustment submodule includes:
[0196] A first adjustment unit is configured to adjust model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model after parameter adjustment;
[0197] A first calculation unit is used to calculate a second difference between the third cross entropy loss value and the second cross entropy loss value;
[0198] a first determining unit, configured to determine a second quality evaluation indicator of the first target data set based on the second difference, a regularization coefficient of the second difference, and a second optimal transmission distance between the first target data set and the training data set;
[0199] a second determining unit, configured to determine, from the first target data set, a second target data set in which the second quality evaluation indicator is greater than or equal to a third threshold;
[0200] a vectorization unit, configured to vectorize the second sample text data contained in the second target data set to obtain a second sample text vector;
[0201] an input-output unit, configured to input the second sample text vector into the first small language model after parameter adjustment, and obtain a second sample prediction vector output by the first small language model after parameter adjustment;
[0202] A second calculation unit is used to calculate a fourth cross entropy loss value between the second sample prediction vector and the sample annotation vector corresponding to the second sample text data;
[0203] The second adjustment unit is used to calculate the fourth cross entropy loss value between the second sample prediction vector and the second sample text number, adjust the model parameters of the first small language model after the parameter adjustment, and obtain the fourth cross entropy loss value between the sample annotation vectors corresponding to the target small language model.
[0204] Optionally, the adjustment submodule includes:
[0205] a third adjusting unit, configured to adjust model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model after parameter adjustment;
[0206] an execution unit, configured to re-execute the step of inputting the first sample text vector into the first small language model to obtain a first sample prediction vector output by the first small language model;
[0207] a statistical unit, configured to count the number of first consecutive occurrences of the situation where the third cross entropy loss value is less than or equal to a fourth threshold and the number of training cycles of the first small language model;
[0208] The stopping module is configured to stop adjusting the model parameters of the first small language model to obtain a target small language model when the first number is greater than or equal to a fifth threshold, or when the number of training cycles is greater than or equal to a sixth threshold.
[0209] The model continuous training device based on joint metric selection in the embodiment of the present application can be an electronic device or a component in an electronic device, such as an integrated circuit or chip. The electronic device can be a terminal or other devices other than a terminal. For example, the electronic device can be a GPUBOX, a mobile phone, a tablet computer, a laptop computer, a PDA, a car electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (Ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (Personal Digital Assistant, PDA), etc. It can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (Personal Computer, PC), a television (Television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
[0210] The model continuous training device based on joint metric selection in the embodiments of the present application can be a device having an operating system. The operating system can be an Android operating system, a Linux operating system, a Windows operating system, or other possible operating systems, which are not specifically limited in the embodiments of the present application.
[0211] The model continuous training device based on joint metric selection provided in the embodiment of the present application can achieve Figures 1 to 3 To avoid repetition, the various processes implemented in the method embodiment are not described here.
[0212] The present application provides an electronic device. Figure 5 The electronic device 50 includes: a processor 501, a memory 502, and a computer program 5021 stored in the memory 502 and executable on the processor 501. When the processor 501 executes the program, the model continuous training method based on joint metric selection of the aforementioned embodiment is implemented.
[0213] An embodiment of the present application also provides a computer-readable storage medium having a computer program / instruction stored thereon, which, when executed by a processor, implements the steps in the model continuous training method based on joint metric selection as disclosed in an embodiment of the present application.
[0214] An embodiment of the present application also provides a computer program product, which, when executed on an electronic device, enables a processor to implement the steps of the model continuous training method based on joint metric selection as disclosed in the embodiment of the present application.
[0215] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0216] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, apparatuses, electronic devices, and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0217] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0218] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0219] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0220] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "includes," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements that are inherent to such process, method, article, or terminal device. In the absence of further restrictions, an element defined by the phrase "comprises a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0221] The above is a detailed introduction to the model continuous training method based on joint measurement indicator selection provided by this application. This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method of this application and its core idea; at the same time, for general technical personnel in this field, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on this application.
Claims
1. A continuous model training method based on joint metric selection, characterized in that: The method comprises: Determining a first cross-entropy loss value for a candidate dataset for a first small language model, and determining a second cross-entropy loss value for a training dataset for a second small language model; wherein the second small language model is a model obtained by adjusting model parameters of the first small language model; and the candidate dataset and the training dataset contain different sample text data; Calculating a first difference between the first cross entropy loss value and the second cross entropy loss value; Determining a first target dataset from the candidate datasets based on the first difference and a first optimal transmission distance between the candidate dataset and the training dataset; and continuously training the first small language model based on the first target dataset to obtain a target small language model. The continuously training the first small language model based on the first target dataset to obtain a target small language model includes: Vectorizing the first sample text data contained in the first target data set to obtain a first sample text vector; Inputting the first sample text vector into the first small language model to obtain a first sample prediction vector output by the first small language model; Calculating a third cross entropy loss value between the first sample prediction vector and the sample annotation vector corresponding to the first sample text data; Adjusting model parameters of the first small language model based on the third cross-entropy loss value to obtain a target small language model; The adjusting the model parameters of the first small language model based on the third cross entropy loss value to obtain a target small language model includes: Adjusting model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model after parameter adjustment; Calculating a second difference between the third cross entropy loss value and the second cross entropy loss value; determining a second quality evaluation indicator of the first target data set based on the second difference, a regularization coefficient of the second difference, and a second optimal transmission distance between the first target data set and the training data set; Determine, from the first target data set, a second target data set in which the second quality evaluation indicator is greater than or equal to a third threshold; Vectorizing the second sample text data contained in the second target data set to obtain a second sample text vector; Inputting the second sample text vector into the first small language model after parameter adjustment to obtain a second sample prediction vector output by the first small language model after parameter adjustment; Calculating a fourth cross entropy loss value between the second sample prediction vector and the sample annotation vector corresponding to the second sample text data; Calculate the second sample prediction vector and the second sample text based on the fourth cross entropy loss value, adjust the model parameters of the first small language model after the parameter adjustment, and obtain a fourth cross entropy loss value between the sample annotation vectors corresponding to the target small language model.
2. The method according to claim 1, characterized in that Determining a first cross entropy loss value of the candidate dataset for the first small language model includes: Inputting first sample text data in the candidate data set into a first small language model to obtain a first prediction vector output by the first small language model; Based on the first prediction vector and the first annotation vector of the first sample text data, a first cross entropy loss value of the candidate dataset for the first small language model is determined.
3. The method according to claim 1, characterized in that Determining a second cross entropy loss value of the training dataset for the second small language model includes: Inputting second sample text data in the training data set into a second small language model to obtain a second prediction vector output by the second small language model; Based on the second prediction vector and the second labeled vector of the second sample text data, a second cross entropy loss value of the training dataset for the second small language model is determined.
4. The method according to claim 1, wherein The determining a first target data set from the candidate data sets based on the first difference and a first optimal transmission distance between the candidate data set and the training data set includes: A first target data set is determined from the candidate data sets, wherein the first difference is greater than or equal to a first threshold, and a first optimal transmission distance between the candidate data set and the training data set is greater than or equal to a second threshold.
5. The method according to claim 1, wherein The determining a first target data set from the candidate data sets based on the first difference and a first optimal transmission distance between the candidate data set and the training data set includes: Determine a first gradient of a first optimal transmission distance between the candidate data set and the training data set for each of the candidate data sets; Calculating a first quality evaluation index of the candidate data set based on the first gradient, a regularization coefficient of the first gradient, and the first difference; Determine a first target data set from the candidate data sets, in which the first quality evaluation indicator is greater than or equal to a third threshold.
6. The method according to claim 1, characterized in that The adjusting the model parameters of the first small language model based on the third cross entropy loss value to obtain a target small language model includes: Adjusting model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model after parameter adjustment; Re-performing the step of inputting the first sample text vector into the first small language model to obtain a first sample prediction vector output by the first small language model; Counting the number of first consecutive occurrences of the third cross entropy loss value being less than or equal to a fourth threshold and the number of training cycles of the first small language model; When the first number is greater than or equal to a fifth threshold, or the number of training cycles is greater than or equal to a sixth threshold, adjusting the model parameters of the first small language model is stopped to obtain a target small language model.
7. A model continuous training device based on joint metric selection, characterized in that: The device comprises: a first determination module, configured to determine a first cross-entropy loss value for a candidate dataset for a first small language model, and to determine a second cross-entropy loss value for a training dataset for a second small language model; wherein the second small language model is a model obtained by adjusting model parameters of the first small language model; and the candidate dataset and the training dataset contain different sample text data; A calculation module, configured to calculate a first difference between the first cross entropy loss value and the second cross entropy loss value; a second determining module, configured to determine a first target data set from the candidate data sets based on the first difference and a first optimal transmission distance between the candidate data set and the training data set; a continuous training module, configured to continuously train the first small language model based on the first target dataset to obtain a target small language model; The continuous training module includes: a vectorization submodule, configured to vectorize the first sample text data contained in the first target data set to obtain a first sample text vector; a third input-output submodule, configured to input the first sample text vector into the first small language model to obtain a first sample prediction vector output by the first small language model; A second calculation submodule is used to calculate a third cross entropy loss value between the first sample prediction vector and the sample annotation vector corresponding to the first sample text data; an adjustment submodule, configured to adjust model parameters of the first small language model based on the third cross-entropy loss value to obtain a target small language model; The adjustment submodule includes: A first adjustment unit is configured to adjust model parameters of the first small language model based on the third cross-entropy loss value to obtain a first small language model after parameter adjustment; A first calculation unit is used to calculate a second difference between the third cross entropy loss value and the second cross entropy loss value; a first determining unit, configured to determine a second quality evaluation indicator of the first target data set based on the second difference, a regularization coefficient of the second difference, and a second optimal transmission distance between the first target data set and the training data set; a second determining unit, configured to determine, from the first target data set, a second target data set in which the second quality evaluation indicator is greater than or equal to a third threshold; a vectorization unit, configured to vectorize the second sample text data contained in the second target data set to obtain a second sample text vector; an input-output unit, configured to input the second sample text vector into the first small language model after parameter adjustment, and obtain a second sample prediction vector output by the first small language model after parameter adjustment; A second calculation unit is used to calculate a fourth cross entropy loss value between the second sample prediction vector and the sample annotation vector corresponding to the second sample text data; The second adjustment unit is used to calculate the fourth cross entropy loss value between the second sample prediction vector and the second sample text number, adjust the model parameters of the first small language model after the parameter adjustment, and obtain the fourth cross entropy loss value between the sample annotation vectors corresponding to the target small language model.
8. An electronic device, characterized in that: It includes a memory, a processor and a computer program stored in the memory, and the processor executes the computer program to implement the model continuous training method based on joint metric selection as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Ecological numerical data augmentation method
CN116451069A
Cross-user activity identification method based on source domain data screening and training feature constraint
CN116628571A
Data quality measurement method and device
CN117556268A