Model training method, device, equipment and storage medium

By filtering out the correlation between user input problems and reference problems, the language model is trained to match semantic-related reference problems, which solves the problem of non-essential descriptions affecting matching in user input problems, and improves the accuracy and fluency of matching.

CN113935464BActive Publication Date: 2025-04-29ECOVACS COMML ROBOTICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111183760.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-11
Publication Date
2025-04-29
Estimated Expiration
2041-10-11

AI Technical Summary

Technical Problem

The prior art is difficult to effectively match user input, especially when the user input problem is mixed with unnecessary descriptions, and it is difficult to find matching reference problems for word matching methods.

Method used

By obtaining multiple sets of semantic-related problem pairs, the first correlation between the user input problems and the second correlation between the reference problems are determined, and the problem pairs are filtered based on these correlations, and the filtered problem pairs are finally trained as training samples.

Benefits of technology

It realizes that even if the user input problem is doped with unnecessary descriptions, the language model can still accurately match the correct reference problem, improving the fluency and accuracy of human-computer dialogue.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113935464B_ABST
    Figure CN113935464B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a model training method, apparatus, device and storage medium, the method comprising: obtaining multiple groups of question pairs, wherein each group of question pairs includes user input questions and reference questions, and the user input questions and reference questions in each group of questions are semantically related; determining a first correlation between user input questions in different groups of question pairs, and determining a second correlation between reference questions in different groups of question pairs; filtering multiple groups of question pairs based on the first correlation and the second correlation; using the filtered question pairs as training samples to train a language model. The language model trained by the method provided by the embodiment of the present invention can better model the deep semantic relationship between the user input questions and the reference questions. Even if the user mixes unnecessary descriptions in the process of inputting questions, the language model can still match the correct reference questions according to the deep semantic relationship of the user input questions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine learning model technology, and in particular to a model training method, device, equipment and storage medium. Background Art

[0002] With the development of science and technology, more and more work that relies on manpower is handed over to machines. For example, the human-computer dialogue function can be used to allow the machine to automatically output answers based on the questions asked by the user. In related technologies, the word matching method is used to match semantically similar reference questions to the questions asked by the user in the question database, and then the answers corresponding to the reference questions are output to the user. The word matching method is relatively simple, but if the user uses a more complex description to explain the problem, it is difficult to find a reference question that matches the question asked by the user through the word matching method. Summary of the invention

[0003] The embodiments of the present invention provide a model training method, apparatus, device and storage medium, which are used to match the correct reference question to the question input by the user even if the user mixes unnecessary descriptions in the process of inputting the question.

[0004] In a first aspect, an embodiment of the present invention provides a model training method, the method comprising:

[0005] Acquire multiple sets of question pairs, wherein each set of question pairs includes a user input question and a reference question, and the user input question and the reference question in each set of questions are semantically related;

[0006] determining a first correlation between user input questions in different sets of question pairs, and determining a second correlation between reference questions in different sets of question pairs;

[0007] Based on the first relevance and the second relevance, filtering out the plurality of question pairs;

[0008] The filtered question pairs are used as training samples to train the language model.

[0009] In a second aspect, an embodiment of the present invention provides a model training device, comprising:

[0010] An acquisition module is used to acquire multiple groups of question pairs, wherein each group of question pairs includes a user input question and a reference question, and the user input question and the reference question in each group of questions are semantically related;

[0011] a determination module, configured to determine a first correlation between user input questions in different sets of question pairs, and to determine a second correlation between reference questions in different sets of question pairs;

[0012] A filtering module, configured to filter out the plurality of question pairs based on the first relevance and the second relevance;

[0013] The training module is used to train the language model by taking the question pairs that have been filtered out as training samples.

[0014] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores executable code, and when the executable code is executed by the processor, the processor can at least implement the model training method in the first aspect.

[0015] In a fourth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the model training method in the first aspect.

[0016] The language model trained by the method provided in the embodiment of the present invention can better model the deep semantic relationship between user input questions and reference questions. Since the word matching method is avoided to match reference questions for user input questions, even if the user mixes unnecessary descriptions in the process of inputting questions, the language model can still match the correct reference questions according to the deep semantic relationship of the user input questions. In order to further improve the performance of the language model, the randomly selected question pairs are also filtered in the embodiment of the present invention, so that there is no situation where the same reference question corresponds to multiple user input questions and there is no situation where different reference questions are semantically related. This can optimize the model training effect and enable the language model to more accurately match the user input questions to the correct reference questions. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0018] Figure 1 A schematic diagram of a flow chart of a question matching method provided by an embodiment of the present invention;

