Knowledge migration-based training method for text understanding model in power field

Through the methods of knowledge transfer and data set fine-tuning, the problem of resource consumption and poor performance of general large-scale language models in text understanding in the electric power field is solved, the high performance of small-scale models and the improvement of text understanding capabilities are achieved, and sensitive data is avoided. Give way.

CN118797075AActive Publication Date: 2024-10-18JIANGXI NORMAL UNIV
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410786567.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2024-10-18
Estimated Expiration
2044-06-18

AI Technical Summary

Technical Problem

General-purpose large-scale language models have problems in text understanding in the electric power field, such as many parameters, large memory usage, long training time, slow prediction speed, risk of sensitive data leakage and high computing costs. They also lack specific knowledge in the electric power field, resulting in poor results.

Method used

A text understanding model training method in the electric power field based on knowledge transfer is adopted. By obtaining relevant text data in the electric power field, a data set is constructed and fine-tuned. The knowledge transfer model is initialized and trained, and a small-scale model is realized by combining knowledge distillation and joint learning with similar data sets. Efficient training and optimization.

Benefits of technology

It achieves high performance of small-scale models, avoids resource consumption and sensitive data leakage risks of large models, improves text understanding capabilities, and performs better than general large-scale models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118797075A_ABST
    Figure CN118797075A_ABST
Patent Text Reader

Abstract

The invention discloses a training method of an electric power field text understanding model based on knowledge migration, and belongs to the technical field of electric power knowledge text understanding, and the training method of the electric power field text understanding model based on knowledge migration comprises the steps: obtaining electric power field related text data, constructing a data set D1 and a data set D2, the method comprises the following steps: obtaining a first model subjected to fine tuning of D1 and a second model subjected to fine tuning of D2, initializing a knowledge migration model KTM by using the second model subjected to fine tuning of D2, respectively inputting training samples in a data set D1 into the knowledge migration model KTM and the first model subjected to fine tuning of D1 for training, and outputting predicted values, soft labels and real labels of the samples, according to the prediction value of the sample, the soft label and the real label of the sample, the loss value is calculated, and then the gradient is reversely propagated back to the knowledge migration model KTM, so that the inherent problems of many parameters, large memory occupation, long training time, slow prediction speed and the like of a large model are avoided, and the win-win situation of resource consumption and performance is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electric power knowledge text comprehension, and in particular to a training method for an electric power field text comprehension model based on knowledge transfer. Background Art

[0002] The texts in the power field have the following three characteristics: first, they are highly professional and usually contain a large number of professional terms and concepts; second, structured and unstructured data coexist, including not only structured tabular data, but also unstructured text reports, fault descriptions, operation logs, etc.; third, multi-source data fusion, the data comes from different sources, such as equipment monitoring data, maintenance records, accident reports, etc. These data types are diverse and require comprehensive analysis.

[0003] There are the following problems when using general large language models (LLMs) directly for text understanding in the power field:

[0004] 1. Many parameters, large memory usage, long training time and slow prediction speed;

[0005] 2. Directly using a general large language model to train actual power production data poses the risk of sensitive data being leaked when uploaded to the cloud;

[0006] 3. General large-scale language models lack specific knowledge in the power sector and are not effective;

[0007] 4. General large-scale language models require large computing resources and are costly.

[0008] Therefore, it is necessary to provide a training method for a text comprehension model in the power field based on knowledge transfer, aiming to solve the above problems. Summary of the invention

[0009] In view of the deficiencies in the prior art, an embodiment of the present invention aims to provide a training method for a text comprehension model in the electric power field based on knowledge transfer, so as to solve the problems in the above-mentioned background technology.

[0010] To achieve the above object, the present invention provides the following technical solutions:

[0011] A training method for a text understanding model in the electric power field based on knowledge transfer includes the following steps:

