Text training model parameter adjusting method and device, storage medium and computer device
By directly connecting the text training unit and the hyperparameter tuning unit, and calculating the total loss function to update the model parameters, the performance degradation caused by the initialization of the hyperparameter tuning adaptation module is solved, and the model achieves efficient hyperparameter tuning and improved generalization ability on specific tasks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PING AN TECH (SHENZHEN) CO LTD
- Filing Date
- 2024-04-17
- Publication Date
- 2026-07-03
AI Technical Summary
In existing technologies, when using additional parameter tuning and adaptation modules to tune native text models, there are initialization issues that lead to a decrease in model performance.
By directly connecting the text training unit with multiple parameter tuning units, the total loss function is calculated and the model parameters are updated by obtaining sample text and task labels, thus avoiding initialization problems and improving the model's performance and generalization ability on specific tasks.
This effectively avoids the initialization problem of the parameter tuning unit, improves the model's performance and generalization ability on specific tasks, and enhances the model's adaptability and accuracy.
Smart Images

Figure CN118278542B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of deep learning technology and digital healthcare, and in particular to a method, apparatus, storage medium, and computer equipment for tuning a text training model. Background Technology
[0002] As the scale of large-scale text pre-trained models grows and the amount of data used to train them increases exponentially, the performance of these models is constantly improving. This has led to text pre-trained models achieving performance comparable to or even surpassing human capabilities in areas such as text generation, question answering, language translation, code generation, information extraction, and sentiment analysis. However, in certain vertical domains, high accuracy is required for the output of text pre-trained models. For example, in the medical field, text pre-trained models can be applied to diagnostic assistance, electronic medical record analysis, drug development, and disease prediction. To ensure the effectiveness of hospital treatment, the accuracy of the output content of the text pre-trained models is extremely important. Therefore, it is necessary to fine-tune the text pre-trained models based on data specific to the vertical domain. However, directly fine-tuning large-scale text pre-trained models with all parameters is expensive and time-consuming.
[0003] Currently, there are many efficient hyperparameter tuning methods for large text pre-trained models. These methods typically reduce the resources and computational costs required for fine-tuning on specific tasks while maintaining the model's performance and generalization ability. However, when these methods are re-fine-tuned, an additional hyperparameter tuning module needs to be added to the original model. Since the newly added hyperparameter tuning module is not native, there is a risk of performance degradation due to initialization issues with the hyperparameter tuning module. Summary of the Invention
[0004] In view of this, this application provides a method, apparatus, storage medium and computer device for tuning the parameters of a text training model. The main purpose is to solve the technical problem of performance degradation caused by initialization issues when using additional parameter tuning and adaptation modules to tune native text models in the prior art.
[0005] According to a first aspect of the present invention, a method for tuning the parameters of a text training model is provided. This method is applied to a pre-trained text training model, the text training model comprising a text training unit and at least one tuning unit, wherein the text training unit and the at least one tuning unit are connected using a preset tuning model structure. The method includes:
[0006] Obtain text sample data under a preset scenario, wherein the text sample data includes sample text and the task tags corresponding to the sample text;
[0007] The sample text is input into the text training unit to obtain the first text training result, and the parameter tuning unit corresponding to the task label is determined as the target parameter tuning unit. The sample text is input into the target parameter tuning unit to obtain the second text training result.
[0008] The total loss function of the text training model is calculated based on the first text training result and the second text training result, and the model parameters of the text training unit and the model parameters of the target parameter tuning unit are updated based on the total loss function to tune the text training model.
[0009] According to a second aspect of the present invention, a parameter tuning apparatus for a text training model is provided, the apparatus comprising:
[0010] The data acquisition module is used to acquire text sample data under a preset scenario, wherein the text sample data includes sample text and the task tags corresponding to the sample text;
[0011] The model training module is used to input the sample text into the text training unit to obtain a first text training result, and to determine the parameter tuning unit corresponding to the task label as the target parameter tuning unit, and input the sample text into the target parameter tuning unit to obtain a second text training result;
[0012] The parameter update module is used to calculate the total loss function of the text training model based on the first text training result and the second text training result, and update the model parameters of the text training unit and the model parameters of the target parameter tuning unit based on the total loss function, so as to tune the text training model.
[0013] According to a third aspect of the present invention, a storage medium is provided on which a computer program is stored, which, when executed by a processor, implements the parameter tuning method of the above-described text training model.
[0014] According to a fourth aspect of the present invention, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the parameter tuning method of the above-described text training model.
[0015] This invention provides a method, apparatus, storage medium, and computer device for tuning the parameters of a text training model. These are applied to a pre-trained text training model, which includes a text training unit and at least one tuning unit. The text training unit and the at least one tuning unit are connected using a preset tuning model structure. Specifically, the method includes: first, acquiring text sample data under a preset scenario, where the text sample data includes sample text and corresponding task labels; then, inputting the sample text into the text training unit to obtain a first text training result; determining the tuning unit corresponding to the task label as the target tuning unit; inputting the sample text into the target tuning unit to obtain a second text training result; finally, calculating the total loss function of the text training model based on the first and second text training results; and updating the model parameters of the text training unit and the target tuning unit based on the total loss function to tune the text training model.
[0016] In the above method, the structure of the text training model is first improved by directly connecting multiple parameter tuning units to the text training unit within the text training model. This allows the parameter tuning unit to be integrated into the text training model and optimized during pre-training, better adapting to specific tasks and avoiding initialization issues. Associating sample text with corresponding task labels helps the model understand the relationship between the text and the specific task, thus improving task completion. By identifying the parameter tuning unit corresponding to the task label as the target parameter tuning unit, parameter tuning can be performed specifically for that task, improving the model's performance on that task. Calculating the total loss function based on the text training results output by both the text training unit and the parameter tuning unit allows for a comprehensive consideration of the differences between the two training results, providing a global optimization objective. Finally, by updating the model parameters, the overall model performance is optimized. This method effectively tunes the text training model and improves its performance and generalization ability on specific tasks. The parameter tuning unit, as part of the model, is optimized during training, effectively avoiding initialization issues that could lead to performance degradation.
[0017] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, specific embodiments of this application are given below. Attached Figure Description
[0018] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0019] Figure 1 A schematic diagram of the model structure of a text training model provided in an embodiment of the present invention is shown;
[0020] Figure 2 This invention illustrates various parameter tuning model structures in the prior art provided by embodiments of the present invention;
[0021] Figure 3 The diagram shows a flowchart of a parameter tuning method for a text training model provided in an embodiment of the present invention.
[0022] Figure 4 The diagram shows a flowchart of a parameter tuning method for a text training model provided in an embodiment of the present invention.
[0023] Figure 5 This diagram illustrates the principle of calculating the total loss function in a text training model provided by an embodiment of the present invention.
[0024] Figure 6 This diagram illustrates the structure of a parameter tuning device for a text training model according to an embodiment of the present invention.
[0025] Figure 7 This diagram illustrates the structure of a parameter tuning device for a text training model according to an embodiment of the present invention.
[0026] Figure 8 A schematic diagram of the device structure of a computer device provided in an embodiment of the present invention is shown. Detailed Implementation
[0027] Exemplary embodiments of the present application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the scope of the present application to those skilled in the art.
[0028] This application provides a parameter tuning method for a text training model, wherein the parameter tuning method is applied to a pre-trained text training model, and the structure of the text training model is as follows. Figure 1 As shown, it specifically includes a text training unit and at least one parameter tuning unit, and the text training unit and at least one parameter tuning unit are connected using a preset parameter tuning model structure.
[0029] In this implementation, existing text training models typically employ a transformer structure, with each transformer layer consisting of multiple transformer blocks stacked together. Currently, the number of parameters in various models ranges from 6 billion to 100 billion. Therefore, fine-tuning after model pre-training is still too costly. Consequently, current approaches typically involve adding a highly efficient parameter tuning module—far fewer than the full set of parameters—after the text training model has completed pre-training for efficient parameter tuning. Figure 2 As shown, existing technologies are mainly divided into four types of efficient hyperparameter tuning modes, from left to right: parallel hyperparameter tuning, serial hyperparameter tuning, cue-based hyperparameter tuning, and step-by-step hyperparameter tuning. In each efficient hyperparameter tuning mode, the left side represents the original text training model, and the right side represents the efficient hyperparameter tuning module. The solid line represents the forward propagation path, and the dashed line represents the backpropagation gradient update path. The fewer modules traversed by the two paths, the higher the efficiency. It can be seen that step-by-step hyperparameter tuning has fewer path parameters and is more efficient.
[0030] Therefore, the text training model structure provided in this application connects the original text training unit with multiple parameter tuning units one by one to form a complete model result. The text training unit in the model is trained together with the corresponding parameter tuning unit, so that the subsequent use and parameter tuning of the model can be carried out directly without having to consider the initialization problem of the parameter tuning unit affecting the running efficiency of the model.
[0031] The parameter tuning method for the text training model provided in this application, such as Figure 3 As shown, the specific steps include:
[0032] 101. Obtain text sample data under the preset scenario, wherein the text sample data includes sample text and the task label corresponding to the sample text.
[0033] Specifically, obtaining text sample data from a pre-defined scenario provides necessary training data for subsequent text training model parameter tuning. The sample text serves as input to the training model, while task labels are used to measure model performance and guide parameter tuning. The text sample data provides a sufficient data foundation for model training, and through the pairing of sample text and task labels, the model can more accurately predict and classify tasks. The task labels correspond to the specific tasks to be solved in the pre-defined scenario. Therefore, during model parameter tuning, adjustments and optimizations can be made for specific tasks to improve model performance on those tasks. Finally, the text sample data from the pre-defined scenario reflects the text input and task requirements in the actual application scenario, making the model more closely aligned with real-world application needs during subsequent training and parameter tuning, thus improving the model's practicality and effectiveness.
[0034] The parameter tuning method for the text training model provided in this application is widely used in the medical field. Therefore, the corresponding text sample data also includes sample texts and task labels specific to the medical field. For example, the sample text might state that a patient's blood sugar level is higher than the normal range, while the task labels include diabetes screening and dietary advice. The sample text can be used simultaneously for diabetes screening tasks and to provide corresponding dietary advice. Another example is a sample text stating that a patient is undergoing chemotherapy, while the task labels are cancer treatment plans and chemotherapy side effect management. The sample text is suitable for cancer treatment plan tasks and provides guidance on managing chemotherapy side effects. It is evident that the parameter tuning method for the text training model has broad application scenarios in the medical field.
[0035] 102. Input the sample text into the text training unit to obtain the first text training result, and determine the parameter tuning unit corresponding to the task label as the target parameter tuning unit. Input the sample text into the target parameter tuning unit to obtain the second text training result.
[0036] Specifically, sample text is input into a text training unit, which uses predefined parameters to train the text, obtaining preliminary text training results based on the initial parameters. Since the text training model has multiple hyperparameter tuning units, a target hyperparameter tuning unit needs to be determined based on the task label. The target hyperparameter tuning unit corresponds to the task label and contains task-related parameters and model configuration. Sample text is then input into the target hyperparameter tuning unit for text training. The text training model is optimized based on the parameters and model configuration in the target hyperparameter tuning unit, yielding a second text training result. This second text training result can evaluate the model's performance and effectiveness on a specific task.
[0037] In this embodiment, after determining the corresponding target parameter tuning unit based on the task label, the sample text is input into the text training unit and the target parameter tuning unit respectively to obtain the corresponding text training results. The first text training result is obtained based on the initial parameters, and the second text training result is obtained based on the parameters related to the task label. By comparing the two text training results and subsequent calculations, the model as a whole is optimized and adjusted in a targeted manner to improve the model's performance on specific tasks, making the text training model more adaptable to different task requirements and improving the model's performance and accuracy.
[0038] 103. Calculate the total loss function of the text training model based on the first text training result and the second text training result, and update the model parameters of the text training unit and the model parameters of the target parameter tuning unit based on the total loss function to tune the text training model.
[0039] Specifically, the total loss function reflects the performance of the text-trained model on at least one task. It comprehensively considers the weights and losses of different tasks to provide an evaluation of the overall model performance. After obtaining the total loss function, the model parameters in the text training unit and the target hyperparameter tuning unit can be updated based on it. By finding the parameter values that minimize the total loss function, the goal is to optimize model performance, thereby making the model better adaptable to specific tasks and improving its performance and accuracy across various tasks. The specific hyperparameter tuning method is an iterative process that continuously updates the model parameters to gradually optimize the model's performance and effectiveness.
[0040] In this embodiment, the total loss function of the text training model is calculated, and the performance indicators of multiple tasks are comprehensively considered, thereby optimizing the overall performance of the text training model and making its performance on multiple tasks more excellent and comprehensive. Updating the model parameters of the text training unit and the target parameter tuning unit based on the total loss function enables the model to collaboratively optimize across different tasks. This allows for knowledge transfer and sharing between multiple tasks through parameter sharing, improving the model's generalization ability. It also allows for more refined optimization of specific tasks; by adjusting the parameters in the target parameter tuning unit, the model's performance on specific tasks is further improved, enhancing its adaptability to task requirements. In summary, by calculating the total loss function and updating and tuning parameters based on it, the text training model can be globally optimized, achieving both multi-task collaborative optimization and task-specific optimization. This improves the overall performance and adaptability of the model, enabling it to achieve better results on multiple tasks.
[0041] This invention provides a parameter tuning method, apparatus, storage medium, and computer device for a text training model. The parameter tuning method is specifically applied to a pre-trained text training model. The text training model includes a text training unit and at least one parameter tuning unit. The text training unit and the at least one parameter tuning unit are connected using a preset parameter tuning model structure. The method specifically includes: first, acquiring text sample data under a preset scenario, wherein the text sample data includes sample text and corresponding task labels; then, inputting the sample text into the text training unit to obtain a first text training result, and determining the parameter tuning unit corresponding to the task label as the target parameter tuning unit; inputting the sample text into the target parameter tuning unit to obtain a second text training result; finally, calculating the total loss function of the text training model based on the first and second text training results, and updating the model parameters of the text training unit and the target parameter tuning unit based on the total loss function to tune the text training model. In the above method, the structure of the text training model is first improved by directly connecting multiple hyperparameter tuning units to the text training unit within the text training model. This allows the hyperparameter tuning units to be integrated into the text training model and optimized during pre-training, better adapting to specific tasks and avoiding initialization issues. Associating sample text with corresponding task labels helps the model understand the relationship between the text and the specific task, thus improving task completion. By identifying the hyperparameter tuning unit corresponding to the task label as the target hyperparameter tuning unit, hyperparameter tuning can be performed specifically for that task, improving the model's performance on that task. The total loss function is calculated based on the text training results output by both the text training unit and the hyperparameter tuning unit. This comprehensively considers the differences between the two text training results, providing a global optimization objective. Finally, by updating the model parameters, the overall model performance is better optimized. This method effectively tunes the text training model and improves its performance and generalization ability on specific tasks. The hyperparameter tuning units are optimized and trained together as part of the model, effectively avoiding performance degradation caused by initialization problems.
[0042] This application provides a method for tuning the parameters of a text training model, such as... Figure 4 As shown, the method includes the following steps:
[0043] 201. Obtain sample text and corresponding task tags for the preset scenario.
[0044] In this embodiment of the application, it is first necessary to obtain text sample data for training the text training model. The text sample data specifically includes sample text and the task label corresponding to the sample text. The text sample data can be multi-domain data, mainly in the medical field. The specific process of this step has been described in step 101 and is consistent with step 101, so it will not be repeated here.
[0045] 202. Input the sample text into the text training unit to obtain the first text training result, and input the sample text into the target parameter tuning unit to obtain the second text training result.
[0046] Specifically, the text training unit includes multiple sequentially connected transformation layers, and the parameter tuning unit includes multiple sequentially connected parameter tuning layers, with the number of transformation layers and parameter tuning layers being equal; each transformation layer in the text training unit is connected one-to-one with the parameter tuning layer of each parameter tuning unit.
[0047] In the embodiments of this application, by Figure 2 It is known that among the four efficient parameter tuning modes in the existing technology—parallel parameter tuning, serial parameter tuning, cue-based parameter tuning, and step-by-step parameter tuning—step-by-step parameter tuning has fewer path parameters and is the most efficient. However, using step-by-step parameter tuning units in conjunction with a text training model can lead to parameter tuning unit initialization issues. Therefore, this application takes a step-by-step parameter tuning unit as an example, directly connecting the text training unit with multiple parameter tuning units. Each text training unit includes multiple transformation layers, and each parameter tuning unit includes a parameter tuning layer equal in number to the transformation layers. The parameter tuning layers and transformation layers are connected one-to-one, as shown below. Figure 1 As shown, for different numbers of task labels, corresponding parameter tuning units are set up. The text training unit is connected to each parameter tuning unit, that is, the transformation layer in the text training unit is connected to the parameter tuning layer in each parameter tuning unit. The text training model provided in this application achieves structural alignment between the transformation layer and the parameter tuning layer, ensuring that the hierarchical structure of the two units is consistent, which facilitates the understanding and management of the model. Furthermore, the text training unit and the parameter tuning unit share parameters, and the transformation layer and the parameter tuning layer share the same weights and biases, reducing model complexity and training difficulty. At the same time, by connecting the transformation layer and the parameter tuning layer, non-linear model fitting ability can be achieved. The transformation layer can introduce non-linear transformations to increase the expressive power of the model, while the parameter tuning layer can further adjust and optimize the model parameters to better fit the data and task requirements, and increase the flexibility and adjustability of the model.
[0048] Specifically, the sample text is input into the text training unit, and the sample text is converted one by one according to the forward propagation order of multiple conversion layers to obtain the first text training result. Each conversion layer is used to convert the converted text output by the previous conversion layer and outputs the converted text to the corresponding parameter tuning layer and the next conversion layer. Each parameter tuning layer in the parameter tuning unit receives the converted text output by the corresponding conversion layer and the fine-tuning result output by the previous fine-tuning layer, and each fine-tuning layer outputs the fine-tuning result to the next fine-tuning layer until the last fine-tuning layer in the fine-tuning unit outputs the corresponding fine-tuning result, and the fine-tuning result is used as the second text training result of the target parameter tuning unit.
[0049] In this embodiment, both the text training unit and the parameter tuning unit perform sample text transformation and parameter fine-tuning through forward propagation to generate a first text training result and a second text training result. Through forward propagation of multiple transformation layers, the sample text is transformed one by one, converting the input text into a more informative and expressive feature representation. Each transformation layer processes the transformed text output by the previous transformation layer and uses the processed transformed text as its output. In the parameter tuning unit, each parameter tuning layer receives the transformed text output by the corresponding connected transformation layer and the fine-tuning result of the previous fine-tuning layer, and further optimizes the transformed text through parameter fine-tuning. Each fine-tuning layer passes its fine-tuning result to the next fine-tuning layer, and the output of the last fine-tuning layer serves as the second text training result for the target parameter tuning unit. Through this transformation process of the transformation layers, combined with the fine-tuning process of the fine-tuning layers on the transformed text output by the transformation layers and the fine-tuning results, the features of the input sample text can be extracted and optimized. Through the layer-by-layer processing of the transformation layers and the parameter fine-tuning of the parameter tuning layers, the model's ability to represent and adapt to data is improved, resulting in better training results and performance.
[0050] In the medical field, when the input sample text is a patient's medical record, it contains information such as symptom descriptions, physical signs, and medical examination results. The first transformation layer in the text training unit uses word embedding technology to map the words in the sample text into vector representations, capturing the semantic features of the words. The second transformation layer uses a convolutional neural network to process the word embedding vectors, extracting local features of the patient's symptoms and physical signs. The third transformation layer uses a recurrent neural network or attention mechanism to model the entire text sequence, capturing contextual information. After processing through multiple transformation layers, the first text training result output by the text training unit is obtained, which can specifically contain medically significant information, such as the presence of specific symptoms or the manifestation of certain physical signs. In the hyperparameter tuning unit, a hyperparameter tuning layer (which can be a fully connected layer or other structures) is connected to the output of the first transformation layer. This layer associates the output of the transformation layer with the disease-related labels for initial classification. A series of fine-tuning layers then further refine the model. Each fine-tuning layer receives the results from the previous layer and the output of the transformation layer, adjusting parameters to further optimize features and improve the accuracy of disease diagnosis. The output of the last fine-tuning layer serves as the second text training result for the target hyperparameter tuning unit, enabling final disease classification and diagnostic decisions. Through this process, the text training model processes and optimizes patient medical records, extracting key features. These features are then further refined and optimized through hyperparameter tuning and fine-tuning layers, ultimately yielding possible disease diagnoses. This helps doctors use the model in subsequent clinical practice, enabling more accurate disease diagnosis and treatment planning.
[0051] 203. Calculate the total loss function of the text training model based on the training results of the first and second texts.
[0052] Specifically, the first true label corresponding to the sample text in the text training unit and the second true label corresponding to the sample text in the target hyperparameter tuning unit are obtained; a first loss function is calculated based on the effective encoding of the first true label and the first text training result, wherein the first text training result is used to indicate the class probability value of the sample text in the text training unit; a second loss function is calculated based on the effective encoding of the second true label and the second text training result, wherein the second text training result is used to indicate the class probability value of the sample text in the target hyperparameter tuning unit; the first loss function and the second loss function are summed to generate the total loss function.
[0053] In this embodiment, it is first necessary to obtain the first true label of the sample text in the text training unit and the second true label of the sample text in the target parameter tuning unit. These true labels can be the category labels of the corresponding sample text or other forms of label information. Then, the effective encoding of the first true label and the first text training result are used for calculation. The first text training result can be regarded as the category probability value of the sample text in each category in the text training unit, which can be compared with the first true label. By calculating the loss function, the difference between the first text training result and the first true label can be measured. Similarly, the effective encoding of the second true label and the second text training result are used for calculation. The second text training result can be regarded as the class probability value of the sample text in each category in the target hyperparameter tuning unit, which can be compared with the second true label. By calculating the loss function, the difference between the second text training result and the second true label can be measured. The specific formula is: L=-Σ(y_i*log(p_i)), where y_i represents the one-hot encoding of the true label and p_i represents the predicted class probability value. The above process is used to compare the difference between the text result of the sample text in the text training unit and the true label and to measure the performance of the training model. Then, by optimizing the total loss function, the accuracy and robustness of the model can be improved. In addition to calculating the loss function of the text training unit, this application also introduces the loss function of the hyperparameter tuning unit to further improve the accuracy of the calculation.
[0054] Furthermore, based on the first text training result, a first probability is determined for the text training unit to output a preset discrete value, and a second probability is determined based on the second text training result for the target parameter tuning unit to output a preset discrete value; relative entropy is calculated on the first probability and the second probability to obtain the information divergence loss function between the text training unit and the target parameter tuning unit; the first loss function, the second loss function, and the information divergence loss function are summed based on preset weights to obtain the total loss function of the text training model.
[0055] In this embodiment, in addition to introducing the loss function of the parameter tuning unit, this application further provides an information divergence loss function, namely KL distance, or Kullback-Leibler difference, also known as relative entropy. First, the first probability of the text training unit outputting discrete values can be determined using the first text training result. This first probability reflects the prediction probability distribution of the text training unit for each category. Then, the second probability of the target parameter tuning unit outputting discrete values can be determined using the second text training result. This second probability reflects the prediction probability distribution of the target parameter tuning unit for each category. Finally, the information divergence loss function between the text training unit and the target parameter tuning unit is calculated, such as... Figure 5 As shown, relative entropy is used to measure the difference between two probability distributions. The specific formula is KL(P||Q)=Σ(P(x)*log(P(x) / Q(x))), where P(x) represents the probability of the text training unit outputting a discrete value x, and Q(x) represents the probability of the parameter tuning unit outputting a discrete value x. This loss function is used to measure the difference between the output probability distributions of the text training unit and the target parameter tuning unit. In this application, the value needs to be as small as possible so that the difference between the output distributions of the two units is not too large. Finally, based on the preset weights, the first loss function, the second loss function, and the information divergence loss function are weighted and summed to obtain the total loss function of the text training model. The choice of weights can be determined according to the task requirements and optimization objectives. By considering the difference between probability distributions, further optimization constraints are introduced to help the model better model the input and make accurate predictions of the output. Adjusting the weights can balance the importance of different loss functions, thereby improving the training effect of the model.
[0056] 204. Update the model parameters of the text training unit and the target parameter tuning unit based on the total loss function to tune the text training model.
[0057] Specifically, the first gradient information corresponding to the text training unit and the second gradient information corresponding to the target parameter tuning unit are calculated according to the total loss function. Based on the first gradient information, the model parameters of the text training unit are updated along the back propagation direction of the text training unit using the gradient descent method. Based on the second gradient information, the model parameters of the text training unit are updated along the back propagation direction of the target parameter tuning unit using the gradient descent method.
[0058] In this embodiment, the text training unit and the target hyperparameter tuning unit are units that perform gradient calculation and parameter update based on different parts of the total loss function during the training process. The first gradient information refers to the gradient information about the model parameters calculated based on the total loss function for the text training unit. The first gradient information is used to guide the update of the model parameters of the text training unit. By updating the model parameters along the backpropagation direction, the loss function is gradually reduced. The second gradient information refers to the second-order gradient information about the model parameters calculated based on the total loss function for the target hyperparameter tuning unit. It is also called the Hessian matrix. The second gradient information is used to guide the update of the model parameters of the target hyperparameter tuning unit. By updating the model parameters along the backpropagation direction, more precise parameter adjustment is achieved. By calculating the gradient information of the total loss function, parameters can be updated for different parts of the text training unit and the target parameter tuning unit according to the specific task requirements, thereby optimizing the performance of the entire model. Gradient descent is an iterative optimization algorithm that gradually reduces the value of the loss function by updating the model parameters along the gradient direction, allowing the model to gradually converge to a better state. Using the first and second gradient information can more accurately guide parameter updates and improve the convergence speed. The second gradient information can provide more information about the interaction between parameters. By utilizing this information, the model parameters can be adjusted more precisely to adapt to different task requirements and data characteristics.
[0059] 205. Use text validation data to validate and optimize the text training model.
[0060] Specifically, firstly, text verification data under a preset scenario is obtained, including verification text and corresponding verification results. Then, the verification text is input into the text training model to obtain the model output. Finally, the model output is compared with the verification results to obtain the comparison results. Based on the comparison results, the model performance of the text training model is determined, and the parameters of the text training unit and the target parameter tuning unit are optimized according to the model performance. The model performance is used to indicate the accuracy of the model output and the generalization ability of the text training model.
[0061] In this embodiment, the verification text is used to evaluate the model's performance and accuracy in real-world scenarios. The model's output is compared with the verification results to obtain a comparison result. This comparison result determines the model's accuracy on the verification text, i.e., the model's performance. Based on the comparison result, the performance of the text-trained model can be evaluated, including the accuracy of the model's output and its generalization ability. Finally, based on the evaluation of model performance, the parameters of the text training unit and the target parameter tuning unit are optimized as needed to further improve the model's performance and generalization ability. By comparing the model's output with the verification results, the performance and accuracy of the text-trained model in real-world scenarios can be objectively evaluated. This helps to understand the model's performance in practical applications and can identify potential problems and errors. Specifically, this could be misclassification, misjudgment, or other errors in the model's handling of certain verification texts. By promptly identifying and correcting these problems, the model's stability and accuracy can be improved. Verification text data, as an unseen sample, can be used to evaluate the model's generalization ability, i.e., the model's performance on unknown data. By adjusting and optimizing the model based on the comparison results, the model's generalization ability can be improved, helping it better adapt to different text data. Overall, by evaluating model performance and optimizing parameters based on validation text data, we can comprehensively assess the model's performance, identify problems and make improvements, thereby enhancing the model's accuracy, generalization ability, and stability, which helps ensure the model's effectiveness and reliability in practical applications.
[0062] This invention provides a method, apparatus, storage medium, and computer device for tuning the parameters of a text training model. First, sample text and corresponding task labels in a preset scenario are obtained. Then, the sample text is input into a text training unit to obtain a first text training result. The sample text is then input into a target tuning unit to obtain a second text training result. Next, the total loss function of the text training model is calculated based on the first and second text training results. The model parameters of the text training unit and the target tuning unit are then updated based on the total loss function to tune the text training model. Finally, text validation data is used to validate and optimize the text training model.
[0063] In the above method, by acquiring sample text and corresponding task labels, the content of the text and the task to be performed can be comprehensively considered, enabling the establishment of a text training model for a specific task and improving the model's performance on that task. By inputting the sample text into the text training unit and the target parameter tuning unit respectively, two different text training results can be obtained, thus processing the sample text from different angles and methods, enriching the learning and expressive capabilities of the training model. Furthermore, by calculating the total loss function from the first and second text training results, the performance of the two text training units and the task requirements can be comprehensively considered. Based on the total loss function, gradient descent or other optimization algorithms can be used to update the model parameters of the text training unit and the target parameter tuning unit, allowing the model to better fit the task requirements. Finally, the trained model is validated and optimized using text validation data, thereby evaluating the model's performance and accuracy in real-world scenarios. Further adjustments and optimizations are made based on the feedback results, helping to improve the model's generalization ability and application effectiveness. In summary, this method comprehensively considers text content and task requirements, obtains multifaceted training results, updates parameters based on the total loss function, and validates and optimizes on validation data to improve the model's performance and application effectiveness.
[0064] Furthermore, as Figure 4 In terms of specific implementation, this application provides a parameter tuning device for a text training model, such as... Figure 6 As shown, the device includes: a data acquisition module 301, a model training module 302, and a parameter update module 303.
[0065] The data acquisition module 301 is used to acquire text sample data under a preset scenario, wherein the text sample data includes sample text and the task label corresponding to the sample text;
[0066] The model training module 302 is used to input sample text into the text training unit to obtain the first text training result, and to determine the parameter tuning unit corresponding to the task label as the target parameter tuning unit, input sample text into the target parameter tuning unit to obtain the second text training result;
[0067] The parameter update module 303 is used to calculate the total loss function of the text training model based on the first text training result and the second text training result, and update the model parameters of the text training unit and the model parameters of the target parameter tuning unit based on the total loss function, so as to tune the text training model.
[0068] In specific application scenarios, the parameter update module 303 can be used to obtain the first true label corresponding to the sample text in the text training unit and the second true label corresponding to the sample text in the target parameter tuning unit; calculate a first loss function based on the effective encoding of the first true label and the first text training result, wherein the first text training result is used to indicate the class probability value of the sample text in the text training unit; calculate a second loss function based on the effective encoding of the second true label and the second text training result, wherein the second text training result is used to indicate the class probability value of the sample text in the target parameter tuning unit; and sum the first loss function and the second loss function to generate the total loss function.
[0069] In specific application scenarios, the parameter update module 303 can also be used to determine the first probability of the text training unit outputting a preset discrete value based on the first text training result, and to determine the second probability of the target parameter tuning unit outputting a preset discrete value based on the second text training result; to calculate the relative entropy of the first probability and the second probability to obtain the information divergence loss function between the text training unit and the target parameter tuning unit; and to sum the first loss function, the second loss function and the information divergence loss function based on preset weights to obtain the total loss function of the text training model.
[0070] In specific application scenarios, the parameter update module 303 can be used to calculate the first gradient information corresponding to the text training unit and the second gradient information corresponding to the target parameter tuning unit according to the total loss function; based on the first gradient information, the model parameters of the text training unit are updated along the back propagation direction of the text training unit using the gradient descent method, and based on the second gradient information, the model parameters of the text training unit are updated along the back propagation direction of the target parameter tuning unit using the gradient descent method.
[0071] In specific application scenarios, such as Figure 7 As shown, the device also includes a model verification module 304, which can be used to acquire text verification data under a preset scenario. The text verification data includes verification text and the corresponding verification result. The verification text is input into the text training model to obtain the model output result. The model output result is compared with the verification result to obtain the comparison result. The model performance of the text training model is determined based on the comparison result. The parameters of the text training unit and the target parameter tuning unit are optimized according to the model performance. The model performance is used to indicate the accuracy of the model output result and the generalization ability of the text training model.
[0072] In specific application scenarios, the text training unit in the model training module 302 includes multiple sequentially connected transformation layers, and the parameter tuning unit includes multiple sequentially connected parameter tuning layers. The number of transformation layers and parameter tuning layers are equal. Each transformation layer in the text training unit is connected to a parameter tuning layer in each parameter tuning unit in a one-to-one correspondence.
[0073] In specific application scenarios, the model training module 302 can be used to input sample text into the text training unit, and process the sample text one by one according to the forward propagation order of multiple transformation layers to obtain the first text training result. Each transformation layer is used to process the transformed text output by the previous transformation layer, and outputs the obtained transformed text to the corresponding connected parameter tuning layer and the next transformation layer. Each parameter tuning layer in the parameter tuning unit receives the transformed text output by the corresponding connected transformation layer and the fine-tuning result output by the previous fine-tuning layer, and each fine-tuning layer outputs the fine-tuning result to the next fine-tuning layer, until the last fine-tuning layer in the fine-tuning unit outputs the corresponding fine-tuning result, and uses the fine-tuning result as the second text training result of the target parameter tuning unit.
[0074] It should be noted that other corresponding descriptions of the functional units involved in the parameter tuning device for a text training model provided in this embodiment can be found in [reference needed]. Figure 3 and Figure 4 The corresponding description in [the document] will not be repeated here.
[0075] Based on the above, Figure 3 Accordingly, this embodiment also provides a storage medium storing a computer program that, when executed by a processor, implements the parameter tuning method of the above-described text training model.
[0076] Based on this understanding, the technical solution of this application can be embodied in the form of a software product. The software product to be identified can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, or portable hard drive), including several instructions to enable a computer device (such as a personal computer, server, or network device) to execute the parameter tuning method of the text training model in various implementation scenarios of this application.
[0077] Based on the above, Figure 3 and Figure 4 The method shown, and Figure 6 and Figure 7 The illustrated embodiment of the parameter tuning device for the text training model, in order to achieve the above objectives, is as follows: Figure 8 As shown, this embodiment also provides a physical device for tuning the parameters of a text training model. This device includes a communication bus, a processor, a memory, and a communication interface. It may also include input / output interfaces and a display device. The various functional units can communicate with each other via the bus. The memory stores a computer program, and the processor executes the program stored in the memory to perform the parameter tuning method for the text training model described in the above embodiment.
[0078] Optionally, the physical device may also include a user interface, a network interface, a camera, radio frequency (RF) circuitry, sensors, audio circuitry, a Wi-Fi module, etc. The user interface may include a display screen, input units such as a keyboard, etc., and optional user interfaces may also include USB interfaces, card reader interfaces, etc. The network interface may optionally include standard wired interfaces, wireless interfaces (such as Wi-Fi interfaces), etc.
[0079] Those skilled in the art will understand that the parameter tuning entity device structure of the text training model provided in this embodiment does not constitute a limitation on the entity device, and may include more or fewer components, or combine certain components, or have different component arrangements.
[0080] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the aforementioned physical device, supporting the operation of information processing programs and other software and / or programs to be identified. The network communication module is used to enable communication between the various components within the storage medium, as well as communication with other hardware and software in the information processing physical device.
[0081] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms, or it can be implemented by hardware. By applying the technical solution of this application, the parameter tuning method of the text training model is specifically applied to the pre-trained text training model. The text training model includes a text training unit and at least one parameter tuning unit. The text training unit and the at least one parameter tuning unit are connected by a preset parameter tuning model structure. The method specifically includes: firstly, acquiring text sample data under a preset scenario, wherein the text sample data includes sample text and the task label corresponding to the sample text; then, inputting the sample text into the text training unit to obtain a first text training result, and determining the parameter tuning unit corresponding to the task label as the target parameter tuning unit; inputting the sample text into the target parameter tuning unit to obtain a second text training result; finally, calculating the total loss function of the text training model based on the first text training result and the second text training result, and updating the model parameters of the text training unit and the model parameters of the target parameter tuning unit based on the total loss function to tune the text training model. In the above method, the structure of the text training model is first improved by directly connecting multiple parameter tuning units to the text training unit within the text training model. This allows the parameter tuning unit to be integrated into the text training model and optimized during pre-training, better adapting to specific tasks and avoiding initialization issues. Associating sample text with corresponding task labels helps the model understand the relationship between the text and the specific task, thus improving task completion. By identifying the parameter tuning unit corresponding to the task label as the target parameter tuning unit, parameter tuning can be performed specifically for that task, improving the model's performance on that task. Calculating the total loss function based on the text training results output by both the text training unit and the parameter tuning unit allows for a comprehensive consideration of the differences between the two training results, providing a global optimization objective. Finally, by updating the model parameters, the overall model performance is optimized. This method effectively tunes the text training model and improves its performance and generalization ability on specific tasks. The parameter tuning unit, as part of the model, is optimized during training, effectively avoiding initialization issues that could lead to performance degradation.
[0082] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of a preferred embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing this application. Those skilled in the art will understand that the modules in the apparatus of the embodiment can be distributed within the apparatus of the embodiment as described, or can be modified to be located in one or more apparatuses different from this embodiment. The modules of the above-described embodiment can be combined into one module, or further divided into multiple sub-modules.
[0083] The serial numbers in this application are for descriptive purposes only and do not represent the superiority or inferiority of any particular implementation scenario. The above disclosures are merely a few specific implementation scenarios of this application; however, this application is not limited thereto, and any variations conceived by those skilled in the art should fall within the protection scope of this application.
Claims
1. A parameter tuning method for a text training model, characterized in that, The parameter tuning method for the text training model is applied to a pre-trained text training model, which includes a text training unit and at least one parameter tuning unit. The text training unit and the at least one parameter tuning unit are connected using a preset parameter tuning model structure. The method includes: Obtain text sample data under a preset scenario, wherein the text sample data includes sample text and the task tags corresponding to the sample text; The sample text is input into the text training unit to obtain the first text training result, and the parameter tuning unit corresponding to the task label is determined as the target parameter tuning unit. The sample text is input into the target parameter tuning unit to obtain the second text training result. The total loss function of the text training model is calculated based on the first text training result and the second text training result, and the model parameters of the text training unit and the model parameters of the target parameter tuning unit are updated based on the total loss function to tune the text training model.
2. The method according to claim 1, characterized in that, The step of calculating the total loss function of the text training model based on the first text training result and the second text training result includes: Obtain the first true label corresponding to the sample text in the text training unit and the second true label corresponding to the sample text in the target parameter tuning unit; A first loss function is calculated based on the effective encoding of the first real label and the first text training result, wherein the first text training result is used to indicate the class probability value of the sample text in the text training unit; A second loss function is calculated based on the effective encoding of the second real label and the training result of the second text, wherein the training result of the second text is used to indicate the class probability value of the sample text in the target parameter tuning unit; The first loss function and the second loss function are summed to generate the total loss function.
3. The method according to claim 2, characterized in that, The total loss function further includes an information divergence loss function; the total loss function of the text training model calculated based on the first text training result and the second text training result further includes: Based on the first text training result, a first probability is determined that the text training unit outputs a preset discrete value, and based on the second text training result, a second probability is determined that the target parameter tuning unit outputs the preset discrete value. The relative entropy of the first probability and the second probability is calculated to obtain the information divergence loss function between the text training unit and the target parameter tuning unit. The first loss function, the second loss function, and the information divergence loss function are summed based on preset weights to obtain the total loss function of the text training model.
4. The method according to claim 1, characterized in that, The step of updating the model parameters of the text training unit and the model parameters of the target hyperparameter tuning unit based on the total loss function to tune the text training model includes: Calculate the first gradient information corresponding to the text training unit and the second gradient information corresponding to the target parameter tuning unit based on the total loss function; Based on the first gradient information, the model parameters of the text training unit are updated along the backpropagation direction of the text training unit using gradient descent, and based on the second gradient information, the model parameters of the text training unit are updated along the backpropagation direction of the target parameter tuning unit using gradient descent.
5. The method according to claim 1, characterized in that, After updating the model parameters of the text training unit and the model parameters of the target hyperparameter tuning unit based on the total loss function to tune the text training model, the method includes: Obtain text verification data under a preset scenario, wherein the text verification data includes verification text and the verification result corresponding to the verification text; The verification text is input into the text training model to obtain the model output. The model output is compared with the validation result to obtain a comparison result. The model performance of the text training model is determined based on the comparison result. The parameters of the text training unit and the target parameter tuning unit are optimized according to the model performance. The model performance is used to indicate the accuracy of the model output and the generalization ability of the text training model.
6. The method according to claim 1, characterized in that, The text training unit includes multiple sequentially connected transformation layers, and the parameter tuning unit includes multiple sequentially connected parameter tuning layers, wherein the number of transformation layers is equal to the number of parameter tuning layers; Each of the transformation layers in the text training unit is connected to a corresponding parameter tuning layer in each parameter tuning unit.
7. The method according to claim 6, characterized in that, The process of inputting the sample text into the text training unit to obtain a first text training result, determining the parameter tuning unit corresponding to the task label as the target parameter tuning unit, and inputting the sample text into the target parameter tuning unit to obtain a second text training result includes: The sample text is input into the text training unit, and the sample text is converted one by one according to the forward propagation order of the multiple conversion layers to obtain the first text training result. Each conversion layer is used to convert the converted text output by the previous conversion layer, and outputs the obtained converted text to the parameter tuning layer connected to the conversion layer and the next conversion layer corresponding to the conversion layer. Each of the parameter tuning layers in the parameter tuning unit receives the converted text output by the corresponding connected conversion layer and the fine-tuning result output by the previous fine-tuning layer. Each fine-tuning layer outputs the fine-tuning result to the next fine-tuning layer until the last fine-tuning layer in the fine-tuning unit outputs the corresponding fine-tuning result, and the fine-tuning result is used as the second text training result of the target parameter tuning unit.
8. A parameter tuning device for a text training model, characterized in that, The device is applied to a pre-trained text training model, the text training model including a text training unit and at least one parameter tuning unit, the text training unit and the at least one parameter tuning unit being connected using a preset parameter tuning model structure, wherein the device includes: The data acquisition module is used to acquire text sample data under a preset scenario, wherein the text sample data includes sample text and the task tags corresponding to the sample text; The model training module is used to input the sample text into the text training unit to obtain a first text training result, and to determine the parameter tuning unit corresponding to the task label as the target parameter tuning unit, and input the sample text into the target parameter tuning unit to obtain a second text training result; The parameter update module is used to calculate the total loss function of the text training model based on the first text training result and the second text training result, and update the model parameters of the text training unit and the model parameters of the target parameter tuning unit based on the total loss function, so as to tune the text training model.
9. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.