Question and answer pair generation method and device, equipment and medium

By determining text types and pattern matching rules, the knowledge extraction of text in the enterprise knowledge base is solved, and the problem of cumbersome and low efficiency in the existing technology is solved, and efficient and low-cost Q&A pair generation is achieved. .

CN119025633AActive Publication Date: 2024-11-26CHINA CONSTRUCTION BANK +1

Patent Information

Application Number
CN202410818458.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-11-26
Estimated Expiration
2044-06-24

AI Technical Summary

Technical Problem

The generation process of Q&A pairs in the existing enterprise knowledge base is cumbersome, the generation efficiency is low, and it relies on manual sorting and high-quality Q&A pairs. The large-scale neural network generation method requires a large amount of computing resources and high cost of manual labeling.

Method used

By determining the text type, using pattern matching rules to extract knowledge of the target text, generate question-and-answer pairs, simplify the generation process and improve efficiency. The specific steps include: responding to the Q&A production request, determining the text type, extracting text knowledge and knowledge elements based on the pattern matching rules, and constructing Q&A based on the generation rules.

Benefits of technology

The process of generating questions and answers is simplified, the generation efficiency is improved, the threshold for technicians and computing resource requirements are reduced, and the quality of questions and answers is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025633A_ABST
    Figure CN119025633A_ABST
Patent Text Reader

Abstract

The invention relates to the field of artificial intelligence, in particular to a question and answer pair generation method and device, equipment and a medium, and is used for solving the problems that the generation process of question and answer pairs is tedious and the generation efficiency is low. The method comprises the following steps: in response to a question-answer pair production request, determining a text type of a target text based on text features of the target text corresponding to the question-answer pair production request; performing knowledge extraction on the target text by utilizing a mode matching rule corresponding to the text type to obtain text knowledge and text knowledge elements; and generating a question-answer pair of the target text based on the text knowledge, the text knowledge elements and a question-answer pair generation rule corresponding to the mode matching rule. The text knowledge and the text knowledge elements in the text are extracted by utilizing the mode matching rule corresponding to the text type of the text, and then the text knowledge elements and the text knowledge are converted into questions and answers according to the question and answer pair generation rule corresponding to the mode matching rule, so that the question and answer pair generation process is simplified, and the generation efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and specifically to a method, device, equipment and medium for generating question-answer pairs. Background Art

[0002] Enterprise knowledge bases are used in all walks of life. They can help enterprises realize intelligent human-machine collaboration systems for online services, improve the efficiency of agent services, and reduce labor costs and business knowledge learning costs for new employees. However, existing enterprise knowledge bases are heavily dependent on the quality of manually organized knowledge bases, and the machine learning or deep learning methods used internally rely on a large number of high-quality question-answer pairs. Therefore, the construction of question-answer pairs is the basic work in the construction of enterprise knowledge bases.

[0003] At present, it takes a lot of effort to manually sort out question-answer pairs from various unstructured texts, such as business documents, product manuals, requirement documents, training materials, etc. This solution is limited by the technical staff's understanding of the vertical field and is unable to build high-quality and in-depth question-answer pairs. The question-answer pairs generated by large-scale neural networks also require a lot of computing resources and manual labeling costs. In addition, it not only has a certain threshold for technical staff, but also it is difficult to explain the extraction process.

[0004] Therefore, the existing question-answer pair generation methods have the problems of cumbersome generation process and low generation efficiency. Summary of the invention

[0005] The embodiments of the present application provide a method, apparatus, device and medium for generating question-answer pairs, which are used to solve the problems of complicated generation process and low generation efficiency of question-answer pairs in the existing stage.

[0006] In a first aspect, the present application provides a method for generating a question-answer pair, the method comprising:

[0007] In response to a question-answer pair generation request, determining a text type of the target text based on text features of the target text corresponding to the question-answer pair generation request;

[0008] Extracting knowledge from the target text using a pattern matching rule corresponding to the text type to obtain text knowledge and text knowledge elements of the target text;

[0009] Based on the text knowledge, the text knowledge elements and the question-answer pair generation rule corresponding to the pattern matching rule, a question-answer pair of the target text is generated.

[0010] In a possible embodiment, the extracting knowledge from the target text using a pattern matching rule corresponding to the text type to obtain text knowledge and text knowledge elements of the target text includes:

[0011] Matching each pattern matching rule in the pattern matching rule set corresponding to the text type with the target text in sequence, and determining the pattern matching rule that successfully matches as a target pattern matching rule, wherein the target pattern matching rule contains a sub-matching pattern that matches a target text segment in the target text;

[0012] Extracting knowledge from the target text based on the target pattern matching rule to obtain text knowledge of the target text;

[0013] The text knowledge is divided based on the sub-matching patterns in the target pattern matching rule, and each divided text knowledge fragment is determined as the text knowledge element of the target text.

[0014] In a possible embodiment, each pattern matching rule in the pattern matching rule set corresponding to the text type is matched with the target text in sequence, including:

[0015] For any pattern matching rule, obtaining each sub-matching pattern in the pattern matching rule;

[0016] If each text segment in the target text matches each sub-matching pattern, it is determined that the pattern matching rule matches the target text.

