Language model training method, question-answer pair generation method, device and equipment

By generating a training text sequence containing answers and questions, and using a supervised learning algorithm to train the language model, it solves the problem in the existing technology that the language model cannot predict answers that are not in the training text, realizes the function of generating questions based on the answers, and improves Language model suitability and accuracy.

CN113672708BActive Publication Date: 2024-10-08WUHAN TCL CORP RES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010400998.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-13
Publication Date
2024-10-08
Estimated Expiration
2040-05-13

AI Technical Summary

Technical Problem

Existing language model training methods cannot be applied to application scenarios of inferring questions based on real answers, because the target words are all derived from the training text, and answers that are not included in the training text cannot be predicted.

Method used

By obtaining the training text, a training text sequence containing answer text and question text is generated, a supervised learning algorithm is used to train the language model, and a target language model is generated, which can generate corresponding questions based on the text content and answers.

Benefits of technology

It realizes the question of predicting the answer based on the answer. The output question does not need to be included in the text content. It is suitable for the application scenario of predicting the answer based on the answer and improves the prediction accuracy of the language model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113672708B_ABST
    Figure CN113672708B_ABST
Patent Text Reader

Abstract

The present application is applicable to the field of information processing technology, and provides a language model training method, a question-answer pair generation method, an apparatus and a device. The language model training method includes obtaining a training text; generating multiple training text sequences based on the training text; wherein each training text sequence includes the training text, the answer text contained in the training text, and the question text corresponding to the answer text; using the training text and the answer text in each training text sequence as features, and using the question text in each training text sequence as a label, training the language model based on a supervised learning algorithm to obtain a trained target language model. The target language model obtained based on the language model training method is suitable for application scenarios in which questions corresponding to answers are obtained based on answer prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of information processing technology, and in particular, relates to a language model training method, a question-answer pair generation method, a device and equipment. Background Art

[0002] Natural Language Processing (NLP) is an important field in computer science and artificial intelligence. It can realize the interaction between people and computers through natural language. Language model training, as one of the core methods of natural language processing, is widely used in various NLP tasks such as intelligent question-answering tasks, classroom auxiliary teaching tasks or after-sales service tasks.

[0003] Language model training in current NLP tasks usually encodes words in the context of the training text, and then identifies the starting position and ending point of the target word from the training text based on the semantic information of the context to obtain the target word.

[0004] It can be seen that the target words in the above language model training method all come from the training text. Therefore, this language model training method is suitable for application scenarios where answers are predicted based on questions (contained in the training text), but cannot be used in application scenarios where questions are inferred based on real answers (not contained in the training text). Summary of the invention

[0005] In view of this, the embodiments of the present application provide a language model training method, apparatus and device to solve the problem that the language model obtained by training based on the prior art cannot meet the demand of predicting the answer corresponding to the question based on the answer.

[0006] In a first aspect, an embodiment of the present application provides a language model training method, comprising:

[0007] Get training text;

[0008] Generate multiple training text sequences according to the training text; wherein each training text sequence includes the training text, the answer text contained in the training text, and the question text corresponding to the answer text;

[0009] The training text and answer text in each training text sequence are used as features, the question text in each training text sequence is used as a label, and the language model is trained based on a supervised learning algorithm to obtain a trained target language model.

[0010] In a possible implementation of the first aspect, the training text and the answer text in each training text sequence are used as features, the question text in each training text sequence is used as a label, and a language model is trained based on a supervised learning algorithm to obtain a trained target language model, including:

[0011] For each training text sequence, the training text sequence is encoded according to a preset dictionary to generate a multidimensional vector corresponding to the training text sequence; wherein the multidimensional vector includes a first vector corresponding to the training text, a second vector corresponding to the answer text, and a third vector corresponding to the question text;

[0012] splicing the first vector of the multidimensional vector and the second vector of the multidimensional vector to generate a fourth vector of the multidimensional vector;

[0013] Using the fourth vector of the multidimensional vector as a feature and the third vector of the multidimensional vector as a label, generating a training vector corresponding to the multidimensional vector;

[0014] Taking multiple training vectors as input, the language model is trained based on a supervised learning algorithm to obtain a trained target language model.

[0015] In a possible implementation manner of the first aspect, multiple training vectors are used as input, and a language model is trained based on a supervised learning algorithm to obtain a trained target language model, including:

[0016] For each training vector, the label of the training vector is masked and replaced to generate a masked training vector;

[0017] The masked training vector is input into the language model for processing to obtain the probability distribution of the predicted value of the label of the training vector on the preset dictionary;

[0018] Determine the value of the cross entropy function based on the label and probability distribution of the training vector;

[0019] When the value of the cross entropy function does not meet the preset conditions, update the parameters of the language model, and return to execute the step of performing mask replacement on the label of the training vector for each training vector to generate a masked training vector until the value of the cross entropy function meets the preset conditions;

[0020] Save the model parameters of the current language model and generate a trained target language model.

[0021] In a second aspect, an embodiment of the present application provides a method for generating a question-answer pair, including:

[0022] Get the text information to be parsed;

[0023] Generate a candidate answer set according to the text information; the candidate answer set includes at least one candidate answer;

[0024] Input the text information and the candidate answer set into the target language model for processing, obtain the questions corresponding to each candidate answer in the candidate answer set, and generate a question set according to the questions corresponding to each candidate answer;

[0025] According to the text information and the question set, the predicted answer corresponding to each question in the question set is obtained;

[0026] For each question in the question set, the semantic similarity between the candidate answer corresponding to the question and the predicted answer corresponding to the question is compared, and a question-answer pair is generated based on the comparison result.

[0027] In a possible implementation of the second aspect, the text information and the candidate answer set are input into a target language model for processing to obtain a question corresponding to each candidate answer in the candidate answer set, including:

[0028] For each candidate answer in the candidate answer set, combine the text information and the candidate answer to generate a text sequence to be predicted;

[0029] Encode the text sequence to be predicted and generate the corresponding array vector to be predicted;

[0030] Input the array vector to be predicted into the target language model, and determine the prediction value corresponding to the array vector to be predicted;

[0031] If the predicted value does not match the preset end value, the array vector to be predicted and the predicted value are concatenated to generate a concatenated array vector; and the concatenated array vector is used as the array vector to be predicted, and the step of inputting the array vector to be predicted into the target language model and determining the predicted value corresponding to the array vector to be predicted is returned until the current predicted value matches the preset end value;

[0032] The current array vector to be predicted and the current predicted value are concatenated to generate a target array vector;

[0033] Decode the target array vector to generate the question corresponding to the candidate answer.

[0034] In a possible implementation of the second aspect, for each question in the question set, a semantic similarity comparison is performed between a candidate answer corresponding to the question and a predicted answer corresponding to the question, and a question-answer pair is generated according to the comparison result, including:

[0035] For each question in the question set, calculate the semantic similarity between the candidate answer corresponding to the question and the predicted answer corresponding to the question;

[0036] When the semantic similarity is less than the preset threshold, the question and the corresponding predicted answer are deleted;

[0037] When the semantic similarity is greater than or equal to a preset threshold, the question and the candidate answer corresponding to the question are combined to generate a question-answer pair.

[0038] In a possible implementation manner of the second aspect, generating a candidate answer set according to the text information includes:

