A method and device for generating question sentences

By obtaining preset question keywords and context in the field of financial technology, questions are automatically generated, which solves the problem of wasting human resources by manually editing questions, and achieves efficient and usable question generation.

CN111222309BActive Publication Date: 2024-09-24WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010040957.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-01-15
Publication Date
2024-09-24
Estimated Expiration
2040-01-15

AI Technical Summary

Technical Problem

In the field of financial technology, customer service robot dialogue systems require manual editing of a large number of questions to be input into the knowledge base, resulting in a waste of human resources, and it is difficult for existing technology to efficiently generate questions suitable for new businesses or products.

Method used

By obtaining the key words and context in the preset question, determine the candidate slot and its context similarity, automatically generate the question, use the semantic model to fill in the key words into the slot in the target template, and generate a highly usable question. Save human resources.

Benefits of technology

It realizes automatic question generation without manual editing of questions, saves human resources, and improves the usability and efficiency of question generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111222309B
    Figure CN111222309B
Patent Text Reader

Abstract

The present invention relates to the field of financial technology (Fintech), and discloses a method and device for generating a question sentence, wherein the method comprises: obtaining a keyword and a context of the keyword in a preset question sentence; determining a candidate slot and a context of the candidate slot from a target template of the preset question sentence; if the similarity between the context of the keyword and the context of the candidate slot meets a first preset condition, the keyword is filled into the candidate slot to generate a question sentence corresponding to the preset question sentence. The technical solution does not need to manually mark a large number of questions, saves human resources, and the generated question sentence has high usability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of financial technology (Fintech), and in particular, to a method and device for generating a question. Background Art

[0002] With the development of computer technology, more and more technologies are applied in the financial field. The traditional financial industry is gradually transforming to Fintech (Fintech). However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology.

[0003] The customer service robot dialogue system has a complete knowledge base system, which contains a set of questions and can be applied to existing businesses or products. However, for new businesses or products, a large number of questions need to be manually edited and input into the knowledge base, which wastes a lot of human resources. Summary of the invention

[0004] The embodiment of the present invention provides a method and device for generating question sentences, which do not require manual marking of a large number of question sentences, save human resources, and the generated question sentences have strong usability.

[0005] An embodiment of the present invention provides a method for generating a question, comprising:

[0006] Obtaining key words in a preset question sentence and the context of the key words;

[0007] Determining a candidate slot and a context of the candidate slot from a target template of the preset question;

[0008] If the similarity between the context of the keyword and the context of the candidate slot meets the first preset condition, the keyword is filled into the candidate slot to generate a question sentence corresponding to the preset question sentence.

[0009] In the above technical scheme, a question is automatically generated according to a preset question and a target template corresponding to the preset question. Specifically, a key word in the preset question is extracted, and the key word is the word filled in the slot of the target template. In order to achieve the availability of the generated question, this scheme determines the similarity between the context of the key word in the preset question and the context of the slot in the target template. When the similarity meets the preset conditions, the key word will be filled into the slot, which is equivalent to filling the key word into the semantically consistent slot based on the semantic features of the preset question and the target template, so as to automatically generate a question corresponding to the preset question. This method of automatically generating a question does not require manual editing of the question, saves human resources, and takes into account the context of the key word in the preset question, and finds the corresponding candidate slot from the target template according to the context, fully considers the context information, and the generated question has strong availability.

[0010] Optionally, if the similarity between the context of the keyword and the context of the candidate slot meets a first preset condition, filling the keyword into the candidate slot includes:

[0011] Inputting the context of the key words into a semantic model to obtain a first semantic vector;

[0012] Inputting the context of each candidate slot in the target template into the semantic model to obtain a second semantic vector for each candidate slot;

[0013] Determining the similarity between the first semantic vector and each second semantic vector, and determining the second semantic vector having the greatest similarity to the first semantic vector;

[0014] The key word is filled into the candidate slot corresponding to the second semantic vector having the greatest similarity to the first semantic vector.

[0015] In the above technical solution, the context of the keyword and the context of the candidate slot are respectively input into the pre-trained semantic model, and the candidate slot corresponding to the context with similar semantics to the keyword is determined as the target slot, and the semantic characteristics of the question are fully considered, so that the question generated after the keyword is filled in the target slot has stronger usability.

[0016] Optionally, filling the keyword into the candidate slot includes:

[0017] If there are at least two key words to be filled into the same candidate slot, then determining a short sentence consisting of each key word and the context of the candidate slot, and the number of occurrences of the short sentence in the original question set;

[0018] According to the number of occurrences, a key word to be filled into the candidate slot is determined from the at least two key words.

[0019] In the above technical solution, while ensuring that the similarity between the context of the keyword and the context of the slot meets the preset conditions, it is determined that the short sentence generated when the keyword is filled into the slot has a higher number of times in the original question set, further ensuring the availability of the corresponding question.

[0020] Optionally, determining a candidate slot and a context of the candidate slot from the target template of the preset question sentence includes:

[0021] Determine a slot having the same preset part of speech as the keyword among the multiple slots of the target template as the candidate slot;

[0022] According to the number of words included in the context of the key word, the same number of words in the preset question sentence that are located before the candidate slot are determined as the context of the candidate slot;

[0023] According to the number of words included in the context of the key word, the same number of words located after the candidate slot in the preset question sentence are determined as the context of the candidate slot;

[0024] The context of the candidate slot is composed of the context above the candidate slot and the context below the candidate slot.

[0025] In the above technical solution, only the slots with the same preset part of speech as the keyword are matched, which improves the efficiency and the usability of generating questions; further, when determining the context of the candidate slot from the target template, it is determined according to the context of the keyword in the preset question, which is equivalent to the position of the keyword in the keyword context being the same as the position of the candidate slot in the candidate slot context. Based on this, the similarity between the determined context of the candidate slot and the context of the keyword can better reflect the semantic rationality of filling the keyword into the candidate slot.