[0019] Figure 2 A schematic diagram of the structure of a language model provided by an embodiment of the present invention;

[0020] Figure 3 A schematic diagram of a flow chart of a model training method provided by an embodiment of the present invention;

[0021] Figure 4 A schematic diagram of the structure of a language model provided by an embodiment of the present invention;

[0022] Figure 5 A schematic diagram of the structure of a model training device provided by an embodiment of the present invention;

[0023] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two.

[0026] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0027] In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.

[0028] The embodiment of the present invention provides a model training method, the trained model can be called a language model, and the training method can be executed in an electronic device. The electronic device can include commercial service robots, sweeping robots, floor scrubbers, kitchen robots, smart speakers, smart phones, and other devices with voice recognition, control functions, and voice interaction.

[0029] In actual applications, when a user inputs a question, the question input by the user may not be edited according to standard rules, so it is necessary to first match the corresponding target reference question for the question input by the user in the question database, wherein a large number of reference questions pre-edited according to standard rules are stored in the question database. Each reference question in the question database is preset with corresponding reply information, so after determining the target reference question, the target reply information corresponding to the target reference question can be searched, and the target reply information can be returned to the user as the reply content of the question input by the user.

[0030] like Figure 1 As shown, the process of matching the corresponding target reference question for the question input by the user can be implemented as follows: the user inputs the question; the question input by the user is input into the language model, and the language model converts the question input by the user into a first semantic vector; all reference questions in the question database are converted into second semantic vectors in advance through the language model; the correlation between the first semantic vector and each second semantic vector is calculated; the sorting model determines the target semantic vector with the highest correlation with the first semantic vector in the second semantic vector; determines the target reference question corresponding to the target semantic vector; and outputs the target reference question.

[0031] It is understandable that when the performance of the language model is better, the semantic vector based on the output of the language model can more accurately match the questions input by the user to semantically related reference questions, thereby achieving the correct answer to the question and improving the fluency of the human-computer dialogue. Therefore, the embodiment of the present invention aims to provide a training method for improving the performance of the language model. The language model trained by the method provided by the embodiment of the present invention can accurately match semantically related reference questions to the questions input by the user.

[0032] The language model training process can be divided into two stages, including comparative training of random batch negative samples based on multi-tasks and comparative training of batch negative samples based on trained models.

[0033] The first training stage may include: generating multiple sets of second negative sample question pairs based on user input questions and non-reference questions in the question pairs; and training the language model using the above question pairs and the multiple sets of second negative sample question pairs as training samples.

[0034] Assume that the original data is a large number of question pairs consisting of user input questions and corresponding reference questions. In theory, the user input questions and reference questions in the question pairs should be semantically related, and semantic relevance means the same or similar semantics. Some question pairs can be randomly selected from the original data as positive samples, and in order to obtain negative samples, user input questions and reference questions that are not in the same question pair can be freely combined, so that multiple groups of second negative sample question pairs can be obtained. After obtaining positive and negative samples, the language model can be trained by combining positive and negative samples with the twin network using contrastive learning.

[0035] Among them, the twin network can shorten the distance between the semantically related first semantic vector and the second semantic vector, and increase the distance between the semantically unrelated first semantic vector and the second semantic vector. Two sub-models can be set in the twin network, including a first conversion sub-model and a second conversion sub-model, which are respectively used to convert user input questions and reference questions. That is, different types of questions are converted using different sub-models, so that the trained language model can be better applied to the application scenario of long and short sentence question answering.

[0036] By means of comparative learning, a reasonable loss function can be designed, so that the network parameters can be adjusted based on such a loss function. When the second semantic vectors are sorted according to the distance, the second semantic vectors that match the first semantic vector are ranked in the front, and the second semantic vectors that do not match the first semantic vector are ranked in the back. Ultimately, the long sentences of semantically related user input questions and the short sentences of reference questions can be well associated. For this reason, the method provided in the embodiment of the present invention is more suitable for the application scenario of long and short sentence question answering.

[0037] During the training process, the following training objectives can be set: to make the semantic vector distance between question pairs in the positive samples converted by the language model small, and to make the semantic vector distance between question pairs in the negative samples converted by the language model large. This training method can improve the training efficiency of the model, accelerate the convergence speed of the model, and improve the performance of the model.