[0017] In a possible embodiment, the method further includes:

[0018] Based on the pre-set knowledge filtering rules corresponding to the pattern matching rules, the text knowledge and the text knowledge elements are filtered to obtain filtering results; wherein, the knowledge filtering rules are to filter out the text knowledge corresponding to the text knowledge elements that do not conform to any preset parts of speech, and the preset parts of speech include part or all of predicates, adverbials, and proper nouns.

[0019] In a possible embodiment, the method further includes:

[0020] Based on the pre-set knowledge conversion rules corresponding to the pattern matching rules, the text knowledge elements are converted to obtain the processed text knowledge elements; wherein the knowledge conversion rules include deleting punctuation marks in the text knowledge elements and extracting proper nouns in the text knowledge elements.

[0021] In a possible embodiment, the generating the question-answer pair of the target text based on the text knowledge, the text knowledge elements and the question-answer pair generating rule corresponding to the pattern matching rule includes:

[0022] Based on the pattern matching rule, a target text knowledge element among the text knowledge elements is determined as a component element of the question; wherein the target text knowledge element is part or all of the text knowledge elements that match the sub-matching pattern in the pattern matching rule;

[0023] Combining the component elements with the preset question words corresponding to the text type, and determining the combination result as the question of the question-answer pair;

[0024] The text knowledge elements among the text knowledge elements except the target text knowledge element are determined as answers to the question-answer pair.

[0025] In a second aspect, the present application provides a device for generating a question-answer pair, the device comprising:

[0026] A determination module, configured to respond to a question-answer pair generation request and determine a text type of the target text based on text features of the target text corresponding to the question-answer pair generation request;

[0027] An extraction module, used to extract knowledge from the target text using a pattern matching rule corresponding to the text type, to obtain text knowledge and text knowledge elements of the target text;

[0028] A generation module is used to generate question-answer pairs of the target text based on the text knowledge, the text knowledge elements and question-answer pair generation rules corresponding to the pattern matching rules.

[0029] In a possible embodiment, the extraction module is specifically used to:

[0030] Matching each pattern matching rule in the pattern matching rule set corresponding to the text type with the target text in sequence, and determining the pattern matching rule that successfully matches as a target pattern matching rule, wherein the target pattern matching rule contains a sub-matching pattern that matches a target text segment in the target text;

[0031] Extracting knowledge from the target text based on the target pattern matching rule to obtain text knowledge of the target text;

[0032] The text knowledge is divided based on the sub-matching patterns in the target pattern matching rule, and each divided text knowledge fragment is determined as the text knowledge element of the target text.

[0033] In a possible embodiment, the extraction module is specifically used to:

[0034] For any pattern matching rule, obtain each sub-matching pattern in the pattern matching rule;

[0035] If each text segment in the target text matches each sub-matching pattern, it is determined that the pattern matching rule matches the target text.

[0036] In a possible embodiment, the device further includes:

[0037] A filtering module is used to filter the text knowledge and the text knowledge elements based on a pre-set knowledge filtering rule corresponding to the pattern matching rule to obtain a filtering result; wherein the knowledge filtering rule is to filter out the text knowledge corresponding to the text knowledge elements that do not conform to any preset part of speech, and the preset part of speech includes part or all of the predicate, adverbial, and proper noun.

[0038] In a possible embodiment, the device further includes:

[0039] A conversion module is used to convert the text knowledge elements based on pre-set knowledge conversion rules corresponding to the pattern matching rules to obtain the processed text knowledge elements; wherein the knowledge conversion rules include deleting punctuation marks in the text knowledge elements and extracting proper nouns in the text knowledge elements.

[0040] In a possible embodiment, the generating module is specifically used to:

[0041] Based on the pattern matching rule, a target text knowledge element among the text knowledge elements is determined as a component element of the question; wherein the target text knowledge element is part or all of the text knowledge elements that match the sub-matching pattern in the pattern matching rule;

[0042] Combining the component elements with the preset question words corresponding to the text type, and determining the combination result as the question of the question-answer pair;

[0043] The text knowledge elements among the text knowledge elements except the target text knowledge element are determined as answers to the question-answer pair.

[0044] In a third aspect, the present application provides an electronic device, including:

[0045] A memory for storing program instructions;

[0046] The processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods in the first aspect according to the obtained program instructions.

[0047] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes any one of the methods described in the first aspect.

[0048] In a fifth aspect, the present application provides a computer program product, comprising: a computer program code, when the computer program code is run on a computer, the computer executes any one of the methods described in the first aspect.

[0049] The beneficial effects of this application are as follows:

[0050] In an embodiment of the present application, in response to a question-answer pair generation request, the text type of the target text is determined based on the text features of the target text corresponding to the question-answer pair generation request; knowledge is extracted from the target text using a pattern matching rule corresponding to the text type to obtain text knowledge and text knowledge elements of the target text; and a question-answer pair of the target text is generated based on the text knowledge, text knowledge elements, and question-answer pair generation rules corresponding to the pattern matching rules. In this way, by obtaining the text type of the text, extracting the text knowledge and text knowledge elements in the text using the pattern matching rules corresponding to the text type, and then converting the text knowledge elements and text knowledge into questions and answers according to the question-answer pair generation rules corresponding to the pattern matching rules, the generation process of the question-answer pair is simplified and the generation efficiency of the question-answer pair is improved by customizing the pattern matching rules and the question-answer pair generation rules.