[0039] Divide the text information into multiple natural sentences;

[0040] For each of the multiple natural sentences, extract entity words from the natural sentence and generate entity word vectors of the natural sentence;

[0041] A hierarchical candidate answer set is generated according to multiple natural sentences and entity word vectors of each natural sentence in the multiple natural sentences.

[0042] In a possible implementation manner of the second aspect, the question-answer pair generating method further includes:

[0043] For each candidate answer in the hierarchical candidate answer set, find out whether the candidate answer exists in multiple question-answer pairs;

[0044] If there are no candidate answers for multiple question-answer pairs, the candidate answers are deleted from the hierarchical candidate answer set;

[0045] If there are candidate answers for multiple question-answer pairs, the questions corresponding to the candidate answers are added to the corresponding positions of the candidate answers in the hierarchical candidate answer set to generate a hierarchical question-answer pair set.

[0046] In a third aspect, an embodiment of the present application provides a language model training device, comprising:

[0047] A first acquisition module is used to acquire training text;

[0048] A first generating module is used to generate a plurality of training text sequences according to the training text; wherein each training text sequence includes a training text, an answer text contained in the training text, and a question text corresponding to the answer text;

[0049] The training module is used to use the training text and answer text in each training text sequence as features, use the answer text in each training text sequence as a label, train the language model based on a supervised learning algorithm, and obtain a trained target language model.

[0050] In a fourth aspect, an embodiment of the present application provides a question-answer pair generating device, including:

[0051] The second acquisition module is used to acquire the text information to be parsed;

[0052] A comparison module, used to generate a candidate answer set according to the text information; the candidate answer set includes at least one candidate answer;

[0053] A processing module is used to input the text information and the candidate answer set into the target language model for processing, obtain the questions corresponding to each candidate answer in the candidate answer set, and generate a question set according to the questions corresponding to each candidate answer;

[0054] A prediction module, used for obtaining the predicted answer corresponding to each question in the question set according to the text information and the question set;

[0055] The comparison module is used to compare the semantic similarity between the candidate answers and the predicted answers of each question in the question set, and generate a target question-answer pair based on the comparison results.

[0056] In a fifth aspect, an embodiment of the present application provides a language model training device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of any one of the methods in the first aspect are implemented.

[0057] In a sixth aspect, an embodiment of the present application provides a question-answer pair generating device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of any one of the methods in the second aspect are implemented.

[0058] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of any one of the methods in the first aspect are implemented.

[0059] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of any one of the methods in the second aspect are implemented.

[0060] In a ninth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute any one of the methods in the first aspect.

[0061] In a tenth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute any one of the methods in the second aspect.

[0062] The language model training method provided in the embodiment of the present application trains the language model based on a supervised learning algorithm. The input of the supervised task is the text content and the answer contained in the text content, and the question corresponding to the answer is output. When using the target language model obtained based on the training method, only the text content and the answer contained in the text content need to be input, that is, the question that can generate the answer. The output question may not be contained in the text content, which is suitable for application scenarios where the question corresponding to the answer is obtained based on the answer prediction.

[0063] On the other hand, the training text may also be determined according to the application field of the target language model so that the prediction accuracy of the trained target language model is higher.

[0064] It can be understood that the beneficial effects of the third, fifth, seventh and ninth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.

[0065] The question-answer pair generation method provided in the embodiment of the present application directly obtains a candidate answer set based on the text information to be parsed. Each candidate answer in the candidate answer set is directly obtained based on the text information rather than being generated by prediction, so each candidate answer has clear semantics and does not have grammatical errors.

[0066] After obtaining the candidate answer set, the candidate answer set and text information are input into the target language model to obtain the question corresponding to each candidate answer in the candidate answer set and generate a question set; then the predicted answers corresponding to each question in the question set are predicted; finally, for each question in the question set, the semantic similarity between the candidate answer corresponding to the question and the predicted answer is compared, and the predicted answer is screened according to the comparison result, so that the retained predicted answer has a high semantic similarity with the corresponding candidate answer, that is, the retained predicted answer has clearer semantics and no grammatical errors.

[0067] Since the predicted answer is obtained by question prediction, when the predicted answer has clear semantics and no grammatical errors, it can be determined that the question corresponding to the predicted answer has clear semantics and no grammatical errors; therefore, the question-answer pair generated based on the question has clear semantics and no grammatical errors.

[0068] The question-answer pair generation method provided in the embodiment of the present application realizes the screening of predicted answers by comparing the semantic similarity between the corresponding candidate answers and the predicted answers, thereby realizing the screening of the questions obtained by reasoning, greatly reducing the problem of unclear semantics / grammatical errors in questions or answers in the question-answer pairs, and improving the quality of the question-answer pairs.

[0069] It can be understood that the beneficial effects of the fourth, sixth, eighth and tenth aspects mentioned above can be found in the relevant description of the second aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0071] Figure 1 It is a flowchart of a language model training method provided in one embodiment of the present application;

[0072] Figure 2 is a schematic diagram of a process for generating a target language model provided by an embodiment of the present application;

[0073] Figure 3 It is a flowchart of a method for generating question-answer pairs provided in an embodiment of the present application;

[0074] Figure 4 This is a flowchart of obtaining questions corresponding to candidate answers provided by an embodiment of the present application;

[0075] Figure 5 is a schematic diagram of a process for generating a hierarchical candidate answer set provided by an embodiment of the present application;

[0076] Figure 6 It is a schematic diagram of a process for generating a hierarchical question-answer pair set provided by an embodiment of the present application;

[0077] Figure 7 is a structural diagram of a language model training device provided in one embodiment of the present application;

[0078] Figure 8 is a structural diagram of a question-answer pair generating device provided in an embodiment of the present application;

[0079] Fig. 9 It is a schematic diagram of the hardware composition of a language model training device provided in one embodiment of the present application.

[0080] Fig.10 It is a schematic diagram of the hardware composition of a question-answer pair generating device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0081] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0082] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0083] The following is an illustrative example of the technical solution of the present application and how the technical solution of the present application solves the above technical problems. It is worth noting that the specific embodiments listed below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0084] Figure 1 This is a flow chart of a language model training method provided in one embodiment of the present application. The execution subject of this embodiment is a language model training device; the language model training device includes but is not limited to mobile terminals such as smart phones, tablet computers, wearable devices, etc., and can also be desktop computers, robots, servers, etc. Figure 1 The language model training method shown may include:

[0085] S11. Obtain training text.

[0086] In this embodiment, the training text may refer to a large-scale text sequence library that has been scientifically sampled and processed. Specifically, the training text may be obtained according to the application field of the language model training.

[0087] For example, if the language model training device is used in machine teaching to automatically generate questions and answers for reading comprehension questions, it is possible to collect relevant information in the fields of professional terms, keywords, and course questions of object-oriented courses in advance through course material collation and expert consultation, and use this information as the basis for retrieval to obtain training texts to improve the pertinence of the training texts.

[0088] The training text may include a plurality of article texts, each of which may include one or more sentences. For example, the training text may be all articles in a junior high school Chinese textbook.

[0089] It should be understood that, in one implementation, multiple article texts may be obtained, and each article text may serve as a training text.

