A method, device, electronic device and computer storage medium for automatic question answering
By using a trained semantic similarity model and text generation model, the problem of existing automatic question answering methods failing to generate answers when matching errors is solved, thus achieving accurate question answering for complex questions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING SINOVOICE TECH CO LTD
- Filing Date
- 2023-07-03
- Publication Date
- 2026-05-01
AI Technical Summary
Existing automatic question answering methods rely on the accuracy of matching user questions with stored questions, cannot generate correct answers when the match is incorrect, and cannot handle complex questions.
By using a trained semantic similarity model and a text generation model, the input question is matched with multiple question templates to generate the answer to be output. The trained text generation model is then used to concatenate the answers from multiple question templates.
Generating reasonable answers when a match is incorrect can handle complex questions and improve the accuracy and flexibility of question-answering systems.
Smart Images

Figure CN116910209B_ABST
Abstract
Description
A method, apparatus, electronic device, and computer storage medium for automatic question answering. Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to an automatic question-answering method, an automatic question-answering device, an electronic device, and a computer-readable storage medium. Background Technology
[0002] Existing automated question-answering methods match user-input questions with corresponding answers. These questions are stored in the computer and have pre-defined answers. Once a matching question is found, the appropriate answer is output based on preset answers.
[0003] The accuracy of existing automated question-answering methods primarily relies on the matching accuracy between user questions and stored questions. This matching result is unique, and only the answer corresponding to the question with the highest matching degree can be output. If the matching is incorrect, the correct answer cannot be output. Furthermore, existing automated question-answering methods can only answer pre-prepared questions, which are generally directed at a single audience and cannot be used for complex questions. Summary of the Invention
[0004] In view of the above problems, embodiments of the present invention are proposed to provide an automatic question-answering method, an automatic question-answering apparatus, an electronic device, and a computer-readable storage medium that overcome or at least partially solve the above problems.
[0005] To address the aforementioned problems, this invention discloses an automatic question-answering method, the method comprising:
[0006] When an input question is received, the input question is matched with multiple preset first question templates to obtain a matching score for each first question template; wherein, each first question template includes a first preset question and a first preset answer corresponding to the first preset question;
[0007] The top N target matching scores are determined in descending order, and the target question template corresponding to each target matching score is determined; where N is a positive integer.
[0008] The first preset answer in each of the target question templates is concatenated with the input question to generate the answer to be output.
[0009] Display the answer to be output.
[0010] In one or more embodiments, matching the input question with a plurality of preset first question templates includes:
[0011] The input question is matched with multiple preset first question templates using a trained semantic similarity model;
[0012] The trained semantic similarity model is generated in the following way:
[0013] A pre-trained model is obtained by using a pre-set text corpus and the MASK prediction method to pre-train the original semantic similarity model.
[0014] Similar sentences in the preset training data are used as positive samples, and sentences other than similar sentences are used as negative samples. The pre-trained model is then fine-tuned using contrastive learning loss to obtain the trained semantic similarity model.
[0015] In one or more embodiments, the step of concatenating the first preset answer in each of the target question templates with the input question to generate the answer to be output includes:
[0016] The trained text generation model is used to concatenate the first preset answer in each target question template with the input question to generate the answer to be output.
[0017] The trained text generation model is generated in the following manner:
[0018] The preset text generation model is trained first to obtain the first candidate text generation model; the first training is used to train the generation of the final answer;
[0019] The first candidate text generation model is trained a second time to obtain a second candidate text generation model; the second training is used to train multiple simple questions to generate complex questions.
[0020] The second candidate text generation model is subjected to a third training exercise to obtain a trained text generation model; the third training exercise is used to train the generation of answers to complex questions.
[0021] In one or more embodiments, the step of performing a first training on a preset text generation model to obtain a first candidate text generation model includes:
[0022] The preset text generation model is trained using a preset sample question, a preset second question template, and a preset final answer to obtain the first candidate text generation model.
[0023] In one or more embodiments, the step of performing a second training on the first candidate text generation model to obtain a second candidate text generation model includes:
[0024] The first candidate text generation model is trained a second time using a set of preset simple questions and preset complex questions to obtain a second candidate text generation model; wherein the preset simple questions and preset complex questions have the same semantics.
[0025] In one or more embodiments, the third training of the second candidate text generation model to obtain the trained text generation model includes:
[0026] The second candidate text generation model is trained by using a preset complex question, the answers to multiple preset simple questions, and the answers to the preset complex question to obtain the trained text generation model.
[0027] Accordingly, embodiments of the present invention disclose an automatic question-answering device, the device comprising:
[0028] The matching module, when receiving an input question, matches the input question with multiple preset first question templates to obtain a matching score corresponding to each first question template; wherein, each first question template includes a first preset question and a first preset answer corresponding to the first preset question;
[0029] The determination module determines the top N target matching scores from the matching scores in descending order, and determines the target question template corresponding to each target matching score; where N is a positive integer.
[0030] The generation module concatenates the first preset answer in each of the target question templates with the input question to generate the answer to be output.
[0031] The output module displays the answer to be output.
[0032] In one or more embodiments, the matching module includes:
[0033] The matching submodule is used to match the input question with multiple preset first question templates using a trained semantic similarity model;
[0034] The training submodule is used to pre-train the original semantic similarity model using a pre-defined text corpus and the MASK prediction method to obtain a pre-trained model.
[0035] Similar sentences in the preset training data are used as positive samples, and sentences other than similar sentences are used as negative samples. The pre-trained model is then fine-tuned using contrastive learning loss to obtain the trained semantic similarity model.
[0036] In one or more embodiments, the generation module includes:
[0037] A generation submodule is used to concatenate the first preset answer in each of the target question templates with the input question, input the concatenation into the trained text generation model, and generate the answer to be output.
[0038] The first training submodule is used to perform a first training on a preset text generation model to obtain a first candidate text generation model; the first training is used to train and generate the final answer.
[0039] The second training submodule is used to perform a second training on the first candidate text generation model to obtain a second candidate text generation model; the second training is used to train multiple simple questions to generate complex questions.
[0040] The third training submodule is used to perform a third training on the second candidate text generation model to obtain a trained text generation model; the third training is used to train the generation of answers to complex questions.
[0041] In one or more embodiments, the first training submodule includes:
[0042] The first training unit is used to perform the first training on the preset text generation model using preset sample questions, preset second question templates, and preset final answers, so as to obtain the first candidate text generation model.
[0043] In one or more embodiments, the second training submodule includes:
[0044] The second training unit is used to perform a second training on the first candidate text generation model using a set of preset simple questions and preset complex questions to obtain a second candidate text generation model; wherein the preset simple questions and the preset complex questions have the same semantics.
[0045] In one or more embodiments, the third training submodule includes:
[0046] The third training unit is used to perform a third training on the second candidate text generation model using a preset complex question, the answers to multiple preset simple questions, and the answers to the preset complex question, to obtain the trained text generation model.
[0047] Accordingly, this invention discloses an electronic device, including: a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the various steps of the above-described automatic question-answering method embodiments.
[0048] Accordingly, embodiments of the present invention disclose a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the various steps of the above-described automatic question-answering method embodiments.
[0049] The embodiments of the present invention have the following advantages:
[0050] The automatic question-answering method of this invention, when an input question is received, matches the input question with multiple preset first question templates to obtain a matching score corresponding to each first question template. Each first question template includes a first preset question and a first preset answer corresponding to the first preset question. The method determines the top N target matching scores in descending order and determines the target question template corresponding to each target matching score; N is a positive integer. The first preset answer in each target question template is concatenated with the input question to generate an answer to be output. The answer to be output is then displayed. This method solves the problem of not being able to generate a corresponding answer when the matched question is incorrect, i.e., the highest-scoring candidate is not the desired question. This invention can select the top N target question templates with the highest matching scores and then combine them with the reference answers of the N target question templates to generate the corresponding answer. Attached Figure Description
[0051] Figure 1 is a flowchart of the steps in a first embodiment of the automatic question-answering method of the present invention;
[0052] Figure 2 is a structural block diagram of an embodiment of the automatic question-and-answer device of the present invention. Detailed Implementation
[0053] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0054] One of the core concepts of this invention is that the automatic question-answering method of this invention, when an input question is received, matches the input question with multiple preset first question templates to obtain a matching score corresponding to each first question template; wherein, each first question template includes a first preset question and a first preset answer corresponding to the first preset question; the top N target matching scores are determined based on descending order of matching scores, and a target question template corresponding to each target matching score is determined; N is a positive integer; the first preset answer in each target question template is concatenated with the input question to generate an answer to be output; and the answer to be output is displayed. Through the above method, the problem of not being able to generate a corresponding answer when the matching question is incorrect, i.e., the highest-scoring candidate is not the desired question, can be solved. This invention can select the top N target question templates with matching scores, and then combine them with the reference answers of the N target question templates to generate the corresponding answer.
[0055] Referring to Figure 1, a flowchart of a first embodiment of the automatic question-answering method of the present invention is shown, which may specifically include the following steps:
[0056] Step 101: When an input question is obtained, the input question is matched with multiple preset first question templates to obtain a matching score corresponding to each first question template; wherein, each first question template includes a first preset question and a first preset answer corresponding to the first preset question.
[0057] Specifically, the automatic question-answering method can be applied to an automatic question-answering system. Users can ask questions in the system, and once the system receives the question, it can answer it and display the answer to the user. The user's question received by the system is the input question.
[0058] After receiving an input question, the automated question-answering system matches the input question with multiple preset first question templates to obtain a matching score for each template. Each first question template includes a first preset question. During matching, the input question is matched with the first preset question within each first question template to obtain the corresponding matching score.
[0059] Furthermore, the first question template also includes a first preset answer corresponding to the first preset question. The first preset answer is specifically used to concatenate with the input question, which will be explained in detail later.
[0060] In this embodiment of the invention, matching the input question with multiple preset first question templates includes:
[0061] The input question is matched with multiple preset first question templates using a trained semantic similarity model;
[0062] The trained semantic similarity model is generated in the following way:
[0063] A pre-trained model is obtained by using a pre-set text corpus and the MASK prediction method to pre-train the original semantic similarity model.
[0064] Similar sentences in the preset training data are used as positive samples, and sentences other than similar sentences are used as negative samples. The pre-trained model is then fine-tuned using contrastive learning loss to obtain the trained semantic similarity model.
[0065] Specifically, the automatic question answering system can use a trained semantic similarity model to match the input question with multiple preset first question templates. The trained semantic similarity model can be generated through pre-training and fine-tuning. Using a large amount of preset text data, the original semantic similarity model is pre-trained using the MASK prediction method to obtain a pre-trained model. Then, similar sentences in the preset training data are used as positive samples, and sentences other than similar sentences are used as negative samples. Finally, the pre-trained model is fine-tuned using contrastive learning loss to obtain the trained semantic similarity model.
[0066] Step 102: Determine the top N target matching scores from the matching scores in descending order, and determine the target question template corresponding to each target matching score; where N is a positive integer.
[0067] Specifically, after obtaining all matching scores, the scores are sorted in descending order to determine the top N matching scores, which are the target matching scores. Then, the pre-defined question templates corresponding to these target matching scores are determined, where N is a positive integer. The trained semantic similarity model matches the input question with multiple pre-defined question templates, obtaining a matching score for each template. Based on this descending order, the top N target matching scores are determined, along with the target question template corresponding to each target matching score.
[0068] Step 103: Concatenate the first preset answer in each target question template with the input question to generate the answer to be output;
[0069] Specifically, the automatic question answering system can find the first preset answer in the target question template, concatenate the first preset answer with the input question, and then input it into the trained text generation model to generate the answer to be output. The following templates can be used for concatenation and input into the trained text generation model.
[0070] For example, the splicing template is as follows:
[0071] question:
[0072] [Input Issue]
[0073] refer to:
[0074] [First Sample Answer]
[0075] [Second Reference Answer]
[0076] …
[0077] [Reference Answer for Passage N]
[0078] Text generation models, also known as large language models, can be trained in a specific way to output text content according to requirements based on input text content and prompts. By concatenating the input question and a first preset answer according to the above template and inputting them into the trained text generation model, the desired answer can be generated.
[0079] In this embodiment of the invention, the first preset answer in each of the target question templates is concatenated with the input question and input into the trained text generation model to generate the answer to be output.
[0080] The trained text generation model is generated in the following manner:
[0081] The preset text generation model is trained first to obtain the first candidate text generation model; the first training is used to train the generation of the final answer;
[0082] The first candidate text generation model is trained a second time to obtain a second candidate text generation model; the second training is used to train multiple simple questions to generate complex questions.
[0083] The second candidate text generation model is subjected to a third training to obtain a trained text generation model; the third training is used to train the generation of answers to complex questions.
[0084] Specifically, the automatic question-answering system can use a trained text generation model to generate the answer to be output. This trained text generation model can be generated through a first training, a second training, and a third training. The first training of the preset text generation model yields a first candidate text generation model, which is used to train the generation of the final answer. The second training of the second candidate text generation model yields a second candidate text generation model, which is used to train the generation of complex questions from multiple simple questions. The third training of the second candidate text generation model yields the trained text generation model, which is used to train the generation of answers to complex questions.
[0085] Generally speaking, simple questions ask about a single object, so it is possible to enumerate and exhaust all related questions. However, questions can also compare different objects or require multiple steps of reasoning to arrive at an answer. These types of questions have a rich variety of combinations and cannot be exhaustively enumerated. These types of questions are referred to as complex questions in the following description.
[0086] Furthermore, the preset text generation model is trained using a preset sample question, a preset second question template, and a preset final answer to obtain the first candidate text generation model.
[0087] Specifically, a pre-set sample question can be input into the trained semantic similarity model to obtain a second question template. Then, the second pre-set answer in the second question template is concatenated with the pre-set sample question according to a concatenation template to obtain the first training data input. The first training data output is the final answer that can answer the pre-set sample question, generated by selecting effective content from the second pre-set answer and combining it with the pre-set sample question. A pre-set text generation model is trained on the above training data to obtain a first candidate text generation model, which has the ability to summarize multiple reference answers to generate the final answer.
[0088] Furthermore, the first candidate text generation model is trained a second time using a set of preset simple questions and preset complex questions to obtain a second candidate text generation model; wherein the preset simple questions and the preset complex questions have the same semantics.
[0089] Specifically, the input data for the second training iteration consists of multiple pre-set simple questions, while the output data consists of pre-set complex questions. These simple questions are input into the second candidate text generation model, which combines them to generate a single complex question. If multiple complex questions are needed, the model can generate them multiple times. Because the model's generation results are random, multiple complex questions can be obtained, thus enhancing the accuracy of complex question generation. For example, the input template is as follows:
[0090] Based on the following multiple questions, generate a complex question:
[0091] question:
[0092]
Simple Question 1
[0093]
Simple Question 2
[0094] …
[0095] [Simple Question N]
[0096] The complex problem is: XXX.
[0097] Furthermore, the second candidate text generation model is trained a third time using a preset complex question, the answers to multiple preset simple questions, and the answers to the preset complex question, to obtain the trained text generation model.
[0098] Specifically, a pre-set complex question can be input into the trained semantic similarity model, which can then match answers to multiple simple questions. The pre-set complex question and the answers to the matched simple questions can be used as input data for a third training exercise, while the answer to the pre-set complex question can be used as output data. Using this data, the second candidate text generation model is trained a third time, resulting in a trained text generation model that enhances its ability to answer complex questions.
[0099] Step 104: Display the answer to be output.
[0100] Specifically, after generating the answer to be output, the automated question-and-answer system can display the answer to the user. It enables users to ask questions within the system, and once the system receives the question, it can answer it and then display the automated answer to the user.
[0101] The automatic question-answering method of this invention, when an input question is received, matches the input question with multiple preset first question templates to obtain a matching score corresponding to each first question template. Each first question template includes a first preset question and a first preset answer corresponding to the first preset question. The method determines the top N target matching scores in descending order and determines the target question template corresponding to each target matching score; N is a positive integer. The first preset answer in each target question template is concatenated with the input question to generate an answer to be output. The answer to be output is then displayed. This method solves the problem of not being able to generate a corresponding answer when the matched question is incorrect, i.e., the highest-scoring candidate is not the desired question. This invention can select the top N target question templates with the highest matching scores and then combine them with the reference answers of the N target question templates to generate the corresponding answer.
[0102] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0103] Referring to Figure 2, a structural block diagram of an embodiment of the automatic question-answering device of the present invention is shown, which may specifically include the following modules:
[0104] The matching module 201, when receiving an input question, matches the input question with multiple preset first question templates to obtain a matching score corresponding to each first question template; wherein, each first question template includes a first preset question and a first preset answer corresponding to the first preset question;
[0105] The determining module 202 determines the top N target matching scores in descending order of the matching scores, and determines the target question template corresponding to each target matching score; where N is a positive integer.
[0106] The generation module 203 concatenates the first preset answer in each of the target question templates with the input question to generate the answer to be output;
[0107] Output module 204 displays the answer to be output.
[0108] In this embodiment of the invention, the matching module further includes:
[0109] The matching submodule is used to match the input question with multiple preset first question templates using a trained semantic similarity model;
[0110] The training submodule is used to pre-train the original semantic similarity model using a pre-defined text corpus and the MASK prediction method to obtain a pre-trained model.
[0111] Similar sentences in the preset training data are used as positive samples, and sentences other than similar sentences are used as negative samples. The pre-trained model is then fine-tuned using contrastive learning loss to obtain the trained semantic similarity model.
[0112] In this embodiment of the invention, the generation module further includes:
[0113] The generation submodule is used to use the trained text generation model to concatenate the first preset answer in each of the target question templates with the input question to generate the answer to be output;
[0114] The first training submodule is used to perform a first training on a preset text generation model to obtain a first candidate text generation model; the first training is used to train and generate the final answer.
[0115] The second training submodule is used to perform a second training on the first candidate text generation model to obtain a second candidate text generation model; the second training is used to train multiple simple questions to generate complex questions.
[0116] The third training submodule is used to perform a third training on the second candidate text generation model to obtain a trained text generation model; the third training is used to train the generation of answers to complex questions.
[0117] In this embodiment of the invention, the first training submodule further includes:
[0118] The first training unit is used to perform the first training on the preset text generation model using preset sample questions, preset second question templates, and preset final answers, so as to obtain the first candidate text generation model.
[0119] In this embodiment of the invention, the second training submodule further includes:
[0120] The second training unit is used to perform a second training on the first candidate text generation model using a set of preset simple questions and preset complex questions to obtain a second candidate text generation model; wherein the preset simple questions and the preset complex questions have the same semantics.
[0121] In this embodiment of the invention, the third training submodule further includes:
[0122] The third training unit is used to perform a third training on the second candidate text generation model using a preset complex question, the answers to multiple preset simple questions, and the answers to the preset complex question, to obtain the trained text generation model.
[0123] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0124] This invention also provides an electronic device, comprising:
[0125] It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described automatic question-answering method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0126] This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described automatic question-answering method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0127] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0128] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0129] Embodiments of the present invention are described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or one or more blocks of the block diagrams.
[0130] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more block diagrams.
[0131] These computer program instructions may also be loaded onto a computer or other programmable data processing terminal equipment to cause a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable terminal equipment, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.
[0132] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0133] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0134] The above provides a detailed description of an automatic question-answering method and an automatic question-answering device provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. An automatic question-answering method, characterized in that, The method includes: when an input question is obtained, matching the input question with multiple preset first question templates to obtain a matching score corresponding to each first question template; wherein each first question template includes a first preset question and a first preset answer corresponding to the first preset question; determining the top N target matching scores in descending order of the matching scores, and determining the target question template corresponding to each target matching score; wherein N is a positive integer; concatenating the first preset answer in each target question template with the input question to generate an answer to be output; the answer to be output includes the final answer and the answer to complex questions; displaying the answer to be output; wherein the first preset answer in each target question template... The process of concatenating the input question with the target question template to generate the output answer includes: concatenating the first preset answer in each target question template with the input question, inputting the result into a trained text generation model, and generating the output answer; the trained text generation model is generated in the following manner: performing a first training on a preset text generation model to obtain a first candidate text generation model; the first training is used to train the generation of the final answer; performing a second training on the first candidate text generation model to obtain a second candidate text generation model; the second training is used to train the generation of complex questions from multiple simple questions; performing a third training on the second candidate text generation model to obtain a trained text generation model; the third training is used to train the generation of the answer to the complex question.
2. The automatic question-answering method according to claim 1, characterized in that, The step of matching the input question with multiple preset first question templates includes: matching the input question with multiple preset first question templates using a trained semantic similarity model; the trained semantic similarity model is generated in the following manner: using a preset text corpus and a MASK prediction method to pre-train the original semantic similarity model to obtain a pre-trained model; using similar sentences in the preset training data as positive samples and sentences other than similar sentences as negative samples, and using contrastive learning loss to fine-tune the pre-trained model to obtain the trained semantic similarity model.
3. The method according to claim 1, characterized in that, The step of performing a first training on a preset text generation model to obtain a first candidate text generation model includes: using a preset sample question, a preset second question template, and a preset final answer to perform a first training on the preset text generation model to obtain a first candidate text generation model.
4. The method according to claim 1, characterized in that, The step of performing a second training on the first candidate text generation model to obtain a second candidate text generation model includes: performing a second training on the first candidate text generation model using a preset set of simple questions and a preset set of complex questions to obtain a second candidate text generation model; wherein the preset set of simple questions and the preset set of complex questions have the same semantics.
5. The method according to claim 1, characterized in that, The step of performing a third training on the second candidate text generation model to obtain a trained text generation model includes: using a preset complex question, the answers to multiple preset simple questions, and the answers to the preset complex question to perform a third training on the second candidate text generation model to obtain a trained text generation model.
6. An automatic question-and-answer device, characterized in that, The device includes: a matching module, which, upon receiving an input question, matches the input question with multiple preset first question templates to obtain a matching score corresponding to each first question template; wherein each first question template includes a first preset question and a first preset answer corresponding to the first preset question; a determining module, which determines the top N target matching scores in descending order of the matching scores, and determines the target question template corresponding to each target matching score; wherein N is a positive integer; a generating module, which concatenates the first preset answer in each target question template with the input question to generate an answer to be output; wherein the answer to be output includes the final answer and the answer to complex questions; and an output module, which displays the answer to be output; the generating module... The module includes: a generation submodule, used to concatenate the first preset answer in each of the target question templates with the input question, and input the concatenation into a trained text generation model to generate an output answer; a first training submodule, used to perform a first training on the preset text generation model to obtain a first candidate text generation model; the first training is used to train and generate the final answer; a second training submodule, used to perform a second training on the first candidate text generation model to obtain a second candidate text generation model; the second training is used to train and generate a complex question from multiple simple questions; a third training submodule, used to perform a third training on the second candidate text generation model to obtain a trained text generation model; the third training is used to train and generate the answer to the complex question.
7. The apparatus according to claim 6, characterized in that, The matching module, upon receiving an input question, matches the input question with multiple preset first question templates to obtain a matching score corresponding to each first question template; wherein each first question template includes a first preset question and a first preset answer corresponding to the first preset question; the device further includes: a matching submodule, used to match the input question with multiple preset first question templates using a trained semantic similarity model; a training submodule, used to pre-train the original semantic similarity model using a preset text corpus and a MASK prediction method to obtain a pre-trained model; using similar sentences in the preset training data as positive samples and sentences other than similar sentences as negative samples, and using contrastive learning loss to fine-tune the pre-trained model to obtain the trained semantic similarity model.
8. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the automatic question-answering method as described in any one of claims 1-5.
9. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the automatic question-answering method as described in any one of claims 1-5.
Citation Information
Patent Citations
Data matching method, device and equipment and computer readable medium
CN112836035A
Text generation method, device and equipment and readable storage medium
CN115146050A