[0051] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 A flowchart of a method for generating question-answer pairs provided in an embodiment of the present application;

[0053] Figure 2 A flowchart of another method for generating question-answer pairs provided in an embodiment of the present application;

[0054] Figure 3 A flowchart of another method for generating question-answer pairs provided in an embodiment of the present application;

[0055] Figure 4 A schematic diagram of the structure of a device for generating question-answer pairs provided in an embodiment of the present application;

[0056] Figure 5A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0057] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.

[0058] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.

[0059] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.

[0060] In the technical solution of this application, the acquisition, transmission, storage, and use of data are in compliance with the requirements of relevant national laws and regulations.

[0061] Before introducing the method for generating question-answer pairs provided in the embodiment of the present application, in order to facilitate understanding, the technical background of the embodiment of the present application is first introduced in detail below.

[0062] Enterprise knowledge bases are used in all walks of life. They can help enterprises realize intelligent human-machine collaboration systems for online services, improve the efficiency of agent services, and reduce labor costs and business knowledge learning costs for new employees. However, existing enterprise knowledge bases are heavily dependent on the quality of manually organized knowledge bases, and the machine learning or deep learning methods used internally rely on a large number of high-quality question-answer pairs. Therefore, the construction of question-answer pairs is the basic work in the construction of enterprise knowledge bases.

[0063] At present, it takes a lot of effort to manually sort out question-answer pairs from various unstructured texts, such as business documents, product manuals, requirement documents, training materials, etc. This solution is limited by the technical staff's understanding of the vertical field and is unable to build high-quality and in-depth question-answer pairs. The question-answer pairs generated by large-scale neural networks also require a lot of computing resources and manual labeling costs. In addition, it not only has a certain threshold for technical staff, but also it is difficult to explain the extraction process.

[0064] Therefore, the existing question-answer pair generation methods have the problems of cumbersome generation process and low generation efficiency.

[0065] In view of this, in order to solve the problem that the generation process of question-answer pairs is cumbersome and the generation efficiency is low at the current stage, the embodiment of the present application provides a method, device, equipment and medium for generating question-answer pairs. The following describes some preferred embodiments of the present application in conjunction with the drawings of the specification.

[0066] See also Figure 1 , Figure 1 A flowchart of a method for generating question-answer pairs is provided in an embodiment of the present application. The method can be implemented by an electronic device, which may be a terminal or a server. The present application does not limit this. The method includes the following steps.

[0067] In step 101, in response to a question-answer pair generation request, a text type of a target text is determined based on text features of a target text corresponding to the question-answer pair generation request.

[0068] During specific implementation, after receiving the target text corresponding to the question-and-answer production request, the target text can be parsed, and the text type of the target text can be determined based on the text features of the target text, such as keywords. The text type of the target text can be pre-divided according to the semantic features and functions of each type of text, for example, it can include the following categories: definition class, introduction class, basis class, channel class, processing material class, processing location class, condition class, reason class, requirement class, etc.

[0069] Definition text refers to text with clear meanings and characteristics of concepts, terms or objects, such as academic documents, professional manuals and other texts involving relevant paragraphs / content of definitions.

[0070] Introductory text refers to text that can provide an overview of a person, organization, product, service, event, concept or theory, such as brochures, product manuals and other texts that contain relevant paragraphs / content related to the introduction.

[0071] Basis text refers to text that can provide basis, evidence, rules, legal provisions, policy guidance, standard specifications, etc. For example, text of relevant paragraphs / content related to basis in legal provisions, business operation procedures, etc.

[0072] Channel text refers to text related to the channels and descriptions of information dissemination or services, such as customer support contact information, service acquisition methods, product purchase channels, business processing methods, and other text related to channel-related paragraphs / content.

[0073] Processing materials text refers to text used to guide how to complete the materials, procedures or operating steps required for a specific business, such as the required materials, precautions, and other relevant paragraphs / content related to the processing materials.

[0074] Processing location text refers to text that involves geographical location and place descriptions when handling business, such as location introductions, location instructions, maps, facility layouts, and other text that contains relevant paragraphs / content related to the processing location.

[0075] Conditional text refers to text that sets rules, prerequisites or standards to explain actions, qualifications, requirements and applicable conditions. For example, texts related to conditions in policy documents, contracts, terms of service, competition rules, etc.

[0076] Causal texts refer to texts that aim to explain, analyze or explore the causes, motivations or background of a phenomenon, event or result, such as news reports, academic research, historical research, accident investigation reports and other texts that contain relevant paragraphs / content related to causes.

[0077] Requirements text refers to the text that clearly states the conditions, standards or expectations that need to be met, such as skills, documents, qualifications, and quality standards. For example, texts related to requirements such as project proposals and job requirements.

[0078] It should be noted that the text types listed above are only possible text types listed in the embodiments of the present application. The actual text type categories are not necessarily as listed above. The specific text type can be set by technical personnel according to the actual application situation, and the present application does not limit this.