[0090] S12. Generate multiple training text sequences according to the training text.

[0091] In this embodiment, each training text sequence includes a training text, an answer text contained in the training text, and a question text corresponding to the answer text.

[0092] The answer text and the question text corresponding to the answer are obtained by pre-analyzing the training text.

[0093] In one implementation, the training text may include a large number of article texts, each of which includes one or more sentences.

[0094] Before training the model, for each article text, multiple questions are extracted based on the article text to generate multiple question texts, wherein the real answers corresponding to all the above question texts can be found in the article text. Then each question and the answer corresponding to each question constitute a certain question-answer pair.

[0095] Exemplarily, multiple determined question-answer pairs in a known article text may be obtained by crawling with a crawler, for example, by crawling Baidu Q&A.

[0096] Optionally, the multiple questions extracted based on the article text may not be included in the article text. For example, general questions in the application field of the language training device are set, and it is only necessary to ensure that the true answers to the general questions can be obtained in the article text.

[0097] For example, if the language training device is used for classroom auxiliary teaching, the common questions may be "What is the main idea of ​​this article?" "Who is the protagonist of this article?" and so on.

[0098] After obtaining multiple determined question-answer pairs in the article text, for each question-answer pair, the article text, the answer text in the question-answer pair, and the question text of the question-answer pair are combined to generate a training text sequence. For example, the article text, the answer text, and the question text may be combined in the order, and an identifier may be added between the article text, the answer text, and the question text.

[0099] Optionally, you can use the following format: article text-answer text-question text <bos>Article text<answer_text> Answer text<question_text> Question text <eos>Combine to generate training text sequence Z.

[0100] in, <bos>,<answer_text> ,<question_text> as well as <eos>These are all preset identifiers. <bos>Indicates the beginning of a sentence. <eos>Indicates the end of a sentence.<answer_text> Mark the answer text,<question_text> Represents the question text.

[0101] For example, the article text is "Back Figure" by Zhu Ziqing, and the multiple question-answer pairs extracted based on "Back Figure" can be question 1 "What do I do when my father and I go home?", answer 1 "To attend my grandmother's funeral"; question 2 "Why did my father decide to see me off himself?", answer 2 "I was worried that the waiter would not be polite"; question 3 "What did my father buy for me?", answer 3 "Oranges".

[0102] Then, for each question-answer pair, the article text-answer text-question text is combined to generate a training text sequence. The three training text sequences are:

[0103] Training text sequence Z1: <bos>"Back"<answer_text> Funeral for grandmother<question_text> What do I do when my father and I go home? <eos>;

[0104] Training text sequence Z2: <bos>"Back"<answer_text> Worried about the inappropriate teahouse<question_text> Why did my father decide to send me off himself? <eos>;

[0105] Training text sequence Z3: <bos>"Back"<answer_text> tangerine<question_text> What is my father going to buy for me? <eos>;

[0106] It should be understood that the "back figure" in the training text sequence specifically refers to the text content in the article text "Back Figure".

[0107] In another embodiment, the training text may be a complete article text, and each training text sequence includes a training text, an answer text, and a question text corresponding to the answer text.

[0108] S13. Taking the training text and the answer text in each training text sequence as features, taking the question text in each training text sequence as a label, training the language model based on a supervised learning algorithm, and obtaining a trained target language model.

[0109] In this embodiment, the language model is trained based on a supervised learning algorithm, wherein the training samples in the supervised learning algorithm need to include input and output, that is, features and labels.

[0110] In this embodiment, the training text and the answer text in each training text sequence are used as features, and the question text in each training text sequence is used as a label.

[0111] Exemplarily, the process of determining the label and features of each training text sequence may include:

[0112] Step A1: For each training text sequence, encode the training text sequence according to a preset dictionary to generate a multidimensional vector corresponding to the training text sequence; wherein the multidimensional vector includes a first vector corresponding to the training text, a second vector corresponding to the answer text, and a third vector corresponding to the question text.

[0113] In this step, the preset dictionary is used to encode the training text sequence. Optionally, the preset dictionary may include all words in the standard modern Chinese corpus, domain keywords and professional terms of object-oriented courses; the preset dictionary may also include the respective values ​​of all the above words. It should be understood that the values ​​corresponding to each word in the preset dictionary are generally different.

[0114] Optionally, the update frequency of the preset dictionary can be set to regularly add domain keywords and professional terms of object-oriented courses to the preset dictionary.

[0115] It should be understood that the preset dictionary also includes preset identifiers, such as <bos>,<answer_text> ,<question_text> as well as <eos>The corresponding values.

[0116] In this step, encoding the training text sequence according to the preset dictionary may mean mapping each word in the training text sequence to a corresponding numerical value in the preset dictionary for each training text sequence to obtain a multidimensional vector corresponding to the training text sequence.

[0117] Each multidimensional vector may include a first vector corresponding to the training text, a second vector corresponding to the answer text, and a third vector corresponding to the question text.

[0118] It can be understood that the encoded multidimensional vector represents all the semantic information of the training text sequence, wherein the second vector represents all the semantic information of the answer text in the training text sequence, and the third vector represents all the semantic information of the question text in the training text sequence. When vectors are used to represent semantic information, when the distance between two vectors in space is very close, the semantic content of the texts they correspond to is also similar.

[0119] Step A2: concatenate the first vector of the multidimensional vector and the second vector of the multidimensional vector to generate a fourth vector of the multidimensional vector.

[0120] Step A3: Use the fourth vector of the multidimensional vector as a feature and the third vector of the multidimensional vector as a label to generate a training vector corresponding to the multidimensional vector.

[0121] In this embodiment, after obtaining a plurality of training vectors, the plurality of training vectors are used as input, and a language model is trained based on a supervised learning algorithm to obtain a trained target language model.

[0122] For example, multiple training vectors can be used as input language models to calculate the value of the loss function, and the parameters of the language model can be adjusted according to the value of the loss function; when the value of the loss function reaches a preset condition, such as being lower than a first preset threshold, the model iteration is completed, and the parameters of the current language model are saved to obtain a trained target language model. The first preset threshold is a threshold value preset by the user.

[0123] The value of the loss function is determined according to the difference between the predicted value obtained by the language model and the third vector value in the training array.

[0124] The language model training method provided in the embodiment of the present application trains the language model based on a supervised learning algorithm. The input of the supervised task is the text content and the answer contained in the text content, and the question corresponding to the answer is output. When using the target language model obtained based on the training method, only the text content and the answer contained in the text content need to be input, that is, the question that can generate the answer. The output question may not be contained in the text content, which is suitable for application scenarios where the question corresponding to the answer is obtained based on the answer prediction.

[0125] On the other hand, the training text may also be determined according to the application field of the target language model so that the prediction accuracy of the trained target language model is higher.

[0126] Figure 2 FIG. 1 is a flow chart of generating a target language model according to an embodiment of the present application. Figure 1 In step 13 of the embodiment, after obtaining multiple training vectors, a feasible implementation method of generating a target language model is as follows. Figure 2 As shown, multiple training vectors are used as input, and the language model is trained based on a supervised learning algorithm to obtain a trained target language model, including:

[0127] S131 . For each training vector, perform mask replacement on the label of the training vector to generate a masked training vector.