[0012] Step S1, obtaining text data related to the power field, constructing a data set D1 and a data set D2, fine-tuning the first model according to the data set D1 to obtain the first model fine-tuned by D1, and fine-tuning the second model according to the data set D2 to obtain the second model fine-tuned by D2;

[0013] Step S2, using the second model fine-tuned by D2 to initialize the knowledge transfer model KTM;

[0014] Step S3, input the training samples in the data set D1 into the knowledge transfer model KTM and the first model fine-tuned by D1 for training, and output the predicted value, soft label and true label of the sample;

[0015] Step S4: Calculate the loss value based on the predicted value, soft label and true label of the sample, and then let the gradient back propagate back to the knowledge transfer model KTM.

[0016] As a further solution of the present invention, the data set D1 in step S1 is obtained by traversing multiple data sets and randomly dividing and merging data, and the data set D2 is a professional data set in the power field.

[0017] As a further solution of the present invention, the training in step S3 includes: given an m-classification data set in the form of samples (X, Y), by minimizing the cross entropy loss function To train the classifier, P = Softmax(z),

[0018]

[0019] Among them, CE is the first model fine-tuned by D1, P is the category probability distribution, is the logits of the model, Y is the true label, and k represents the training batch.

[0020] As a further solution of the present invention, the prediction value of the sample in step S3 includes a soft prediction value u and a hard prediction value q, and the calculation formula of the soft prediction value u is:

[0021] u=softmax(z s ; T = τ),

[0022] The calculation formula of the hard prediction value q is:

[0023] q=softmax(z t ; T = τ),

[0024] Among them, the z t and z s are the logits of the first model fine-tuned by D1 and the second model fine-tuned by D2, respectively, and τ is a hyperparameter.

[0025] As a further solution of the present invention, the loss function when the second model fine-tuned by D2 learns the output of the first model fine-tuned by D1 is Defined as:

[0026]

[0027] Wherein, KD is the second model fine-tuned by D2, q k is the hard prediction value for the kth batch of training, u k is the soft prediction value of the kth training batch.

[0028] As a further solution of the present invention, the knowledge transfer model KTM The loss function is:

[0029]

[0030] Where Θ is the sum of the parameters of KTM, |·| represents the number of elements in the set, KD is the second model fine-tuned by D2, q is the hard prediction value, u is the soft prediction value, D1 is the data set to be trained, k is the starting position of the knowledge text, l is the ending position of the knowledge text, j represents the jth word in the knowledge text, L is the text length, N is the number of categories, a is the subscript of the category array N, and t is a value of the category array N, that is, t=N[a].

[0031] As a further solution of the present invention, the optimization goal of the knowledge transfer model KTM is and Weighted sum:

[0032]

[0033] Among them, λ and γ are weights.

[0034] In summary, compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0035] The present invention proposes a pre-trained model with a smaller scale that is suitable for text understanding in the power field. The method avoids the problems inherent in large models, such as large number of parameters, large memory usage, long training time and slow prediction speed. It avoids the risk of sensitive data being leaked when directly using a general large-scale language model to train actual power production data. The application makes use of knowledge distillation, joint learning of similar data sets and fine-tuning of similar tasks to make the performance of the small model comparable to or surpass that of the large model, thereby achieving a win-win situation in resource consumption and performance.

[0036] In order to more clearly illustrate the structural features and effects of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 It is a flow chart of an embodiment of the invention. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0039] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments.

[0040] In one embodiment of the present invention, see Figure 1 The training method of the electric power field text understanding model based on knowledge transfer comprises the following steps:

[0041] Step S1, obtaining text data related to the power field, constructing a data set D1 and a data set D2, fine-tuning the first model according to the data set D1 to obtain the first model fine-tuned by D1, and fine-tuning the second model according to the data set D2 to obtain the second model fine-tuned by D2;

[0042] Step S2, using the second model fine-tuned by D2 to initialize the knowledge transfer model KTM;

[0043] Step S3, input the training samples in the data set D1 into the knowledge transfer model KTM and the first model fine-tuned by D1 for training, and output the predicted value, soft label and true label of the sample;