[0079] In step 102, knowledge is extracted from the target text using pattern matching rules corresponding to the text type to obtain text knowledge and text knowledge elements of the target text.

[0080] In the specific implementation, taking the target text as unstructured text as an example, the text knowledge in the unstructured text generally has certain rules, which include language rules, entities and relationships, themes and topics, time series and other aspects. These rules can be used to quickly extract information and knowledge from the text. Therefore, the pattern matching rules corresponding to each text type can be configured according to these rules, and then the target text can be extracted from the knowledge using the pattern matching rules that match the text type. Among them, the text mode suitable for the knowledge extraction task of the unstructured target text can be a pure text mode or a mixed mode. The pure text mode uses pure text information for matching without adding additional information, such as matching letters in the text, matching multiple consecutive Chinese characters in the text, etc. For example, the pure text mode can be expressed by regular expressions, and the mixed mode adds other information in addition to the pure text information, such as matching the name + place name fragments in the text.

[0081] In specific implementation, each pattern matching rule in the pattern matching rule set corresponding to the text type can be matched with the target text in turn, and the pattern matching rule that matches successfully is determined as the target pattern matching rule, and the target pattern matching rule contains a sub-matching pattern that matches the target text fragment in the target text, wherein the target text fragment is, for example, a keyword in the target text. For example, the sub-matching pattern may include keywords, phrases, URLs, N consecutive characters, N numbers, part-of-speech features, semantic features, etc. Knowledge is extracted from the target text based on the target pattern matching rule to obtain text knowledge of the target text. Finally, the text knowledge is divided based on the sub-matching pattern in the target pattern matching rule, and each divided text knowledge fragment is determined as a text knowledge element of the target text, wherein each sub-matching pattern corresponds to a text knowledge element.

[0082] In specific implementation, in the process of matching each pattern matching rule in the pattern matching rule set corresponding to the text type with the target text in turn, for any pattern matching rule, each sub-matching pattern in the pattern matching rule can be obtained; if each text fragment in the target text matches the sub-matching pattern, it is determined that the pattern matching rule matches the target text.

[0083] For example, the text type of the target text A is channel type. Three pattern matching rules are preset in the pre-set channel type pattern matching rule set, namely pattern matching rule 1, pattern matching rule 2, and pattern matching rule 3, and each pattern matching rule is configured according to the text type. For example, the channel type text usually contains relevant channel type texts such as "pass" and "adopt". Therefore, the channel type pattern matching rules can be configured as "(pass)(n characters)(method)", "(adopt)(n characters)(method)", "(pass)(n characters)(processing)", etc. Assuming that pattern matching rule 1 is "(pass)(n characters)(method)", pattern matching rule 2 is "(adopt)(n characters)(method)", and pattern matching rule 3 is "(pass)(n characters)(processing)", then the target text A can be matched with each pattern matching rule in turn. If the target text A includes the sub-matching patterns corresponding to pattern matching rule 3, that is, "(pass), (n characters), (processing)", then rule 3 is matched successfully.

[0084] Use pattern matching rule 3 to extract text knowledge of target text A: Assume that the extracted text knowledge a is (the business can be handled through the "Residence Permit Handling" column in the "One-stop Service" platform.), then the text knowledge a can be divided based on the "(through), (n characters), (handling)" in pattern matching rule 3, that is, the text knowledge fragments after division are fragment 1: can, fragment 2: through, fragment 3: "Residence Permit Handling" column in the "One-stop Service" platform, fragment 4: handling, fragment 5: business, that is, the text knowledge elements of target text A are: text knowledge element 1: can, text knowledge element 2: through, text knowledge element 3: "Residence Permit Handling" column in the "One-stop Service" platform, text knowledge element 4: handling, text knowledge element 5: business.

[0085] For another example, the text type of the target text B is a definition class. In the process of matching the target text B in turn with each pattern matching rule in the pattern matching rule set corresponding to the definition class, the successfully matched pattern matching rule is pattern matching rule 2, and pattern matching rule 2 is "(n characters) (refers to) (n characters)". Pattern matching rule 2 is used to extract knowledge from the target text B, and the extracted text knowledge b is (The Seven Sages of the Bamboo Grove refers to seven famous scholars in the late Wei and early Jin dynasties: Ruan Ji, Ji Kang, Shan Tao, Liu Ling, Ruan Xian, Xiang Xiu, and Wang Rong.). Afterwards, the text knowledge b can be divided based on (n characters), (refers to), and (n characters) in pattern matching rule 2, and the text knowledge elements after division are: Text knowledge element 1: The Seven Sages of the Bamboo Grove, Text knowledge element 2: refers to, Text knowledge element 3: Seven famous scholars in the late Wei and early Jin dynasties: Ruan Ji, Ji Kang, Shan Tao, Liu Ling, Ruan Xian, Xiang Xiu, and Wang Rong.

[0086] The following is an example of the present application in which the target pattern matching rules corresponding to each text type are used to extract knowledge from various target texts, and the text knowledge and text knowledge elements corresponding to the obtained target texts are shown in Table 1.

[0087] Table 1