[0026] Optionally, obtaining key words in a preset question sentence includes:

[0027] Performing word segmentation on the preset question sentence;

[0028] Determine words with preset parts of speech from the words after word segmentation of the preset question sentence, and determine the words with preset parts of speech as the key words.

[0029] In the above technical solution, the preset question is segmented, and words with preset parts of speech are determined as key words. In this way, words with substantive meanings in the preset question can be found to be filled into the target template to generate a question.

[0030] Optionally, determining the words with preset parts of speech from the words after word segmentation of the preset question sentence includes:

[0031] If there are two consecutive words with the preset part of speech in the words after the preset question is segmented, the two words are merged; wherein the part of speech of the merged word is the same as the part of speech of the latter word of the two words.

[0032] In the above technical scheme, it is taken into consideration that when the preset question is segmented, phrases may be broken, such as a noun phrase may be split into several nouns, and a gerund phrase may be split into a verb and a noun, thereby leading to unclear semantics. In order to avoid this problem, a technical scheme for reintegrating words is set. Specifically, if there are two consecutive words with preset parts of speech in the words after the preset question is segmented, the two words are merged, and the part of speech of the merged word is the same as the part of speech of the latter word of the two words, thereby avoiding the problem of unclear semantics caused by phrase breakage when the preset question is segmented.

[0033] Optionally, after segmenting the preset question, the method further includes:

[0034] Determining words with functional parts of speech from the words after word segmentation of the preset question sentence;

[0035] After filling the key words into the candidate slots, the method further includes:

[0036] For words with functional parts of speech, replace them with words with the same functional parts of speech.

[0037] In the above technical solution, when the preset question is segmented, the words with functional parts of speech in the preset question are determined, so that after the key words are filled into the candidate slots, the words with functional parts of speech are replaced with words with the same functional parts of speech to achieve synonymous expansion of the generated question.

[0038] Optionally, the target template is determined by the following steps:

[0039] Obtaining an original template; the original template is obtained by removing words with preset parts of speech from the original question;

[0040] Determine the similarity between the original template and the preset question sentence according to the similarity between each word after word segmentation of the original template and all words after word segmentation of the preset question sentence;

[0041] If the similarity between the original template and the preset question sentence meets the second preset condition, determining the original template as a candidate template;

[0042] Inputting the candidate template and the preset question sentence after removing the words with the preset part of speech into the semantic model respectively;

[0043] If it is determined that the similarity between the candidate template and the preset question sentence after the words with the preset part of speech are removed meets the third preset condition, the candidate template is determined to be the target template.

[0044] In the above technical solution, the words with preset parts of speech in the original question are removed to obtain the original template, and the similarity between each word after word segmentation in the original template and all words after word segmentation in the preset question is determined, thereby determining the similarity between the original template and the preset question. In this way, it is possible to quickly determine whether the original template can be used as a candidate template. Then the candidate template and the preset question are respectively input into the pre-trained semantic model. When it is determined that the semantics of the candidate template and the preset question are relatively similar, the candidate template is determined as the target template, and the semantic features of the question are fully considered, so that the question generated according to the target template and the preset question has stronger usability.

[0045] Optionally, the type of the preset part of speech of the slot in the target template is the same as the type of the preset part of speech of the key words in the preset question sentence; the number of slots in the candidate template belonging to the same preset part of speech is the same as the number of key words in the preset question sentence.

[0046] In the above technical scheme, when determining whether a candidate template is a target template, a preliminary determination can be made based on the following features of the target template: the type of the preset part of speech of the target slot is the same as the type of the preset part of speech of the key words in the preset question, and the number of slots in the candidate template with the same preset part of speech is the same as the number of key words in the preset question, thereby quickly judging whether the candidate template is the target template and improving efficiency.

[0047] Accordingly, an embodiment of the present invention further provides a device for generating a question, comprising:

[0048] Processing unit, generation unit;

[0049] The processing unit is used to obtain key words and contexts of the key words in a preset question sentence; determine candidate slots and contexts of the candidate slots from a target template of the preset question sentence;

[0050] The generating unit is configured to fill the keyword into the candidate slot if the similarity between the context of the keyword and the context of the candidate slot meets a first preset condition, so as to generate a question sentence corresponding to the preset question sentence.

[0051] Optionally, the generating unit is specifically used for:

[0052] Inputting the context of the key words into a semantic model to obtain a first semantic vector;

[0053] Inputting the context of each candidate slot in the target template into the semantic model to obtain a second semantic vector for each candidate slot;

[0054] Determining the similarity between the first semantic vector and each second semantic vector, and determining the second semantic vector having the greatest similarity to the first semantic vector;

[0055] The key word is filled into the candidate slot corresponding to the second semantic vector having the greatest similarity to the first semantic vector.

[0056] Optionally, the generating unit is specifically used for:

[0057] If there are at least two key words to be filled into the same candidate slot, then determining a short sentence consisting of each key word and the context of the candidate slot, and the number of occurrences of the short sentence in the original question set;

[0058] According to the number of occurrences, a key word to be filled into the candidate slot is determined from the at least two key words.

[0059] Optionally, the processing unit is specifically used for:

[0060] Determine a slot having the same preset part of speech as the keyword among the multiple slots of the target template as the candidate slot;

[0061] According to the number of words included in the context of the key word, the same number of words in the preset question sentence that are located before the candidate slot are determined as the context of the candidate slot;

[0062] According to the number of words included in the context of the key word, the same number of words located after the candidate slot in the preset question sentence are determined as the context of the candidate slot;

[0063] The context of the candidate slot is composed of the context above the candidate slot and the context below the candidate slot.

[0064] Optionally, the processing unit is specifically used for:

[0065] Performing word segmentation on the preset question sentence;

[0066] Determine words with preset parts of speech from the words after word segmentation of the preset question sentence, and determine the words with preset parts of speech as the key words.