[0044] Step S4: Calculate the loss value based on the predicted value, soft label and true label of the sample, and then let the gradient back propagate back to the knowledge transfer model KTM.

[0045] In this embodiment, the data set D1 in step S1 is a data set that traverses multiple data sets and randomly divides and merges data, and the data set D2 is a professional data set in the power field;

[0046] The training in step S3 includes: given an m-classification data set in the form of samples (X, Y), by minimizing the cross entropy loss function To train the classifier,

[0047] P = Softmax(z),

[0048]

[0049] Among them, CE is the first model fine-tuned by D1, P is the category probability distribution, is the logits of the model, Y is the true label, and k represents the training batch. If the above training process is the process of the classifier learning based on the true label Y, then knowledge distillation also includes the process of the student model learning based on the category probability distribution q output by the teacher model; similar to Y, in many cases, the probability value of Y on the correct category will be very high, close to 1, and the probability of other categories will be 0;

[0050] The prediction value of the sample in step S3 includes a soft prediction value u and a hard prediction value q. The calculation formula of the soft prediction value u is:

[0051] u=softmax(z s ; T = τ),

[0052] The calculation formula of the hard prediction value q is:

[0053] q=softmax(z t ; T = τ),

[0054] Among them, the z t and z s are the logits of the first model fine-tuned by D1 and the second model fine-tuned by D2, respectively. τ is a hyperparameter. The larger the value of T, the softer q is, and the more information the teacher model provides. Therefore, q is often called a soft label, and the corresponding true label Y is called a hard label. u is called a soft prediction value, and q is called a hard prediction value.

[0055] The loss function when the second model fine-tuned by D2 learns the output of the first model fine-tuned by D1 Defined as:

[0056]

[0057] Wherein, KD is the second model fine-tuned by D2, q k is the hard prediction value for the kth batch of training, u k is the soft prediction value of the kth training batch;

[0058] Through the above formula, we can get the D1 soft label q * D1 ,D2 soft labelq * D2 , and the soft prediction value u* of the knowledge transfer model KTM ( *=k,l,t), with u k For example:

[0059]

[0060] Where T is temperature, W is weight matrix, b1 is weight deviation value, is the real temperature;

[0061] After replacing the above soft labels and soft prediction values, calculate the true value and the probability distribution p * , we can get the knowledge transfer model KTM Loss function:

[0062]

[0063] Where Θ is the sum of the parameters of KTM, |·| represents the number of elements in the set, KD is the second model fine-tuned by D2, q is the hard prediction value, u is the soft prediction value, D1 is the data set to be trained, k is the starting position of the knowledge text, l is the ending position of the knowledge text, j represents the jth word in the knowledge text, L is the text length, N is the number of categories, a is the subscript of the category array N, and t is a value of the category array N, that is, t=N[a].

[0064] In summary, the optimization goal of the knowledge transfer model KTM is and Weighted sum:

[0065]

[0066] Among them, λ and γ are weights. The whole training process iterates epochmax rounds. Before each round, the training set is shuffled. Ensure the randomness of the training samples, and then, from the disordered training set Select a mini-batch from: α , whose samples come from the same data set α; b α The large model fine-tuned by the dataset α and the knowledge transfer model KTM are input respectively, and the soft labels and soft and hard prediction values ​​required to calculate the loss value are output; then, b is calculated according to different datasets. α The loss value Finally, the gradient of each parameter is calculated by the loss value and the knowledge transfer model KTM is updated.

[0067] In summary, this application proposes a small-scale pre-trained model suitable for text understanding in the power field, which avoids the problems inherent in large models such as large number of parameters, large memory usage, long training time, slow prediction speed, etc.; it makes the performance of the small model comparable to or even exceeds that of the large model by comprehensively using knowledge distillation, joint learning of similar data sets, and fine-tuning of similar tasks, achieving a win-win situation in resource consumption and performance.

