Method, device, electronic device and storage medium for generating triplet samples
By using the pre -training problem to generate models, based on the semantic representation model of pre -trained semantics, the three -yuan sample samples are generated, and the problem of poor three yuan group samples caused by the small amount of data in the target field in the existing technology, realizing high accuracy of high accuracy And low -cost ternary samples.
Patent Information
- Application Number
- CN202010587031.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-24
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2040-06-24
AI Technical Summary
In the case where the data volume of the target field is small, the accuracy of the generated (Q, P, A) triple samples is poor.
The pre -training problem is used to generate models. This model is based on the pre -training semantic representation model training. It is used to extract answers fragments and generate corresponding questions from the paragraph text to obtain a three -yuan group sample.
The accuracy of the samples of the (Q, P, a) three -yuan group of (q, p, a), reduced the cost of acquiring training data, and saved the cost of manual labeling samples.
Smart Images

Figure CN111858883B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, in particular to the field of natural language processing technology based on artificial intelligence, and the field of deep learning technology, and specifically to a method, device, electronic device and storage medium for generating triplet samples. Background Art
[0002] In Natural Language Processing (NLP), question generation technology refers to finding a questionable answer fragment A in a given natural text paragraph P, and asking questions about the answer fragment A to generate questions Q. Using question generation technology, large-scale (Q, P, A) triplets can be generated from massive amounts of natural text. These triplets can provide a large number of training samples for paragraph sorting and reading comprehension model training, saving the cost of manually annotating samples; at the same time, they can also support search and question-answering systems in the form of key-value (kv) retrieval.
[0003] The existing method for obtaining samples of (Q, P, A) triples mainly uses traditional sequence-to-sequence model structures such as recurrent neural network (RNN), long short-term memory (LSTM) network or Transformer to train directly on the dataset of the target domain. Then, the trained model is used to generate the corresponding generated question Q from the provided paragraph P and answer fragment A.
[0004] However, the target domain dataset has a small amount of data, resulting in unsatisfactory results for the trained model. As a result, the trained model has poor accuracy when used to generate the corresponding generation question Q, resulting in poor accuracy for the triple (Q, P, A) samples generated by the existing method. Summary of the invention
[0005] In order to solve the above problems, the present application provides a method, device, electronic device and storage medium for generating a triplet sample.
[0006] According to one aspect of the present application, a method for generating a triple sample is provided, wherein the method comprises:
[0007] Get the paragraph text in the triple sample;
[0008] extracting at least one answer fragment from the paragraph text;
[0009] Based on the paragraph text and each of the answer fragments, a pre-trained question generation model is used to generate corresponding questions to obtain the triple samples; the pre-trained question generation model is trained based on a pre-trained semantic representation model.
[0010] According to another aspect of the present application, a device for generating a triple sample is provided, wherein the device comprises:
[0011] An acquisition module, used to acquire paragraph text in a triple sample;
[0012] An answer extraction module, used to extract at least one answer fragment from the paragraph text;
[0013] A question generation module is used to generate corresponding questions based on the paragraph text and each answer fragment using a pre-trained question generation model to obtain the triple samples; the pre-trained question generation model is trained based on a pre-trained semantic representation model.
[0014] According to another aspect of the present application, there is provided an electronic device, comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described above.
[0018] According to yet another aspect of the present application, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method as described above.
[0019] According to yet another aspect of the present application, a computer program product is provided, comprising a computer program, wherein the computer program implements the above method when executed by a processor.
[0020] According to the technology of the present application, since the pre-trained question generation model is trained based on the pre-trained semantic representation model, the accuracy of the question generation model is very good. Therefore, the accuracy of the (Q, P, A) triple samples generated by the question generation model is very high.
[0021] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.
[0023] Figure 1 is a schematic diagram according to the first embodiment of the present application;
[0024] Figure 2 is a schematic diagram according to a second embodiment of the present application;
[0025] Figure 3 yes Figure 2 Example diagrams of the illustrated embodiments;
[0026] Figure 4 is a schematic diagram according to a third embodiment of the present application;
[0027] Figure 5 is a schematic diagram according to a fourth embodiment of the present application;
[0028] Figure 6 It is a block diagram of an electronic device used to implement the method for generating triplet samples according to an embodiment of the present application. DETAILED DESCRIPTION
[0029] 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, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit 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.
[0030] Figure 1 is a schematic diagram according to the first embodiment of the present application; Figure 1 As shown, this embodiment provides a method for generating a triplet sample, which may specifically include the following steps:
[0031] S101, obtaining paragraph text in a triple sample;
[0032] The executor of the method for generating triple samples in this embodiment is a device for generating triple samples, which may be an electronic entity or an application integrated with software. When used, the application is run on a computer device to generate triple samples.
[0033] The paragraph text of this embodiment is a paragraph of any article that can be obtained. For example, in order to generate a triple sample, in this embodiment, any article in various books, journals, and magazines can be obtained, and any paragraph can be extracted to achieve the generation of a triple sample. In addition, in this embodiment, any article can also be obtained from online platforms such as news, e-books, or forums on the Internet, and any paragraph text in the article can be extracted to achieve the generation of a triple sample.
[0034] S102, extracting at least one answer fragment from the paragraph text;
[0035] In the paragraph text of the present embodiment, at least one sentence is included. Generally, a paragraph text may include multiple sentences. Because the paragraph text content is relatively rich, the number of answer fragments that can be used as answers in the paragraph text also includes at least one. Based on this, at least one answer fragment can be extracted from the paragraph text, and now the paragraph text and each answer fragment can constitute a group of (P, A).
[0036] S103. Based on the paragraph text and each answer fragment, a pre-trained question generation model is used to generate corresponding questions to obtain triple samples; the pre-trained question generation model is trained based on a pre-trained semantic representation model.
[0037] For the paragraph text and answer fragments obtained above, that is, a set of (P, A), a pre-trained question generation model can be used to generate a corresponding question Q, and a (Q, P, A) triple is obtained.
[0038] The pre-trained question generation model of this embodiment is obtained by training based on the pre-trained semantic representation model, that is, in the fine-tuning stage of training, a small number of (Q, P, A) triple samples collected from the target field are used to fine-tune the semantic representation model obtained through pre-training to obtain the question generation model. Since the question generation model is obtained by fine-tuning the pre-trained semantic representation model through the fine-tuning stage without having to collect a large amount of training data from scratch, pre-training for generation tasks is achieved, the acquisition cost of the question generation model is low, and since the pre-trained semantic representation model is used, the accuracy is very high, so the effect of the obtained question generation model is also very good.
[0039] Optionally, the semantic representation model of this embodiment can specifically adopt a pre-trained model known in the art, such as a Transformer-based bidirectional encoder (Bidirectional Encoder Representation from Transformers; BERT) or a knowledge enhanced semantic representation model (Enhanced Representation from knowledge Integration; ERNIE).
[0040] By adopting the technical solution of this embodiment, for each paragraph text P obtained, at least one corresponding answer fragment A can be extracted, and then based on each (P, A) group, the above-mentioned pre-trained question generation model can be used to generate the corresponding Q, thereby obtaining each (Q, P, A) triple sample. By adopting the above-mentioned scheme, a large number of (Q, P, A) triple samples can be generated for a large number of paragraph text screens obtained. Due to the technical solution of this embodiment, the accuracy of the generated (Q, P, A) triple samples is very high. These (Q, P, A) triple samples can be used as a large number of training samples for the training of paragraph sorting and reading comprehension models, saving the cost of manually annotating samples. At the same time, it can also support search and question-answering systems in accordance with the kv retrieval method.
[0041] The method for generating triple samples in this embodiment obtains paragraph text in the triple sample; extracts at least one answer fragment from the paragraph text; and generates corresponding questions using a pre-trained question generation model based on the paragraph text and each answer fragment, so as to obtain a triple sample. In this embodiment, since the pre-trained question generation model is trained based on a pre-trained semantic representation model, the accuracy of the question generation model is very good, and thus the accuracy of the (Q, P, A) triple sample generated using the question generation model is very high.
[0042] Figure 2 is a schematic diagram according to the second embodiment of the present application; Figure 2 As shown, the method for generating triplet samples in this embodiment is as follows: Figure 1 Based on the technical solutions of the illustrated embodiments, the technical solutions of the present application are further described in more detail. Figure 2 As shown, the method for generating a triplet sample in this embodiment may specifically include the following steps:
[0043] S201, obtaining paragraph text in triple sample;
[0044] The implementation method of this step is the same as above Figure 1 The implementation of step S101 in the illustrated embodiment is the same, and reference is made to the relevant records of the above embodiment for details, which will not be repeated here.
[0045] S202, extracting at least one answer fragment from the paragraph text using a pre-trained answer selection model, where the answer selection model is trained based on a pre-trained semantic representation model;
[0046] This step S202 is the above Figure 1 An implementation of step S102 of the illustrated embodiment. In this implementation, an answer selection model is used to extract at least one answer fragment from a paragraph. For example, optionally, step S202 may specifically include the following steps:
[0047] (1) Using the pre-trained answer selection model, predict the probability that all candidate answer fragments in the paragraph text can be used as answer fragments;
[0048] (2) Select at least one answer segment with the highest probability from all candidate answer segments as at least one answer segment.
[0049] Specifically, when implementing this embodiment, the answer selection model needs to analyze all candidate answer fragments in the paragraph text when extracting the answer fragment. Specifically, the paragraph text can be segmented, such as obtaining T1, T2, ..., T N There are N word segments in total. Then each word segment can be used as a candidate answer segment alone, and each word segment can also form a candidate answer segment with at least one adjacent word segment. For example, we can start from the first word segment and divide the candidate answer segments into all possible lengths to obtain the following candidate answer segments: T1, T1T2, T1T2 T3, ..., T1 ... T N , T2, T2T3, T2T3 T4,..., T2...T N ,……,T N-2 , T N-2 T N-1 , T N-2 T N-1 T N , T N-1 , T N-1 T N , T N The answer selection model of this embodiment can predict the probability of each candidate answer fragment after the encoding processing of the encoding layer and the prediction of the prediction layer. Then, the top N with the highest probability can be selected as the answer fragment to be selected according to the needs, where N can be a positive integer equal to or greater than 1.
[0050] By adopting the above answer selection model to screen answer fragments, the accuracy of the screened candidate answer fragments can be effectively guaranteed, so as to ensure the accuracy of the subsequently extracted (Q, P, A) triple samples.
[0051] In addition, optionally, the above Figure 1 Step S102 of the illustrated embodiment, “extracting at least one answer fragment from the paragraph text”, may specifically be: extracting at least one answer fragment from the paragraph text according to a preset answer fragment extraction rule.
[0052] For example, in this embodiment, professionals in the field can analyze answer fragments that can be used as answers in all paragraph texts in the field, extract corresponding answer fragment extraction rules, and then extract at least one answer fragment from the paragraph text based on the answer fragment extraction rules. Specifically, one, two or more answer fragment extraction rules can be preset according to actual needs.
[0053] By adopting the above answer fragment extraction rules to screen the answer fragments, the accuracy of the screened candidate answer fragments can also be effectively guaranteed, so as to ensure the accuracy of the subsequently extracted (Q, P, A) triple samples.
[0054] S203, for each answer segment, using the question generation model to decode the answer segment and the paragraph text in a preset word library, and obtaining the word with the highest probability as the first word of the question;
[0055] S204, using the question generation model to continue decoding in a preset word library based on the answer fragment, the paragraph text, and the first N words that have been decoded in the question, and obtain the word with the highest probability as the N+1th word of the question; wherein N is greater than or equal to 1;
[0056] S205, determining whether the N+1th word is a terminator or whether the total length of the currently obtained N+1 words has reached a preset length threshold; if so, executing step S206; otherwise, returning to step S204;
[0057] S206, determine that the decoding is completed, and concatenate the N+1 words in the decoding order to obtain the question.
[0058] The above steps S203-S206 are Figure 1 An implementation of step S103 of the illustrated embodiment.
[0059] In this embodiment, during the process of generating the question, all the words in the question are not generated at once, but are generated gradually one word at a time.
[0060] For example, for each answer fragment, in the process of generating the corresponding question, the extracted answer fragment and paragraph text are input into the question generation model. The question generation model can decode the input information in the preset word library and obtain the word with the highest probability as the first word of the question. The preset word library can be a pre-established word library including all word segments of a field. The preset word library can be set in the question generation model, or set outside the question generation model, but can be called at any time when the question generation model is used.
[0061] Similarly, in the question generation model, there is a cyclic decoding process, starting from decoding the second word, based on the answer fragment, paragraph text and the first N words that have been decoded, continue decoding in the preset vocabulary to obtain the word with the highest probability as the N+1th word of the question; N is greater than or equal to 1.
[0062] Furthermore, starting from the decoding of the second word, after decoding, it is necessary to detect whether the N+1th word currently decoded is the end symbol, and at the same time, it is necessary to detect whether the total length of the N+1 words currently decoded has reached the preset length threshold. As long as one of the conditions is met, the decoding is stopped, and the N+1 words obtained by decoding are spliced in the decoding order to generate the question. Otherwise, step S204 is adopted to continue decoding, and so on, until the decoding is completed and the question is generated.
[0063] For example Figure 3 yes Figure 2 An example diagram of the embodiment shown. Figure 3 As shown in the figure, a question generation system composed of an answer selection model and a question generation model is taken as an example. The answer selection model is used to complete the work of step 1, selecting the answer segment A from the provided text paragraph P. The question generation model is used to complete the work of step 2, decoding based on the text paragraph P and the answer segment A to obtain the response question Q.
[0064] like Figure 3 As shown, taking a text paragraph P as an example, the text paragraph P is: "Wang Xizhi (321-379, or 303-61), whose courtesy name is Yi Shao, was a famous calligrapher in the Eastern Jin Dynasty. He was born in Linyi, Langya (now Linyi, Shandong). He initially served as a secretary, and later as General Ningyuan, Governor of Jiangzhou, General of the Right Army, Internal History of Kuaiji, etc. He was known as Wang Youjun. Later, due to disagreements with the Governor of Yangzhou, Wang Shu, he resigned and settled in Shanyin, Kuaiji (now Shaoxing). Wang Xizhi was born in..."
[0065] Then, the method for generating triplet samples of this embodiment is used to extract the answer segment A from the obtained text paragraph P using the answer selection model, such as Figure 3In the question generation model of this embodiment, the corresponding question Q can be generated based on the input text paragraph P and the answer segment A "Eastern Jin Dynasty", such as Figure 3 The question Q generated in the above example can be “Which dynasty was Wang Xizhi from?” Figure 3 Only one implementation is shown. In actual applications, according to the method of this embodiment, the generation of (Q, P, A) triples can be realized in any field and based on any paragraph text.
[0066] The method for generating triplet samples in this embodiment, by adopting the above-mentioned technical scheme, can use a pre-trained answer selection model to extract answer fragments from paragraph text, and use a pre-trained question generation model to generate corresponding questions based on the paragraph text and the answer fragments. Since the adopted answer selection model and question generation model are both trained based on the pre-trained semantic representation model, the accuracy of the answer selection model and the question generation model is very high, thereby ensuring that the accuracy of the generated (Q, P, A) triples is very high.
[0067] Figure 4 is a schematic diagram according to the third embodiment of the present application; Figure 4 As shown, this embodiment provides a device 400 for generating a triple sample, including:
[0068] An acquisition module 401 is used to acquire paragraph text in a triple sample;
[0069] An answer extraction module 402 is used to extract at least one answer segment from the paragraph text;
[0070] The question generation module 403 is used to generate corresponding questions based on the paragraph text and each answer fragment using a pre-trained question generation model to obtain triple samples; the pre-trained question generation model is trained based on a pre-trained semantic representation model.
[0071] The device 400 for generating triple samples of this embodiment, by adopting the above modules to realize the realization principle and technical effect of generating triple samples, is the same as the realization of the above related method embodiments. For details, please refer to the records of the above related embodiments, which will not be repeated here.
[0072] Figure 5 is a schematic diagram according to the fourth embodiment of the present application; Figure 5 As shown, the device 400 for generating triple samples of this embodiment, in the above Figure 4 Based on the technical solution of the illustrated embodiment, the technical solution of the present application is further described in more detail.
[0073] In the device 400 for generating triplet samples of this embodiment, the answer extraction module 402 is used to:
[0074] At least one answer fragment is extracted from the paragraph text according to a preset answer fragment extraction rule.
[0075] Or the answer extraction module 402 is used to:
[0076] A pre-trained answer selection model is used to extract at least one answer fragment from the paragraph text, and the answer selection model is trained based on the pre-trained semantic representation model.
[0077] Furthermore, the answer extraction module 402 is used to:
[0078] Using the answer selection model, predict the probability that all candidate answer fragments in the paragraph text can be used as answer fragments;
[0079] At least one with the highest probability is selected from all candidate answer segments as at least one answer segment.
[0080] Further optionally, if Figure 5 As shown, in the device 400 for generating triple samples of this embodiment, the question generating module 403 includes:
[0081] The first decoding unit 4031 is used to decode each answer segment in a preset word library based on the answer segment and the paragraph text using the question generation model, and obtain the word with the highest probability as the first word of the question;
[0082] The second decoding unit 4032 is used to use the question generation model to continue decoding in a preset word library based on the answer fragment, the paragraph text and the first N words that have been decoded in the question, and obtain the word with the highest probability as the N+1th word of the question; where N is greater than or equal to 1;
[0083] A detection unit 4033 is used to determine whether the N+1th word is a terminator or whether the total length of the currently obtained N+1 words has reached a preset length threshold;
[0084] The generating unit 4034 is used to determine that the decoding is finished if so, and concatenate the N+1 words in the decoding order to obtain the question.
[0085] The device 400 for generating triple samples of this embodiment, by adopting the above modules to realize the realization principle and technical effect of generating triple samples, is the same as the realization of the above related method embodiments. For details, please refer to the records of the above related embodiments, which will not be repeated here.
[0086] According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
[0087] like Figure 6, is a block diagram of an electronic device for realizing a method for generating a triplet sample of an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples, and are not intended to limit the implementation of the present application described and / or required herein.
[0088] like Figure 6 As shown, the electronic device includes: one or more processors 601, a memory 602, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 601 is taken as an example.
[0089] The memory 602 is a non-transitory computer-readable storage medium provided in the present application. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the method for generating triple samples provided in the present application. The non-transitory computer-readable storage medium of the present application stores computer instructions, which are used to enable a computer to perform the method for generating triple samples provided in the present application.
[0090] The memory 602 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the method for generating triplet samples in the embodiment of the present application (for example, the attached Figure 4 and attached Figure 5 The processor 601 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 602, that is, the method for generating triplet samples in the above method embodiment is implemented.
[0091] The memory 602 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created according to the use of an electronic device that implements a method for generating a triple sample, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 602 may optionally include a memory remotely arranged relative to the processor 601, and these remote memories may be connected to the electronic device that implements the method for generating a triple sample via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0092] The electronic device implementing the method for generating triplet samples may further include: an input device 603 and an output device 604. The processor 601, the memory 602, the input device 603 and the output device 604 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0093] The input device 603 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device that implements the method for generating triple samples, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 604 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.
[0094] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0095] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0096] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0097] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0098] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0099] According to the technical solution of the embodiment of the present application, by obtaining the paragraph text in the triple sample; extracting at least one answer fragment from the paragraph text; and based on the paragraph text and each answer fragment, respectively using a pre-trained question generation model to generate corresponding questions, a triple sample is obtained. In this embodiment, since the pre-trained question generation model is trained based on a pre-trained semantic representation model, the accuracy of the question generation model is very good, and therefore, the accuracy of the (Q, P, A) triple sample generated by using the question generation model is very high.
[0100] According to the technical solution of the embodiment of the present application, a pre-trained answer selection model can be used to extract answer fragments from the paragraph text, and a pre-trained question generation model can be used to generate corresponding questions based on the paragraph text and the answer fragments. Since the adopted answer selection model and question generation model are both trained based on the pre-trained semantic representation model, the accuracy of the answer selection model and the question generation model are very high, which can ensure that the accuracy of the generated (Q, P, A) triples is very high.
[0101] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.
[0102] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A method for generating a triplet sample, wherein the method comprises: Obtain paragraph text in the triple sample; the paragraph text is any paragraph in any article; extracting at least one answer fragment from the paragraph text; Based on the paragraph text and each of the answer fragments, a pre-trained question generation model is used to generate corresponding questions to obtain the triple sample; the pre-trained question generation model is trained based on a pre-trained semantic representation model, and in the fine-tuning stage of training, the pre-trained semantic representation model is adjusted using the triple samples collected in the target field to obtain the question generation model; the semantic representation model uses a Transformer-based bidirectional encoder or a knowledge-enhanced semantic representation model; Extracting at least one answer fragment from the paragraph text includes: A pre-trained answer selection model is used to extract at least one answer fragment from the paragraph text; the answer fragment includes a word segment in the paragraph text, or at least two adjacent word segments; the answer selection model can analyze all candidate answer fragments in the paragraph text, and obtain the probability of each candidate answer fragment through encoding processing at the encoding layer and prediction at the prediction layer, and then extract the at least one answer fragment based on the probability of each candidate answer fragment.
2. The method according to claim 1, wherein: Extracting at least one answer fragment from the paragraph text may also be performed in the following manner: According to a preset answer segment extraction rule, the at least one answer segment is extracted from the paragraph text.
3. The method according to claim 1, wherein: The answer selection model is trained based on a pre-trained semantic representation model.
4. The method according to claim 3, wherein: Using a pre-trained answer selection model to extract the at least one answer fragment from the paragraph text includes: Using the answer selection model, predicting the probability that all candidate answer segments in the paragraph text can be used as answer segments; At least one with the highest probability is selected from all the candidate answer segments as the at least one answer segment.
5. The method according to any one of claims 1 to 4, wherein: Based on the paragraph text and each of the answer fragments, a pre-trained question generation model is used to generate corresponding questions, including: For each of the answer segments, the question generation model is used to decode the answer segment and the paragraph text in a preset word library to obtain the word with the highest probability as the first word of the question; Using the question generation model to continue decoding in the preset word library based on the answer fragment, the paragraph text and the first N words that have been decoded in the question, and obtain the word with the highest probability as the N+1th word of the question; where N is greater than or equal to 1; Determine whether the N+1th word is a terminator or whether the total length of the currently obtained N+1 words has reached a preset length threshold; If so, it is determined that the decoding is completed, and the N+1 words are concatenated in the decoding order to obtain the question.
6. A device for generating a triple sample, wherein the device comprises: An acquisition module, used to acquire paragraph text in a triple sample; The paragraph text is any paragraph in any article; An answer extraction module, used to extract at least one answer fragment from the paragraph text; A question generation module is used to generate corresponding questions based on the paragraph text and each of the answer fragments using a pre-trained question generation model to obtain the triple sample; the pre-trained question generation model is trained based on a pre-trained semantic representation model, and in the fine-tuning stage of training, the pre-trained semantic representation model is adjusted using triple samples collected in the target field to obtain the question generation model; the semantic representation model uses a Transformer-based bidirectional encoder or a knowledge-enhanced semantic representation model; The answer extraction module is used to: A pre-trained answer selection model is used to extract at least one answer fragment from the paragraph text; the answer fragment includes a word segment in the paragraph text, or at least two adjacent word segments; the answer selection model can analyze all candidate answer fragments in the paragraph text, and obtain the probability of each candidate answer fragment through encoding processing at the encoding layer and prediction at the prediction layer, and then extract the at least one answer fragment based on the probability of each candidate answer fragment.
7. The device according to claim 6, wherein: The answer extraction module can also be executed by the following steps: According to a preset answer segment extraction rule, the at least one answer segment is extracted from the paragraph text.
8. The device according to claim 6, wherein: The answer selection model is trained based on a pre-trained semantic representation model.
9. The device according to claim 8, wherein: The answer extraction module is used to: Using the answer selection model, predicting the probability that all candidate answer segments in the paragraph text can be used as answer segments; At least one with the highest probability is selected from all the candidate answer segments as the at least one answer segment.
10. The device according to any one of claims 6 to 9, wherein: The question generating module comprises: A first decoding unit is used for decoding each of the answer segments using the question generation model based on the answer segment and the paragraph text in a preset word library to obtain a word with the highest probability as the first word of the question; A second decoding unit is used to use the question generation model to continue decoding in the preset word library based on the answer fragment, the paragraph text and the first N words that have been decoded in the question, and obtain the word with the highest probability as the N+1th word of the question; wherein N is greater than or equal to 1; A detection unit, used to determine whether the N+1th word is a terminator or whether the total length of the currently obtained N+1 words has reached a preset length threshold; The generating unit is used for determining that the decoding is finished if yes, and concatenating the N+1 words in the decoding order to obtain the question.
11. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
12. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Automatic problem generation method based on deep learning
CN109657041A
Implementation method and device for machine reading understanding, storage medium and electronic equipment
CN110543631A