Intelligent question answering method and apparatus
By combining pre-trained language models and attention models in electronic devices, and dynamically selecting between retrieval-based or generative question-answering methods, the problem of inaccurate answers in multi-round question answering is solved, achieving higher intelligence and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-04
- Publication Date
- 2026-03-20
AI Technical Summary
In existing technologies, electronic devices exhibit poor natural language processing intelligence when handling multi-turn question-and-answer sessions, resulting in a poor user experience, especially when they fail to accurately determine the question type, leading to inaccurate answers.
An intelligent question-answering method is adopted, which combines pre-trained language models and attention models with extraction and generative question-answering methods. Based on the feature parameters of the already answered questions and the current question, the answering method is dynamically selected to extract or generate answers from electronic documents.
It improves the accuracy of answers in multi-turn question answering, and enhances the intelligence and user experience of natural language processing.
Smart Images

Figure CN114860895B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computers, and in particular to an intelligent question-answering method and device. BACKGROUND
[0002] With the rapid development of technology and the wide popularity of electronic devices such as computers, more and more information exists in electronic devices in the form of electronic documents. After reading the electronic document, the electronic device can usually help the user to extract the content in the electronic document through a question-answering manner.
[0003] At present, the commonly used question-answering manners include single-round question-answering and multi-round question-answering. In single-round question-answering, the electronic device can extract relevant content from the electronic document according to a question and output the content as an answer. In multi-round question-answering, the answer of the electronic device is usually generated in combination with the electronic document and historical questions. When a single-round question-answering and a multi-round question-answering are included in one question-answering, the electronic device usually needs to know in advance whether the question belongs to single-round question-answering or multi-round question-answering, and then implement targeted answering.
[0004] However, in the prior art, the user needs to pre-select whether each question is related, and there is a problem of poor intelligence of natural language processing of the electronic device and poor user experience. SUMMARY
[0005] The present application provides an intelligent question-answering method and device to solve the problem of poor intelligence of natural language processing of the electronic device and poor user experience in the prior art.
[0006] In a first aspect, the present application provides an intelligent question-answering method, comprising:
[0007] obtaining an electronic document and question data corresponding to the electronic document, the question data comprising unanswered questions and replied questions;
[0008] determining an answering manner of a current question according to the electronic document and the question data, the answering manner comprising a first answering manner and a second answering manner, the first answering manner being an extraction answering manner, the second answering manner being a generation answering manner, and the current question being one of the unanswered questions;
[0009] determining an answer of the current question according to the answering manner, the electronic document, and the question data, the answer being obtained according to the answering manner and the electronic document.
[0010] Optionally, the determining of the answering manner of the current question according to the electronic document and the question data comprises:
[0011] inputting the electronic document and the replied question into a pre-trained language model and a first attention model to obtain first features, wherein the first features include a plurality of feature parameters;
[0012] inputting the replied question and the first feature parameters into a second attention model to obtain first information, wherein the first information is a feature parameter of a first answering mode, and the first feature parameters are parameters in the first features;
[0013] inputting the current question, the replied question and the first feature parameters into a third attention model to obtain second information, wherein the second information is a feature parameter of a second answering mode;
[0014] determining the answering mode of the current question according to the first information, the second information and a preset function.
[0015] Optionally, the determining the answering mode of the current question according to the first information, the second information and a preset function comprises:
[0016] determining a probability of the first answering mode according to the first information and the preset function;
[0017] determining a probability of the second answering mode according to the second information and the preset function;
[0018] determining the answering mode of the current question according to the probability of the first answering mode and the probability of the second answering mode.
[0019] Optionally, the inputting the electronic document and the replied question into a pre-trained natural language processing model and a first attention model to obtain first features, wherein the first features include a plurality of feature parameters, comprises:
[0020] inputting the electronic document and the current question into a pre-trained language model to obtain second features, wherein the second features include a plurality of feature parameters;
[0021] inputting the second features and the replied question into the first attention model to obtain the first features.
[0022] Optionally, when the answering mode is the first answering mode, the determining the answer of the current question according to the answering mode, the electronic document and the question data comprises:
[0023] inputting part of the parameters in the first features and the replied question into a fourth attention model to obtain a start position and an end position;
[0024] According to the start position and the end position, an answer to the current question is determined in the electronic document, and the answer is a word in the electronic document from the start position to the end position.
[0025] Optionally, when the answering mode is a generation answering mode, the determining the answer to the current question according to the answering mode, the electronic document and the question data comprises:
[0026] inputting the second information as initial data into a seq2seq model;
[0027] inputting the replied question and the current question into a fifth attention model to generate third information;
[0028] inputting the third information into the seq2seq model to generate the answer to the current question.
[0029] In a second aspect, the present application provides an intelligent question answering device, comprising:
[0030] an acquisition module configured to acquire an electronic document and question data corresponding to the electronic document, wherein the question data comprises an unreplied question and a replied question;
[0031] a judgment module configured to determine an answering mode of a current question according to the electronic document and the question data, wherein the answering mode comprises a first answering mode and a second answering mode, the first answering mode is an extraction answering mode, the second answering mode is a generation answering mode, and the current question is one of the unreplied questions;
[0032] an answering module configured to determine an answer to the current question according to the answering mode, the electronic document and the question data, wherein the answer is obtained according to the answering mode and the electronic document.
[0033] Optionally, the judgment module comprises:
[0034] a first determination sub-module configured to input the electronic document and the question data into a pre-trained language model and a first attention model to calculate a first feature, wherein the first feature comprises a plurality of feature parameters;
[0035] a second determination sub-module configured to input the replied question and the first feature parameters into a second attention model to calculate first information, wherein the first information is a feature parameter of the first answering mode, and the first feature parameters are parameters in the first feature;
[0036] a third determining sub-module, configured to input the current question, the replied question and the first feature parameter into a third attention model, and calculate a second information, the second information being a feature parameter of a second answering mode;
[0037] a fourth determining sub-module, configured to determine the answering mode of the current question according to the first information, the second information and a preset function.
[0038] Optionally, the fourth determining sub-module is specifically configured to determine a probability of a first answering mode according to the first information and a preset function, determine a probability of a second answering mode according to the second information and a preset function, and determine the answering mode of the current question according to the probability of the first answering mode and the probability of the second answering mode.
[0039] Optionally, the first determining sub-module is specifically configured to input the electronic document and the current question into a pre-trained language model to obtain a second feature, the second feature including a plurality of feature parameters, and input the second feature and the replied question into a first attention model to obtain a first feature.
[0040] Optionally, when the answering mode is the first answering mode, the answering module includes:
[0041] a fifth determining sub-module, configured to input part of parameters in the first feature and the replied question into a fourth attention model to calculate a start position and an end position;
[0042] a sixth determining sub-module, configured to determine an answer of the current question in the electronic document according to the start position and the end position, the answer being a text from the start position to the end position in the electronic document.
[0043] Optionally, when the answering mode is the generative answering mode, the answering module includes:
[0044] an initializing sub-module, configured to input the second information as initial data into a seq2seq model;
[0045] a first generating sub-module, configured to input the replied question and the current question into a fifth attention model to generate a third information;
[0046] a second generating sub-module, configured to input the third information into the seq2seq model to generate an answer of the current question.
[0047] In a third aspect, the present application provides an electronic device, including a memory and a processor.
[0048] The memory is configured to store the intelligent question-answering program.
[0049] The processor is configured to invoke the intelligent question-answering program stored in the memory to execute the intelligent question-answering method in the first aspect and any possible design of the first aspect.
[0050] In a fourth aspect, the present application provides a readable storage medium, and the readable storage medium stores an execution instruction. When at least one processor of an electronic device executes the execution instruction, the electronic device executes the intelligent question-answering method in the first aspect and any possible design of the first aspect.
[0051] In a fifth aspect, the present application provides a computer program product, and the computer program product includes a computer program. When at least one processor of an electronic device executes the computer program, the electronic device executes the intelligent question-answering method in the first aspect and any possible design of the first aspect.
[0052] The intelligent question-answering method and device provided by the present application can improve the accuracy of answering the current question, improve the intelligence of natural language processing, and improve the user experience effect by obtaining the electronic document and the question data corresponding to the electronic document, selecting a question from the unanswered questions as the current question, inputting the electronic document and the question data into the intelligent question-answering model to determine the answering mode of the current question, and the answering mode includes a first answering mode and a second answering mode, the first answering mode is an extraction answering mode, and the second answering mode is a generation answering mode. BRIEF DESCRIPTION OF DRAWINGS
[0053] In order to more clearly illustrate the technical solutions of the present application or the prior art, the following will briefly introduce the drawings needed in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0054] Figure 1 A scene diagram of intelligent question-answering provided by an embodiment of the present application;
[0055] Figure 2 A model diagram of intelligent question-answering provided by an embodiment of the present application;
[0056] Figure 3 A flowchart of an intelligent question-answering method provided by an embodiment of the present application;
[0057] Figure 4 A flowchart illustrating another intelligent question-answering method provided in an embodiment of this application;
[0058] Figure 5 A schematic diagram of the structure of an intelligent question-answering device provided in an embodiment of this application;
[0059] Figure 6 A schematic diagram of the structure of another intelligent question-answering device provided in an embodiment of this application;
[0060] Figure 7 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0061] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0062] It should be understood that although the terms first, second, third, etc., may be used herein to describe various information, such information should not be limited to these terms. These terms are used only to distinguish information of the same type from one another. For example, without departing from the scope of this document, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if," as used herein, can be interpreted as "when," "when," or "in response to determination." Furthermore, as used herein, the singular forms "a," "an," and "the" are intended to also include the plural forms unless the context indicates otherwise. It should be further understood that the terms "comprising," "including," indicate the presence of a feature, step, operation, element, component, item, kind, and / or group, but do not exclude the presence, occurrence, or addition of one or more other features, steps, operations, elements, components, items, kinds, and / or groups. The terms "or" and "and / or" as used herein are interpreted as inclusive, or mean any one or any combination thereof. Therefore, "A, B, or C" or "A, B, and / or C" means "any one of the following: A; B; C; A and B; A and C; B and C; A, B, and C". Exceptions to this definition will only occur if the combination of elements, functions, steps, or operations is inherently mutually exclusive in some way.
[0063] It should be understood that although the steps in the flowcharts in the above embodiments are shown in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the indication of the arrows. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and they can be executed in other sequences. Moreover, at least part of the steps in the figure can include multiple sub-steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence is not necessarily sequential, but can be alternately or alternately executed with other steps or sub-steps or stages of other steps.
[0064] With the rapid development of technology and the wide popularity of electronic devices such as computers, more and more information exists in the form of electronic documents in electronic devices. After reading the electronic document, the electronic device can usually help the user extract the content in the electronic document in the form of question and answer. This information extraction method is widely used in machine reading comprehension. The machine reading comprehension can include the electronic device helping the user to extract the core content of the electronic document, the electronic device extracting the answer from the electronic document according to the preset question, and the like.
[0065] In the reading comprehension mode of extracting the answer from the electronic document according to the preset question, the commonly used question and answer mode includes single-turn question and answer and multi-turn question and answer. In single-turn question and answer, the current question is usually independent of other preset questions. The electronic device can extract relevant content from the electronic document according to the current question, and output the content as an answer. Most of the existing researches are carried out for this question and answer mode. The answer to the current question is usually in the form of an extraction answer, that is, the answer usually comes from a fragment in the electronic document. The electronic device can predict the start position and the end position of the answer in the electronic document. Then, the electronic device determines the answer to the current question according to the electronic document and the start position and the end position. The data set of this extraction answer mode is easy to make, the data model is simple, and the accuracy of the answer is high.
[0066] However, in a multi-turn question and answer, the current question is usually related to the replied question, and is not completely independent. The correlation can include that there is a certain correlation between the current question and the question of the replied question, or there is a certain correlation between the current question and the answer of the replied question. At this time, if the electronic device still uses the extraction answering mode to answer the current question, there can be a question with an inaccurate answer. That is, when the current question is a question in a multi-turn question and answer, the electronic device cannot directly extract relevant content from the electronic document as an answer according to the current question. Therefore, when the current question is a question in a multi-turn question and answer, the electronic device can use the generation answering mode to generate an answer to the current question according to the electronic document, the replied question and the current question.
[0067] However, the preset question can also include questions of single-turn question and answer and multi-turn question and answer at the same time. When the electronic device knows in advance that the current question belongs to single-turn question and answer or multi-turn question and answer, the electronic device can determine the answering mode of the current question according to the question and answer mode of the current question. When the electronic device is not sure whether the current question belongs to single-turn question and answer or multi-turn question and answer, Chuan Meng et al. once proposed a hybrid decoding method for a dialogue system in the prior art. The overall decoding structure of the hybrid decoding method is generation decoding, that is, the current question is answered using the generation answering mode. The hybrid decoding method can judge whether the output is a single word generated or a piece of text extracted from the electronic document in each step of decoding. However, the hybrid decoding method defaults that the context has a correlation, and once the replied question is wrong, the subsequent reply to the unanswered question will be more prone to errors.
[0068] To solve the above problems, an intelligent question and answer method is proposed in the present application. In the present application, the electronic device inputs the electronic document and the current question into a natural language recognition model to obtain a second feature. The electronic device inputs the second feature and the replied question into an attention model to obtain a first feature. The electronic device can determine first information according to a first feature parameter in the first feature and the replied question. The first information is used to determine the probability of a first answering mode. The first answering mode is the extraction answering. The electronic device can determine second information according to the first feature parameter, the replied question and the current question. The second information is used to determine the probability of a second answering mode. The second answering mode is the generation answering. The electronic device can determine the answering mode of the current question according to the first information and the second information. Then, the electronic device uses different extraction modes to extract an answer to the current question from the electronic document according to the answering mode. The intelligent question and answer mode of the present application enables the system to determine the answering mode of the current question according to the replied question, and also enables the system to learn the replied question to make the answer to the current question more accurate.
[0069] The technical solutions of the present application are described in detail below with specific examples. The following specific examples can be combined with each other, and the same or similar concepts or processes may not be described in some examples.
[0070] Figure 1 A scene diagram of an intelligent question answering provided by an embodiment of the present application is shown. As shown in the figure, it includes an article and a question and answer pair. The article part shows an electronic document including four paragraphs. The question and answer pair part shows four rounds of question and answer. Each round of question and answer includes a question Q, a clue R and an answer A. As can be seen from the figure, the second question is “What is the name of her dog?”. “She” in the question refers to “Alida” in the answer 1. If the first question is not answered or answered incorrectly, the answer to the second question will be affected. As can be seen from the figure, the fourth question is “What makes the children feel at ease?”. The question is not directly related to the previous three rounds of questions. If the questions and answers of the previous three rounds of question and answer are added to the reference, Alida and Gibbs will affect the answer to the question in the fourth round of question and answer. Figure 1
[0071] A model diagram of an intelligent question answering provided by an embodiment of the present application is shown. As shown in the figure, the intelligent question answering model mainly adopts a hybrid framework of a pre-trained language model and a bidirectional recurrent neural network. The pre-trained language model can be a natural language processing model such as a BERT model, a RoBERTa model, etc. The bidirectional recurrent neural network can be a BiGRU model, a BiLSTM model, etc. Figure 2 Figure 2 The present application arranges an electronic document and a current question into an input sequence and inputs the input sequence into a pre-trained language model. The input sequence can be as shown in the lower right corner of the figure. The input sequence includes words / characters in the electronic document and the current question. The electronic document and the current question are separated by a separator [SEP]. The electronic device encodes the input sequence to obtain word embedding, segment embedding and position embedding information of each word / character. The electronic device adds the three kinds of information to obtain the output of the encoding end Encoder. After learning of the pre-trained language model, the output of the encoding end can obtain a second feature. The second feature can be represented as U j . Wherein j is a positive integer, representing the number of features in the second feature. For example, as shown in the figure, the second feature U
[0072] Figure 2 As shown, the second feature includes 8 feature parameters. When j = 0, U0represents the output of the first special symbol [CLS] of the pre-trained language model. [CLS] is the cumulative representation of the input sequence, that is, the U0contains the cumulative information of the entire input sequence.
[0073] In order to better utilize U0and realize the selection of the answering mode, the application uses a recurrent neural network to learn the replied question and the current question. The electronic device first uses a recurrent neural network to learn the current question and the conversation history respectively. The electronic device adds the learned conversation history, the current question and U0to the first attention model, the second attention model and the third attention model to realize the calculation of the first information and the second information. The first information can be as shown in letter A in Figure 2 The second information can be as shown in letter B in Figure 2 The electronic device calculates P(A) and P(B) according to the first information and the second information. P(A) is used to represent the probability of selecting the extractive answering mode. P(B) is used to represent the probability of selecting the generative answering mode. The electronic device can determine the answering mode of the current question by comparing P(A) and P(B). For example, when P(A) > P(B), the electronic device selects the extractive answering mode to answer the current question. Otherwise, the electronic device selects the generative answering mode to answer the current question.
[0074] In the application, the electronic device is the execution subject of the intelligent question answering method of the embodiments. Specifically, the execution subject can be a hardware device of the electronic device, or a software application for implementing the embodiments in the electronic device, or a computer readable storage medium installed with the software application for implementing the embodiments.
[0075] Figure 3 A flowchart of an intelligent question answering method provided by an embodiment of the application is shown. In Figure 1 and Figure 2 Based on the embodiments shown in Figure 3 As the execution subject, the method of the embodiment can include the following steps:
[0076] S101, obtaining an electronic document and question data corresponding to the electronic document, the question data including an unanswered question and a replied question.
[0077] In this embodiment, the electronic device obtains an electronic document and problem data corresponding to the electronic document. The electronic document and the problem data are content that the electronic device needs to read and understand. The electronic device will determine the answer to the current question from the electronic document according to the problem data and reply. The problem data includes at least one question. The question needs to be replied by the electronic device according to the electronic document. The problem data can include unanswered questions and answered questions. The answered question is a question that has been replied in the problem data corresponding to the electronic document. The unanswered question is a question that has not been replied in the problem data corresponding to the electronic document.
[0078] S102, determining the answering mode of the current question according to the electronic document and the problem data, the answering mode including a first answering mode and a second answering mode, the first answering mode being an extraction answering mode, the second answering mode being a generation answering mode, and the current question being one of the unanswered questions.
[0079] In this embodiment, the electronic device selects one question from the unanswered questions as the current question. The electronic device will reply to the current question in the following steps. The questions in the problem data can include serial numbers. When the questions in the problem data include serial numbers, the electronic device can reply to the unanswered questions in the problem data in order according to the serial numbers. When the questions in the problem data include serial numbers, the current question is the question with the earliest serial number in the unanswered questions.
[0080] The electronic device can include an intelligent question and answer model as shown in Figure 2 After obtaining the electronic document and the problem data, the electronic device can input the electronic document and the problem data into the intelligent question and answer model. The electronic device can determine the answering mode of the current question through the pre-trained language model and the attention model in the intelligent question and answer model. The answering mode of the current question includes the first answering mode and the second answering mode. The first answering mode is an extraction answering mode, that is, the electronic device can extract the corresponding content from the electronic document and determine that the content is the answer to the current question. The second answering mode is a generation answering mode, that is, the electronic device can extract features from the electronic document and the answered questions, and generate the answer to the current question according to the features.
[0081] S103, determining the answer to the current question according to the answering mode, the electronic document and the problem data, the answer being obtained according to the answering mode and the electronic document.
[0082] In this embodiment, when the electronic device determines the answering mode of the current question, the electronic device can extract the answer of the current question from the electronic document according to the answering mode, or the electronic device can generate the answer of the current question according to the answering mode and the electronic document. When the answering mode is the first answering mode, the electronic device can extract the corresponding content from the electronic document and determine that the content is the answer of the current question. When the answering mode is the second answering mode, the electronic device can extract features from the electronic document and the replied questions, and generate the answer of the current question according to the features.
[0083] The intelligent question answering method provided in the application includes the following steps: an electronic device obtains an electronic document and question data corresponding to the electronic document. The electronic device selects a question from the unreplied questions as a current question. The electronic device inputs the electronic document and the question data into the intelligent question answering model to determine an answering mode of the current question. The answering mode includes a first answering mode and a second answering mode. The first answering mode is an extraction answering mode, and the second answering mode is a generation answering mode. When the electronic device determines the answering mode of the current question, the electronic device can extract the answer of the current question from the electronic document according to the answering mode, or the electronic device can generate the answer of the current question according to the answering mode and the electronic document. In the application, by determining the answering mode of the current question, the accurate extraction of the answer of the current question is realized, the intelligence of natural language processing is improved, and the user experience is improved.
[0084] Figure 4 A flowchart of another intelligent question answering method provided by an embodiment of the application is shown. In FIG. 1 to Figure 3 Based on the embodiments shown in FIG. 1 to Figure 4 The method provided by the embodiment can include the following steps with the electronic device as the execution subject:
[0085] S201, obtaining an electronic document and question data corresponding to the electronic document, the question data including unreplied questions and replied questions.
[0086] The step S201 is similar to the step S101 in the embodiment, and will not be described here. Figure 3 The implementation of the step S101 in the embodiment is similar, and will not be described here.
[0087] S202, inputting the electronic document and the question data into a preset natural language processing model and a first attention model to calculate a first feature, the first feature including a plurality of feature parameters.
[0088] In this embodiment, after obtaining the electronic document and the question data, the electronic device inputs the electronic document and the current question into a preset natural language processing model to obtain a second feature. The electronic device inputs the second feature and the replied question into a first attention model to obtain a first feature. The specific steps of the process can include:
[0089] Step 1: input the electronic document and the current question into a preset natural language processing model to obtain a second feature, which includes a plurality of feature parameters.
[0090] In this step, after obtaining the electronic document and the current question, the electronic device adds the electronic document and the current question into an input sequence. The input sequence includes a special symbol [CLS] and a separator [SEP]. The special symbol [CLS] is located at the head of the input sequence. The separator [SEP] is located between the electronic document and the current question, and is used to separate the electronic document and the current question.
[0091] The preset natural language processing model can include an encoding module and a learning module. The encoding module is used to encode the input sequence to obtain word embedding, segment embedding, and position embedding information of each word / token. The electronic device adds the three kinds of information to obtain the output of the encoding end. The electronic device inputs the output data of the encoding end into the learning module for learning. The learning module includes a natural language processing model such as a BERT model or a RoBERTa model. The data output by the encoding end is learned by the learning module to obtain a second feature. The second feature includes a plurality of feature parameters. For example, as shown in Figure 2 , the second feature can include 8 feature parameters, which can be represented by U0 to U7. U0 represents the output of the special symbol [CLS] in the input sequence. The U0 contains the cumulative information of the entire input sequence.
[0092] Step 2: input the second feature and the replied question into a first attention model to obtain a first feature.
[0093] In this step, after determining the second feature, the electronic device uses the first attention model to add the replied question as a hidden layer to the learning of the second feature. Through the learning of the first attention model, the second feature can learn the features of the replied question, and obtain a first feature. The number of parameters of the first feature is consistent with the number of parameters of the second feature. For example, as shown in Figure 2 , the first feature can include 8 feature parameters, which can be represented by to . Among them, The second feature is a feature learned by the first attention model from U0. The second feature also contains cumulative information of the entire input sequence.
[0094] It should be noted that the replied question used here is data of the replied question that has been subjected to feature extraction by the recurrent neural network. For example, as shown in the conversation history module in the first feature, the replied question, after being learned by the recurrent neural network, can be represented as Figure 2
[0095] S203, input the replied question and the first feature parameter into the second attention model to calculate the first information, the first information being a feature parameter of the first answering mode, and the first feature parameter being a parameter in the first feature.
[0096] In this embodiment, the first feature parameter is the first parameter in the first feature, i.e., the parameter B shown in the first feature. Figure 2 The parameter B contains cumulative information of the entire input sequence. The electronic device inputs the first feature parameter into the second attention model and adds the replied question as a hidden layer to the learning of the first feature parameter. After the first feature parameter learns the features of the replied question, the first information is obtained. The first information is a feature parameter of the first answering mode. The first answering mode is an extraction answering mode. As shown in the first information, the first information can be represented as B. It should be noted that, as in the previous step, the replied question used here is data of the replied question that has been subjected to feature extraction by the recurrent neural network. Figure 2 The second attention model can be a model with different parameters from the first attention model. The parameters of the model can be obtained by training. Alternatively, the parameters of the model can be existing parameters.
[0097] S204, input the current question, the replied question and the first feature parameter into the third attention model and calculate the second information, the second information being a feature parameter of the second answering mode.
[0098] In this embodiment, as in the previous step, the first feature parameter used in this step is the first parameter in the first feature, i.e., the parameter B.
[0099] Meanwhile, the current question and the replied question used in this step are both data subjected to feature extraction by the recurrent neural network. The data of the replied question can be, for example, the data of the replied question shown in the conversation history module in the first feature.
[0100] In this embodiment, as in the previous step, the first feature parameter used in this step is the first parameter in the first feature, i.e., the parameter B. Meanwhile, the current question and the replied question used in this step are both data subjected to feature extraction by the recurrent neural network. The data of the replied question can be, for example, the data of the replied question shown in the conversation history module in the first feature. Figure 2 The conversation history module shown in The data of the current question can be, for example, Figure 2 The the currentquestion module shown in
[0101] The electronic device inputs the first feature parameter into a third attention model, and adds the current question and the replied question as a hidden layer into the learning of the first feature parameter. After the first feature parameter learns the features of the current question and the replied question, a second information is obtained. The second information is a feature parameter of a second answering mode. The second answering mode is a generative answering mode. As shown in Figure 2 The second information can be represented as A.
[0102] The third attention model can be a model with different parameters from the first attention model. The parameters of the model can be obtained through training. Alternatively, the parameters of the model can be existing parameters.
[0103] The third attention model has the same model parameters as the second attention model. Alternatively, the third attention model can have different model parameters from the second attention model. The parameters of the model can be obtained through training. Alternatively, the parameters of the model can be existing parameters.
[0104] S205, determining the answering mode of the current question according to the first information, the second information, and a preset function.
[0105] In this embodiment, the electronic device inputs the first information and the second information into a preset function. The preset function can be an activation function such as a softmax function, a sigmoid function, etc. The electronic device determines the probability corresponding to the first information and the second information through the preset function, and determines the answering mode of the current question according to the probability. The specific process can include:
[0106] Step 1, determining the probability of the first answering mode according to the first information and the preset function.
[0107] In this step, the electronic device inputs the first information into the preset function to obtain a first probability. The first probability is the probability of the first answering mode. That is, the first probability is the probability of using the extractive answering mode to answer the current question. For example, as shown in Figure 2 The probability can be represented as P(B).
[0108] Step 2, determining the probability of the second answering mode according to the second information and the preset function.
[0109] In this step, the electronic device inputs the second information into the preset function to obtain a second probability. The second probability is the probability of the second answering mode. That is, the second probability is the probability of using the generative answering mode to answer the current question. For example, as shown in Figure 2 , the probability can be represented as P(A).
[0110] Step 3, determining the answering mode of the current question according to the probability of the first answering mode and the probability of the second answering mode.
[0111] In this step, the electronic device compares the first probability and the second probability. When the first probability is greater than the second probability, the electronic device determines that the answering mode of the current question is the first answering mode. When the first probability is less than the second probability, the electronic device determines that the answering mode of the current question is the second answering mode.
[0112] S206, when the answering mode is the first answering mode, determining the answer of the current question according to the answering mode, the electronic document and the question data.
[0113] In this embodiment, when the electronic device determines that the answering mode of the current question is the first answering mode, the electronic device answers the current question by the extraction-based answering mode. In this answering process, the electronic device needs to calculate the start position and the end position of the answer of the current question in the electronic document. Further, according to the start position and the end position, the electronic device determines the answer of the current question in the electronic document. For example, as shown in Figure 2 , the calculation process of the first answering mode can be completed by the Extraction-based Prediction module.
[0114] The specific process of the electronic device to determine the answer of the current question according to the answering mode, the electronic document and the question data includes:
[0115] Step 1, inputting part of the parameters in the first feature and the replied question into the fourth attention model to obtain the start position and the end position.
[0116] In this step, as shown in Figure 2 , the electronic device inputs the features in the first feature from to into the fourth attention model. At the same time, the electronic device inputs the replied question as a hidden layer into the learning of the above-mentioned features from to . Through the learning of the fourth attention model, the electronic device obtains the start position parameter and the end position parameter . The electronic device determines the start position in the electronic document according to the start position parameter . The electronic device determines the end position in the electronic document according to the end position parameter determining the end position in the electronic document.
[0117] The fourth attention model has different parameters from the above-mentioned attention model. The parameters of the model can be obtained by training. Alternatively, the parameters of the model can be existing parameters.
[0118] Step 2, determining the answer of the current question in the electronic document according to the start position and the end position, the answer being the text in the electronic document from the start position to the end position.
[0119] In this step, the electronic device finds the corresponding content in the electronic document according to the start position and the end position. The electronic device copies the content of the electronic document from the start position to the end position in the electronic document. The electronic device determines that the content of the electronic document from the start position to the end position is the answer to the current question. The electronic device outputs the content of the electronic document from the start position to the end position in the answer to the current question.
[0120] S207, when the answering mode is the generative answering mode, determining the answer of the current question according to the answering mode, the electronic document and the question data.
[0121] In this embodiment, when the electronic device determines that the answering mode of the current question is the second answering mode, the electronic device answers the current question by the generative answering mode. In the answering process, the electronic device needs to decode the features to generate a word or a sentence. The word or the sentence generated by the electronic device is the answer to the current question. For example, as shown in the following table, the calculation process of the second answering mode can be completed by a Generation-based Prediction module. Figure 2
[0122] The specific process of determining the answer of the current question by the electronic device according to the answering mode, the electronic document and the question data includes:
[0123] Step 1, inputting the second information as initial data into the seq2seq model.
[0124] In this step, the electronic device inputs the second information calculated in S205 as the initialization input into the seq2seq model. The seq2seq model generates the first word according to the initialization input. The seq2seq model takes the generated word as the input of the next step.
[0125] Step 2, inputting the replied question and the current question into the fifth attention model to generate third information.
[0126] In this step, the electronic device inputs the current question of the current question module and the replied question in the conversation history module into the fifth attention model. The electronic device generates third information through the first attention model. The third information is obtained by learning the replied question and the current question.
[0127] The fifth attention model is a model with different parameters from the above attention model. The parameters of the model can be obtained by training. Alternatively, the parameters of the model can be existing parameters.
[0128] Step 3, input the third information into the seq2seq model to generate the answer to the current question.
[0129] In this step, the seq2seq model takes the word / word generated in the last step as the input of the current step, and the electronic device also inputs the third information as the hidden state of the current step. The electronic device calculates the word / word output in the current step according to the third information and the word / word generated in the last step, and generates the word / word in the current step.
[0130] The electronic device sequentially generates the answer to the current question according to the above method until the end symbol is output.
[0131] When the electronic device outputs the end symbol, the electronic device determines that the output content currently generated is the answer to the current question.
[0132] The intelligent question answering method provided in the application, an electronic device obtains an electronic document and question data corresponding to the electronic document. The electronic device inputs the electronic document and a current question into a preset natural language processing model to obtain second features. The electronic device inputs the second features and a replied question into a first attention model to obtain first features. The electronic device inputs the first feature parameters into a second attention model and adds the replied question as a hidden layer into learning of the first feature parameters. When the first feature parameters learn the features of the replied question, first information is obtained. The electronic device inputs the first feature parameters into a third attention model and adds the current question and the replied question as hidden layers into learning of the first feature parameters. When the first feature parameters learn the features of the current question and the replied question, second information is obtained. The electronic device determines a probability corresponding to the first information and the second information through the preset function, and determines an answering mode of the current question according to the probability. When the answering mode is a first answering mode, the electronic device determines an answer of the current question according to the answering mode, the electronic document and the question data. When the answering mode is a generated answering mode, the electronic device determines an answer of the current question according to the answering mode, the electronic document and the question data. In the application, the answering mode of the current question is determined, the accuracy of the answer of the current question is realized, the intelligence of natural language processing is improved, and the user experience is improved.
[0133] Figure 5 A structural schematic diagram of an intelligent question answering device provided in an embodiment of the application is shown in FIG. 1. Figure 5 The intelligent question answering device 10 in the embodiment is used to realize the operations of the electronic device corresponding to any method embodiment described above. The intelligent question answering device 10 in the embodiment includes:
[0134] The obtaining module 11 is configured to obtain an electronic document and question data corresponding to the electronic document, the question data including replied questions and unanswered questions.
[0135] The determining module 12 is configured to determine an answering mode of a current question according to the electronic document and the question data, the answering mode including a first answering mode and a second answering mode, the first answering mode being an extraction answering mode, the second answering mode being a generated answering mode, and the current question being one of the unanswered questions.
[0136] The answering module 13 is configured to determine an answer of the current question according to the answering mode, the electronic document and the question data, the answer being obtained according to the answering mode and the electronic document.
[0137] The intelligent question answering device 10 provided in the embodiment of the application can execute the method embodiments described above, and the specific implementation principles and technical effects can be referred to the method embodiments described above, which will not be described here in the embodiment.
[0138] Figure 6 Fig. 1 shows a structural schematic diagram of another intelligent question answering device provided by an embodiment of the present application, in which Figure 5 Based on the embodiment shown, as Figure 6 The intelligent question answering device 10 of the embodiment is used to implement the operation corresponding to the electronic device in any of the above method embodiments. The judgment module 11 and the answering module 13 of the embodiment include:
[0139] The first determining sub-module 121 is configured to input the electronic document and the question data into the pre-trained language model and the first attention model, and calculate a first feature, the first feature including a plurality of feature parameters.
[0140] The second determining sub-module 122 is configured to input the replied question and the first feature parameter into the second attention model, and calculate a first information, the first information being a feature parameter of the first answering mode, and the first feature parameter being a parameter in the first feature.
[0141] The third determining sub-module 123 is configured to input the current question, the replied question and the first feature parameter into the third attention model, and calculate a second information, the second information being a feature parameter of the second answering mode.
[0142] The fourth determining sub-module 124 is configured to determine the answering mode of the current question according to the first information, the second information and a preset function.
[0143] In an example, the fourth determining sub-module is specifically configured to determine a probability of the first answering mode according to the first information and the preset function; determine a probability of the second answering mode according to the second information and the preset function; and determine the answering mode of the current question according to the probability of the first answering mode and the probability of the second answering mode.
[0144] In an example, the first determining sub-module is specifically configured to input the electronic document and the current question into the pre-trained language model to obtain a second feature, the second feature including a plurality of feature parameters; and input the second feature and the replied question into the first attention model to obtain the first feature.
[0145] When the answering mode is the first answering mode, the answering module 13 includes:
[0146] The fifth determining sub-module 131 is configured to input part of the parameters in the first feature and the replied question into the fourth attention model, and calculate a start position and an end position.
[0147] The sixth determining sub-module 132 is configured to determine an answer of the current question in the electronic document according to the start position and the end position, the answer being a text from the start position to the end position in the electronic document.
[0148] When the answering mode is the generative answering mode, the answering module 13 comprises:
[0149] The initialization submodule 133 is configured to input the second information as initial data into the seq2seq model.
[0150] The first generation submodule 134 is configured to input the replied question and the current question into the fifth attention model to generate the third information.
[0151] The second generation submodule 135 is configured to input the third information into the seq2seq model to generate the answer to the current question.
[0152] The intelligent question answering device 10 provided by the embodiment of the present application can execute the method embodiments described above, and the specific implementation principles and technical effects can be referred to the method embodiments described above, and the embodiment will not be described here again.
[0153] Figure 7 A hardware structure schematic diagram of an electronic device provided by the embodiment of the present application is shown. As shown in FIG. 7, the electronic device 20 is configured to implement the operations corresponding to the electronic device in any of the method embodiments described above, and the electronic device 20 of the embodiment can comprise a memory 21 and a processor 22.
[0154] The memory 21 is configured to store a computer program. The memory 21 can comprise a random access memory (RAM) and can also comprise a non-volatile memory (NVM), for example at least one disk memory, and can also be a U disk, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0155] The processor 22 is configured to execute the computer program stored in the memory to implement the intelligent question answering method in the embodiments described above. Details can be referred to the related description in the method embodiments described above.
[0156] Optionally, the memory 21 can be independent or integrated with the processor 22.
[0157] When the memory 21 is independent of the processor 22, the electronic device 20 can further comprise:
[0158] A bus 23 is used to connect the memory 21 and the processor 22. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, and the like. For the sake of representation, the bus in the drawings of the present application does not limit to only one bus or one type of bus.
[0159] The electronic device provided in the embodiment can be used to execute the intelligent question and answer method described above, and the implementation manner and technical effects are similar. The embodiment will not be described here.
[0160] The present application also provides a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the method provided in various embodiments.
[0161] The present application also provides a program product, which includes execution instructions stored in a computer readable storage medium. At least one processor of a device can read the execution instructions from the computer readable storage medium, and the at least one processor executes the execution instructions to make the device implement the method provided in various embodiments.
[0162] The present application also provides a chip, which includes a memory and a processor. The memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the device installed with the chip executes the method in various possible embodiments.
[0163] It should be understood that the processor described above can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), or the like. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the application can be directly embodied as the execution of the hardware processor, or the execution of the combination of hardware and software modules in the processor.
[0164] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented by other manners. For example, the apparatus embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and actual implementation can have another division manner, for example, a plurality of modules can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed modules can be indirect coupling or communication connection through some interfaces, apparatuses or modules, and can be electrical, mechanical or other forms.
[0165] The modules described as separate components can or can not be physically separated, and the components shown as modules can or can not be physical units, that is, can be located in one place, or can be distributed to a plurality of network units. Part or all of the modules can be selected to achieve the purpose of the embodiment according to actual needs.
[0166] In addition, the function modules in each embodiment of the present application can be integrated in one processing unit, or each module can be physically present separately, or two or more modules can be integrated in one unit. The unit formed by the above modules can be realized in the form of hardware or in the form of hardware and software function unit.
[0167] The integrated modules realized in the form of software function modules can be stored in a computer readable storage medium. The software function modules are stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, an electronic device, or a network device, etc.) or a processor to execute part of the steps of the method of each embodiment of the present application.
[0168] Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by program instruction related hardware. The aforementioned program can be stored in a computer readable storage medium. The program executes when executed, and the steps of the above-mentioned method embodiments are executed. The aforementioned storage medium includes ROM, RAM, magnetic disc or optical disc and various storage medium which can store program code.
[0169] Finally, it should be pointed out that the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions recorded in the above embodiments can be modified, or some or all of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. An intelligent question-answering method, characterized in that, The method includes: Acquire electronic documents and corresponding issue data, including unanswered and answered issues; Based on the electronic document and question data, the answering method for the current question is determined. The answering method includes a first answering method and a second answering method. The first answering method is an extraction-based answering method, and the second answering method is a generation-based answering method. The current question is one of the unanswered questions. The answer to the current question is determined based on the answering method, the electronic document, and the question data. The answer is obtained based on the answering method and the electronic document. The step of determining the answer method for the current question based on the electronic document and question data includes: The electronic document and the question data are input into a pre-trained language model and a first attention model to calculate a first feature, which includes multiple feature parameters. The answered question and the first feature are input into the second attention model to calculate the first information, where the first information is the feature parameter of the first answering method and the first feature parameter is the parameter in the first feature. The current question, the answered question, and the first feature parameter are input into the third attention model, and the second information is calculated, which is the feature parameter of the second answering method. Based on the first information, the second information, and the preset function, the answer method for the current question is determined, wherein the preset function is an activation function; The step of determining the answer method for the current question based on the first information, the second information, and the preset function includes: Based on the first information and the preset function, determine the probability of the first answer method; Based on the second information and the preset function, determine the probability of the second answer method; The answer method for the current question is determined based on the probability of the first answer method and the probability of the second answer method.
2. The method according to claim 1, characterized in that, The electronic document and the answered questions are input into a preset natural language processing model and a first attention model to calculate a first feature, which includes multiple feature parameters, including: The electronic document and the current question are input into a pre-trained language model to obtain a second feature, which includes multiple feature parameters; The second feature and the answered question are input into the first attention model to obtain the first feature.
3. The method according to claim 1 or 2, characterized in that, When the answering method is the first answering method, determining the answer to the current question based on the answering method, the electronic document, and the question data includes: Input some parameters from the first feature and the answered question into the fourth attention model to calculate the start and end positions; Based on the start position and the end position, determine the answer to the current question in the electronic document, where the answer is the text in the electronic document from the start position to the end position.
4. The method according to claim 1 or 2, characterized in that, When the answering method is a generative answering method, determining the answer to the current question based on the answering method, the electronic document, and the question data includes: The second information is used as initial data input into the seq2seq model; The already answered questions and the current question are input into the fifth attention model to generate third information; The third piece of information is input into the seq2seq model to generate the answer to the current question.
5. An intelligent question-and-answer device, characterized in that, The device includes: The acquisition module is used to acquire electronic documents and corresponding issue data for the electronic documents, wherein the issue data includes unanswered issues and answered issues. The judgment module is used to determine the answering method for the current question based on the electronic document and question data. The answering method includes a first answering method and a second answering method. The first answering method is an extraction-based answering method, and the second answering method is a generation-based answering method. The current question is one of the unanswered questions. The question-answering module is used to determine the answer to the unanswered question based on the question-answering method, the electronic document, and the question data. The answer is obtained based on the question-answering method and the electronic document. The judgment module includes: The first determining submodule is used to input the electronic document and the question data into a pre-trained language model and a first attention model to calculate a first feature, wherein the first feature includes multiple feature parameters; The second determining submodule is used to input the answered question and the first feature into the second attention model to calculate the first information, where the first information is the feature parameter of the first answering method and the first feature parameter is the parameter in the first feature. The third determining submodule is used to input the current question, the answered question, and the first feature parameter into the third attention model, and calculate the second information, which is the feature parameter of the second answering method; The fourth determining submodule is used to determine the answer method for the current question based on the first information, the second information, and a preset function, wherein the preset function is an activation function; The fourth determining submodule is specifically used to determine the probability of the first answer method based on the first information and the preset function; determine the probability of the second answer method based on the second information and the preset function; and determine the answer method for the current question based on the probability of the first answer method and the probability of the second answer method.
6. An electronic device, characterized in that, The electronic device includes: a memory and a processor; Memory; used to store intelligent question-answering programs; A processor is configured to implement the intelligent question-answering method as described in any one of claims 1 to 4, based on the intelligent question-answering program.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores an intelligent question-answering program, which, when executed by a processor, is used to implement the intelligent question-answering method as described in any one of claims 1 to 4.
8. A computer program product, characterized in that, The computer program product includes a computer program, characterized in that, when executed by a processor, the computer program implements the intelligent question-answering method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Machine reading understanding method for complex data
CN110134946A
Dialogue method and system based on free text knowledge
CN110297895A