[0067] Optionally, the processing unit is specifically used for:

[0068] If there are two consecutive words with the preset part of speech in the words after the preset question is segmented, the two words are merged; wherein the part of speech of the merged word is the same as the part of speech of the latter word of the two words.

[0069] Optionally, the processing unit is further used for:

[0070] After the preset question is segmented, words with functional parts of speech are determined from the words after the segmentation of the preset question;

[0071] The generating unit is further configured to:

[0072] After the key words are filled into the candidate slots, the words with functional parts of speech are replaced with words with the same functional parts of speech.

[0073] Optionally, the processing unit is specifically used for:

[0074] Obtaining an original template; the original template is obtained by removing words with preset parts of speech from the original question;

[0075] Determine the similarity between the original template and the preset question sentence according to the similarity between each word after word segmentation of the original template and all words after word segmentation of the preset question sentence;

[0076] If the similarity between the original template and the preset question sentence meets the second preset condition, determining the original template as a candidate template;

[0077] Inputting the candidate template and the preset question sentence after removing the words with the preset part of speech into the semantic model respectively;

[0078] If it is determined that the similarity between the candidate template and the preset question sentence after the words with the preset part of speech are removed meets the third preset condition, the candidate template is determined to be the target template.

[0079] Optionally, the type of the preset part of speech of the slot in the target template is the same as the type of the preset part of speech of the key words in the preset question sentence; the number of slots in the candidate template belonging to the same preset part of speech is the same as the number of key words in the preset question sentence.

[0080] Accordingly, an embodiment of the present invention further provides a computing device, including:

[0081] A memory for storing program instructions;

[0082] The processor is used to call the program instructions stored in the memory and execute the above-mentioned question generation method according to the obtained program.

[0083] Correspondingly, an embodiment of the present invention further provides a computer-readable non-volatile storage medium, including computer-readable instructions. When a computer reads and executes the computer-readable instructions, the computer executes the above-mentioned question generation method. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0085] Figure 1 A flowchart of a method for generating a question provided by an embodiment of the present invention;

[0086] Figure 2 A schematic diagram of a flow chart of a method for determining a candidate template provided by an embodiment of the present invention;

[0087] Figure 3 A schematic diagram of a flow chart of a method for determining a target template provided by an embodiment of the present invention;

[0088] Figure 4 A schematic flow chart of a method for determining a slot matching a keyword provided by an embodiment of the present invention;

[0089] Figure 5 A flowchart of another method for generating a question provided by an embodiment of the present invention;

[0090] Figure 6 A schematic diagram of the structure of a device for generating a question provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0091] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0092] Figure 1 The process of a method for generating a question provided by an embodiment of the present invention is exemplarily shown, and the process can be executed by a device for generating a question.

[0093] like Figure 1 As shown in the figure, the process specifically includes:

[0094] Step 101, obtaining key words in a preset question sentence and the context of the key words;

[0095] Step 102, determining a candidate slot and a context of the candidate slot from the target template of the preset question;

[0096] Step 103, if the similarity between the context of the keyword and the context of the candidate slot meets the first preset condition, then fill the keyword into the candidate slot to generate the question corresponding to the preset question.

[0097] The preset question can be understood as a pre-set known question, and the keyword used to generate the question can be extracted from the preset question. For example, the two keywords used to generate the question extracted from the preset question are "say" and "apply"; the target template corresponding to the preset question can be understood as the question template that matches the preset question. Among them, the question template is used to represent the framework of the question, that is, there are no substantial words in the question template. For example, the target template is "Didn't I __ in the morning and don't __ anymore?", and this target template includes two slots, the first slot is between "didn't" and "don't", and the second slot is between "anymore" and "anymore".

[0098] In the embodiment of the present invention, the question is automatically generated according to the preset question and the target template corresponding to the preset question. Specifically, the keyword in the preset question is extracted, and this keyword is the word to be filled into the slot of the target template. In order to ensure the usability of the generated question, this solution determines the similarity between the context of the keyword in the preset question and the context of the slot in the target template. When the similarity meets the first preset condition, the keyword will be filled into the slot, which is equivalent to filling the keyword into the slot that conforms to the semantics based on the semantic features of the preset question and the target template to automatically generate the question corresponding to the preset question. This method of automatically generating questions does not require manual editing of questions, saves human resources, and takes into account the context of the keyword in the preset question, and finds the corresponding candidate slot in the target template according to this context, fully considering the context information, and the generated question has strong usability.

[0099] In step 101, when obtaining the keyword in the preset question, the preset question can be segmented first, and the words with a preset part of speech are determined from the multiple words after the segmentation of the preset question, and then the word with the preset part of speech is determined as the keyword. Here, the preset part of speech includes at least the verb part of speech and the noun part of speech. That is to say, among the multiple words after the segmentation of the preset question, the words with the verb part of speech and the noun part of speech are determined as keywords. For example, words with the noun part of speech such as "bank" and "account" are determined as keywords, and words with the verb part of speech such as "activate" and "fail" are determined as keywords. Through this method, the words with substantial meaning in the preset question can be found to be filled into the target template to generate questions.

[0100] When the preset question is segmented, phrases may be broken, such as a noun phrase may be split into several nouns, and a gerund phrase may be split into a verb and a noun, thereby causing a problem of unclear semantics. To avoid this problem, in an embodiment of the present invention, a technical solution for re-integrating words is set. Specifically, if there are two consecutive words with preset parts of speech in the words after the preset question is segmented, the two words are merged, and the part of speech of the merged word is the same as the part of speech of the latter word of the two words, thereby avoiding the problem of unclear semantics caused by phrase breakage when the preset question is segmented.

[0101] For example, when segmenting the preset question, if there are two adjacent words "bank" and "account" among the multiple words after the segmentation, it can be determined that the two words are merged into one word, namely "bank account", and the part of speech of the word is determined to be a noun; for another example, if there are two adjacent words "open" and "account" among the multiple words after the segmentation, it can be determined that the two words are merged into one word, namely "open an account", and the part of speech of the word is determined to be a noun.