[0088]

[0089]

[0090]

[0091] It should be noted that if no pattern matching rule is matched in the process of matching the target text with the pattern matching rules in the pattern matching rule set corresponding to the text type in turn, then based on the matching results of the target text and the pattern matching rules, the pattern matching rule with the highest similarity can be used as the target pattern matching rule, or the pattern matching rule with the highest frequency of use can be used as the target pattern matching rule, and the present application does not limit this. If there are multiple pattern matching rules that are successfully matched in the process of matching the target text with the pattern matching rules in the pattern matching rule set corresponding to the text type in turn, then one can be randomly selected from the successfully matched pattern matching rules, or all the successfully matched pattern matching rules can be used as the target pattern matching rules. Afterwards, the target text can be extracted from the successfully matched pattern matching rules respectively, and a variety of extraction results can be obtained at this time, and the present application does not limit this.

[0092] In step 103, question-answer pairs of the target text are generated based on the text knowledge, text knowledge elements, and question-answer pair generation rules corresponding to the pattern matching rules.

[0093] In specific implementation, based on the pattern matching rules, the target text knowledge elements among the text knowledge elements can be determined as the constituent elements of the question; wherein the target text knowledge elements include part or all of the text knowledge elements that match the sub-matching patterns in the pattern matching rules; the constituent elements of the question are combined with the question words corresponding to the preset text type, and the combination result is determined as the question of the question and answer pair; the text knowledge elements among the text knowledge elements except the target text knowledge elements are determined as the answers to the question and answer pair.

[0094] Among them, the question words corresponding to the preset text types, for example, the question words corresponding to the requirement type can be "what are the requirements", the question words corresponding to the reason type can be "what are the reasons", the question words corresponding to the condition type can be "what are the conditions", the question words corresponding to the location type can be "where / what is the location", the question words corresponding to the processing materials type can be "what materials", the question words corresponding to the channel type can be "what channels", the question words corresponding to the basis type can be "what", the question words corresponding to the introduction type can be "what", the question words corresponding to the definition type can be "what does it mean / what is it", etc.

[0095] For example, taking the text B shown in Table 1 as an example, the knowledge elements are selected: "Element 1: digestive tract, element 2: includes" and then the question word corresponding to the introduction category is "what" to form the question and answer pair of text B: "What does the digestive tract include?", then element 3 is selected, namely "oral cavity, pharynx, esophagus, stomach, small intestine (duodenum, jejunum, ileum) and large intestine (cecum, appendix, colon, rectum, anal canal) and other parts.", as the answer, and finally the question and answer pair of text B is generated, namely the question: "What does the digestive tract include?", the answer "oral cavity, pharynx, esophagus, stomach, small intestine (duodenum, jejunum, ileum) and large intestine (cecum, appendix, colon, rectum, anal canal) and other parts.".

[0096] In addition, for some texts, due to the presence of different question words, when generating questions, multiple combinations can be used to obtain multiple different questions. The same question word can also generate different questions by combining it with different knowledge elements of the target text. For example, for the handling location category, the generated questions can be "Where is the handling location for something?" or "Where can I handle something?" etc. It can be seen that decomposing text knowledge to the level of text knowledge elements improves the flexibility of constructing question-answer pairs.

[0097] According to the above generation method, the following are the question-answer pairs generated by the texts corresponding to Table 1 listed in the embodiment of the present application, as shown in Table 2.

[0098] Table 2

[0099]

[0100]

[0101]

[0102] In an embodiment of the present application, in response to a question-answer pair generation request, the text type of the target text is determined based on the text features of the target text corresponding to the question-answer pair generation request; knowledge is extracted from the target text using a pattern matching rule corresponding to the text type to obtain text knowledge and text knowledge elements of the target text; and a question-answer pair of the target text is generated based on the text knowledge, text knowledge elements, and question-answer pair generation rules corresponding to the pattern matching rules. In this way, by obtaining the text type of the text, extracting the text knowledge and text knowledge elements in the text using the pattern matching rules corresponding to the text type, and then converting the text knowledge elements and text knowledge into questions and answers according to the question-answer pair generation rules corresponding to the pattern matching rules, the generation process of the question-answer pair is simplified and the generation efficiency of the question-answer pair is improved by customizing the pattern matching rules and the question-answer pair generation rules.

[0103] In practical applications, considering that some pattern matching rules may not be applicable to semantic analysis of text knowledge elements, in order to avoid the extracted text knowledge elements being insufficient to generate fluent question-answer pairs, the extraction results can also be filtered.

[0104] See also Figure 2 , Figure 2 A flowchart of another method for generating a question-answer pair provided in an embodiment of the present application, the method comprising the following steps:

[0105] In step 201, in response to a question-answer pair generation request, a text type of a target text is determined based on text features of a target text corresponding to the question-answer pair generation request.

[0106] In step 202, knowledge is extracted from the target text using pattern matching rules corresponding to the text type to obtain text knowledge and text knowledge elements of the target text.

[0107] In step 203, based on the pre-set knowledge filtering rules corresponding to the pattern matching rules, the text knowledge and text knowledge elements are filtered to obtain filtering results; wherein the knowledge filtering rules are to filter out the text knowledge corresponding to the text knowledge elements that do not conform to any preset part of speech.