[0128] The composition structure of each training vector is the same, including a first vector corresponding to the training text, a second vector corresponding to the answer text, and a third vector corresponding to the question text, and the combination is first vector + second vector + third vector.

[0129] Among them, the label of the training vector is the third vector corresponding to the question text.

[0130] In some implementations, the training text sequence Z is in the following format: <bos>Article text<answer_text> Answer text<question_text> Question text <eos>The starting value of the third vector of the training vector obtained by encoding the training text sequence is<question_text> The corresponding value x, the end value is <eos>Therefore, the labels of the training vectors are masked and replaced, specifically, the values ​​between x and y in the training array are masked and replaced to obtain the masked training vector Y.

[0131] S132: Input the masked training vector into the language model for processing to obtain the probability distribution of the predicted value of the label of the training vector on the preset dictionary.

[0132] A language model is usually constructed as a probability distribution over a word sequence. For a given sequence of length m, it can generate a probability P(w_1,w_2,…,w_m) for the entire sequence, which is used to characterize the probability of each word appearing in the sequence.

[0133] In this embodiment, the preset dictionary and Figure 1 The preset dictionaries in the embodiments are the same.

[0134] Exemplarily, the masked training array may be Y, and Y is used as input, and after forward propagation of the language model, the probability distribution of the next word on the preset dictionary is predicted, that is, the probability that the next word is each word in the preset dictionary.

[0135] S133. Determine the value of the cross entropy function according to the label and probability distribution of the training vector.

[0136] In this embodiment, the loss function of the language model may be a cross entropy function, and the value of the cross entropy function is the value of the loss function.

[0137] In this embodiment, the first array vector corresponding to the article text and the second array vector corresponding to the answer text in each training vector are used as features (input), and the array vector corresponding to the question text in each training vector is used as a label (output). Since the input data and output have been determined, it can be known that the actual probability distribution has been determined.

[0138] The value of the cross entropy function can be determined according to the difference between the true probability distribution and the predicted probability distribution, so as to update the parameters of the language model according to the value of the cross entropy function.

[0139] It should be understood that the smaller the value of the cross entropy function, the better the prediction result.

[0140] S134. When the value of the cross entropy function does not meet the preset conditions, update the parameters of the language model, and return to execute the step of performing mask replacement on the label of the training vector for each training vector to generate a masked training vector until the value of the cross entropy function reaches the preset conditions.

[0141] Among them, the preset condition can be one of the following: the value of the cross entropy function is less than or equal to a second preset threshold value, or the difference between two adjacent cross entropy function values ​​is less than a third preset threshold value.

[0142] In this embodiment, the parameters of the language model may be updated according to the Adam optimizer.

[0143] S135. Save the model parameters of the current language model and generate a trained target language model.

[0144] When the cross entropy function value reaches the preset condition, the model parameters of the current language model are saved and the target language model is generated.

[0145] The target language model can be widely used in intelligent question-answering tasks, classroom auxiliary teaching tasks or after-sales service tasks. For example, in classroom auxiliary teaching tasks, the target language model can be used to automatically generate question-answer pairs for the target reading text, so that the machine can become a teacher and interact with students by asking questions, or automatically generate reading comprehension questions.

[0146] Then, the question in the target language model is obtained by reasoning, and the question-answer pairs generated based on the question inevitably have unclear semantics or grammatical errors, which cannot well support classroom auxiliary teaching tasks.

[0147] Based on this, an embodiment of the present application also provides a question-answer pair generation method to solve the above technical problems, which is exemplified below with a specific embodiment.

[0148] Figure 3 This is a flow chart of a question-answer pair generation method provided in an embodiment of the present application. The execution subject of this embodiment is a question-answer pair generation device; the question-answer pair generation device includes but is not limited to mobile terminals such as smart phones, tablet computers, wearable devices, and can also be desktop computers, robots, servers, etc. Figure 3 The question-answer pair generation method shown may include:

[0149] S21. Obtain text information to be parsed.

[0150] In this embodiment, the text information can be text content input by the user, or text content extracted from any multimedia form containing text content such as documents, web pages, text pictures, etc., or text content obtained by recognizing the voice input by the user, which is not limited here. For example, the text information can be an article used for reading comprehension teaching and learning.

[0151] The text content includes a large number of text sequences, wherein a text sequence is a string of more than one characters in sequence, and each text sequence may include one or more sentences.

[0152] Exemplarily, obtaining text information to be parsed may refer to collecting web page information from the Internet through an information analysis script; preprocessing the web page information by removing navigation bars, removing advertising noise data, etc. to obtain initial text information, and then extracting a text sequence from the initial text information to obtain the text information to be parsed.

[0153] S22. Generate a candidate answer set according to the text information, where the candidate answer set includes at least one candidate answer.

[0154] In natural language, questions are asked in the form of 5W2H, where 5W refers to "What", "Where", "When", "Who" and "Why", and 2H refers to "How" and "How much". The answer to any one or more of the 5W2H questions can constitute a candidate answer.

[0155] In this embodiment, any semantic text containing one or more description information in the text information can constitute a candidate answer; wherein the description information can be event description information, state description information or entity description information, etc., which is not limited here.

[0156] In one implementation, the text information may be divided into a plurality of natural sentences, and then each natural sentence is used as a candidate answer.

[0157] Among them, sentences or paragraphs of text information are generally separated by delimiters, and the text information can be divided into multiple natural sentences by identifying the delimiters in the text information.

[0158] For example, the text information may be an article Pa for reading comprehension teaching and learning. The text is divided into a plurality of natural sentences S to obtain:

[0159] Pa={S1,S2,S3……}

[0160] Among them, Pa is text information, Si represents the i-th natural sentence in the text information, and i is a positive integer.

[0161] In another embodiment, the professional terminology and course questions of the object-oriented course can be collected in advance through course material organization and expert consultation, and search keywords can be determined based on the field information. A search is performed in the text information based on the search keywords to generate a candidate answer set.

[0162] It should be understood that multiple candidate answer sets for multiple search keywords may be obtained by performing multiple searches, and the candidate answer sets for the multiple search keywords may be combined to generate a candidate answer set for the text information.

[0163] Each candidate answer in the candidate answer set obtained in this step is directly obtained based on text information rather than being generated by prediction, so each candidate answer has clear semantics and does not have grammatical errors.

[0164] S23. Input the text information and the candidate answer set into the target language model for processing to obtain the questions corresponding to each candidate answer in the candidate answer set; and generate a question set according to the questions corresponding to each candidate answer.

[0165] The target language model in this embodiment is Figure 1 or Figure 2 The trained target language model obtained in the embodiment. The input of the target language model is text information and candidate answers, and the output is a question, and the question is related to the candidate answers.

[0166] In this embodiment, for each candidate answer in the candidate answer set, the text information and the candidate answer can be combined to generate a text sequence to be predicted, and then the text sequence to be predicted is encoded according to a preset dictionary to generate a corresponding array vector to be predicted; the array vector to be predicted is input into a pre-trained language model to obtain the question corresponding to the candidate answer.

[0167] The preset dictionary is used to encode and decode the text sequence. Figure 1 Optionally, you can set the update frequency of the preset dictionary and regularly add domain keywords and professional terms of object-oriented courses to the preset dictionary.