[0038] In order to understand the process of training language models through contrastive learning, combined with Figure 2 The example shown here illustrates the process of training a language model. Figure 2As shown, the user input question is "After I mopped the floor last night, I placed the floor scrubber on the base to charge. When I woke up in the morning, I found that the base was leaking", and the corresponding reference question is "The base of the machine is leaking"; the user input question is "The vacuum cleaner in my home is new, but I haven't used it for several years. Why doesn't it work after charging it?", and the corresponding reference question is "The vacuum cleaner has no response after charging"; the user input question is "The floor scrubber I am using now will automatically restart. It will ask us to contact customer service or restart after a short time of turning it on", and the corresponding reference question is "What is the reason for the automatic restart after turning it on"; the user input question is "I bought this machine during the shopping festival last year. I want to ask you, how often should I change the roller brush", and the corresponding reference question is "How often should I change the roller brush". Figure 2 The solid lines in the figure are positive samples, and the dotted lines are negative samples. As mentioned above, during the training process, the distance between the semantic vectors corresponding to the positive samples can be reduced, and the distance between the semantic vectors corresponding to the negative samples can be increased.

[0039] It is understandable that the model training method provided by the embodiment of the present invention can be applied in a variety of fields, including the field of product after-sales. In the human-computer dialogue after the sale of goods, users often add some unnecessary descriptions to the questions they want to consult based on their personal emotions, which increases the difficulty of matching reference questions. However, the model training method provided by the embodiment of the present invention can avoid this problem.

[0040] It should be noted that in the first training stage, the language model can also be trained to complete the binary classification task, so that when a question pair is input to the language model, the language model can determine whether the user input question and the reference question in the question pair can match. It is understandable that the user input question and the reference question in the question pair in the original data that can be used as a positive sample are not necessarily truly matched. They may be mistakenly combined together and used as positive samples due to some error, which will greatly affect the accuracy of the language model conversion semantic vector. Therefore, by training the language model, it is possible to verify whether the question pair in the original data as a positive sample is truly matched.

[0041] It is understandable that due to the particularity of the conversation, the same reference question in the question database may correspond to multiple user input questions with similar semantics. If the same reference question corresponds to multiple user input questions in the positive sample, the training effect cannot be guaranteed. In addition, even if the two reference questions are not exactly the same in words, but the actual semantics contained are similar, the training effect of using such positive samples for training cannot be guaranteed. During the first training phase of the language model, since the positive samples are some question pairs randomly extracted from the original data, the above situation may inevitably occur and affect the training effect. In order to solve this problem, in the second training phase, a de-randomization method can be used to filter out the positive samples that affect the training effect, so as to further improve the performance of the language model.

[0042] like Figure 3 As shown, the training process of the second training stage may include:

[0043] 301. Obtain multiple sets of question pairs.

[0044] 302. Determine a first correlation between user input questions in different groups of question pairs, and determine a second correlation between reference questions in different groups of question pairs.

[0045] 303. Filter out multiple groups of question pairs based on the first relevance and the second relevance.

[0046] 304. Use the filtered question pairs as training samples to train the language model.

[0047] The above-mentioned multiple groups of question pairs can be question pairs randomly extracted from the original data. After extracting multiple groups of question pairs, the user input questions in all question pairs can be extracted, and then the first correlation between the user input questions can be calculated. The reference questions in all question pairs can also be extracted, and then the second correlation between the reference questions can be calculated.

[0048] Optionally, the above process of calculating the first correlation and the second correlation can be implemented as follows: inputting the user input questions in multiple question pairs into the first conversion sub-model in the language model before optimization training, respectively, to obtain the first semantic vectors corresponding to the user input questions in the multiple question pairs; based on the first semantic vectors, determining the first correlation between the user input questions in different question pairs; inputting the reference questions in multiple question pairs into the second conversion sub-model in the language model before optimization training, respectively, to obtain the second semantic vectors corresponding to the reference questions in the multiple question pairs; based on the second semantic vectors, determining the second correlation between the reference questions in different question pairs.