[0108] Among them, the preset parts of speech include part or all of the predicate, adverbial, and proper noun.

[0109] For example, the text knowledge corresponding to the target text 1 is text knowledge 1 and text knowledge element 1, text knowledge element 2 and text knowledge element 3. Combined with text knowledge 1, part of speech analysis is performed on each text knowledge element to determine whether text knowledge element 1 acts as one of the predicate, adverbial modifier, or proper noun in text knowledge 1, determine whether text knowledge element 2 acts as one of the predicate, adverbial modifier, or proper noun in text knowledge 1, and determine whether text knowledge element 3 acts as one of the predicate, adverbial modifier, or proper noun in text knowledge 1. If the judgment results are all yes, the text knowledge is retained. Otherwise, the text knowledge is filtered out, that is, the text knowledge is not used to generate question-answer pairs.

[0110] In step 204, it is determined whether the filtering result is retained text knowledge, if so, step 205 is executed, otherwise step 206 is executed.

[0111] In step 205, question-answer pairs of the target text are generated based on the text knowledge, text knowledge elements, and question-answer pair generation rules corresponding to the pattern matching rules.

[0112] In step 206, the text knowledge and text knowledge elements are not used to generate question-answer pairs of the target text.

[0113] In this way, after filtering the text knowledge elements, it is helpful to improve the quality of question and answer pairs.

[0114] In practical applications, in order to further improve the quality of question-answer pairs, the extracted text knowledge elements can also be converted. The conversion process can be performed after filtering to determine the retained text knowledge, or before filtering. The following takes the conversion process before filtering as an example.

[0115] See also Figure 3 , Figure 3 A flowchart of another method for generating a question-answer pair provided in an embodiment of the present application, the method comprising the following steps:

[0116] In step 301, in response to a question-answer pair generation request, a text type of a target text is determined based on text features of a target text corresponding to the question-answer pair generation request.

[0117] In step 302, knowledge is extracted from the target text using pattern matching rules corresponding to the text type to obtain text knowledge and text knowledge elements of the target text.

[0118] In step 303, based on the pre-set knowledge conversion rules corresponding to the pattern matching rules, the filtered text knowledge elements are converted to obtain processed text knowledge elements; wherein the knowledge conversion rules include deleting punctuation marks in the text knowledge elements and extracting proper nouns in the text knowledge elements.

[0119] Among them, the deleted punctuation marks include period, question mark, exclamation mark, comma, colon, semicolon, etc. For example, take the text B in Table 2 above as an example, the text knowledge is "Digestive tract: including oral cavity, pharynx, esophagus, stomach, small intestine (duodenum, jejunum, ileum) and large intestine (cecum, appendix, colon, rectum, anal canal) and other parts." In the knowledge element 1 "Digestive tract:" there is an extra colon, so it is necessary to perform conversion processing in the generated question, that is, delete the colon. The generated question is: "What does the digestive tract include?"

[0120] For another example, if the proper nouns in the text knowledge elements carry a large number of modifiers and titles, in order to generate simple questions, the proper nouns in the text knowledge elements can be extracted.

[0121] It should be noted that the knowledge conversion rules here are not limited to deleting punctuation marks in text knowledge elements and extracting proper nouns in text knowledge elements, but may also include other knowledge conversion rules, which are not limited in this application.

[0122] In step 304, based on the pre-set knowledge filtering rules corresponding to the pattern matching rules, the text knowledge and text knowledge elements are filtered to obtain filtering results; wherein the knowledge filtering rules are to filter out the text knowledge corresponding to the text knowledge elements that do not conform to any preset part of speech.

[0123] In step 305 , it is determined whether the filtering result is retained text knowledge, if so, step 306 is executed, otherwise step 307 is executed.

[0124] In step 306, question-answer pairs of the target text are generated based on the text knowledge, text knowledge elements, and question-answer pair generation rules corresponding to the pattern matching rules.

[0125] In step 307, the text knowledge and text knowledge elements are not used to generate question-answer pairs of the target text.

[0126] In this way, after the conversion of text knowledge elements, it is helpful to further improve the quality of question and answer pairs.

[0127] During specific implementation, you can also configure in advance according to the text type, a joint rule that integrates the pattern matching rules, knowledge filtering rules, knowledge conversion rules and question-answer pair generation rules corresponding to the text type. In this way, when the text type of the target text is determined, the joint rule corresponding to the text type is directly selected to generate the question-answer pairs of the target text. The customized joint rules can explain the extraction and generation process and are flexible in configuration, which simplifies the question-answer pair generation process and improves the generation efficiency of the question-answer pairs. At the same time, the setting of knowledge filtering rules and knowledge conversion rules is also conducive to improving the generation quality of question-answer pairs.

[0128] In specific implementation, when generating question-answer pairs corresponding to the target text, the generated question-answer pairs can be output, and the extracted text knowledge and text knowledge elements can also be output together. This also makes it easy for technical personnel to trace the original text based on the text knowledge in order to verify the generated results.