[0168] After obtaining the question corresponding to each candidate answer, all questions are combined to generate a question set.

[0169] S24. Obtain predicted answers corresponding to each question in the question set based on the text information and the question set.

[0170] The purpose of this step is to predict the answers corresponding to each question in the question set based on the text information and the question set. For example, the prediction can be based on language models such as BERT, XLNET, GPT transformer-xl in natural language processing, and no specific limitation is made here.

[0171] In some embodiments, the predicted answer corresponding to each question can be obtained based on the BERT language model, where the BERT language model is a pre-trained deep bidirectional Transformer language model.

[0172] Exemplarily, the process of obtaining the predicted answer corresponding to each question based on the BERT language model may include:

[0173] Step B1: Convert the text information and each question in the question set into a word vector sequence that can be recognized by the BERT language model. For example, the text information can be processed by word embedding to obtain a first word vector sequence of the text information, and each question in the question set can be processed by word embedding to obtain a second word vector sequence corresponding to each question.

[0174] Step B2: concatenate the first word vector sequence with each second word vector sequence to obtain a third vector sequence that corresponds one-to-one to the multiple second word vector sequences.

[0175] Step B3: For each third vector sequence, the third vector sequence is input into the BERT language model to obtain a prediction answer corresponding to the third vector sequence.

[0176] S25. For each question in the question set, compare the semantic similarity between the candidate answer corresponding to the question and the predicted answer corresponding to the question, and generate a question-answer pair based on the comparison result.

[0177] The purpose of this step is to filter the predicted answers based on the semantic similarity between the corresponding candidate answers and the predicted answers.

[0178] Since each candidate answer in the candidate answer set is directly obtained based on text information rather than predicted, each candidate answer has clear semantics and no grammatical errors. If the semantic similarity between the candidate answer corresponding to the question and the predicted answer corresponding to the question is high, it means that the semantics of the predicted answer is relatively accurate and clear, and there are no inaccurate grammatical errors.

[0179] Comparing the semantic similarity between the candidate answer corresponding to the question and the predicted answer corresponding to the question may refer to calculating the semantic similarity between the candidate answer corresponding to the question and the predicted answer corresponding to the question.

[0180] For example, the candidate answers and predicted answers can be converted into word vectors respectively, and the semantic similarity between the candidate answers and the predicted answers can be represented according to the distance between the word vectors in space.

[0181] Among them, generating a question-answer pair based on the comparison result may mean: when the semantic similarity is less than a set preset threshold, deleting the question and the predicted answer corresponding to the question; when the semantic similarity is greater than or equal to the first preset threshold, combining the question and the candidate answer corresponding to the question to generate a question-answer pair.

[0182] The preset threshold value may be a fourth preset threshold value, and the fourth preset threshold value is a threshold value preset by a user.

[0183] When the semantic similarity is less than the fourth preset threshold, it means that the predicted answer has unclear semantics or grammatical errors. Since the predicted answer is obtained by question prediction, when the predicted answer has unclear semantics or grammatical errors, the question corresponding to the predicted answer may also have the above situation. Based on the quality of the question and answer pair generated by this question, the question and the corresponding predicted answer are deleted.

[0184] When the semantic similarity is greater than or equal to the fourth preset threshold, it indicates that the semantics of the predicted answer are relatively clear and there are no grammatical errors, and it can be determined that the semantics of the question corresponding to the predicted answer are relatively clear and there are no grammatical errors. At this time, the question and the candidate answer corresponding to the question are combined to generate a question-answer pair, ensuring that the question-answer pair has a high quality.

[0185] The question-answer pair generation method provided in the embodiment of the present application realizes the screening of predicted answers by comparing the semantic similarity between the corresponding candidate answers and the predicted answers, thereby realizing the screening of the questions obtained by reasoning, greatly reducing the problem of unclear semantics / grammatical errors in questions or answers in the question-answer pairs, and improving the quality of the question-answer pairs.

[0186] Figure 4 is a flowchart of obtaining questions corresponding to candidate answers provided by an embodiment of the present application, which describes Figure 3 A possible implementation method of obtaining the questions corresponding to each candidate answer in the candidate answer set in step 23 of the embodiment. Figure 4 As shown, the text information and the candidate answer set are input into the target language model for processing to obtain the questions corresponding to each candidate answer in the candidate answer set, including:

[0187] S231. For each candidate answer in the candidate answer set, combine the text information and the candidate answer to generate a text sequence to be predicted.

[0188] In this embodiment, the article information and candidate answers can be in the following form: <bos>Text information<answer_text> Candidate Answers <eos>Combine them to generate the text sequence A to be predicted.

[0189] in, <bos>,<answer_text> ,as well as <eos>They are all preset tag symbols. Each tag symbol can be regarded as a word, and the value corresponding to each tag symbol can also be obtained by looking up in the preset dictionary.

[0190] S232. Encode the text sequence to be predicted to generate a corresponding array vector to be predicted.

[0191] In this embodiment, the text sequence to be predicted may be encoded according to a preset dictionary;

[0192] Among them, the preset dictionary and Figure 3 The preset dictionary in the embodiment is the same, including all words in the training text and the numerical values ​​corresponding to each word. Among them, the numerical values ​​corresponding to each word are not equal to each other. It should be understood that the preset dictionary includes all words in the text information.

[0193] The preset dictionary also includes preset tag symbols, such as <bos>,<answer_text> ,<question_text> as well as <eos>The corresponding values.

[0194] In this embodiment, encoding the text sequence to be predicted according to the preset dictionary may specifically refer to mapping each word in the text sequence to be predicted A to a corresponding numerical value in the preset dictionary to obtain a prediction array vector B corresponding to the text sequence to be predicted.

[0195] Each array to be predicted may include a fourth array vector corresponding to the text information and a fifth array vector corresponding to the candidate answer.

[0196] S233 , input the array vector to be predicted into the target language model, and determine the prediction value corresponding to the array vector to be predicted.

[0197] In this embodiment, the array vector to be predicted is input into the target language model. The above-mentioned text sequence A to be predicted is taken as input. After the forward propagation process of the model, the probability distribution of the next word in the preset dictionary is obtained, and the value in the preset dictionary corresponding to the maximum probability value is selected as the predicted value y.

[0198] S234. If the predicted value does not match the preset end value, the array vector to be predicted is concatenated with the predicted value to generate a concatenated array vector; and the concatenated array vector is used as the array vector to be predicted, and the process returns to step S233 until the current predicted value matches the preset end value.

[0199] In this embodiment, the preset termination value refers to the termination label symbol in the text sequence to be predicted. <eos>The corresponding value in the preset dictionary.

[0200] After obtaining the predicted value C, it is determined whether the predicted value y matches the preset end value, wherein the match may specifically refer to that the predicted value C is the same as the preset end value.

[0201] If the predicted value C is the same as the preset end value, it means that the final prediction result is obtained.

[0202] If the predicted value C is different from the preset end value, C and B are concatenated to obtain the concatenated result B1, and the concatenated result B1 is used as the new input value. After forward propagation of the prediction model, the next predicted value C1 is obtained. The above process is then repeated until the current predicted value matches the preset end value.

[0203] S235. Concatenate the current array vector to be predicted and the current predicted value to generate a target array vector.