[0049] It should be noted that the above optimized language model before training is the model trained in the first training phase. Figure 4 As shown, the language model before optimization training includes three parts, the first part can be called the first conversion sub-model, the first conversion sub-model is used to convert the user input question into the first semantic vector, the second part can be called the second conversion sub-model, the second conversion sub-model is used to convert the reference question into the second semantic vector, and the third part can be called the confidence calculation model, the confidence calculation model is used to determine whether the user input question and the reference question in the question pair really match. It can be understood that the confidence calculation model can also be set as an independent model for use.

[0050] The user input question can be converted into a first semantic vector by a first conversion submodel, and the reference question can be converted into a second semantic vector by a second conversion model. Then, based on the first semantic vector, a first correlation between the user input questions in different groups of question pairs is determined, and based on the second semantic vector, a second correlation between the reference questions in different groups of question pairs is determined.

[0051] Optionally, the above process of determining the first correlation between user input questions in different groups of question pairs based on the first semantic vector, and determining the second correlation between reference questions in different groups of question pairs based on the second semantic vector can be implemented as: determining the first cosine distance between the first semantic vectors corresponding to every two user input questions in different groups of question pairs, as the first correlation between the corresponding two user input questions in different groups of question pairs; determining the second cosine distance between the second semantic vectors corresponding to every two reference questions in different groups of question pairs, as the second correlation between the corresponding two reference questions in different groups of question pairs.

[0052] After obtaining the first relevance and the second relevance, multiple question pairs can be filtered out based on the first relevance and the second relevance. Optionally, the filtering process can be implemented as follows: determining at least two user input questions in multiple question pairs whose first cosine distance is less than a first preset threshold; filtering the at least two user input questions to retain any one of the at least two user input questions; determining at least two reference questions in multiple question pairs whose second cosine distance is less than a second preset threshold; filtering the at least two reference questions to retain any one of the at least two reference questions; filtering out question pairs with a single question in multiple question pairs from which the user input questions and reference questions have been filtered out.

[0053] The first preset threshold may be expressed as question_threshold, and the second preset threshold may be expressed as answer_threshold. The first preset threshold and the second preset threshold may be adjusted according to actual needs.

[0054] In practical applications, assuming that the first cosine distance between multiple similar user input questions is less than the first preset threshold, similar user input questions can be randomly deleted, and only one user input question is retained. Similarly, assuming that the second cosine distance between multiple similar reference questions is less than the second preset threshold, similar reference questions can be randomly deleted, and only one reference question is retained. Since the user input question or the reference question in the question pair may be unilaterally deleted, leaving only the user input question or the reference question, question pairs with only a single question can be filtered out.

[0055] Optionally, after filtering out multiple groups of question pairs based on the first relevance and the second relevance, the method provided by the embodiment of the present invention may further include: inputting the filtered question pairs into a confidence calculation model respectively to obtain the confidence corresponding to each filtered question pair, the confidence being used to describe the probability of semantic relevance between the user input questions and the reference questions in the filtered question pairs; filtering out the filtered question pairs whose confidence is less than a third preset threshold.

[0056] As mentioned above, the language model consists of three parts, one of which is the confidence calculation model. The confidence calculation model can be used to determine whether the questions in the question pair are truly matched. Therefore, the question pairs that have been filtered out can be input into the confidence calculation model to obtain the confidence corresponding to each of the question pairs that have been filtered out, and the question pairs that have been filtered out with confidences less than the third preset threshold are filtered out. The third preset threshold can be expressed as qa_threshold.

[0057] Optionally, the filtered question pairs can also be sorted in order of confidence from high to low, and then a preset number of question pairs ranked first are selected as the final positive samples. The preset number can be expressed as mini_batch_size. In order to make the remaining number of randomly selected positive samples after filtering greater than or equal to mini_batch_size, the number of randomly selected positive samples can be appropriately increased. The number of randomly selected positive samples can be expressed as big_batch_size. In a possible implementation, big_batch_size can be set to 8 times mini_batch_size.

[0058] The above introduces the method of filtering out positive samples. After filtering out the positive samples, you can also: generate multiple groups of first negative sample question pairs based on user input questions and non-reference questions in different groups of question pairs that have been filtered out; use the filtered out question pairs and multiple groups of first negative sample question pairs as training samples to optimize the language model.

[0059] The user input questions and reference questions that are not in the same set of question pairs can be freely combined to obtain multiple sets of first negative sample question pairs. The filtered question pairs are then used as positive samples to optimize the language model together with the multiple sets of first negative sample question pairs.