[0068] The knowledge transfer method combines the characteristics of text understanding, fully utilizes the common characteristics between data sets to expand training samples, and combines similar text understanding tasks to allow the model to learn how to understand the text in advance and maximize the performance of the small model.

[0069] Compared with large models, the knowledge transfer model KTM has fewer parameters, lower memory usage, significantly shorter training time, and faster prediction speed. At the same time, through customized training for specific tasks in the power field, its text comprehension ability performs better than general large models.

[0070] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A training method for a text comprehension model in the electric power field based on knowledge transfer, characterized in that: The following steps are involved: Step S1, obtaining text data related to the power field, constructing a data set D1 and a data set D2, fine-tuning the first model according to the data set D1 to obtain the first model fine-tuned by D1, and fine-tuning the second model according to the data set D2 to obtain the second model fine-tuned by D2; Step S2, using the second model fine-tuned by D2 to initialize the knowledge transfer model KTM; Step S3, input the training samples in the data set D1 into the knowledge transfer model KTM and the first model fine-tuned by D1 for training, and output the predicted value, soft label and true label of the sample; Step S4: Calculate the loss value based on the predicted value, soft label and true label of the sample, and then let the gradient back propagate back to the knowledge transfer model KTM.

2. The training method of the electric power field text comprehension model based on knowledge transfer according to claim 1 is characterized in that: In the step S1, the data set D1 is obtained by traversing multiple data sets and randomly dividing and merging data, and the data set D2 is a professional data set in the power field.

3. The training method of the electric power field text comprehension model based on knowledge transfer according to claim 1 is characterized in that: The training in step S3 includes: given an m-classification data set in the form of samples (X, Y), by minimizing the cross entropy loss function To train the classifier, P = Softmax(z), Among them, CE is the first model fine-tuned by D1, P is the category probability distribution, is the logits of the model, Y is the true label, and k represents the training batch.

4. The training method of the electric power field text comprehension model based on knowledge transfer according to claim 3 is characterized in that: The prediction value of the sample in step S3 includes a soft prediction value u and a hard prediction value q. The calculation formula of the soft prediction value u is: u=softmax(z s ;T=τ), The calculation formula of the hard prediction value q is: q=softmax(z t ;T=τ), Wherein, zt and zs are logits of the first model fine-tuned by D1 and the second model fine-tuned by D2, respectively, and τ is a hyperparameter.

5. The training method of the electric power field text comprehension model based on knowledge transfer according to claim 4 is characterized in that: The loss function when the second model fine-tuned by D2 learns the output of the first model fine-tuned by D1 Defined as: Wherein, KD is the second model fine-tuned by D2, q k is the hard prediction value for the kth batch of training, u k is the soft prediction value of the kth training batch.

6. The training method of the electric power field text comprehension model based on knowledge transfer according to claim 5 is characterized in that: The knowledge transfer model KTM The loss function is: Where Θ is the sum of the parameters of KTM, |·| represents the number of elements in the set, KD is the second model fine-tuned by D2, q is the hard prediction value, u is the soft prediction value, D1 is the data set to be trained, k is the starting position of the knowledge text, l is the ending position of the knowledge text, j represents the jth word in the knowledge text, L is the text length, N is the number of categories, a is the subscript of the category array N, and t is a value of the category array N, that is, t=N[a].

7. The training method of the electric power field text comprehension model based on knowledge transfer according to claim 6 is characterized in that: The optimization goal of the knowledge transfer model KTM is and Weighted sum: Among them, λ and γ are weights.

Citation Information

Patent Citations

  • Deep migration learning system and method based on entropy minimization

    CN110580496A

  • Question and answer model compression method and device based on knowledge distillation and related equipment

    CN115204412A

  • Model training method and device based on knowledge distillation, equipment and medium

    CN117313830A

  • Text classification method based on model internal characteristic distillation

    CN117807235A

  • Power industry model training method based on cross-language knowledge migration and experience driving

    CN117933364A