[0204] Among them, the current prediction value is the prediction value C obtained after N iterations. N , then the current array vector to be predicted is B+C1+C2+…+C N-1 , the target array vector is B+C1+C2+…+C N-1 +C N

[0205] Wherein, N is an integer greater than or equal to 2, and "+" represents concatenation of arrays.

[0206] S236. Decode the target array vector according to a preset dictionary to generate questions corresponding to the candidate answers.

[0207] In this embodiment, decoding the target array vector according to a preset dictionary may specifically refer to mapping each numerical value in the target array vector to a corresponding word in the preset dictionary to obtain an answer corresponding to the target array vector.

[0208] In this embodiment, after each prediction value is generated, the prediction value is added. After each new word is generated, the word is added after the previously generated text sequence to be predicted to form a new text sequence to be predicted. The new text sequence with prediction will become the new input of the language model in the next step, forming an autoregressive mechanism, which can greatly improve the accuracy of the prediction.

[0209] In the application field of machine reading comprehension or machine teaching, question-answer pair generation equipment can be used to automatically generate questions and answers for reading comprehension questions, which can be used to simulate the interaction between teachers and students to assist teaching. Questions in teaching generally include specific questions and abstract questions. Abstract questions can generally be answered through sentences, and specific questions generally need to be broken down into specific elements in a sentence, such as characters, time, actions, etc. In actual teaching, teachers generally ask an abstract question first, and then ask specific questions based on the answer to the abstract question. Therefore, in order to conform to the question-answering habits in reading comprehension teaching, a hierarchical candidate answer set can be set, and a hierarchical question-answer pair set can be obtained based on the hierarchical candidate answer set. The following is through Figure 5 and Figure 6 The embodiments are described exemplarily respectively.

[0210] Figure 5 is a schematic diagram of a process for generating a candidate answer set provided by an embodiment of the present application, which describes Figure 3 In step 22 of the embodiment, a possible implementation method is to generate a candidate answer set based on text information. Figure 5 As shown, generating a candidate answer set based on text information includes:

[0211] S221. Divide the text information into multiple natural sentences.

[0212] In natural language processing, sentences or paragraphs in text information are generally separated by delimiters, and the text information can be divided into multiple natural sentences by identifying the delimiters in the text information.

[0213] S222. For each natural sentence in the multiple natural sentences, extract entity words from the natural sentence and generate an entity word vector for the natural sentence.

[0214] Among them, entity words include nouns, pronouns and noun phrases.

[0215] The entity words in each natural sentence can be identified based on the part-of-speech tagging method in natural language processing, and then the identified entity words are combined in sequence to generate entity word vectors.

[0216] For example, if the natural sentence S is "Xiao Ming did three hours of math homework at home today", after part-of-speech tagging and entity word extraction for the natural sentence S, the entity word vector obtained is {Xiao Ming, today, three hours, math homework}.

[0217] Part-of-speech tagging in natural language processing refers to the process of determining the grammatical category of each word in a given sentence, determining the part of speech of each word and tagging it. Commonly used methods include: rule-based methods, statistical model-based methods, and deep learning-based methods. There is no limitation here.

[0218] In this embodiment, verbs in natural sentences may also be extracted, and the extracted entity words and verbs may be combined in the order in the natural sentences to generate word vectors.

[0219] S223. Generate a hierarchical candidate answer set based on multiple natural sentences and the entity word vectors of each natural sentence in the multiple natural sentences.

[0220] The candidate answer set contains two layers of answer sets. The first layer of answer set is the natural sentences obtained by dividing the text information, and the second layer of answer set is the entity word vector of each natural sentence.

[0221] Figure 6 FIG. 1 is a flow chart of generating a hierarchical question-answer pair set provided by an embodiment of the present application, and describes a possible implementation method of generating a hierarchical question-answer pair set after obtaining multiple question-answer pairs. Figure 6 As shown, the question-answer pair generation method also includes:

[0222] S261. For each candidate answer in the hierarchical candidate answer set, search multiple question-answer pairs to see whether the candidate answer exists.

[0223] Depend on Figure 3 It can be seen from the illustrated embodiment that, for each question in the question set, the candidate answer corresponding to the question is compared with the predicted answer corresponding to the question for semantic similarity, and only when the semantic similarity is greater than or equal to a first preset threshold, a question-answer pair is generated between the question and the candidate answer corresponding to the question.

[0224] Therefore, the number of candidate answers for multiple question-answer pairs is smaller than the number of candidate answers in the candidate answer set.

[0225] Among them, searching whether there is a target question with a corresponding candidate answer in multiple question-answer pairs can be performed by matching the numbers of the candidate answers in the question-answer pairs and the numbers of the candidate answers in the hierarchical candidate answer set.

[0226] S262. If there are no candidate answers for multiple question-answer pairs, the candidate answers are deleted from the hierarchical candidate answer set.

[0227] After deleting the candidate answer and its number, the numbers of other candidate answers in the hierarchical candidate answer set remain unchanged.

[0228] Exemplarily, for candidate answer S2, if the candidate answer numbers in multiple question-answer pairs do not include number 2, the candidate answer S2 in the hierarchical candidate answer set is deleted.

[0229] S263: If there are candidate answers for multiple question-answer pairs, then add the questions corresponding to the candidate answers to the corresponding positions of the candidate answers in the hierarchical candidate answer set to generate a hierarchical question-answer pair set.

[0230] In this embodiment, each candidate answer in the hierarchical candidate answer set can be judged in turn according to the number of the candidate answer, and a deletion or addition action can be performed according to the judgment result until the last candidate answer in the hierarchical candidate answer set, and finally a hierarchical question-answer pair set is obtained.

[0231] In the embodiment of the present application, a hierarchical candidate answer set is constructed to generate hierarchical question-answer pairs corresponding to the candidate answer set, and each question-answer pair in the hierarchical question-answer pair set does not have unclear semantics or grammatical errors. In addition, the hierarchical question-answer pairs conform to the question-answering habits during reading comprehension teaching, can assist manual teaching, automatically generate hierarchical draft questions for reading comprehension, and interact with users.

[0232] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0233] Based on the question-answer pair generation method provided in the above embodiment, the embodiment of the present invention further provides an apparatus embodiment for implementing the above method embodiment.

[0234] Figure 7 This is a schematic diagram of the structure of a language model training device provided in one embodiment of the present application. The units included are used to execute Figure 1 , Figure 2 For details of the steps in the corresponding embodiments, please refer to Figure 1 , Figure 2 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 7 The language model training device 30 includes a first acquisition module 301, a first generation module 302 and a processing module 303.

[0235] The first acquisition module 301 is used to acquire training text.

[0236] The first generating module 302 is used to generate a plurality of training text sequences according to the training text; wherein each training text sequence includes the training text, the answer text contained in the training text, and the question text corresponding to the answer text.

[0237] The processing module 303 is used to use the training text and answer text in each training text sequence as features, and the question text in each training text sequence as a label, to train the language model based on a supervised learning algorithm to obtain a trained target language model.

[0238] Optionally, the processing module 303 uses the training text and the answer text in each training text sequence as features, uses the question text in each training text sequence as a label, and trains the language model based on a supervised learning algorithm to obtain a trained target language model, which may include:

[0239] For each training text sequence, the training text sequence is encoded according to a preset dictionary to generate a multidimensional vector corresponding to the training text sequence; wherein the multidimensional vector includes a first vector corresponding to the training text, a second vector corresponding to the answer text, and a third vector corresponding to the question text;

[0240] splicing the first vector of the multidimensional vector and the second vector of the multidimensional vector to generate a fourth vector of the multidimensional vector;

[0241] Using the fourth vector of the multidimensional vector as a feature and the third vector of the multidimensional vector as a label, generating a training vector corresponding to the multidimensional vector;

[0242] Taking multiple training vectors as input, the language model is trained based on a supervised learning algorithm to obtain a trained target language model.

[0243] Optionally, the processing module 303 takes the multiple training vectors as input, trains the language model based on a supervised learning algorithm, and obtains a trained target language model, which may include:

[0244] For each training vector, the label of the training vector is masked and replaced to generate a masked training vector;

[0245] The masked training vector is input into the language model for processing to obtain the probability distribution of the predicted value of the label of the training vector on the preset dictionary;

[0246] Determine the value of the cross entropy function based on the label and probability distribution of the training vector;

[0247] When the value of the cross entropy function does not meet the preset conditions, update the parameters of the language model, and return to execute the step of performing mask replacement on the label of the training vector for each training vector to generate a masked training vector until the value of the cross entropy function meets the preset conditions;

[0248] Save the model parameters of the current language model and generate a trained target language model.

[0249] The language model training device provided in the embodiment of the present application trains the language model based on a supervised learning algorithm. The input of the supervised task is the text content and the answer contained in the text content, and the question corresponding to the answer is output. When using the target language model obtained based on the training method, only the text content and the answer contained in the text content need to be input, that is, the question that can generate the answer. The output question may not be contained in the text content, which is suitable for application scenarios where the question corresponding to the answer is obtained based on the answer prediction.

[0250] On the other hand, the training text may also be determined according to the application field of the target language model so that the prediction accuracy of the trained target language model is higher.

[0251] Figure 8 A schematic diagram of the structure of a question-answer pair generating device provided in an embodiment of the present application. The units included are used to execute Figures 3 to 6 For details of the steps in the corresponding embodiments, please refer to Figures 3 to 6 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 8 The question-answer pair generating device 40 includes a second acquiring module 401 , a second generating module 402 , a processing module 403 , a prediction module 404 and a comparison module 405 .

[0252] The second acquisition module 401 is used to acquire text information to be parsed.

[0253] The second generating module 402 is used to generate a candidate answer set according to the text information; the candidate answer set includes at least one candidate answer.

[0254] Processing module 403 is used to input the text information and the candidate answer set into the target language model for processing, obtain the questions corresponding to each candidate answer in the candidate answer set, and generate a question set according to the questions corresponding to each candidate answer;

[0255] The prediction module 404 is used to obtain the predicted answer corresponding to each question in the question set according to the text information and the question set.

[0256] The comparison module 405 is used to compare the semantic similarity between the candidate answer corresponding to the question and the predicted answer corresponding to the question for each question in the question set, and generate a question-answer pair according to the comparison result.

[0257] Optionally, the processing module 403 inputs the text information and the candidate answer set into the target language model for processing to obtain the question corresponding to each candidate answer in the candidate answer set, which may include:

[0258] For each candidate answer in the candidate answer set, combine the text information and the candidate answer to generate a text sequence to be predicted;

[0259] Encode the text sequence to be predicted according to the preset dictionary and generate the corresponding array vector to be predicted;

[0260] Input the array vector to be predicted into the target language model, and determine the prediction value corresponding to the array vector to be predicted;

[0261] If the predicted value does not match the preset end value, the array vector to be predicted and the predicted value are concatenated to generate a concatenated array vector; and the concatenated array vector is used as the array vector to be predicted, and the step of inputting the array vector to be predicted into the target language model and determining the predicted value corresponding to the array vector to be predicted is returned until the current predicted value matches the preset end value;

[0262] The current array vector to be predicted and the current predicted value are concatenated to generate a target array vector;

[0263] Decode the target array vector according to the preset dictionary to generate the question corresponding to the candidate answer.

[0264] Optionally, for each question in the question set, the comparison module 405 compares the candidate answer corresponding to the question with the predicted answer corresponding to the question, and generates a question-answer pair according to the comparison result, which may include:

[0265] Calculate the semantic similarity between the candidate answer corresponding to the question and the predicted answer corresponding to the question;

[0266] When the semantic similarity is less than the preset threshold, the question and the corresponding predicted answer are deleted;

[0267] When the semantic similarity is greater than or equal to a preset threshold, the question and the predicted answer corresponding to the question are combined to generate a question-answer pair.

[0268] Optionally, the second generating module 402 generates a candidate answer set according to the text information, which may include:

[0269] Divide the text information into multiple natural sentences;

[0270] For each of the multiple natural sentences, extract entity words from the natural sentence and generate entity word vectors of the natural sentence;

[0271] A hierarchical candidate answer set is generated according to multiple natural sentences and entity word vectors of each natural sentence in the multiple natural sentences.

[0272] The question-answer pair generating device further includes a third generating module, which is used to:

[0273] For each candidate answer in the hierarchical candidate answer set, find out whether the candidate answer exists in multiple question-answer pairs;

[0274] If there are no candidate answers for multiple question-answer pairs, the candidate answers are deleted from the hierarchical candidate answer set;

[0275] If there are candidate answers for multiple question-answer pairs, the questions corresponding to the candidate answers are added to the corresponding positions of the candidate answers in the hierarchical candidate answer set to generate a hierarchical question-answer pair set.

[0276] The question-answer pair generation device provided in the embodiment of the present application realizes the screening of predicted answers by comparing the semantic similarity between the corresponding candidate answers and the predicted answers, thereby realizing the screening of the questions obtained by reasoning, greatly reducing the problem of unclear semantics / grammatical errors in questions or answers in the question-answer pairs, and improving the quality of the question-answer pairs.

[0277] Fig. 9 Schematic diagram of a language model training device provided in one embodiment of the present application. Fig. 9 As shown, the language model training device 50 of this embodiment includes: at least one first processor 501, a first memory 502, and a computer program stored in the first memory 502 and executable on the first processor 501. The language model training device also includes a first communication component 503, wherein the first processor 501, the first memory 502, and the first communication component 503 are connected via a first bus 504.

[0278] When the first processor 501 executes the computer program, the steps in the above-mentioned question-answer pair generation method embodiments are implemented, for example: Figure 1 Steps S11 to S13 in the illustrated embodiment. Alternatively, the first processor 501 implements the functions of each module / unit in the above-mentioned device embodiments when executing the computer program, for example Figure 7 Functions of modules 301 to 303 are shown.

[0279] Those skilled in the art will understand that Fig. 9 It is only an example of a language model training device and does not constitute a limitation of the language model training device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components, such as input and output devices, network access devices, buses, etc.

[0280] Fig.10 Schematic diagram of a question-answer pair generating device provided in an embodiment of the present application. Fig.10 As shown, the question-answer pair generating device 60 of this embodiment includes: at least one second processor 601, a second memory 602, and a computer program stored in the second memory 602 and executable on the second processor 601. The question-answer pair generating device also includes a second communication component 603, wherein the second processor 601, the second memory 602, and the second communication component 603 are connected via a second bus 604.

