Model training and interaction method and device, equipment and medium
By augmenting data on the first sample and using the first model for knowledge distillation training, a second model that can accurately understand the intention of the scene problem and provide accurate answers is obtained, and the problem of inaccurate answers in the prior art is solved, and more efficient consultation problem solving is achieved.
Patent Information
- Application Number
- CN202311176827.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-12
- Publication Date
- 2025-03-21
AI Technical Summary
In the prior art, when using artificial intelligence technology to answer consulting questions, the recalled answers are often inaccurate and cannot solve users' consulting problems in a timely manner, mainly because simple text matching cannot understand the true intention of the problem.
By performing data augmentation processing on the acquired first sample, a second sample is obtained, and knowledge distillation training is performed using the second sample and the first model with intentional understanding ability to obtain a second model with text classification ability. This model can accurately understand the true intention of the scene problem and find the corresponding scene answers.
Through data augmentation and knowledge distillation training, the model's intention understanding ability and answer accuracy of scenario problems are improved, and users' consulting problems can be solved faster and more accurately.
Smart Images

Figure CN119670911A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to model training, interaction methods, devices, equipment and media. Background Art
[0002] In some application scenarios, there are often consultation questions related to various professional scenarios. With the development of artificial intelligence technology, the requirements for artificial intelligence technology are getting higher and higher, including the requirements for faster response speed of professional scenario questions and answers, and higher recall accuracy of scenario questions and answers.
[0003] In the prior art, when artificial intelligence technology is used to answer consultation questions, the answers recalled are often not very accurate. This is because in the prior art, the words contained in the consultation question are usually matched with the content contained in the question library. As a result, the recalled answers obtained by matching are not what the user needs, and the user's consultation problem cannot be solved in time. Therefore, a solution that can use artificial intelligence technology to accurately recall answers is needed. Summary of the invention
[0004] In order to solve or improve the problems existing in the prior art, the embodiments of the present application provide a model training method, an interaction method, an apparatus, a device and a medium.
[0005] In a first aspect, in one embodiment of the present application, a model training method is provided. The method comprises:
[0006] Performing data enhancement processing on the acquired first sample to obtain a second sample;
[0007] The model to be trained is trained by knowledge distillation using the second sample and the first model to obtain a second model with text classification capability; wherein the second model after knowledge distillation training learns intent understanding capability from the first model.
[0008] In a second aspect, in one embodiment of the present application, an interaction method is provided. The method comprises:
[0009] Get the scenario question;
[0010] Inputting the scenario question into the trained second model with text classification capability; wherein the second model is a model with intent understanding capability obtained by performing knowledge distillation training using the second sample and the first model;
[0011] The scenario answers are displayed according to the preset sorting rules.
[0012] In a third aspect, in one embodiment of the present application, a model training device is provided, the device comprising:
[0013] The data enhancement module is used to perform data enhancement processing on the acquired first sample to obtain a second sample.
[0014] A training module is used to perform knowledge distillation training on the to-be-trained model using the second sample and the first model to obtain a second model with text classification capability; wherein the second model after knowledge distillation training learns intent understanding capability from the first model.
[0015] In a fourth aspect, in one embodiment of the present application, an electronic device is provided, including a memory and a processor; wherein:
[0016] The memory is used to store programs;
[0017] The processor is coupled to the memory, and is used to execute the program stored in the memory, so as to implement the method described in the first aspect or the method described in the second aspect.
[0018] In the fifth aspect, in one embodiment of the present application, a non-temporary machine-readable storage medium is provided, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor executes the method described in the first aspect, or executes the method described in the second aspect.
[0019] In the technical solution provided by the embodiment of the present application, during the model training process, due to the limited number of currently available samples, the accuracy of the model obtained by training with a limited number of samples is poor. Therefore, it is necessary to perform data enhancement processing based on the existing first sample. After the data enhancement processing, the second sample is obtained. Then, the second model is trained with knowledge distillation using the second sample and the first model with intent understanding capability, so as to obtain the second model with text classification capability. In the above manner, after the first model is trained with limited scene problem samples, the first model has intent understanding capability, so that the trained second model can accurately understand the true intent of the scene problem and accurately find the scene answer corresponding to the scene problem. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0021] Figure 1 A flowchart of a model training method provided in an embodiment of the present application;
[0022] Figure 2 A schematic diagram of a model training scheme provided in an embodiment of the present application;
[0023] Figure 3 A flowchart of an interactive method provided in an embodiment of the present application;
[0024] Figure 4 A schematic diagram of a database question-answering system provided in an embodiment of the present application;
[0025] Figure 5 A schematic diagram of a model training device provided in an embodiment of the present application;
[0026] Figure 6 A schematic diagram of an interactive device provided in an embodiment of the present application;
[0027] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0029] In some processes described in the specification, claims and the above-mentioned figures of the present application, multiple operations appearing in a specific order are included, and these operations may not be executed or executed in parallel in the order in which they appear in this article. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit "first" and "second" to different types. In addition, the embodiments described below are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application.
[0030] In database application scenarios, the question texts raised by users contain various information such as products, functions, fault names, etc. The database system contains many kinds of products, and various products cooperate with each other to complete a certain task. Therefore, when asking questions, users cannot simply provide answers based on the surface meaning of the text (for example, simply classifying the question text). They need to further understand the true intention of the question text and other products related to the product contained in the question text that may cause the problem. In addition, a product type may contain multiple sub-product types. For each sub-product type, it is necessary to accurately lock which sub-product type in the product is based on the product and intention in the question. In the prior art, the search engine matches the scenario questions with the knowledge base content based on word matching, and does not understand the intention contained in the question statement. The matched results often contain answers that are irrelevant to the scenario questions. Therefore, there is a need for a solution that can accurately answer scenario questions in a database application scenario containing multiple product types.
[0031] Terminology explanation:
[0032] BERT model: The main feature is the bidirectional encoder. Unlike the traditional unidirectional language model, it can simultaneously use contextual information to understand the meaning of words. This means that BERT can learn the representation of words from all the contexts of a sentence, not just limited to the information on the left or right.
[0033] The explanation of the BERT model is as follows:
[0034] Pretraining: The BERT model is pretrained using large-scale unlabeled text data. During the pretraining phase, the model learns to predict masked or randomly hidden words from the input text. This enables the model to learn the contextual information and semantic representation of words.
[0035] Bidirectional Encoder: The BERT model uses the Transformer encoder to model bidirectional contextual information. Transformer is a neural network architecture based on the self-attention mechanism, which can capture global contextual dependencies when processing sequence data.
[0036] Query: The input data used by the user for retrieval, such as the scenario question mentioned below.
[0037] GBDT (Gradient Boosting Decision Tree): is an ensemble algorithm based on decision trees. Gradient Boosting is an algorithm in the ensemble boosting method, which iterates the new learning model through gradient descent.
[0038] CNN (Convolutional Neural Networks): is a type of feedforward neural network that includes convolutional calculations and has a deep structure.
[0039] TextCNN: TextCNN has the same network structure as CNN, with one convolution layer, one max-pooling layer, and finally an external softmax to output for classification, but uses text instead of images as input.
[0040] Knowledge Distillation: The knowledge (“Knowledge”) contained in the trained model is extracted (‘Distill’) into another model, so that the second model can learn the generalization ability of the teacher model.
[0041] The technical solution implemented in this application will be explained below in conjunction with specific embodiments.
[0042] like Figure 1 A flow chart of the model training method provided in the embodiment of the present application. Figure 1 You can see that the specific steps include the following:
[0043] 101: Perform data enhancement processing on the acquired first sample to obtain a second sample.
[0044] 102: Perform knowledge distillation training on the to-be-trained model using the second sample and the first model to obtain a second model with text classification capability; wherein the second model after the knowledge distillation training learns intent understanding capability from the first model.
[0045] It should be noted here that the above model training method can be applied to various scenarios as needed, such as database question and answer scenarios, cloud service question and answer scenarios, e-commerce question and answer scenarios, etc. For ease of understanding, in the following embodiments, the database question and answer scenario will be used as an example for illustration, and the corresponding scenario questions can be database questions, and the scenario answers can be database answers. The database scenario is only used as an example and does not constitute a limitation on the technical solution of this application.
[0046] In the database intelligent question and answer application scenario, in order to improve the accuracy of the answer, a large number of training samples need to be provided to train the machine learning model. However, the number of actual database question and answer samples is very limited. It is difficult to obtain a good training effect by relying solely on the current existing question and answer historical data as training samples. Therefore, it is necessary to perform data enhancement processing on the samples in order to obtain a rich and diverse sample. In order to obtain better training results, when constructing samples, they can be constructed according to the combination of questions and answers. For example, the constructed second sample (such as the second database question and answer sample) can be in the form of (database question 1, database answer 1). It should be noted that questions and answers are not necessarily one-to-one, that is, questions of different forms may correspond to the same answer, and the same question may also correspond to multiple valid answers. The specific data enhancement processing scheme will be described in the following embodiments, and will not be repeated here.
[0047] In actual applications, databases contain many types of products. For example, RDS databases include computing resource products, storage resources, specification types (number of CPU cores), and so on. If certain problems arise during the use of the database, multiple product types may be involved at the same time. If text matching or text classification is performed only through text content such as words contained in database questions, it is easy to recall incorrect database answers. For example, if the database question raised by the requester is "RDS instance link layer exception", the recalled answer may be a result related to "instance status configuration change" rather than a result related to "RDS monitoring alarm". Obviously, text matching through words such as "instance" and "abnormality" in database questions cannot understand the true intention of the user asking the question, and it is impossible to recall the accurate answer.
[0048] Therefore, it is necessary to truly understand the true intention of the database question. When understanding the intention of database questions, the intention is understood based on the contextual relationship in the database question text. In order to improve the ability and accuracy of intent understanding, large models such as the first model BERT are often used as teacher models. However, many database question-and-answer scenarios are online questions and answers, and it is difficult to deploy large models online. Therefore, lightweight small models are usually deployed online. In order to make the lightweight small model achieve an effect similar to that of the first model, in the present application scheme, the second model is trained with knowledge distillation using the second sample and the first model as the teacher model, so that the trained second model has the ability to understand the intention of the scenario questions, while meeting the needs of timely response to online questions and answers. The second model mentioned here is the student model obtained after knowledge distillation training using the first model.
[0049] In the above manner, the second model is trained by using more samples and the first model, so that the second model has the ability to understand the intention of scenario questions (such as database questions or cloud service questions, etc.), rather than just recalling answers based on text matching such as words contained in the scenario questions, thereby making the recall results (that is, scenario answers) more accurate.
[0050] In one or more embodiments of the present application, performing data enhancement processing on the acquired first sample to obtain the second sample includes:
[0051] Using random processing to expand the first sample size;
[0052] Fine-tune the first model using the enlarged first sample;
[0053] A second sample including scenario questions and product types is constructed based on the historical work order data and the fine-tuned text matching model.
[0054] When performing data augmentation, random augmentation processing is performed on the words in the scenario question, such as random cropping, random replacement, random deletion, random insertion, etc.
[0055] In order to obtain better data enhancement effects, targeted data enhancement can be performed. An optional random processing method is to weight each word in the scenario question, and then perform corresponding random processing according to the weight score of each word. For example, synonym replacement or random deletion is performed for words or phrases with high weight scores, and the frequency of random processing for words with high weight scores is higher, while words with low weight scores can be selectively randomly processed as needed, or remain as they are without any random processing.
[0056] For example, the database problem is: rds instance link layer anomaly, and the synonym of rds is RDS. After word segmentation and scoring, the weight score of each word segmentation is: [rds: 0.7 instance: 0.2 link layer: 0.4 anomaly: 0.1, RDS: 0.7].
[0057] After the first data enhancement of the first sample is completed by random processing, the number of scene problem samples increases. Further, the text matching model (for example, it can be a roBERTa model) is fine-tuned (Fine-tuning) using the enlarged first sample. Specifically, after pre-training, the roBERTa (the text matching model mentioned above) model can be fine-tuned on specific tasks to adapt to different downstream tasks, such as text classification, named entity recognition, word relationship discrimination, etc. In the fine-tuning stage, the model will perform supervised training on the labeled data of specific tasks to optimize the parameters of the text matching model.
[0058] After completing the fine-tuning task, the text matching model has a certain ability to understand intent. At this time, the historical work order data and the fine-tuned text matching model are used for prediction, and the prediction results are used as samples for data enhancement, thereby obtaining a large number of QA pairs consisting of scenario questions and scenario answers. The result of the prediction processing using the fine-tuned text matching model and historical work order data (the historical work order data contains historical scenario questions and scenario answers corresponding to some scenario questions) is used as the second sample.
[0059] Through the above method, the first data enhancement processing is first performed based on the existing samples in a random processing mode to obtain the enlarged first sample. On this basis, the historical work order data and the fine-tuned text matching model are further used for prediction, and the prediction results are used as the samples obtained by data enhancement to achieve secondary enhancement of the database samples, which effectively solves the problem of insufficient samples.
[0060] In one or more embodiments of the present application, the second sample including scenario problems and product types is constructed based on the historical work order data and the fine-tuned first model, including:
[0061] Obtain historical work order data containing scenario issues;
[0062] Inputting the scenario question and the first sample into the fine-tuned text matching model to obtain a matching relationship between the product type and the scenario question;
[0063] Based on the matching relationship, a second sample including scenario questions and product types is constructed.
[0064] In actual applications, historical work order data collected in the form of logs and the like includes scenario problems that have been received and the product type to which the scenario problems belong.
[0065] Furthermore, multiple scenario questions in the historical work order data and the expanded first sample are input into the first model for matching to obtain a question-and-answer (QApair) result with a matching relationship. The matching relationship mentioned here refers to the matching relationship between the question and the answer in at least one prediction result corresponding to a scenario question. For example, the matching relationship may be that scenario question 1 and scenario answer 1, scenario question 1 and scenario answer 2 have a matching relationship, respectively.
[0066] Optionally, the prediction results with matching relationships can be screened, for example, they can be screened according to the matching degree. Assume that the scenario question and the matched scenario answer are vectorized respectively, and then the similarity between the vectors is calculated. If the similarity value is greater than a threshold value of 0.6, it is considered a match, otherwise it is considered a mismatch. The prediction result with a correct matching relationship is taken as a positive sample, and the prediction result with an incorrect matching relationship is taken as a negative sample. Based on the positive and negative samples, a second sample containing product type and scenario question is constructed.
[0067] Through the above method, rapid data enhancement of training samples can be achieved, thereby obtaining positive and negative samples that can meet training requirements, which can effectively improve the prediction effect of the first model and indirectly improve the intention understanding ability and prediction effect of the second model.
[0068] In one or more embodiments of the present application, the step of performing knowledge distillation training on the second model using the second sample and the first model with intent understanding capability to obtain a text classification model includes:
[0069] Calculating a first loss function based on a second sample and the first model; and calculating a second loss function based on a second sample and the second model;
[0070] The second model is trained based on the first loss function and the second loss function to obtain the second model with text classification capability.
[0071] In actual applications, the second model is to be deployed online in the database automatic question answering system, which has certain requirements for response speed and recall accuracy. The first model is a larger teacher model than the second model, with better intent understanding ability. Although the first model has better intent understanding ability, it is not suitable for online deployment due to its large model size. Therefore, a compromise solution is adopted, which is to use the teacher model to perform knowledge distillation training on the second model.
[0072] It should be noted that an important purpose of knowledge distillation training is to allow the second model to learn the generalization ability of the teacher model. A very efficient distillation method is to use the category probability output by the softmax layer in the teacher model as a soft label, and do cross entropy with the softmax output in the second model. The training process of knowledge distillation is soft labeling, using the category probability of the teacher model as a soft label.
[0073] The main process of knowledge distillation training is:
[0074] First, use the complete complex model to train a teacher model (that is, the first model mentioned above) using the training sample (that is, the second sample obtained after two data enhancements). Then design a small-scale student model.
[0075] Then fix the weight parameters of the teacher model, and then design a series of loss functions, namely the first loss function mesloss and the second loss function NLLloss. Then, use the first loss function and the second loss function to make the student model gradually approach the performance characteristics of the teacher model during the knowledge distillation training process, so that the prediction accuracy of the student model gradually approaches that of the teacher model. In this way, the trained second model not only has the ability to understand intent, but also has the characteristics of convenient online deployment, fast response speed, and high prediction accuracy.
[0076] In one or more embodiments of the present application, the scenario answer includes: product type, multiple subtypes contained in the product type, and product functions.
[0077] The intent understanding capability of the second model is used to understand the intent of the scenario questions provided by the requester, thereby obtaining various scenario answers including product types. As mentioned above, since the database system contains many products, and the generation and resolution of a problem may involve multiple products. Therefore, when the second model is used for prediction, the results obtained include product types. After accurately determining the product type, the scope of scenario answers is greatly narrowed, and the corresponding scenario answers can be found in the current product type, improving the efficiency and accuracy of answer search.
[0078] It should be noted that the database system contains many product types, and some product types contain many sub-types. Some scenario problems are caused by sub-types of a certain product type. Therefore, in order to more accurately locate the problem and accurately provide the corresponding scenario answer, it is necessary to use the intent understanding ability to accurately analyze and predict whether sub-types are involved.
[0079] In one or more embodiments of the present application, the training of the second model based on the first loss function and the second loss function to obtain the second model with text classification capability includes:
[0080] Select any sample from the second samples and input it into the first model and the second model;
[0081] comparing the first loss function and the second loss function;
[0082] Based on the comparison result of the first loss function and the second loss function and the cross entropy of the second model, the second model is iteratively trained to obtain the second model having a loss function similar to that of the first model.
[0083] In practical applications, when training the second model, the first loss function corresponding to the first model and the second loss function corresponding to the second model are obtained. Then, the two loss functions are compared, and the second model is iteratively trained according to the comparison result, so that the training effect of the second model is as close as possible to that of the teacher model.
[0084] For ease of understanding, the following will be described by way of specific examples. Figure 2 Schematic diagram of the model training scheme provided in an embodiment of the present application.
[0085] Since the number of samples currently used to train the first model (roBERTa) is insufficient, data enhancement processing is required for the samples. Specifically, assuming that there are currently 170 basic QApairs (first samples), the first data enhancement processing can be performed on them. A random processing method can be used (for example, random cropping, random deletion, random insertion, random replacement, etc. At least one of the various enhancement methods). After expansion, 3060 QApairs (expanded first samples) are obtained. Then, the first model is fine-tuned to obtain a text matching model. Further historical work order data is obtained, and the fine-tuned first model is used for prediction to obtain many prediction results, which are used as 32962 QApairs (second samples).
[0086] After the training samples are prepared, the teacher model (that is, the first model (roBERTa) mentioned above) is further used to train the second model (TextCNN), and the two loss functions (mseloos and NLLloss) are compared. The second model is iteratively trained according to the comparison results to obtain a text classification model.
[0087] Specifically, BERT is used as the teacher model to teach the student model TextCNN. The loss of BERT is introduced during TextCNN training:
[0088] loss=a*CrossEntropyLoss(trueresult,TextCNNpredict)+b
[0089] *MSEloss(BERTpredict,TextCNNpredict),
[0090] Among them, a and b are hyperparameters, CrossEntropyLoss(trueresult,TextCNNpredict) is the cross entropy of the true result of the second model textCNN and the result predicted by TextCNN (that is, the cross entropy of the second model mentioned above), and MSEloss(BERTpredict,TextCNNpredict) is the mean square error of the prediction score of BERT (corresponding to the first loss function mentioned above) and the prediction score of TextCNN (corresponding to the second loss function mentioned above), that is, the comparison result of the first loss function and the second loss function mentioned above. The smaller the comprehensive loss, the better the training result of the current second model.
[0091] Based on the same idea, the present application embodiment also provides an interaction method. Figure 3 A flow chart of an interactive method provided in an embodiment of the present application. Figure 3 You can see that the specific steps include the following:
[0092] 301: Problem getting the scene.
[0093] 302: Input the scenario problem into a second model with text classification capability obtained through training; wherein the second model is a model with intent understanding capability obtained through knowledge distillation training using the second sample and the first model.
[0094] 303: Display the scenario answers according to the preset sorting rules.
[0095] For example, if Figure 4 A schematic diagram of a database question-answering system provided in an embodiment of the present application. Figure 4 As can be seen in the figure, the user (that is, the requester) sends a query to the server through the client. In actual applications, after the user sends a database question online, the server will recall the relevant database answers for the database question. Specifically, after the server receives the database question, it will use the trained second model to understand the intent of the database question online and determine at least one product type corresponding to the database question. Then, based on at least one product type, search for a database answer corresponding to a product type required by the user. Use the intent understanding capability to first determine the product type corresponding to the database question, narrow the range of answers, and then further accurately search for possible answers.
[0096] It should be noted that the second model mentioned here is obtained by knowledge distillation training using the second sample and the first model with intent understanding capability. Since the second model needs to be deployed online, it means that the second model needs to be a lightweight and easy-to-deploy model, and at the same time, the second model must be able to meet the prediction accuracy requirements. Therefore, the knowledge distillation training method is adopted. The first model is first trained with sufficient second samples, and then the second model is trained with the trained first model, so that the trained second model has intent understanding capability and can also be easily deployed online.
[0097] In actual applications, there may be many scenario answers obtained through recall, and it is necessary to sort multiple scenario answers according to relevance. That is, the more accurate the prediction result, the higher the ranking. In addition, when the user clicks on the recalled answer, the recall result can be dynamically updated, such as adding other relevant scenario answers based on the user's click, thereby providing users with more choices.
[0098] In one or more embodiments of the present application, the scenario answers are displayed according to a preset sorting rule, including:
[0099] If multiple scenario answers are obtained through recall, at least one of text similarity, semantic similarity and click rate corresponding to each scenario answer is determined;
[0100] The plurality of scenario answers are sorted according to at least one of the text similarity, the semantic similarity and the click rate.
[0101] When sorting, you can sort by text similarity (text similarity between scenario questions and recalled answers), semantic similarity (semantic similarity between scenario questions and recalled answers), or click-through rate (click-through rate of each scenario answer recalled, generally believed that the higher the click-through rate, the greater the possibility of being selected by the user). Of course, you can also sort by considering the above three factors comprehensively. Optionally, the sorting results can be further sent to the user's client.
[0102] Through the above solution, users can quickly find the scenario answers they need from numerous recall results.
[0103] In one or more embodiments of the present application, after inputting the scenario question into the trained second model with text classification capability, the method further includes:
[0104] Perform semantic understanding and intent understanding processing on the received scenario questions;
[0105] Determine at least one product type corresponding to the scenario problem according to the intent understanding result;
[0106] The at least one product type is screened according to key words in the scenario question determined according to the semantic understanding result.
[0107] In actual applications, after the scenario problem is input into the second model, it will be further processed for semantic understanding and intent understanding.
[0108] Determine whether to trigger the template in the template library based on the result of semantic understanding. If triggered, call the following API service, for example, call the RDS instance unlock API. In addition, the key words in the scenario question can be further determined based on the result of semantic understanding, and the product types related to the key words can be filtered out from at least one product type based on the weight value of the key words, so as to further improve the accuracy of the recalled answers.
[0109] Determine the corresponding product type based on the intent understanding. For example, if the scenario problem is "RDS instance link layer abnormality", the corresponding recalled product type is:
[0110] Database, cloud database RDS, monitoring / alarm / optimization / active operation and maintenance
[0111] Database, cloud database RDS, database connection
[0112] Database, cloud database RDS, parameter management
[0113] Database, cloud database RDS, SQL server engine features
[0114] Database, cloud database RDS, data backup and recovery
[0115] In one or more embodiments of the present application, after obtaining the scenario problem, the method further includes:
[0116] Determine the role type of the requester who provides the scenario problem;
[0117] A plurality of product types related to the requester are determined according to the role type.
[0118] It is easy to understand that different requesters use different product types of databases. In order to narrow the scope of the recall, the role type of the requester and the product type corresponding to the role type can be considered. For example, the requester is an administrator, internal operation and maintenance, external operation and maintenance, and so on. Different requesters have different permissions, and the corresponding scenario answers they can access are also different. Furthermore, after narrowing the scope of the recall based on the role type, the intent understanding, semantic understanding and other solutions described above can be further used to further recall the required scenario answers.
[0119] Through the above scheme, in the process of model training, due to the limited number of currently available samples, the accuracy of the model trained with a limited number of samples is poor. Therefore, it is necessary to perform data enhancement processing based on the existing first sample. After data enhancement processing, the second sample is obtained. Then, the second model is trained with knowledge distillation using the second sample and the first model with intent understanding capability, so as to obtain the second model with text classification capability. Through the above method, after the first model is trained with limited scene problem samples, the first model has intent understanding capability, so that the trained second model can accurately understand the true intent of the scene problem and accurately find the scene answer corresponding to the scene problem.
[0120] Based on the same idea, the present application embodiment also provides a model training device. Figure 5 A schematic diagram of a model training device provided in an embodiment of the present application. Figure 5 It can also be seen that the device includes:
[0121] The data enhancement module 51 is used to perform data enhancement processing on the acquired first sample to obtain a second sample.
[0122] The training module 52 is used to perform knowledge distillation training on the to-be-trained model using the second sample and the first model to obtain a second model with text classification capability; wherein the second model after knowledge distillation training learns intent understanding capability from the first model.
[0123] A data enhancement module 51, configured to expand the number of first samples by using random processing;
[0124] Fine-tune the text matching model using the enlarged first sample;
[0125] A second sample including scenario questions and product types is constructed based on the historical work order data and the fine-tuned text matching model.
[0126] A training module 52, configured to calculate a first loss function based on a second sample and the first model; and, to calculate a second loss function based on a second sample and the second model;
[0127] The second model is trained based on the first loss function and the second loss function to obtain the second model with text classification capability.
[0128] Optionally, a construction module 53 is further included, for obtaining historical work order data including product types and scenario issues;
[0129] Inputting the scenario problem and the first sample into the fine-tuned first model to obtain a matching relationship between the product type and the scenario problem;
[0130] Based on the matching relationship, a second sample including scenario questions and product types is constructed.
[0131] Optionally, the scenario answer includes: product type, multiple subtypes contained in the product type, and product functions.
[0132] A training module 52, configured to select any sample from the second samples and input it into the first model and the second model;
[0133] comparing the first loss function and the second loss function;
[0134] Based on the comparison result of the first loss function and the second loss function and the cross entropy of the second model, the second model is iteratively trained to obtain the second model having a loss function similar to that of the first model.
[0135] Based on the same idea, the embodiment of the present application also provides an interactive device. Figure 6 A schematic diagram of an interactive device provided in an embodiment of the present application. Figure 6 It can also be seen that the device includes:
[0136] The acquisition module 61 is used to acquire scene problems.
[0137] An input module 62 is used to input the scenario problem into a trained second model with text classification capability; wherein the second model is obtained by knowledge distillation training using a second sample and a first model with intent understanding capability.
[0138] The sorting module 63 is used to display the scenario answers according to the preset sorting rules.
[0139] A sorting module 63, for determining at least one of text similarity, semantic similarity and click rate corresponding to each of the scenario answers if multiple scenario answers are obtained through recall;
[0140] The plurality of scenario answers are sorted according to at least one of the text similarity, the semantic similarity and the click rate.
[0141] An acquisition module 61 is used to perform semantic understanding and intention understanding processing on the received scenario question;
[0142] Determine at least one product type corresponding to the scenario problem according to the intent understanding result;
[0143] The at least one product type is screened according to key words in the scenario question determined according to the semantic understanding result.
[0144] Optionally, it further comprises a determination module 64, which is used to determine the role type of the requester who provides the scenario question;
[0145] At least one product type related to the requester is determined according to the role type.
[0146] An embodiment of the present application also provides an electronic device. The electronic device is a master node electronic device in a computing unit. Figure 7 The electronic device includes a memory 701, a processor 702 and a communication component 703;
[0147] The memory 701 is used to store programs;
[0148] The processor 702 is coupled to the memory and is configured to execute the program stored in the memory to:
[0149] Performing data enhancement processing on the acquired first sample to obtain a second sample;
[0150] The model to be trained is trained by knowledge distillation using the second sample and the first model to obtain a second model with text classification capability; wherein the second model after knowledge distillation training learns intent understanding capability from the first model.
[0151] The processor 702 is used to expand the first sample size by using random processing;
[0152] Fine-tune the text matching model using the enlarged first sample;
[0153] A second sample including scenario questions and product types is constructed based on the historical work order data and the fine-tuned text matching model.
[0154] The processor 702 is configured to calculate a first loss function based on a second sample and the first model after fine-tuning; and calculate a second loss function based on a second sample and the second model;
[0155] The second model is trained based on the first loss function and the second loss function to obtain the second model with text classification capability.
[0156] Processor 702 is used to obtain historical work order data containing scenario problems;
[0157] Inputting the scenario problem and the first sample into the fine-tuned first model to obtain a matching relationship between the product type and the scenario problem;
[0158] Based on the matching relationship, a second sample including scenario questions and product types is constructed.
[0159] Optionally, the scenario answer includes: product type, multiple subtypes contained in the product type, and product functions.
[0160] The processor 702 is configured to select any sample from the second samples and input it into the first model and the second model;
[0161] comparing the first loss function and the second loss function;
[0162] Based on the comparison result of the first loss function and the second loss function and the cross entropy of the second model, the second model is iteratively trained to obtain the second model having a loss function similar to that of the first model.
[0163] The processor 702 is also used to obtain scene problems;
[0164] Inputting the scenario question into a trained second model with text classification capability; wherein the second model is trained by knowledge distillation using the second sample and the first model with intent understanding capability;
[0165] The scenario answers are displayed according to the preset sorting rules.
[0166] The processor 702 is further configured to determine at least one of text similarity, semantic similarity and click rate corresponding to each of the scenario answers if multiple scenario answers are obtained through recall;
[0167] The plurality of scenario answers are sorted according to at least one of the text similarity, the semantic similarity and the click rate.
[0168] The processor 702 is further configured to perform semantic understanding and intention understanding processing on the received scenario question;
[0169] Determine at least one product type corresponding to the scenario problem according to the intent understanding result;
[0170] The at least one product type is screened according to key words in the scenario question determined according to the semantic understanding result.
[0171] The processor 702 is further configured to determine a role type of a requester who provides the scenario question;
[0172] At least one product type related to the requester is determined according to the role type.
[0173] The memory 701 can be configured to store various other data to support operations on the electronic device. Examples of these data include instructions for any application or method for operating on the electronic device. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0174] Furthermore, the processor 702 in this embodiment may specifically be: a programmable switching processing chip, in which a data replication engine is configured to replicate received data.
[0175] When the processor 702 executes the program in the memory, in addition to the above functions, it can also realize other functions, which can be specifically referred to the description of the above embodiments. Figure 7 As shown, the electronic device also includes: a power supply component 704 and other components.
[0176] The present application also provides a non-transitory machine-readable storage medium, wherein the non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor executes Figure 1 or Figure 3 The method described in the corresponding embodiment.
[0177] Based on the above embodiment, in the process of model training, due to the limited number of currently available samples, the accuracy of the model obtained by training with a limited number of samples is poor. Therefore, it is necessary to perform data enhancement processing based on the existing first sample. After data enhancement processing, the second sample is obtained. Then, the second model is trained with knowledge distillation using the second sample and the first model with intent understanding capability, so as to obtain the second model with text classification capability. In the above manner, after the first model is trained with limited scene problem samples, the first model has intent understanding capability, so that the trained second model can accurately understand the true intent of the scene problem and accurately find the scene answer corresponding to the scene problem.
[0178] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0179] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0180] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0181] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A model training method, characterized in that: The method comprises: Performing data enhancement processing on the acquired first sample to obtain a second sample; The model to be trained is trained by knowledge distillation using the second sample and the first model to obtain a second model with text classification capability; wherein the second model after knowledge distillation training learns intent understanding capability from the first model.
2. The method according to claim 1, characterized in that The step of performing data enhancement processing on the acquired first sample to obtain a second sample includes: Using random processing to expand the first sample size; Fine-tune the text matching model using the enlarged first sample; A second sample including scenario questions and product types is constructed based on the historical work order data and the fine-tuned text matching model.
3. The method according to claim 2, characterized in that The method of performing knowledge distillation training on the to-be-trained model using the second sample and the first model to obtain a second model with text classification capability includes: Calculating a first loss function based on a second sample and the first model; and calculating a second loss function based on a second sample and the second model; The second model is trained based on the first loss function and the second loss function to obtain the second model with text classification capability.
4. The method according to claim 2, characterized in that: The second sample including scenario problems and product types is constructed based on the historical work order data and the fine-tuned first model, including: Get historical work order data containing scenario issues; Inputting the scenario problem and the first sample into the fine-tuned first model to obtain a matching relationship between the product type and the scenario problem; Based on the matching relationship, a second sample including scenario questions and product types is constructed.
5. The method according to any one of claims 2 to 4, characterized in that The scenario answer includes: product type, multiple subtypes contained in the product type, and product functions.
6. The method according to claim 3, characterized in that The step of training the second model based on the first loss function and the second loss function to obtain the second model having text classification capability includes: Select any sample from the second samples and input it into the first model and the second model; comparing the first loss function and the second loss function; Based on the comparison result of the first loss function and the second loss function and the cross entropy of the second model, the second model is iteratively trained to obtain the second model having a loss function similar to that of the first model.
7. An interactive method, characterized in that: The method comprises: Get the scenario question; Inputting the scenario question into the trained second model with text classification capability; wherein the second model is a model with intent understanding capability obtained by performing knowledge distillation training using the second sample and the first model; Display scenario answers according to preset sorting rules.
8. The method according to claim 7, characterized in that The scenario answers are displayed according to the preset sorting rules, including: If multiple scenario answers are obtained through recall, at least one of text similarity, semantic similarity and click rate corresponding to each scenario answer is determined; The plurality of scenario answers are sorted according to at least one of the text similarity, the semantic similarity and the click rate.
9. The method according to claim 7, characterized in that: After inputting the scenario problem into the trained second model with text classification capability, the method further includes: Perform semantic understanding and intent understanding processing on the received scenario questions; Determine at least one product type corresponding to the scenario problem according to the intent understanding result; The at least one product type is screened according to key words in the scenario question determined according to the semantic understanding result.
10. The method according to claim 7, characterized in that After obtaining the scenario questions, it also includes: Determine the role type of the requester who provides the scenario problem; At least one product type related to the requester is determined according to the role type.
11. A model training device, characterized in that: The device comprises: A data enhancement module, used to perform data enhancement processing on the acquired first sample to obtain a second sample; A training module is used to perform knowledge distillation training on the to-be-trained model using the second sample and the first model to obtain a second model with text classification capability; wherein the second model after knowledge distillation training learns intent understanding capability from the first model.
12. An electronic device comprising a memory and a processor; wherein: The memory is used to store programs; The processor, coupled to the memory, is used to execute the program stored in the memory, so as to implement the method of any one of claims 1 to 6, or to implement the method of any one of claims 7 to 10.
13. A non-transitory machine-readable storage medium having executable code stored thereon, which, when executed by a processor of an electronic device, enables the processor to execute the method as described in any one of claims 1 to 6, or to implement the method as described in any one of claims 7 to 10.