[0102] That is to say, when it is determined that there are two adjacent words in the multiple words after word segmentation in the following form, the two adjacent words are merged:

[0103] Noun (NN) + Noun (NN) = Noun (NN);

[0104] Verb(VV)+Verb(VV)=Verb(VV);

[0105] Noun (NN) + Verb (VV) = Verb (VV);

[0106] Verb (VV) + Noun (NN) = Noun (NN);

[0107] It should be noted that nouns can be abbreviated as N or NN, and verbs can be abbreviated as V or VV, and the same applies below.

[0108] In step 102, a target template of a preset question may be obtained first, and the target template may be one or more. When determining any target template, the original template may be obtained by removing the words with preset parts of speech in the original question, and the similarity between the original template and the preset question is determined according to the similarity between each word after word segmentation of the original template and all words after word segmentation of the preset question; if the similarity between the original template and the preset question meets the second preset condition, the original template is determined as a candidate template; and then the candidate template and the preset question after the words with preset parts of speech are removed are respectively input into the semantic model; if it is determined that the similarity between the candidate template and the preset question after the words with preset parts of speech are removed meets the third preset condition, the candidate template is determined as the target template.

[0109] That is, when determining the target template, the original template may be determined first according to the original question, then it may be determined whether the original template is a candidate template, and then it may be determined whether the candidate template is the target template.

[0110] Before determining the original template according to the original question, meaningful and unambiguous questions can be first selected from a large number of questions in the corpus as the original questions. Specifically, a three-classification model can be set, and the three-classification model is obtained by model training based on the user's real questions. When the three-classification model is trained, the training samples can be annotated into three dimensions, namely meaningless, ambiguous, and meaningful and unambiguous. For example, "I'm sorry" and "thank you" are meaningless, "I want to apply for" and "I want to open" lack clear objects and are ambiguous, and "I want to open a micro loan" and "My bank card repayment failed" are meaningful and unambiguous. Then the annotated questions are used as training samples for model training to obtain a three-classification model, such as an LR (logistic regression) model, an xgboost model, etc. Therefore, a large number of questions can be input into the three-classification model to select meaningful and unambiguous questions as original questions.

[0111] After obtaining the original question, the original question can be segmented, and then the words with the preset part of speech can be determined from the words after the original question is segmented, and the words with the preset part of speech in the original question are removed to obtain the original template. In the embodiment of the present invention, there may be a situation where the phrase is broken. In order to solve the problem of unclear semantics caused by the phrase break, after determining that there are two consecutive words with the preset part of speech in the words after the original question is segmented, the two words are merged, and the part of speech of the merged word is the same as the part of speech of the latter word of the two words.

[0112] After the original template is determined, it can be determined whether the original template is a candidate template. The specific implementation can be as follows: Figure 2 As shown:

[0113] Step 201, filtering invalid words from the words after word segmentation of the preset question sentence, and determining the filtered words of the preset question sentence;

[0114] Step 202, filtering invalid words from the words after word segmentation of the original template, and determining the filtered words of the original template;

[0115] Step 203: If it is determined that the similarity between the filtered words of the preset question and the filtered words of the original template meets the second preset condition, the original template is determined as a candidate template.

[0116] In step 201, after segmenting the preset question sentence, multiple words can be obtained, and then the part of speech of each word is determined. If the part of speech of a certain word is the preset part of speech, then the part of speech of this word is marked. It can be to mark its corresponding preset part of speech after this word, or directly replace this word with its corresponding preset part of speech. When marking the part of speech of a word, it can be understood that a part-of-speech tag is attached to this word, and the preset part of speech of this word is the part-of-speech tag. Taking the example of directly replacing this word with its corresponding preset part of speech, the preset question sentence is "How can I fully repay the loan tomorrow?", and after segmenting the preset question sentence, it is "How can I fully repay the loan tomorrow?". Then, the part of speech of multiple words after segmenting the preset question sentence is marked, and it is determined as "How can I fully repay the loan tomorrow? NN VV?", and then the two adjacent words with part-of-speech markings are combined, that is, "How can I fully repay the loan tomorrow? VV?".

[0117] In addition, it is also possible to determine the words with functional parts of speech from multiple words after segmenting the preset question sentence. The words with functional parts of speech can include interrogative words (such as "what") and modal verbs (such as "can"), etc. Specifically, it can be as shown in Table 1. Then, the part of speech of the words with functional parts of speech among multiple words is marked. Taking the example of replacing the word with its corresponding functional part of speech, the preset question sentence is "How can I fully repay the loan tomorrow?", and after segmenting the preset question sentence, it is "How can I fully repay the loan tomorrow?". Then, the preset part of speech of multiple words after segmenting the preset question sentence is marked as "How can I fully repay the loan tomorrow? VV?", and then the functional part of speech is marked as "How can I fully repay the loan tomorrow? how VV?".

[0118] Table 1

[0119]

[0120]

[0121] In the embodiments of the present invention, it can be determined that the words with preset parts of speech and the words with functional parts of speech are both invalid words, and the invalid words in multiple words after segmenting the preset question sentence are filtered to obtain the filtered words of the preset question sentence. In one implementation manner, it can be to filter out the words with verb parts of speech, noun parts of speech, and functional parts of speech in the preset question sentence. For example, directly filter "How can I fully repay the loan tomorrow?" to "How can I tomorrow?"; in another implementation manner, it can be to filter out the part-of-speech tags in multiple words with part-of-speech markings in the preset question sentence. For example, directly filter "How can I fully repay the loan tomorrow?" marked with part of speech as "How can I tomorrow how VV" to "How can I tomorrow?". In addition, it is also possible to filter out the meaningless words in multiple words, such as "de", "ma", etc.