[0281] When the second processor 601 executes the computer program, the steps in the above-mentioned question-answer pair generation method embodiments are implemented, for example: Figure 3 Steps S21 to S25 in the illustrated embodiment. Alternatively, the second processor 601 implements the functions of each module / unit in the above-mentioned device embodiments when executing the computer program, for example Figure 8 Functions of modules 401 to 405 are shown.

[0282] Those skilled in the art will understand that Fig.10 It is only an example of a question-answer pair generating device and does not constitute a limitation of the question-answer pair generating device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components, such as input and output devices, network access devices, buses, etc.

[0283] Fig. 9 Examples and Fig.10 The first processor or the second processor referred to in the embodiment may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0284] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0285] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0286] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0287] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0288] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0289] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0290] In the embodiments provided in the present application, it should be understood that the disclosed apparatus / network equipment and method can be implemented in other ways. 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 units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0291] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. 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. 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, and should all be included in the protection scope of the present application.< / eos> < / eos> < / bos> < / eos> < / bos> < / eos> < / bos> < / eos> < / eos> < / bos> < / eos> < / bos> < / eos> < / bos> < / eos> < / bos> < / eos> < / bos> < / eos> < / bos> < / eos> < / bos> < / eos> < / bos>

Claims

1. A language model training method, characterized in that: include: Get training text; Generate a plurality of training text sequences according to the training text; wherein each of the training text sequences includes the training text, an answer text contained in the training text, and a question text corresponding to the answer text; Taking the training text and the answer text in each of the training text sequences as features, taking the question text in each of the training text sequences as labels, training the language model based on a supervised learning algorithm to obtain a trained target language model; wherein the training sample of the supervised learning algorithm includes features and labels; Wherein, for each training vector corresponding to the training text sequence, the label of the training vector is masked and replaced to generate a masked training vector; Inputting the masked training vector into the language model for processing to obtain a probability distribution of a predicted value of the label of the training vector on a preset dictionary; Determining a value of a cross entropy function according to the label of the training vector and the probability distribution; When the value of the cross entropy function does not meet the preset condition, the parameters of the language model are updated, and the step of performing mask replacement on the label of the training vector for each training vector to generate a masked training vector is returned to be executed until the value of the cross entropy function reaches the preset condition; Save the model parameters of the current language model and generate a trained target language model.

2. The language model training method according to claim 1, characterized in that: The method uses the training text and the answer text in each training text sequence as features, uses the question text in each training text sequence as a label, and trains the language model based on a supervised learning algorithm to obtain a trained target language model, including: For each training text sequence, the training text sequence is encoded according to a preset dictionary to generate a multidimensional vector corresponding to the training text sequence; wherein the multidimensional vector includes a first vector corresponding to the training text, a second vector corresponding to the answer text, and a third vector corresponding to the question text; splicing the first vector of the multidimensional vector and the second vector of the multidimensional vector to generate a fourth vector of the multidimensional vector; Using the fourth vector of the multidimensional vector as a feature and the third vector of the multidimensional vector as a label, generating a training vector corresponding to the multidimensional vector; The plurality of training vectors are used as input, and the language model is trained based on a supervised learning algorithm to obtain a trained target language model.

3. A question-answer pair generation method, characterized in that: include: Get the text information to be parsed; Generate a candidate answer set according to the text information; the candidate answer set includes at least one candidate answer; The text information and the candidate answer set are input into a target language model trained based on a supervised learning algorithm for processing, so as to obtain the questions corresponding to each candidate answer in the candidate answer set, and a question set is generated according to the questions corresponding to each candidate answer; wherein, for each candidate answer in the candidate answer set, the text information and the candidate answer are combined to generate a text sequence to be predicted, the text sequence to be predicted is encoded according to a preset dictionary, and a corresponding array vector to be predicted is generated; the array vector to be predicted is input into the target language model to obtain the question corresponding to the candidate answer; Obtaining predicted answers corresponding to each question in the question set according to the text information and the question set; For each question in the question set, the candidate answer corresponding to the question is compared with the predicted answer corresponding to the question in terms of semantic similarity, and a question-answer pair is generated based on the comparison result; wherein the candidate answer and the predicted answer are respectively converted into word vectors, and the semantic similarity between the candidate answer and the predicted answer is represented based on the distance between the word vectors in space; wherein, when the semantic similarity is greater than or equal to a preset threshold, the question and the candidate answer corresponding to the question are combined to generate a question-answer pair.

4. The question-answer pair generation method according to claim 3, characterized in that: The step of inputting the text information and the candidate answer set into a target language model for processing to obtain the question corresponding to each candidate answer in the candidate answer set includes: For each candidate answer in the candidate answer set, combining the text information and the candidate answer to generate a text sequence to be predicted; Encoding the text sequence to be predicted to generate a corresponding array vector to be predicted; Inputting the array vector to be predicted into a target language model, and determining a prediction value corresponding to the array vector to be predicted; If the predicted value does not match the preset end value, the array vector to be predicted and the predicted value are concatenated to generate a concatenated array vector; and the concatenated array vector is used as the array vector to be predicted, and the step of inputting the array vector to be predicted into the target language model and determining the predicted value corresponding to the array vector to be predicted is returned to be executed until the current predicted value matches the preset end value; The current array vector to be predicted and the current predicted value are concatenated to generate a target array vector; The target array vector is decoded to generate a question corresponding to the candidate answer.

5. The question-answer pair generation method according to any one of claims 3 or 4, characterized in that: For each question in the question set, comparing the semantic similarity between the candidate answer corresponding to the question and the predicted answer corresponding to the question, and generating a question-answer pair according to the comparison result, further comprising: For each question in the question set, calculating the semantic similarity between the candidate answer corresponding to the question and the predicted answer corresponding to the question; When the semantic similarity is less than a preset threshold, the question and the predicted answer corresponding to the question are deleted.

6. The question-answer pair generation method according to any one of claims 3 or 4, characterized in that: Generating a candidate answer set according to the text information comprises: Dividing the text information into a plurality of natural sentences; For each natural sentence in the plurality of natural sentences, extract entity words from the natural sentence and generate an entity word vector for the natural sentence; A hierarchical candidate answer set is generated according to the multiple natural sentences and the entity word vector of each natural sentence in the multiple natural sentences.

7. The question-answer pair generation method according to claim 6, characterized in that: The method further comprises: For each candidate answer in the hierarchical candidate answer set, searching whether the candidate answer exists in the plurality of question-answer pairs; If the candidate answer does not exist in the multiple question-answer pairs, deleting the candidate answer from the hierarchical candidate answer set; If the candidate answers exist in the multiple question-answer pairs, the questions corresponding to the candidate answers are added to the corresponding positions of the candidate answers in the hierarchical candidate answer set to generate a hierarchical question-answer pair set.

8. A language model training device, characterized in that: include: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to claim 1 or 2 when executing the computer program.

9. A question-answer pair generating device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 3 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to claim 1 or 2 are implemented, or the steps of the method according to any one of claims 3 to 7 are implemented.