Question and answer pair generation method and device, computer device, and storage medium
By calculating the similarity of candidate question-answer pairs and using the trained model to expand the questions, the shortcomings of template expansion methods are addressed, the number and diversity of question-answer pairs are increased, and the accuracy of question-answering in intelligent systems is improved.
Patent Information
- Application Number
- CN202110604494.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-31
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2041-05-31
AI Technical Summary
In existing technologies, template-based question-answering pair expansion methods are difficult to meet the diverse needs of user input questions, resulting in insufficient accuracy of intelligent systems in question answering.
By acquiring reference question-answer pairs and reference corpus, candidate question-answer pairs are extracted, and the similarity between candidate questions and reference questions and the similarity between candidate answers and reference answers are calculated to determine expanded question-answer pairs. The trained model is then used to expand questions and obtain answer context.
It increased the number and diversity of extended question-answer pairs, thereby improving the accuracy of the intelligent system's question-answering.
Smart Images

Figure CN115481223B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, and particularly relates to a method and device for generating a question and answer pair, a computer device and a storage medium. BACKGROUND
[0002] With the wide application of question and answer technology in intelligent customer service, intelligent robots and intelligent sound boxes and other intelligent systems, how to build a question and answer system has become a hot issue. In the era of information explosion, the amount of information added every day is immeasurable, and the number of document files added every day is incalculable, and the newly added document files contain a large amount of question and answer pair data.
[0003] In the related art, the expansion of the question and answer pair mostly provides a plurality of templates for the type of question and answer pair that needs to be expanded, and replaces the keywords therein, so that the expanded question and answer pair obtained by the technology has a high similarity with the original question and answer pair. However, in actual use, the problem input by the user is usually complex and diverse, so that the expansion mode of the question and answer pair based on the template is difficult to meet the needs of the intelligent system. SUMMARY
[0004] The present disclosure aims to at least solve one of the technical problems in the related art to some extent.
[0005] The first aspect of the present disclosure provides a method for generating a question and answer pair, comprising:
[0006] obtaining a reference question and answer pair and a reference corpus; wherein the reference question and answer pair comprises a reference question and a reference answer;
[0007] extracting a plurality of candidate question and answer pairs from the reference corpus; wherein each candidate question and answer pair comprises a candidate question and a candidate answer;
[0008] determining a first similarity between the candidate question in each candidate question and answer pair and the reference question, and a second similarity between the corresponding candidate answer in the candidate question and answer pair and the reference answer;
[0009] determining an expanded question and answer pair corresponding to the reference question and answer pair from the plurality of candidate question and answer pairs according to each first similarity and corresponding second similarity.
[0010] The second aspect of the present disclosure provides a device for generating a question and answer pair, comprising:
[0011] an obtaining module configured to obtain a reference question and answer pair and a reference corpus; wherein the reference question and answer pair comprises a reference question and a reference answer;
[0012] an extracting module configured to extract a plurality of candidate question and answer pairs from the reference corpus; wherein each candidate question and answer pair comprises a candidate question and a candidate answer;
[0013] The first determining module is configured to determine a first similarity between a candidate question in each of the candidate question-answer pairs and the reference question, and a second similarity between a corresponding candidate answer in the candidate question-answer pair and the reference answer;
[0014] The second determining module is configured to determine, according to each of the first similarities and the corresponding second similarities, an extended question-answer pair corresponding to the reference question-answer pair from the plurality of candidate question-answer pairs.
[0015] The third aspect of the present disclosure provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the program, the generation method of the question-answer pair is implemented.
[0016] The fourth aspect of the present disclosure provides a non-transitory computer readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the generation method of the question-answer pair is implemented.
[0017] The fifth aspect of the present disclosure provides a computer program product, and when the processor in the computer program product executes, the generation method of the question-answer pair is executed.
[0018] The generation method of the question-answer pair, the device, the computer device and the storage medium provided by the present disclosure have the following beneficial effects:
[0019] First, the reference question-answer pair and the reference corpus are obtained, then a plurality of candidate question-answer pairs are extracted from the reference corpus, the first similarity between the candidate question in each of the candidate question-answer pairs and the reference question, and the second similarity between the corresponding candidate answer in the candidate question-answer pair and the reference answer are determined, and finally, according to each of the first similarities and the corresponding second similarities, the extended question-answer pair corresponding to the reference question-answer pair from the plurality of candidate question-answer pairs is determined, thereby obtaining the extended question-answer pair corresponding to the reference question-answer pair from a large amount of reference corpus, improving the number and diversity of the extended question-answer pair, and further improving the accuracy of the question and answer in the intelligent system.
[0020] The additional aspects and advantages of the present disclosure will be partially given in the following description, partially will become obvious from the following description, or will be understood by the practice of the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0021] The above and / or additional aspects and advantages of the present disclosure will become apparent and more readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, in which:
[0022] Figure 1A flowchart of a method for generating a question-answer pair according to an embodiment of the present disclosure is shown.
[0023] Figure 2 A flowchart of a method for generating a question-answer pair according to an embodiment of the present disclosure is shown.
[0024] Figure 3 A structural diagram of a device for generating a question-answer pair according to an embodiment of the present disclosure is shown.
[0025] Figure 4 A block diagram of an exemplary computer device suitable for implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0026] Embodiments of the present disclosure are described in detail below with reference to the accompanying drawings, in which like or similar elements or components are denoted throughout by like reference characters, and wherein the embodiments described below are illustrative of the present disclosure and are not intended to be limiting.
[0027] A method, device, computer device and storage medium for generating a question-answer pair according to embodiments of the present disclosure are described below with reference to the accompanying drawings.
[0028] Figure 1 A flowchart of a method for generating a question-answer pair according to an embodiment of the present disclosure is shown.
[0029] Embodiments of the present disclosure are described below with reference to the accompanying drawings, in which like or similar elements or components are denoted throughout by like reference characters, and wherein the embodiments described below are illustrative of the present disclosure and are not intended to be limiting.
[0030] The computer device can be a personal computer (PC), a cloud device, a mobile device, etc. The mobile device can be, for example, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, a vehicle-mounted device, etc. The mobile device can have various operating systems, touch screens and / or display screens.
[0031] As shown in FIG. 1, the method for generating a question-answer pair can include the following steps: Figure 1
[0032] In step 101, a reference question-answer pair and a reference corpus are obtained. The reference question-answer pair includes a reference question and a reference answer.
[0033] The reference question-answer pair can be a reference question that needs to be expanded and a corresponding reference answer.
[0034] The reference corpus can be a relevant corpus obtained from a domain where the reference question-answer pair is located, or a common question-answer pair corpus in the domain where the reference question-answer pair is located.
[0035] Optionally, the reference question-answer pair is obtained, and the reference question-answer pair is parsed to determine a domain to which the reference question-answer pair belongs, and reference corpora are extracted from the candidate corpora according to the domain to which the reference question-answer pair belongs and the domain to which each candidate corpus belongs.
[0036] The candidate corpus can include corpora of various domains, and the reference corpus is extracted from the corpora of various domains as the same domain as the reference question-answer pair.
[0037] Optionally, the domain to which the reference question-answer pair belongs can be determined according to an intent or a modifier of the reference question-answer pair.
[0038] For example, the question of the reference question-answer pair is “How to buy the A product with positive returns?”, the intent domain word “A product” is insurance, and the modifier “positive returns” is returns, and the domain to which the reference question-answer pair belongs is the financial insurance domain.
[0039] Alternatively, the question of the reference question-answer pair is “Which middle school should I choose?”, and the intent domain word “middle school” is school, and the domain to which the reference question-answer pair belongs is the education domain.
[0040] It should be noted that the above examples are only illustrative and cannot be used as a limitation on the reference question-answer pair and the domain to which the reference question-answer pair belongs in the embodiments of the present disclosure.
[0041] In step 102, a plurality of candidate question-answer pairs are extracted from the reference corpus, wherein each candidate question-answer pair includes a candidate question and a candidate answer.
[0042] Optionally, the reference corpus includes reference text, and the reference text can be processed by a preset sliding window to extract a plurality of candidate question-answer pairs.
[0043] The length of the preset sliding window can be a fixed length or determined according to punctuation in the reference text.
[0044] Optionally, the question-answer pairs contained in the reference question can also be randomly extracted as candidate question-answer pairs.
[0045] For example, if the reference text is “What is human-computer interaction? Human-computer interaction is a study of the interaction between systems and users. What is the human-computer interaction interface? The human-computer interaction interface usually refers to the visible part, and the user communicates with the system through the human-computer interaction interface and performs operations.”
[0046] If the length of the sliding window is determined according to the punctuation marks in the reference text, that is, the question mark and the period in the reference text are taken as the end positions of each sliding window, then the candidate question-answer pairs obtained by sliding window processing on the above reference text are: question: "What is human-computer interaction?" answer: "Human-computer interaction is a study of the interaction between systems and users." and question: "What is the human-computer interaction interface?" answer: "The human-computer interaction interface usually refers to the part visible to the user, and the user communicates with the system through the human-computer interaction interface and performs operations."
[0047] Alternatively, the candidate question-answer pairs can also be randomly extracted from the above reference text, and the candidate question-answer pairs obtained can be: question: "What is human-computer interaction?" answer: "Human-computer interaction is a study of the interaction between systems and users.", or the extracted candidate question-answer pairs can also be: question: "What is the human-computer interaction interface?" answer: "The human-computer interaction interface usually refers to the part visible to the user, and the user communicates with the system through the human-computer interaction interface and performs operations.", and the like, which are not limited in the present disclosure.
[0048] Optionally, if the reference corpus is a common question-answer pair corpus, the common question-answer pair corpus can be used as the candidate question-answer pairs.
[0049] In step 103, the first similarity between the candidate question in each candidate question-answer pair and the reference question is determined, and the second similarity between the corresponding candidate answer in the candidate question-answer pair and the reference answer is determined.
[0050] Optionally, the first similarity can be obtained according to the Euclidean distance between the candidate question and the reference question, and the second similarity can be obtained according to the Euclidean distance between the candidate answer and the reference answer.
[0051] For example, the vector corresponding to the candidate question is (1, 1, 2, 1, 3), the vector corresponding to the reference question is (1, 3, 1, 5, 2), the vector corresponding to the candidate answer is (2, 1, 1, 1, 4), and the vector corresponding to the reference answer is (1, 2, 1, 5, 4).
[0052] The Euclidean distance d1 between the candidate question and the reference question is:
[0053]
[0054] The Euclidean distance d2 between the candidate answer and the reference answer is:
[0055]
[0056] Optionally, the first similarity can also be determined according to the cosine similarity between the candidate question and the reference question, and the second similarity can be determined according to the cosine similarity between the candidate answer and the reference answer.
[0057] For example, the vector corresponding to the candidate question is (1, 2, 2, 1, 3), the vector corresponding to the reference question is (1, 3, 1, 2, 1), the vector corresponding to the candidate answer is (2, 2, 1, 1, 3), and the vector corresponding to the reference answer is (1, 3, 1, 2, 4).
[0058] The cosine similarity S1 between the candidate question and the reference question is:
[0059]
[0060] The cosine similarity S2 between the candidate answer and the reference answer is:
[0061]
[0062] It should be noted that the above examples are only illustrative and cannot be regarded as a limitation on the cosine similarity in the embodiments of the present disclosure.
[0063] In step 104, according to each first similarity and the corresponding second similarity, an extended question and answer pair corresponding to the reference question and answer pair is determined from the plurality of candidate question and answer pairs.
[0064] Optionally, a similarity threshold value can be set for the first similarity and the second similarity, and in response to the first similarity and the second similarity of the candidate question and answer pair being greater than the corresponding similarity threshold value, the candidate question and answer pair is the extended question and answer pair corresponding to the reference question and answer pair.
[0065] Optionally, if the sum of the first similarity and the second similarity of the candidate question and answer pair is greater than a set threshold value, the candidate question and answer pair is the extended question and answer pair corresponding to the reference question and answer pair.
[0066] In the embodiments of the present disclosure, the reference question and answer pair and the reference corpus are first obtained, then a plurality of candidate question and answer pairs are extracted from the reference corpus, the first similarity between the candidate question and the reference question in each candidate question and answer pair is determined, and the second similarity between the corresponding candidate answer and the reference answer in the candidate question and answer pair is determined, and finally the extended question and answer pair corresponding to the reference question and answer pair is determined from the plurality of candidate question and answer pairs according to each first similarity and the corresponding second similarity. Thus, the extended question and answer pair corresponding to the reference question and answer pair is obtained from a large amount of reference corpus, the number and diversity of the extended question and answer pair are improved, and the question and answer accuracy in the intelligent system is further improved.
[0067] Figure 2 The flowchart of the method for generating a question and answer pair provided by an embodiment of the present disclosure is shown in FIG. 1.Figure 2 As shown, the method for generating the question-answer pair can include the following steps:
[0068] In step 201, a reference question-answer pair and a reference corpus are obtained, wherein the reference question-answer pair includes a reference question and a reference answer.
[0069] In step 202, a plurality of candidate question-answer pairs are extracted from the reference corpus, wherein each candidate question-answer pair includes a candidate question and a candidate answer.
[0070] The specific implementation forms of steps 201-202 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.
[0071] In step 203, the candidate question in each candidate question-answer pair and the reference question are input into a trained model to determine a first similarity between the candidate question and the reference question.
[0072] In step 204, the corresponding candidate answer in the candidate question-answer pair and the reference answer are input into the trained model to determine a second similarity between the candidate answer and the reference answer.
[0073] It should be noted that the trained model in the present disclosure can be any model that can be used to calculate the similarity between two texts, and the structure and type of the model are not limited in the present disclosure.
[0074] In step 205, the confidence of each candidate question-answer pair is determined according to each first similarity and the corresponding second similarity.
[0075] Optionally, the first similarity and the corresponding second similarity are both greater than or less than a preset similarity threshold, and the confidence of the candidate question-answer pair can be determined according to the average value between the first similarity and the second similarity.
[0076] For example, the similarity threshold is 50%, the first similarity is 80%, and the second similarity is 90%. The first similarity and the second similarity are both greater than the similarity threshold, and the confidence of the candidate question-answer pair is 85%.
[0077] For example, the similarity threshold is 50%, the first similarity is 30%, and the second similarity is 20%. The first similarity and the second similarity are both less than the similarity threshold, and the confidence of the candidate question-answer pair is 25%.
[0078] Optionally, any one of the first similarity and the corresponding second similarity is greater than the similarity threshold, and the other is less than the similarity threshold. The confidence of the candidate question-answer pair can be determined according to the minimum value of the first similarity and the second similarity.
[0079] For example, the similarity threshold is 50%, the first similarity is 80%, and the second similarity is 30%. The first similarity is greater than the similarity threshold, and the second similarity is less than the similarity threshold. The confidence of the candidate question and answer pair can be 30%.
[0080] It should be noted that the above examples are only illustrative and cannot be used as a limitation on the first similarity, the second similarity, and the confidence of the candidate question and answer pair in the embodiments of the present disclosure.
[0081] Step 206: Obtain the context corresponding to the candidate answer in each candidate question and answer pair with a confidence greater than a threshold.
[0082] Optionally, the context of the candidate answer can be obtained from the reference text according to the start position and the end position of the candidate answer in the reference text.
[0083] Step 207: Based on each preset question template, the candidate question corresponding to the candidate answer is expanded according to the context corresponding to the candidate answer to generate a plurality of expansion questions corresponding to the candidate answer.
[0084] Optionally, the question generation network can also be used to generate a plurality of expansion questions corresponding to the candidate answer.
[0085] The question generation network can use an encoder-decoder structure. The question generation network can include a pre-trained language model, an encoder, and a decoder. The pre-trained language model can encode the context of the candidate answer into a context word embedding. Then, the encoder can encode the context word embedding to generate an encoding representation corresponding to the expansion question, and then the decoder can decode the encoding representation of the expansion question to generate the expansion question. The structure of the encoder and the decoder can be set as needed, for example, the encoder can use a two-layer bidirectional long short-term memory network, and the decoder can use a two-layer long short-term memory network.
[0086] Optionally, after generating a plurality of expansion questions corresponding to the candidate answer, the plurality of expansion questions can be further optimized. For example, the mutual information between each expansion question and the candidate answer can be determined, and then the plurality of expansion questions can be screened according to the plurality of mutual information.
[0087] The mutual information can represent the similarity between each expansion question and the candidate answer, that is, the greater the mutual information, the higher the similarity between the words in the expansion question and the words in the candidate answer.
[0088] Optionally, the plurality of expansion questions can be screened according to the plurality of mutual information, or the syntax or completeness of the expansion question can be optimized based on the mutual information, which is not limited in the present disclosure.
[0089] For example, the candidate answer and the extended question are input into the mutual information maximization model, and the mutual information maximization model outputs the optimized extended question.
[0090] It can be understood that, in the process of training, after the mutual information maximization model outputs the optimized extended question, the parameters in the model can be corrected in reverse based on the difference between the mutual information and the expected mutual information between the output optimized extended question and the candidate answer.
[0091] In the embodiments of the present disclosure, after generating the plurality of extended questions corresponding to the candidate answer, the mutual information between each extended question and the candidate answer is further determined, and the plurality of extended questions are screened according to the plurality of mutual information to obtain the extended question and answer pair with higher accuracy, thereby further improving the question and answer accuracy in the intelligent system.
[0092] In the embodiments of the present disclosure, first, the reference question and answer pair and the reference corpus are obtained, a plurality of candidate question and answer pairs are extracted from the reference corpus, the candidate question and the reference question in each candidate question and answer pair are input into the trained model to determine the first similarity between the candidate question and the reference question, the corresponding candidate answer and the reference answer are input into the trained model to determine the second similarity between the candidate answer and the reference answer, the confidence of each candidate question and answer pair is determined according to each first similarity and the corresponding second similarity, the candidate answer corresponding to the context of each candidate question and answer pair with a confidence greater than a threshold is obtained, and finally, based on each preset question template, the candidate question corresponding to the candidate answer is expanded according to the context corresponding to the candidate answer to generate a plurality of extended questions corresponding to the candidate answer. Thus, the candidate question corresponding to the candidate answer is expanded to generate a plurality of extended questions, thereby further improving the number and diversity of the extended question and answer pairs, and further improving the question and answer accuracy in the intelligent system.
[0093] To achieve the above-mentioned embodiments, the present disclosure further provides a question and answer pair generation device.
[0094] Figure 3 The structure diagram of the question and answer pair generation device provided by an embodiment of the present disclosure.
[0095] As Figure 3 shown, the question and answer pair generation device 300 can include an acquisition module 310, an extraction module 320, a first determination module 330, and a second determination module 340.
[0096] The acquisition module 310 is configured to obtain a reference question and answer pair and a reference corpus, wherein the reference question and answer pair includes a reference question and a reference answer.
[0097] The extraction module 320 is configured to extract a plurality of candidate question-answer pairs from the reference corpus, where each candidate question-answer pair comprises a candidate question and a candidate answer.
[0098] The first determination module 330 is configured to determine a first similarity between the candidate question in each candidate question-answer pair and the reference question, and a second similarity between the corresponding candidate answer in the candidate question-answer pair and the reference answer.
[0099] The second determination module 340 is configured to determine, according to each first similarity and the corresponding second similarity, an extended question-answer pair corresponding to the reference question-answer pair from the plurality of candidate question-answer pairs.
[0100] The functions and specific implementation principles of the above modules in the embodiments of the present disclosure can be referred to the above method embodiments, and will not be described here.
[0101] In a possible implementation, the acquisition module 310 is specifically configured to:
[0102] acquire the reference question-answer pair;
[0103] parse the reference question-answer pair to determine a field to which the reference question-answer pair belongs;
[0104] extract the reference corpus from each candidate corpus according to the field to which the reference question-answer pair belongs and the field to which each candidate corpus belongs.
[0105] In a possible implementation, the reference corpus comprises a reference text, and the extraction module 320 is specifically configured to:
[0106] perform sliding window processing on the reference text based on a preset sliding window to extract the plurality of candidate question-answer pairs.
[0107] In a possible implementation, the first determination module 330 is specifically configured to:
[0108] input the candidate question in each candidate question-answer pair and the reference question into a trained model to determine the first similarity between the candidate question and the reference question;
[0109] input the corresponding candidate answer and the reference answer into the trained model to determine the second similarity between the candidate answer and the reference answer.
[0110] In a possible implementation, the second determination module 340 is specifically configured to:
[0111] determine a confidence of each candidate question-answer pair according to each first similarity and the corresponding second similarity;
[0112] acquire a context corresponding to the candidate answer in each candidate question-answer pair with a confidence greater than a threshold value;
[0113] According to the context corresponding to the candidate answer, the candidate question corresponding to the candidate answer is expanded according to each preset question template to generate a plurality of expansion questions corresponding to the candidate answer.
[0114] In a possible implementation, the second determination module 340 is further configured to:
[0115] determine mutual information between each expansion question and the candidate answer;
[0116] screen the plurality of expansion questions according to the plurality of mutual information.
[0117] The functions of the above modules and the specific implementation principles in the embodiments of the present disclosure can be referred to the above method embodiments, which will not be described here.
[0118] The generation device of the question and answer pair in the embodiments of the present disclosure first acquires the reference question and answer pair and the reference corpus, then extracts a plurality of candidate question and answer pairs from the reference corpus, determines the first similarity between the candidate question in each candidate question and answer pair and the reference question, and the second similarity between the corresponding candidate answer in the candidate question and answer pair and the reference answer, and finally determines the expansion question and answer pair corresponding to the reference question and answer pair contained in the plurality of candidate question and answer pairs according to each first similarity and the corresponding second similarity. Thus, the expansion question and answer pair corresponding to the reference question and answer pair is obtained from a large amount of reference corpus, which improves the quantity and diversity of the expansion question and answer pair, and further improves the question and answer accuracy in the intelligent system.
[0119] In order to implement the above-mentioned embodiments, the present disclosure further proposes a computer device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the generation method of the question and answer pair proposed in the foregoing embodiments of the present disclosure when executing the program.
[0120] In order to implement the above-mentioned embodiments, the present disclosure further proposes a non-transitory computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the generation method of the question and answer pair proposed in the foregoing embodiments of the present disclosure.
[0121] In order to implement the above-mentioned embodiments, the present disclosure further proposes a computer program product, when the instructions in the computer program product are executed by a processor, the generation method of the question and answer pair proposed in the foregoing embodiments of the present disclosure is executed.
[0122] Figure 4 A block diagram of an exemplary computer device suitable for implementing embodiments of the present disclosure is shown. Figure 4 The displayed computer device 12 is only an example and should not impose any limitation on the functions and use range of the embodiments of the present disclosure.
[0123] As Figure 4As shown, the computer device 12 is in the form of a general-purpose computing device. The components of the computer device 12 can include, but are not limited to, one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 to the processing unit 16.
[0124] The bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration bus, a processor or local bus using any of a variety of bus architectures. By way of example, these architectures include Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0125] The computer device 12 typically includes a variety of computer system readable media. Such media can be any available media that is located either in or out of the computer device 12, such as volatile and non-volatile media, removable and non-removable media.
[0126] The memory 28 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The computer device 12 can further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, a storage system 34 can be provided for reading from and writing to non-removable, non-volatile magnetic media (e.g., a "hard drive"). Figure 4 not shown, commonly referred to as a "hard disk drive"). Although not specifically shown, the computer device 12 typically further includes other removable / non-removable, volatile / non-volatile computer system storage media such as a magnetic floppy disk drive (with associated floppy diskette) 36 and / or optical disk drive (e.g., a CD-ROM or DVD drive) 38. As will be appreciated by persons skilled in the relevant art, the storage media 36, 38 of the storage system 34 can be employed in connection with performing input / output operations with respect to the computer device 12. Figure 4A disk drive, a floppy disk drive, a CD-ROM drive, a DVD-ROM drive, or other removable media drive, can be provided for reading from and writing to a removable n onvolatile magnetic disk (e.g., a "floppy disk"), and to a removable nonvolatile optical disk (e.g., a CD ROM, a DVD ROM, or another optical medium). In these instances, each drive can be connected to the bus 18 by one or more data media interfaces. The memory 28 can include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the disclosure.
[0127] Program / utility 40, having a set (at least one) of program modules 42, can be stored in memory 28 by way of example, such as an operating system, one or more application programs, other program modules, and program data, each or some combination thereof, may
[0128] Computer device 12 can also communicate with one or more external devices 14 such as a keyboard, a pointing device, a display 24, etc.; one or more devices that enable a user to interact with computer device 12; and / or one or more devices that enable computer device 12 to communicate with one or more other computing devices. Such communication can be via input / output (I / O) interfaces 22. Further, computer device 12 can communicate with one or more networks (such as a Local Area Network (LAN), a Wide Area Network (WAN), and / or the Internet) through network adapter 20. As depicted, network adapter 20 communicates with the other components of computer device 12 via bus 18. It should be appreciated that although not shown, other hardware and / or software modules could be used in conjunction with computer device 12. Such as, but not limited to, microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc.
[0129] Processing unit 16 executes various program applications and data processing by running programs stored in system memory 28, such as implementing the methods mentioned in the foregoing embodiments.
[0130] The technical solution of the present disclosure first acquires a reference question-answer pair and a reference corpus, then extracts a plurality of candidate question-answer pairs from the reference corpus, determines a first similarity between a candidate question in each candidate question-answer pair and a reference question in the reference question-answer pair and a second similarity between a corresponding candidate answer in the candidate question-answer pair and a reference answer, and finally determines an expansion question-answer pair corresponding to the reference question-answer pair from the plurality of candidate question-answer pairs according to each first similarity and the corresponding second similarity. In this way, the expansion question-answer pair corresponding to the reference question-answer pair is acquired from a large amount of reference corpus, the number and diversity of the expansion question-answer pair are improved, and the question and answer accuracy in the intelligent system is further improved.
[0131] In the description of the present disclosure, the description of the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present disclosure. In the present description, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any suitable manner in any one or more embodiments or examples. In addition, the person skilled in the art can combine and combine the different embodiments or examples described in the present description and the features of the different embodiments or examples without contradiction.
[0132] In addition, the terms "first", "second" are only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is at least two, for example, two, three, etc., unless otherwise explicitly specified.
[0133] Any process or method descriptions in the flow charts or otherwise described herein can be understood as representing code modules, segments, or portions of code that include one or more executable instructions for implementing the specified logical functions or processes, and the preferred embodiments of the present disclosure include additional implementation involving other processes or elements as appropriate or desired for particular applications of the present disclosure. The various processes depicted can be conducted by specific hardware components or modules or by logic that programs the hardware components or modules to implement the processes and capabilities described in this disclosure.
[0134] The logic and / or steps represented in flow diagrams or otherwise described herein, for example, can be considered as a sequence of executable instructions, and can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For purposes of this specification, a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. The computer-readable medium can be a product of the manufacturing and / or processing. The computer-readable medium can include, but is not limited to, the following: an electronic connection (an electronic device having one or more wires), a portable computer diskette (a magnetic device), a RAM (random access memory), a ROM (read-only memory), an EPROM (erasable programmable ROM) or Flash memory, an optical fiber device, and a portable CD ROM. Additionally, the computer-readable medium can be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via, for example, an optical scanner, then compiled, interpreted, or otherwise processed, and stored in a computer memory in order to be executed.
[0135] It should be understood that portions of the present disclosure can be implemented in hardware, software, firmware, or combinations thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. As such, if implemented in hardware, and in another embodiment, any of the following technologies, or combinations thereof, can be used: discrete logic circuitry having logic gates for implementing logic functions upon an application of data signals, application-specific integrated circuits having appropriate combinational logic gates, programmable gate arrays (PGA), field-programmable gate arrays (FPGA), and the like.
[0136] Those of ordinary skill in the art can understand that all or part of the steps carried out by the above-mentioned embodiments can be completed by programs instructing relevant hardware, and the programs can be stored in a computer-readable storage medium. When the programs are executed, one or a combination of the steps of the method embodiments is included.
[0137] In addition, each functional unit in each embodiment of the present disclosure can be integrated in one processing module, or each unit can exist physically separately, or two or more units can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software functional module. When the integrated module is realized in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer readable storage medium.
[0138] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present disclosure have been shown and described above, it should be understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure, and those skilled in the art can make changes, modifications, replacements and variations to the above embodiments within the scope of the present disclosure.
Claims
1. A method for generating a question-answer pair, characterized by, The method comprises the following steps: obtaining a reference question and answer pair; parsing the reference question and answer pair to determine the field to which the reference question and answer pair belongs; extracting reference corpus from each candidate corpus according to the field to which the reference question and answer pair belongs and the field to which each candidate corpus belongs, wherein the reference question and answer pair comprises a reference question and a reference answer; extracting a plurality of candidate question and answer pairs from the reference corpus, wherein each candidate question and answer pair comprises a candidate question and a candidate answer; determining a first similarity between the candidate question in each candidate question and answer pair and the reference question, and a second similarity between the corresponding candidate answer in the candidate question and answer pair and the reference answer, wherein the first similarity and the second similarity are respectively set to a similarity threshold; determining a confidence of each candidate question and answer pair according to each first similarity and the corresponding second similarity; obtaining the context corresponding to the candidate answer in each candidate question and answer pair with a confidence greater than a threshold; expanding the candidate question corresponding to the candidate answer according to the context corresponding to the candidate answer based on each preset question template to generate a plurality of expansion questions corresponding to the candidate answer; determining mutual information between each expansion question and the candidate answer; screening the plurality of expansion questions according to a plurality of mutual information. The method further comprises: generating a plurality of expansion questions corresponding to the candidate answer using a question generation network.
2. The method of claim 1, wherein, The reference corpus contains reference text, and the extracting a plurality of candidate question and answer pairs from the reference corpus comprises: performing sliding window processing on the reference text based on a preset sliding window to extract a plurality of candidate question and answer pairs.
3. The method of claim 1, wherein, The determining a first similarity between the candidate question in each candidate question and answer pair and the reference question, and a second similarity between the corresponding candidate answer in the candidate question and answer pair and the reference answer comprises: inputting the candidate question in each candidate question and answer pair and the reference question into a trained model to determine the first similarity between the candidate question and the reference question; inputting the corresponding candidate answer and the reference answer into the trained model to determine the second similarity between the candidate answer and the reference answer.
4. An apparatus for generating a question-answer pair, the apparatus comprising: The method comprises the following steps: an obtaining module is configured to obtain a reference question and answer pair; parsing the reference question and answer pair to determine the field to which the reference question and answer pair belongs; extracting reference corpus from each candidate corpus according to the field to which the reference question and answer pair belongs and the field to which each candidate corpus belongs, wherein the reference question and answer pair comprises a reference question and a reference answer; an extracting module is configured to extract a plurality of candidate question and answer pairs from the reference corpus, wherein each candidate question and answer pair comprises a candidate question and a candidate answer; a first determining module is configured to determine a first similarity between the candidate question in each candidate question and answer pair and the reference question, and a second similarity between the corresponding candidate answer in the candidate question and answer pair and the reference answer, wherein the first similarity and the second similarity are respectively set to a similarity threshold; a second determining module is configured to determine a confidence of each candidate question and answer pair according to each first similarity and the corresponding second similarity; a third determining module is configured to obtain the context corresponding to the candidate answer in each candidate question and answer pair with a confidence greater than a threshold; an expanding module is configured to expand the candidate question corresponding to the candidate answer according to the context corresponding to the candidate answer based on each preset question template to generate a plurality of expansion questions corresponding to the candidate answer; a fourth determining module is configured to determine mutual information between each expansion question and the candidate answer; a screening module is configured to screen the plurality of expansion questions according to a plurality of mutual information. The second determining module is configured to determine a confidence degree of each candidate question-answer pair according to each first similarity and a corresponding second similarity; obtain a context corresponding to a candidate answer in each candidate question-answer pair with a confidence degree greater than a threshold; expand a candidate question corresponding to the candidate answer according to the context corresponding to the candidate answer based on each preset question template to generate a plurality of expanded questions corresponding to the candidate answer; determine mutual information between each expanded question and the candidate answer; screen the plurality of expanded questions according to the mutual information; and The question generation network is used to generate a plurality of expanded questions corresponding to the candidate answer.
5. The apparatus of claim 4, wherein, The reference corpus contains reference texts, and the extraction module is specifically configured to: The reference texts are processed by a sliding window based on a preset sliding window to extract a plurality of candidate question-answer pairs.
6. The apparatus of claim 4, wherein, The first determining module is specifically configured to: Input a candidate question in each candidate question-answer pair and the reference question into a trained model to determine a first similarity between the candidate question and the reference question; Input the corresponding candidate answer and the reference answer into the trained model to determine a second similarity between the candidate answer and the reference answer.
7. A computer device, comprising: The computer program is executed by the processor to implement the question-answer pair generation method of any one of claims 1-3.
8. A computer readable storage medium storing a computer program, characterized in that, The computer program is executed by the processor to implement the question-answer pair generation method of any one of claims 1-3.
9. A computer program product, characterised in that, The computer program is executed by the processor to implement the question-answer pair generation method of any one of claims 1-3.