[0060] Optionally, when updating the language model, the model parameters of the second conversion sub-model in the language model may be fixed, and only the model parameters of the first conversion sub-model may be updated, thereby avoiding operational difficulties caused by frequent updates of the second semantic vector.

[0061] After the language model is trained using the method provided by the embodiment of the present invention, the language model can be used in the process of dialogue question and answer. First, the user can tell the dialogue question and answer system the question to be answered that he wants to ask. The dialogue question and answer system receives the question to be answered and converts the question to be answered into the corresponding first semantic vector through the language model. It should be noted that all questions in the question database can also be converted into their corresponding second semantic vectors in advance through the language model. Then, in the process of retrieving the target question that matches the question to be answered, the target semantic vector whose distance from the first semantic vector meets the preset conditions can be screened in the second semantic vector. The question corresponding to the target semantic vector is the target question that matches the question to be answered. Finally, the target reply information corresponding to the target question can be queried and the target reply information can be output, thus completing a dialogue question and answer process.

[0062] It is worth noting that the above-mentioned dialogue question-answering process is more suitable for the application scenario of long and short sentences. Among them, the application scenario of long and short sentences refers to the situation that the question to be answered input by the user is a long sentence, which may be mixed with many descriptions, and the matching target question is a standard short sentence. Although the question to be answered is a long sentence and the target question is a short sentence, the main question the user wants to ask is actually the meaning expressed by the short sentence.

[0063] The language model trained by the method provided in the embodiment of the present invention can better model the deep semantic relationship between user input questions and reference questions. Since the word matching method is avoided to match reference questions for user input questions, even if the user mixes unnecessary descriptions in the process of inputting questions, the language model can still match the correct reference questions according to the deep semantic relationship of the user input questions. In order to further improve the performance of the language model, the randomly selected question pairs are also filtered in the embodiment of the present invention, so that there is no situation where the same reference question corresponds to multiple user input questions and there is no situation where different reference questions are semantically related. This can optimize the model training effect and enable the language model to more accurately match the user input questions to the correct reference questions.

[0064] For ease of understanding, the specific implementation of the knowledge extraction method provided above is exemplified in combination with the following product after-sales application scenario.

[0065] Assume that the original data includes question pairs: Q1-Q100, and randomly select 7 question pairs from the original data (the data volume in actual applications is larger than that in the example, and this is only a schematic illustration for the convenience of description). The 7 question pairs are assumed to be (user input question - reference question):

[0066] Q3: After I mopped the floor last night, I placed the mopping machine on the bottom bracket to charge. When I woke up in the morning, I found that the bottom bracket was leaking.

[0067] Q17: My vacuum cleaner is new, but I haven't used it for several years. Why doesn't it work after charging it? - The vacuum cleaner doesn't work after charging;

[0068] Q20: The floor mopping machine I am using now will automatically restart. It will ask us to contact customer service after a short while of starting up, or it will restart automatically after starting up. What is the reason?

[0069] Q31: I bought this machine during the shopping festival last year. I would like to ask you how often I should change the roller brush.

[0070] Q32: My vacuum cleaner has never been unpacked. Yesterday, when I tried to use it, I found that it was out of power. However, it did not respond when I tried to charge it, and I could not turn it on. The vacuum cleaner did not respond after charging.

[0071] Q43: What’s the matter with the machine not being able to connect to the phone? -The vacuum cleaner cannot be charged;

[0072] Q57: How much does it cost to replace the roller brush alone? The floor scrubber cannot connect to the Internet.

[0073] The above 7 question pairs can be used as positive samples, and the second negative sample question pairs can be generated based on the question pairs randomly extracted from the original data. For example, the user input question of Q3 and the reference question of Q17 are combined to obtain the following question pair: I put the floor cleaner on the base to charge after mopping the floor last night. When I woke up in the morning, I found that the base was leaking - the vacuum cleaner did not respond after charging. Obviously, the user input question of Q3 and the reference question of Q17 are semantically unrelated and do not match, so this set of question pairs can be used as the second negative sample question pair. Repeat the above operation until multiple sets of second negative sample question pairs are generated. After obtaining the question pairs randomly extracted from the original data and the second negative sample question pairs, the language model can be trained in the first training phase. After completing the training of the first training phase, the above question pairs randomly extracted from the original data can be de-randomized.