[0122] In step 202, the invalid words in the words after the original template segmentation can be filtered as in the implementation method of step 201, which will not be repeated. However, it should be noted that the original template is essentially a template question sentence after the original question sentence is segmented and the words are cut out. The word cutting here is equivalent to cutting out the words with preset parts of speech. For example, the original question sentence is "Didn't I say not to call again this morning?", and the corresponding original template is "Didn't I __ not __ again this morning?", that is, the original template cuts out the words "said" and "call" with preset parts of speech, but does not cut out the "not" with functional parts of speech, so this step will also cut out the words with functional parts of speech after the original template segmentation.

[0123] In step 203, when determining the similarity between the filtered words of the preset question and the filtered words of the original template, the correlation between the filtered words of the preset question and the filtered words of the original template can be determined based on the BM25 algorithm to characterize the similarity between the two. Specifically, assuming that the filtered words of the preset question are N1, and the filtered words of the original template are N2, wherein N1 and N2 are both greater than or equal to 1, the i-th word in the N1 words is used as the morpheme qi, and the correlation score between the morpheme qi and each word in the N2 words is determined, thereby determining the correlation score between the morpheme qi and the N2 words, and further determining the correlation score between the N1 words and the N2 words. If the correlation score is greater than a certain threshold, the original template is determined as a candidate template. Of course, the original template can be K1, and the correlation score between the N1 words and the N2 words corresponding to each original template can be determined, and the correlation score is sorted, and the first K2 words are taken. Here, the number of filtered words of each original template is the same or different.

[0124] After determining that the original template is a candidate template, it is necessary to determine whether the candidate template is a target template. Specifically, Figure 3 The flowchart shown:

[0125] Step 301, inputting the candidate template into the semantic model to obtain a third semantic vector;

[0126] A semantic model can be obtained by pre-training based on training samples containing multiple historical questions. The semantic model is used to represent the semantic features of questions. In a specific implementation, a BERT (Bidirectional Encoder Representation from Transformers) model can be determined based on the training samples. The BERT model uses Masked LM and Next Sentence Prediction methods to capture semantic representations at the word and sentence levels, respectively, in the pre-train method. The semantic features of questions can be well represented by calling the BERT model.

[0127] Step 302, inputting the preset question sentence after removing the words with the preset part of speech into the semantic model to obtain a fourth semantic vector;

[0128] The preset question can be processed. Specifically, the preset question is first segmented to obtain multiple words, and words with preset parts of speech are determined from the multiple words, and the words with the preset parts of speech are removed from the preset question. For example, the preset question is "How do I repay the full amount tomorrow?", then the preset question is segmented to obtain "How do I repay the full amount tomorrow?", and then "full amount" is determined to be a noun part of speech, and "repay" is a verb part of speech, then "full amount" and "repay" in the preset question are removed to obtain "How do I ____ tomorrow?", and then "How do I ____ tomorrow?" is input into the semantic model to obtain the fourth semantic vector.

[0129] Of course, in this example, you can first merge "full amount" and "repayment" into "full repayment", and then remove "full repayment" to get "How should I __ tomorrow?", and then input "How should I __ tomorrow?" into the semantic model to obtain the fourth semantic vector.

[0130] Step 303: If the similarity between the third semantic vector and the fourth semantic vector meets a third preset condition, the candidate template is determined as the target template.

[0131] Here, each of the multiple candidate templates can be input into the semantic model to determine the third semantic vector corresponding to each candidate template, and then determine the similarity between the third semantic vector corresponding to each candidate template and the fourth semantic vector. In a specific implementation, the candidate template corresponding to the third semantic vector whose similarity with the fourth semantic vector is greater than a certain threshold can be determined as the target template, or the candidate templates can be sorted from large to small according to the similarity between the third semantic vector corresponding to each candidate template and the fourth semantic vector to determine the candidate templates corresponding to the first several similarities, and then all of these candidate templates are determined as target templates.

[0132] When determining the similarity between the third semantic vector and the fourth semantic vector, the Euclidean distance or cosine similarity or other similarity between the two vectors may be determined, without limitation.

[0133] In the above embodiment, the candidate template and the preset question are respectively input into the pre-trained semantic model, and the candidate template with semantics close to the preset question is determined as the target template, and the semantic features of the question are fully considered, so that the question generated according to the target template and the preset question has stronger usability.

[0134] In the above embodiment, after determining the original template, it is determined whether the original template is a candidate template, and then it is determined whether the candidate template is a target template; of course, the original template can also be directly input into the semantic model to obtain the semantic vector of the original template, and the preset question sentence after removing the words with the preset part of speech is input into the semantic model to obtain the fourth semantic vector, and then the semantic similarity is determined based on the semantic vector of the original template and the fourth semantic vector. However, in this method, due to the large number of original templates, each original template needs to be input into the semantic model to obtain the semantic vector of the original template, and then the semantic similarity between the semantic vector of each original template and the fourth semantic vector is determined, which is lower than the processing efficiency of the embodiment of the present invention.

[0135] In step 102, after determining the target template, it is necessary to determine the candidate slots and the context of the candidate slots from the target template. Specifically, the slots among multiple slots of the target template that have the same preset part of speech as the keyword can be determined as candidate slots. For example, if the part of speech of the keyword is a noun, then the slot with a noun part of speech is determined from multiple slots as a candidate slot.

[0136] It should be noted that the context of the candidate slot should correspond to the context of the key word, which is equivalent to the position of the candidate slot in its corresponding context being the same as the position of the key word in its corresponding context. For example, if the context of the key word includes 2 words, the context of the candidate slot also includes 2 words. If the context of the key word includes 1 word, the context of the candidate slot also includes 1 word. Similarly, if the context of the key word includes 2 words, the context of the candidate slot also includes 2 words. If the context of the key word includes 1 word, the context of the candidate slot also includes 1 word. The context and the context of the key word in the preset question can be determined based on experience, and the number of words in the context and the number of words in the context can be the same or different.