[0129] Based on the same inventive concept, the present application embodiment provides a structural diagram of a device for generating a question-answer pair. Please refer to Figure 4 , the device comprises:

[0130] A determination module 401 is used to respond to a question-answer pair generation request and determine a text type of the target text based on text features of the target text corresponding to the question-answer pair generation request;

[0131] An extraction module 402 is used to extract knowledge from the target text using a pattern matching rule corresponding to the text type to obtain text knowledge and text knowledge elements of the target text;

[0132] The generation module 403 is used to generate question-answer pairs of the target text based on the text knowledge, the text knowledge elements and question-answer pair generation rules corresponding to the pattern matching rules.

[0133] In a possible embodiment, the extraction module 402 is specifically configured to:

[0134] Matching each pattern matching rule in the pattern matching rule set corresponding to the text type with the target text in sequence, and determining the pattern matching rule that successfully matches as a target pattern matching rule, wherein the target pattern matching rule contains a sub-matching pattern that matches a target text segment in the target text;

[0135] Extracting knowledge from the target text based on the target pattern matching rule to obtain text knowledge of the target text;

[0136] The text knowledge is divided based on the sub-matching patterns in the target pattern matching rule, and each divided text knowledge fragment is determined as the text knowledge element of the target text.

[0137] In a possible embodiment, the extraction module 402 is specifically configured to:

[0138] For any pattern matching rule, obtain each sub-matching pattern in the pattern matching rule;

[0139] If each text segment in the target text matches each sub-matching pattern, it is determined that the pattern matching rule matches the target text.

[0140] In a possible embodiment, the device further includes:

[0141] The filtering module 404 is used to filter the text knowledge and the text knowledge elements based on the pre-set knowledge filtering rules corresponding to the pattern matching rules to obtain filtering results; wherein the knowledge filtering rules are to filter out the text knowledge corresponding to the text knowledge elements that do not conform to any preset parts of speech, and the preset parts of speech include part or all of predicates, adverbials, and proper nouns.

[0142] In a possible embodiment, the device further includes:

[0143] The conversion module 405 is used to convert the text knowledge elements based on the pre-set knowledge conversion rules corresponding to the pattern matching rules to obtain the processed text knowledge elements; wherein the knowledge conversion rules include deleting punctuation marks in the text knowledge elements and extracting proper nouns in the text knowledge elements.

[0144] In a possible embodiment, the generating module 403 is specifically used for:

[0145] Based on the pattern matching rule, a target text knowledge element among the text knowledge elements is determined as a component element of the question; wherein the target text knowledge element is part or all of the text knowledge elements that match the sub-matching pattern in the pattern matching rule;

[0146] Combining the component elements with the preset question words corresponding to the text type, and determining the combination result as the question of the question-answer pair;

[0147] The text knowledge elements among the text knowledge elements except the target text knowledge element are determined as answers to the question-answer pair.

[0148] Based on the same inventive concept, the embodiment of the present application provides an electronic device, which can realize the function of generating a question-answer pair discussed above. Please refer to Figure 5 , the device includes a memory 501 , one or more processors 502 , and a bus 503 .

[0149] The memory 501 is used to store computer programs executed by the processor 501. The memory 501 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0150] The memory 501 may be a volatile memory, such as a random-access memory (RAM); the memory 501 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 501 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 501 may be a combination of the above memories.

[0151] The processor 502 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 502 is used to implement the method for generating question-answer pairs in the above embodiment when calling the computer program stored in the memory 502 .

[0152] The specific connection medium between the memory 501 and the processor 502 is not limited in the embodiment of the present application. Figure 5 In the embodiment, the memory 501 and the processor 502 are connected via a bus 503. The bus 503 is connected to the processor 502 via a bus 503. Figure 5 The connections between other components are shown in bold lines, and are not intended to be limiting. Bus 503 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0153] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, and a computer program product includes: a computer program code, which, when executed on a computer, enables the computer to execute any of the methods for generating question-answer pairs discussed above. Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the method for generating question-answer pairs, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.

[0154] Based on the same inventive concept, the embodiment of the present application also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the methods for generating question-answer pairs discussed above. Since the principle of solving the problem by the above-mentioned computer program product is similar to that of generating question-answer pairs, the implementation of the above-mentioned computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.

[0155] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0156] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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.

[0157] 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.

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

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

Claims

1. A method for generating question-answer pairs, characterized in that: include: In response to a question-answer pair generation request, determining a text type of the target text based on text features of the target text corresponding to the question-answer pair generation request; Extracting knowledge from the target text using a pattern matching rule corresponding to the text type to obtain text knowledge and text knowledge elements of the target text; Based on the text knowledge, the text knowledge elements and the question-answer pair generation rule corresponding to the pattern matching rule, a question-answer pair of the target text is generated.

2. The method according to claim 1, characterized in that The method of extracting knowledge from the target text using a pattern matching rule corresponding to the text type to obtain text knowledge and text knowledge elements of the target text includes: Matching each pattern matching rule in the pattern matching rule set corresponding to the text type with the target text in sequence, and determining the pattern matching rule that successfully matches as a target pattern matching rule, wherein the target pattern matching rule contains a sub-matching pattern that matches a target text segment in the target text; Extracting knowledge from the target text based on the target pattern matching rule to obtain text knowledge of the target text; The text knowledge is divided based on the sub-matching patterns in the target pattern matching rule, and each divided text knowledge fragment is determined as the text knowledge element of the target text.