[0074] First, the user input questions in Q3, Q17, Q20, Q31, Q32, Q43, and Q57 can be input into the language model respectively, and the user input questions in Q3, Q17, Q20, Q31, Q32, Q43, and Q57 can be converted into first semantic vectors. Then, the first cosine distance between the first semantic vectors is calculated, and it is determined that the first cosine distance between the first semantic vectors corresponding to the user input questions in Q17 and Q32 is less than the first preset threshold, then a user input question is randomly retained in the user input questions in Q17 and Q32, such as retaining the user input question in Q17.

[0075] The reference questions in Q3, Q17, Q20, Q31, Q32, Q43, and Q57 may also be input into the language model respectively, and the reference questions in Q3, Q17, Q20, Q31, Q32, Q43, and Q57 may be converted into second semantic vectors. Then, the second cosine distance between the second semantic vectors is calculated, and if it is determined that the second cosine distance between the second semantic vectors corresponding to the reference questions in Q17 and Q43 is less than the second preset threshold, a reference question is randomly retained among the reference questions in Q17 and Q43, such as retaining the reference question in Q17.

[0076] The filtered problem pair becomes:

[0077] Q3: After I mopped the floor last night, I placed the mopping machine on the bottom bracket to charge. When I woke up in the morning, I found that the bottom bracket was leaking.

[0078] Q17: My vacuum cleaner is new, but I haven't used it for several years. Why doesn't it work after charging it? - The vacuum cleaner doesn't work after charging;

[0079] Q20: The floor mopping machine I am using now will automatically restart. It will ask us to contact customer service after a short while of starting up, or it will restart automatically after starting up. What is the reason?

[0080] Q31: I bought this machine during the shopping festival last year. I would like to ask you how often I should change the roller brush.

[0081] Q57: How much does it cost to replace the roller brush alone? The floor scrubber cannot connect to the Internet.

[0082] Q3, Q17, Q20, Q31, and Q57 may be input into the language model to calculate the confidence, and it is determined that the confidence of Q57 is lower than the third preset threshold, so Q57 is deleted. Then, the user input questions and non-reference questions in the remaining different question pairs may be combined to obtain multiple groups of first negative sample question pairs. The above language model is further optimized and trained by the positive samples composed of Q3, Q17, Q20, and Q31 and the multiple groups of first negative sample question pairs generated based on the positive samples to improve the performance of the language model.

[0083] The language model trained by the method provided in the embodiment of the present invention can better model the deep semantic relationship between user input questions and reference questions. Since the word matching method is avoided to match reference questions for user input questions, even if the user mixes unnecessary descriptions in the process of inputting questions, the language model can still match the correct reference questions according to the deep semantic relationship of the user input questions. In order to further improve the performance of the language model, the randomly selected question pairs are also filtered in the embodiment of the present invention, so that there is no situation where the same reference question corresponds to multiple user input questions and there is no situation where different reference questions are semantically related. This can optimize the model training effect and enable the language model to more accurately match the user input questions to the correct reference questions.

[0084] The model training device of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these model training devices can be configured using commercially available hardware components through the steps taught in this solution.

[0085] Figure 5 A schematic diagram of the structure of a model training device provided by an embodiment of the present invention is shown in FIG. Figure 5 As shown, the device comprises:

[0086] An acquisition module 51 is used to acquire multiple groups of question pairs, wherein each group of question pairs includes a user input question and a reference question, and the user input question and the reference question in each group of questions are semantically related;

[0087] A determination module 52, configured to determine a first correlation between user input questions in different sets of question pairs, and to determine a second correlation between reference questions in different sets of question pairs;

[0088] A filtering module 53, configured to filter out the plurality of question pairs based on the first relevance and the second relevance;

[0089] The training module 54 is used to train the language model by using the question pairs that have been filtered out as training samples.

[0090] Optionally, the training module 54 is further used to:

[0091] Generate multiple groups of first negative sample question pairs based on user input questions and non-reference questions in different groups of question pairs that have been filtered out;

[0092] The filtered question pairs and the multiple groups of first negative sample question pairs are used as training samples to train the language model.

[0093] Optionally, the training module 54 is further used to:

[0094] Based on the user input questions and non-reference questions in the unfiltered question pairs, multiple groups of second negative sample question pairs are generated;

[0095] Using the unfiltered question pairs and the multiple groups of second negative sample question pairs as training samples to train the language model;

[0096] The filtered question pairs and the multiple groups of first negative sample question pairs are used as training samples to perform optimization training on the language model.