[0137] When determining the context of a candidate slot from a target template, the same number of words in the target template that are located before the candidate slot can be determined as the context of the candidate slot based on the number of words included in the context of the keyword; the same number of words in the target template that are located after the candidate slot can be determined as the context of the candidate slot based on the number of words included in the context of the keyword; and the context of the candidate slot and the context of the candidate slot can then be combined to form the context of the candidate slot.

[0138] In step 103, there may be multiple candidate slots in the target template, and it is necessary to find the slot that is most suitable for filling in the keyword from the multiple candidate slots, that is, determine the slot corresponding to the context most similar to the context of the keyword from the multiple candidate slots for filling in the keyword.

[0139] You can Figure 4 The process shown:

[0140] Step 401, inputting the context of the key words into the semantic model to obtain a first semantic vector;

[0141] Step 402, inputting the context of each candidate slot in the target template into the semantic model to obtain a second semantic vector of each candidate slot;

[0142] Step 403, determining the similarity between the first semantic vector and each second semantic vector, and determining the second semantic vector having the greatest similarity to the first semantic vector;

[0143] Step 404: Fill the key words into the candidate slot corresponding to the second semantic vector having the greatest similarity to the first semantic vector.

[0144] In the embodiment of the present invention, the semantic model may be the semantic model determined in step 102. The context of the key words and the context of the candidate slots are respectively input into the pre-trained semantic model, and the candidate slot corresponding to the context close to the context of the key words is determined as the target slot, and the semantic features of the question are fully considered, so that the question generated after the key words are filled into the target slot has stronger usability.

[0145] When determining the similarity between the first semantic vector and each second semantic vector, the Euclidean distance or cosine similarity or other similarity between the two vectors may be determined.

[0146] It should be noted that when generating corresponding questions based on preset questions and target templates, multiple key words determined in the preset questions will generally be filled into the slots of the target template respectively, and when filling in, the key words will be filled into the slots with the same preset part of speech according to the preset part of speech of the key words. That is, the target template corresponding to the preset question has the following characteristics: the number of slots in the target template is the same as the number of key words in the preset question, and for a certain preset part of speech, the number of slots belonging to the preset part of speech in the target template is the same as the number of slots belonging to the preset part of speech in the preset question. For example, the preset question includes 5 key words, 2 of which correspond to verb parts of speech and 3 correspond to noun parts of speech. Then the determined target template also needs to include 5 slots, 2 of which correspond to verb parts of speech and 3 correspond to noun parts of speech. In this way, the key words of the 2 verb parts of speech in the preset question can be filled into the 2 verb parts of speech slots of the target template respectively, and the key words of the 3 noun parts of speech in the preset question can be filled into the 3 noun parts of speech slots of the target template respectively.

[0147] Based on the above description, when screening out multiple candidate templates from multiple original templates, some original templates can be pre-screened from the multiple original templates, wherein the types of the preset parts of speech of the slots in the pre-screened partial original templates are the same as the types of the preset parts of speech of the key words in the preset question sentences, and the number of slots in the original templates belonging to the same preset part of speech is the same as the number of key words in the preset question sentences. Thus, the candidate templates are determined from the pre-screened partial original templates. In this way, the efficiency can be further improved.

[0148] In addition, after determining the target template from the candidate templates, the slots in the multiple slots of the target template that have the same preset part of speech as the keyword will be determined as candidate slots, so that only the keyword is matched with the slots with the same preset part of speech, thereby improving the efficiency and the usability of generating questions.

[0149] Further, it may be determined that the first key word in the preset question is filled into the first slot of the target template, and it may be determined that the second key word in the preset question is also filled into the first slot of the target template. At this time, there will be at least two key words to be filled into the same candidate slot. For this case, the short sentence composed of each key word and the context of the same candidate slot can be determined, and then the number of times the short sentence corresponding to each key word appears in the original question set can be determined, and the key words filled into the candidate slot can be determined based on the number of occurrences. For example, the first key word and the first slot form the first short sentence, and the second key word and the first slot form the second short sentence. Statistics show that the first short sentence appears 10 times in the original question set, and the second short sentence appears 20 times in the original question set. It can be determined that the second short sentence is more in line with the question characteristics, so that the second key word is filled into the first slot. In this way, while ensuring that the similarity between the context of the keyword and the context of the slot meets the preset conditions, it is determined that the short sentence generated when the keyword is filled into the slot has a higher number of occurrences in the original question set, further ensuring the availability of the generated question.

[0150] After the key words in the preset question are filled into the slots of the target template, an initial question can be generated. In the embodiment of the present invention, the generated initial question can be expanded. Specifically, the words with functional parts of speech in the initial question can be replaced with words with the same functional parts of speech. For example, the generated initial question is "How can I repay the full amount tomorrow?", where "how" is a word with a functional part of speech, and the corresponding functional part of speech is how. Then, other words in how can be replaced with "how", that is, "How can I repay the full amount tomorrow?" is generated. how Full repayment", "I will How about it Repay in full".

[0151] Through the above implementation, at least one question corresponding to the preset question is generated, and the at least one question can be displayed. In actual application, the at least one generated question can be displayed to the staff, so that the staff can manually check the generated questions, select qualified questions or delete unqualified questions, and finally input the qualified questions into the knowledge base.

[0152] It should be noted that in the embodiment of the present invention, when determining the key words of the preset question, it is necessary to segment the preset question, and when determining the candidate template corresponding to the preset question, it is also necessary to segment the preset question. The two segmentation methods can be the same, and multiple words after the segmentation of a preset question can be stored in the database, so that the two can be shared. Of course, they can also be segmented separately each time they are needed. In addition, when determining the original template from the original question, it is necessary to segment the original question, and when determining the candidate template from the original template, it is also necessary to segment the original template. The two segmentation methods can be the same, and multiple words after the segmentation of the original question can be reused in the process of determining the candidate template. Of course, they can also be segmented separately each time they are needed.