3. The method according to claim 2, characterized in that The pattern matching rules in the pattern matching rule set corresponding to the text type are matched with the target text in sequence, including: For any pattern matching rule, obtain each sub-matching pattern in the pattern matching rule; If each text segment in the target text matches each sub-matching pattern, it is determined that the pattern matching rule matches the target text.

4. The method according to claim 1, characterized in that The method further comprises: Based on the pre-set knowledge filtering rules corresponding to the pattern matching rules, the text knowledge and the text knowledge elements are filtered to obtain filtering results; wherein, the knowledge filtering rules are to filter out the text knowledge corresponding to the text knowledge elements that do not conform to any preset parts of speech, and the preset parts of speech include part or all of predicates, adverbials, and proper nouns.

5. The method according to claim 1, characterized in that The method further comprises: Based on the pre-set knowledge conversion rules corresponding to the pattern matching rules, the text knowledge elements are converted to obtain the processed text knowledge elements; wherein the knowledge conversion rules include deleting punctuation marks in the text knowledge elements and extracting proper nouns in the text knowledge elements.

6. The method according to any one of claims 1 to 5, characterized in that: The step of generating a question-answer pair of the target text based on the text knowledge, the text knowledge elements, and a question-answer pair generation rule corresponding to the pattern matching rule comprises: Based on the pattern matching rule, a target text knowledge element among the text knowledge elements is determined as a component element of the question; wherein the target text knowledge element is part or all of the text knowledge elements that match the sub-matching pattern in the pattern matching rule; Combining the component elements with the preset question words corresponding to the text type, and determining the combination result as the question of the question-answer pair; The text knowledge elements among the text knowledge elements except the target text knowledge element are determined as answers to the question-answer pair.

7. A device for generating question-answer pairs, characterized in that: include: A determination module, configured to respond to a question-answer pair generation request and determine a text type of the target text based on text features of the target text corresponding to the question-answer pair generation request; An extraction module, used to extract knowledge from the target text using a pattern matching rule corresponding to the text type, to obtain text knowledge and text knowledge elements of the target text; A generation module is used to generate question-answer pairs of the target text based on the text knowledge, the text knowledge elements and question-answer pair generation rules corresponding to the pattern matching rules.

8. The device according to claim 7, characterized in that The extraction module is specifically used for: Matching each pattern matching rule in the pattern matching rule set corresponding to the text type with the target text in sequence, and determining the pattern matching rule that successfully matches as a target pattern matching rule, wherein the target pattern matching rule contains a sub-matching pattern that matches a target text segment in the target text; Extracting knowledge from the target text based on the target pattern matching rule to obtain text knowledge of the target text; The text knowledge is divided based on the sub-matching patterns in the target pattern matching rule, and each divided text knowledge fragment is determined as the text knowledge element of the target text.

9. The device according to claim 8, characterized in that The extraction module is specifically used for: For any pattern matching rule, obtain each sub-matching pattern in the pattern matching rule; If each text segment in the target text matches each sub-matching pattern, it is determined that the pattern matching rule matches the target text.

10. The device according to claim 7, characterized in that The device also includes: A filtering module is used to filter the text knowledge and the text knowledge elements based on a pre-set knowledge filtering rule corresponding to the pattern matching rule to obtain a filtering result; wherein the knowledge filtering rule is to filter out the text knowledge corresponding to the text knowledge elements that do not conform to any preset part of speech, and the preset part of speech includes part or all of the predicate, adverbial, and proper noun.

11. The device according to claim 7, characterized in that The device also includes: A conversion module is used to convert the text knowledge elements based on pre-set knowledge conversion rules corresponding to the pattern matching rules to obtain the processed text knowledge elements; wherein the knowledge conversion rules include deleting punctuation marks in the text knowledge elements and extracting proper nouns in the text knowledge elements.

12. The device according to any one of claims 7 to 11, characterized in that: The generation module is specifically used for: Based on the pattern matching rule, a target text knowledge element among the text knowledge elements is determined as a component element of the question; wherein the target text knowledge element is part or all of the text knowledge elements that match the sub-matching pattern in the pattern matching rule; Combining the component elements with the preset question words corresponding to the text type, and determining the combination result as the question of the question-answer pair; The text knowledge elements among the text knowledge elements except the target text knowledge element are determined as answers to the question-answer pair.

13. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of claims 1-6 according to the obtained program instructions.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 6.

15. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Question and answer method and device based on atlas knowledge base, equipment and storage medium

    CN111046133A

  • Question-answer pair generation method and device, electronic equipment and readable storage medium

    CN112183091A

  • Question and answer pair generation method and device based on knowledge graph, equipment and medium

    CN114357195A

  • Document response method and device, equipment and storage medium

    CN116932727A

  • Rule matching method, rule matching apparatus, storage medium and electronic device

    WO2021063089A1

Cited By

  • Question and answer pair generation method and device, electronic equipment and storage medium

    CN120653726A