[0097] Optionally, the determining module 52 is used to:

[0098] Inputting the user input questions in the plurality of question pairs into the first conversion sub-model in the language model before optimization training respectively, to obtain first semantic vectors corresponding to the user input questions in the plurality of question pairs;

[0099] Determining first correlations between user input questions in different groups of question pairs based on the first semantic vector;

[0100] Inputting the reference questions in the plurality of question pairs into the second conversion sub-model in the language model before optimization training respectively, to obtain second semantic vectors corresponding to the reference questions in the plurality of question pairs respectively;

[0101] Based on the second semantic vector, second correlations between reference questions in different groups of question pairs are determined.

[0102] Optionally, the determining module 52 is used to:

[0103] Determine a first cosine distance between first semantic vectors corresponding to each two user input questions in different groups of question pairs as a first correlation between the two user input questions corresponding to the different groups of question pairs;

[0104] A second cosine distance between second semantic vectors corresponding to each two reference questions in different groups of question pairs is determined as a second correlation between the two reference questions corresponding to the different groups of question pairs.

[0105] Optionally, the filtering module 53 is used to:

[0106] Determine at least two user input questions in the plurality of question pairs whose first cosine distance is less than a first preset threshold;

[0107] filtering the at least two user input questions to retain any one of the at least two user input questions;

[0108] Determine at least two reference questions among the plurality of question pairs whose second cosine distance is less than a second preset threshold;

[0109] filtering the at least two reference questions to retain any one of the at least two reference questions;

[0110] Question pairs that contain a single question are filtered out from multiple sets of question pairs that exclude user input questions and reference questions.

[0111] Optionally, the filtering module 53 is further used for:

[0112] Inputting the filtered question pairs into the confidence calculation model respectively to obtain the confidence corresponding to each of the filtered question pairs, wherein the confidence is used to describe the probability that the user input question and the reference question in the filtered question pairs are semantically related;

[0113] The filtered question pairs whose confidence is less than a third preset threshold are filtered out.

[0114] Figure 5 The device shown can perform the aforementioned Figures 1 to 4 The model training method provided in the illustrated embodiment, the detailed execution process and technical effects are described in the aforementioned embodiments and will not be repeated here.

[0115] In one possible design, the above Figure 5 The structure of the model training device shown can be implemented as an electronic device, such as Figure 6As shown, the electronic device may include: a processor 91 and a memory 92. The memory 92 stores executable code, and when the executable code is executed by the processor 91, the processor 91 can at least implement the above-mentioned Figures 1 to 4 The model training method provided in the illustrated embodiment.

[0116] Optionally, the electronic device may further include a communication interface 93 for communicating with other devices.

[0117] In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium, wherein an executable code is stored on the non-transitory machine-readable storage medium. When the executable code is executed by a processor of an electronic device, the processor can at least implement the above-mentioned Figures 1 to 4 The model training method provided in the illustrated embodiment.

[0118] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.

[0119] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0120] The model training method provided in the embodiment of the present invention can be executed by a certain program / software, which can be provided by the network side. The electronic device mentioned in the above embodiment can download the program / software to a local non-volatile storage medium, and when it needs to execute the above model training method, the program / software is read into the memory by the CPU, and then the CPU executes the program / software to implement the model training method provided in the above embodiment. The execution process can refer to the above Figures 1 to 4 Instructions in .

[0121] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention 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 invention.

Claims

1. A model training method, characterized in that: include: Acquire multiple sets of question pairs, wherein each set of question pairs includes a user input question and a reference question, and the user input question and the reference question in each set of questions are semantically related; determining a first correlation between user input questions in different sets of question pairs, and determining a second correlation between reference questions in different sets of question pairs; Based on the first relevance and the second relevance, filtering out at least two questions of the same type that are similar in the plurality of question pairs, so as to retain any one of the at least two questions; The filtered question pairs are used as training samples to train the language model; When the language model is updated during the training process, the model parameters of the second conversion sub-model in the language model are fixed, and only the model parameters of the first conversion sub-model in the language model are updated; the first conversion sub-model is used to convert the user input question for the first relevance determination, and the second conversion sub-model is used to convert the reference question for the second relevance determination.