[0153] In the above embodiment, the original template corresponding to each original question in the original question set is obtained, and then multiple candidate templates that meet a certain preset condition are determined from the multiple original templates, and then multiple target templates that meet a certain preset condition are determined from the multiple candidate templates, and then the question corresponding to the preset question is generated according to the preset question and the target template. Based on this process, a specific implementation method is provided below, which can be as follows: Figure 5 In the process shown in FIG. 1 , the implementation method is specifically divided into three parts, namely, template mining, template selection and template filling.

[0154] (I) Template mining

[0155] Template mining includes screening questions based on classification models, building templates based on part-of-speech analysis, and simplifying templates based on preset rules.

[0156] Filter questions based on classification models:

[0157] The K0 questions are input into a pre-set three-category model to screen out meaningful and unambiguous questions as K1 original questions.

[0158] Build a template based on part-of-speech analysis:

[0159] Each of the K1 original questions is segmented and tagged with parts of speech, thereby obtaining K1 preliminary original templates.

[0160] Simplify templates based on preset rules:

[0161] For each preliminary original template, the following steps are performed: merging two adjacent words with preset parts of speech in the preliminary original template, and removing the words with preset parts of speech in the preliminary original template.

[0162] (II) Template selection

[0163] Template selection includes recall template and rearrangement template;

[0164] Recall Template:

[0165] Determine to segment and tag the preset question, and filter out words with preset parts of speech, words with functional parts of speech, and meaningless words from the multiple words after the segmentation of the preset question, assuming that the filtered words of the preset question are N1; perform segmentation on each of the K1 original templates in the same way, and filter out words with functional parts of speech and meaningless words, assuming that the filtered words of the original templates are N2; then determine the similarity between the N1 words and the N2 words; and sort the similarities corresponding to the K1 original templates, so as to determine the first K2 original templates as candidate templates.

[0166] Rearrange template:

[0167] Determine the similarity between any one of the K2 candidate templates and the preset question sentence after removing the words with the preset part of speech, and sort the K2 candidate templates from high to low according to the similarity to determine the top K3 candidate templates as target templates.

[0168] (III) Template filling

[0169] Template filling includes filling templates based on context. Specifically, each of the K3 target templates can include at least one candidate slot. For any candidate slot of any target template, the similarity between the context of the keyword in the preset question and the context of the candidate slot in the target template is determined, and then the candidate slot in the target template with the highest similarity to the context of the keyword in the preset question is determined, so as to fill the keyword into the candidate slot with the highest similarity, thereby generating a question corresponding to the preset question.

[0170] Here, it can be understood that K0≥K1≥K2≥K3≥1, N1≥1, N2≥1.

[0171] Based on the same inventive concept, Figure 6 The structure of a device for generating a question provided by an embodiment of the present invention is exemplarily shown, and the device can execute the process of the method for generating a question.

[0172] The device comprises:

[0173] Processing unit 601, generating unit 602;

[0174] The processing unit 601 is used to obtain key words and contexts of the key words in a preset question sentence; determine candidate slots and contexts of the candidate slots from a target template of the preset question sentence;

[0175] The generating unit 602 is configured to fill the keyword into the candidate slot to generate a question sentence corresponding to the preset question sentence if the similarity between the context of the keyword and the context of the candidate slot meets a first preset condition.

[0176] Optionally, the generating unit 602 is specifically configured to:

[0177] Inputting the context of the key words into a semantic model to obtain a first semantic vector;

[0178] Inputting the context of each candidate slot in the target template into the semantic model to obtain a second semantic vector for each candidate slot;

[0179] Determining the similarity between the first semantic vector and each second semantic vector, and determining the second semantic vector having the greatest similarity to the first semantic vector;

[0180] The key word is filled into the candidate slot corresponding to the second semantic vector having the greatest similarity to the first semantic vector.

[0181] Optionally, the generating unit 602 is specifically configured to:

[0182] If there are at least two key words to be filled into the same candidate slot, then determining a short sentence consisting of each key word and the context of the candidate slot, and the number of occurrences of the short sentence in the original question set;

[0183] According to the number of occurrences, a key word to be filled into the candidate slot is determined from the at least two key words.

[0184] Optionally, the processing unit 601 is specifically configured to:

[0185] Determine a slot having the same preset part of speech as the keyword among the multiple slots of the target template as the candidate slot;

[0186] According to the number of words included in the context of the key word, the same number of words in the preset question sentence that are located before the candidate slot are determined as the context of the candidate slot;

[0187] According to the number of words included in the context of the key word, the same number of words located after the candidate slot in the preset question sentence are determined as the context of the candidate slot;

[0188] The context of the candidate slot is composed of the context above the candidate slot and the context below the candidate slot.

[0189] Optionally, the processing unit 601 is specifically configured to:

[0190] Performing word segmentation on the preset question sentence;

[0191] Determine words with preset parts of speech from the words after word segmentation of the preset question sentence, and determine the words with preset parts of speech as the key words.

[0192] Optionally, the processing unit 601 is specifically configured to:

[0193] If there are two consecutive words with the preset part of speech in the words after the preset question is segmented, the two words are merged; wherein the part of speech of the merged word is the same as the part of speech of the latter word of the two words.

[0194] Optionally, the processing unit 601 is further configured to:

[0195] After the preset question is segmented, words with functional parts of speech are determined from the words after the segmentation of the preset question;

[0196] The generating unit 602 is further configured to:

[0197] After the key words are filled into the candidate slots, the words with functional parts of speech are replaced with words with the same functional parts of speech.

[0198] Optionally, the processing unit 601 is specifically configured to:

[0199] Obtaining an original template; the original template is obtained by removing words with preset parts of speech from the original question;

[0200] Determine the similarity between the original template and the preset question sentence according to the similarity between each word after word segmentation of the original template and all words after word segmentation of the preset question sentence;