2. The method according to claim 1, characterized in that: After filtering out the plurality of question pairs based on the first relevance and the second relevance, the method further includes: Generate multiple groups of first negative sample question pairs based on user input questions and non-reference questions in different groups of question pairs that have been filtered out; The step of using the filtered question pairs as training samples to train the language model includes: The filtered question pairs and the multiple groups of first negative sample question pairs are used as training samples to train the language model.

3. The method according to claim 2, characterized in that Before using the filtered question pairs and the plurality of groups of first negative sample question pairs as training samples to train the language model, the method further includes: Based on the user input questions and non-reference questions in the unfiltered question pairs, multiple groups of second negative sample question pairs are generated; Using the unfiltered question pairs and the multiple groups of second negative sample question pairs as training samples to train the language model; The step of using the filtered question pairs and the plurality of groups of first negative sample question pairs as training samples to train the language model includes: The filtered question pairs and the multiple groups of first negative sample question pairs are used as training samples to perform optimization training on the language model.

4. The method according to claim 3, characterized in that The determining of the first correlation between the user input questions in different groups of question pairs, and the determining of the second correlation between the reference questions in different groups of question pairs, comprises: Inputting the user input questions in the plurality of question pairs into the first conversion sub-model in the language model before optimization training respectively, to obtain first semantic vectors corresponding to the user input questions in the plurality of question pairs; Determining first correlations between user input questions in different groups of question pairs based on the first semantic vector; Inputting the reference questions in the plurality of question pairs into the second conversion sub-model in the language model before optimization training respectively, to obtain second semantic vectors corresponding to the reference questions in the plurality of question pairs respectively; Based on the second semantic vector, second correlations between reference questions in different groups of question pairs are determined.

5. The method according to claim 4, characterized in that The determining, based on the first semantic vector, a first correlation between user input questions in different groups of question pairs comprises: Determine a first cosine distance between first semantic vectors corresponding to each two user input questions in different groups of question pairs as a first correlation between the two user input questions corresponding to the different groups of question pairs; The determining, based on the second semantic vector, a second correlation between reference questions in different groups of question pairs comprises: A second cosine distance between second semantic vectors corresponding to each two reference questions in different groups of question pairs is determined as a second correlation between the two reference questions corresponding to the different groups of question pairs.

6. The method according to claim 5, characterized in that The filtering out at least two similar questions of the same type from the plurality of question pairs based on the first relevance and the second relevance to retain any one of the at least two questions includes: Determine at least two user input questions in the plurality of question pairs whose first cosine distance is less than a first preset threshold; filtering the at least two user input questions to retain any one of the at least two user input questions; Determine at least two reference questions among the plurality of question pairs whose second cosine distance is less than a second preset threshold; filtering the at least two reference questions to retain any one of the at least two reference questions; And, the method further comprises: Question pairs that contain a single question are filtered out from multiple sets of question pairs that exclude user input questions and reference questions.

7. The method according to claim 1, characterized in that After filtering out the plurality of question pairs based on the first relevance and the second relevance, the method further includes: Inputting the filtered question pairs into the confidence calculation model respectively to obtain the confidence corresponding to each of the filtered question pairs, wherein the confidence is used to describe the probability that the user input question and the reference question in the filtered question pairs are semantically related; The filtered question pairs whose confidence is less than a third preset threshold are filtered out.

8. A model training device, characterized in that: include: An acquisition module is used to acquire multiple groups of question pairs, wherein each group of question pairs includes a user input question and a reference question, and the user input question and the reference question in each group of questions are semantically related; a determination module, configured to determine a first correlation between user input questions in different sets of question pairs, and to determine a second correlation between reference questions in different sets of question pairs; A filtering module, configured to filter out at least two questions of the same type that are similar in the plurality of question pairs based on the first relevance and the second relevance, so as to retain any one of the at least two questions; A training module, used to train the language model by using the filtered question pairs as training samples; When the language model is updated during the training process, the model parameters of the second conversion sub-model in the language model are fixed, and only the model parameters of the first conversion sub-model in the language model are updated; the first conversion sub-model is used to convert the user input question for the first relevance determination, and the second conversion sub-model is used to convert the reference question for the second relevance determination.

9. An electronic device, characterized in that: include: A memory and a processor; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the model training method as described in any one of claims 1-7.

10. A non-transitory machine-readable storage medium, characterized in that: The non-temporary machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor executes the model training method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Question and answer matching method and system, server and storage medium

    CN110837586A

  • Intelligent question-answering question generation method and device, computer equipment and storage medium

    CN112966076A