[0201] If the similarity between the original template and the preset question sentence meets the second preset condition, determining the original template as a candidate template;

[0202] Inputting the candidate template and the preset question sentence after removing the words with the preset part of speech into the semantic model respectively;

[0203] If it is determined that the similarity between the candidate template and the preset question sentence after the words with the preset part of speech are removed meets the third preset condition, the candidate template is determined to be the target template.

[0204] Optionally, the type of the preset part of speech of the slot in the target template is the same as the type of the preset part of speech of the key words in the preset question sentence; the number of slots in the candidate template belonging to the same preset part of speech is the same as the number of key words in the preset question sentence.

[0205] Based on the same inventive concept, an embodiment of the present invention further provides a computing device, including:

[0206] A memory for storing program instructions;

[0207] The processor is used to call the program instructions stored in the memory and execute the above-mentioned question generation method according to the obtained program.

[0208] Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable non-volatile storage medium, including computer-readable instructions. When a computer reads and executes the computer-readable instructions, the computer executes the above-mentioned question generation method.

[0209] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0210] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0211] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0212] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0213] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for generating a question, characterized in that: include: Obtaining key words in a preset question sentence and the context of the key words; Determining a candidate slot and a context of the candidate slot from a target template of the preset question; If the similarity between the context of the key word and the context of the candidate slot meets the first preset condition, the key word is filled into the candidate slot to generate a question sentence corresponding to the preset question sentence; The target template is determined by the following steps: Obtaining an original template; the original template is obtained by removing words with preset parts of speech from the original question; Determine the similarity between the original template and the preset question sentence according to the similarity between each word after word segmentation of the original template and all words after word segmentation of the preset question sentence; If the similarity between the original template and the preset question sentence meets the second preset condition, determining the original template as a candidate template; Inputting the candidate template and the preset question sentence after removing the words with the preset part of speech into the semantic model respectively; If it is determined that the similarity between the candidate template and the preset question sentence after the words with the preset part of speech are removed meets the third preset condition, the candidate template is determined to be the target template.

2. The method according to claim 1, characterized in that If the similarity between the context of the keyword and the context of the candidate slot meets the first preset condition, filling the keyword into the candidate slot includes: Inputting the context of the key words into a semantic model to obtain a first semantic vector; Inputting the context of each candidate slot in the target template into the semantic model to obtain a second semantic vector for each candidate slot; Determining the similarity between the first semantic vector and each second semantic vector, and determining the second semantic vector having the greatest similarity to the first semantic vector; The key word is filled into the candidate slot corresponding to the second semantic vector having the greatest similarity to the first semantic vector.

3. The method according to claim 1, characterized in that Filling the key words into the candidate slots includes: If there are at least two key words to be filled into the same candidate slot, then determining a short sentence consisting of each key word and the context of the candidate slot, and the number of occurrences of the short sentence in the original question set; According to the number of occurrences, a key word to be filled into the candidate slot is determined from the at least two key words.

4. The method according to claim 1, characterized in that The determining of the candidate slot and the context of the candidate slot from the target template of the preset question sentence includes: Determine a slot having the same preset part of speech as the keyword among the multiple slots of the target template as the candidate slot; According to the number of words included in the context of the key word, the same number of words in the target template that are located before the candidate slot are determined as the context of the candidate slot; According to the number of words included in the context of the key word, the same number of words located after the candidate slot in the target template are determined as the context of the candidate slot; The context of the candidate slot is composed of the context above the candidate slot and the context below the candidate slot.

5. The method according to claim 1, characterized in that The step of obtaining key words in the preset question sentence includes: Performing word segmentation on the preset question sentence; Determine words with preset parts of speech from the words after word segmentation of the preset question sentence, and determine the words with preset parts of speech as the key words.

6. The method according to claim 5, characterized in that The step of determining words with a preset part of speech from the words after word segmentation of the preset question sentence includes: If there are two consecutive words with the preset part of speech in the words after the preset question is segmented, the two words are merged; wherein the part of speech of the merged word is the same as the part of speech of the latter word of the two words.

7. The method according to claim 5, characterized in that After segmenting the preset question, the method further includes: Determining words with functional parts of speech from the words after word segmentation of the preset question sentence; After filling the key words into the candidate slots, the method further includes: For words with functional parts of speech, replace them with words with the same functional parts of speech.

8. The method according to claim 1, characterized in that The type of the preset part of speech of the slot in the target template is the same as the type of the preset part of speech of the key words in the preset question sentence; The number of slots in the candidate templates belonging to the same preset part of speech is the same as the number of key words in the preset question sentence.

9. A device for generating question sentences, characterized in that: include: Processing unit, generation unit; The processing unit is used to obtain key words in a preset question sentence and the context of the key words; Determining a candidate slot and a context of the candidate slot from a target template of the preset question; The generating unit is configured to fill the keyword into the candidate slot to generate a question sentence corresponding to the preset question sentence if the similarity between the context of the keyword and the context of the candidate slot meets a first preset condition; The processing unit is used to obtain the original template; The original template is obtained by removing words with preset parts of speech from the original question; the similarity between the original template and the preset question is determined according to the similarity between each word after word segmentation of the original template and all words after word segmentation of the preset question; If the similarity between the original template and the preset question sentence meets the second preset condition, the original template is determined as a candidate template; the candidate template and the preset question sentence after the words with the preset part of speech are removed are respectively input into the semantic model; If it is determined that the similarity between the candidate template and the preset question sentence after the words with the preset part of speech are removed meets the third preset condition, the candidate template is determined to be the target template.

10. A computing device, characterized in that: include: A memory for storing program instructions; A processor, configured to call the program instructions stored in the memory, and execute the method according to any one of claims 1 to 8 according to the obtained program.

11. A computer-readable non-volatile storage medium, characterized in that: The method comprises computer-readable instructions, and when a computer reads and executes the computer-readable instructions, the computer is caused to execute the method according to any one of claims 1 to 8.