Question answer determination method and device, equipment, medium and program product
By using the answer generation model and feature fusion technology in the intelligent question and answer system, the problem of inaccurate matching of answers to complex questions is solved, and more accurate and efficient information acquisition is achieved.
Patent Information
- Application Number
- CN202410826476.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-09-20
AI Technical Summary
When existing intelligent question answering systems face complex questions, keyword matching is difficult to determine the most accurate answer, resulting in low information utilization efficiency and the need for manual screening.
By inputting the question to be processed into a pre-trained answer generation model, the initial answer is obtained, feature fusion is performed with it, a fusion vector is generated, and the reference vectors of multiple candidate answers are combined for similarity matching, and the target answer is determined based on the matching probability.
It improves the accuracy and reliability of answers, reduces the need for manual screening, and improves information utilization efficiency.
Smart Images

Figure CN118673159A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of artificial intelligence, natural language processing and financial technology, and more specifically to a method, apparatus, device, medium and program product for determining an answer to a question. Background Art
[0002] With the development of natural language processing technology, intelligent question-answering systems have emerged, which parse questions described in natural language and return answers that match the questions. At present, question-answering systems mainly retrieve relevant information from the knowledge base based on keyword matching according to the questions raised by users to obtain relevant answers.
[0003] However, when faced with complex problems, due to a certain degree of similarity between keywords, one question may usually match multiple candidate answers, and it is not certain which candidate answer is the most accurate. Manual investigation and screening are required to find the required accurate information, which reduces the efficiency of information utilization. Summary of the invention
[0004] In view of the above problems, the present disclosure provides a method, apparatus, device, medium and program product for determining an answer to a question.
[0005] According to a first aspect of the present disclosure, a method for determining an answer to a question is provided, comprising: obtaining a plurality of candidate answers matching a question to be processed from a question-and-answer knowledge base; inputting the question to be processed into a pre-trained answer generation model to obtain an initial answer; performing feature fusion on the question to be processed and the initial answer to obtain a fusion vector; performing similarity matching on the fusion vector with a plurality of reference vectors respectively to obtain a matching probability corresponding to each reference vector, wherein the plurality of reference vectors are obtained based on a plurality of candidate answers; and determining a corresponding target answer from the plurality of candidate answers according to the matching probability corresponding to each reference answer vector.
[0006] According to an embodiment of the present disclosure, feature fusion is performed on the question to be processed and the initial answer to obtain a fusion vector, including: vectorizing the question to be processed and the initial answer respectively to obtain a question to be processed vector and an initial answer vector; fusing the question to be processed vector and the initial answer vector to obtain a fusion vector.
[0007] According to an embodiment of the present disclosure, the problem vector to be processed and the initial answer vector are fused to obtain a fused vector, including: inputting the problem vector to be processed and the initial answer vector into a fully connected layer network with a nonlinear activation function to obtain a first eigenvector of the problem vector to be processed and a second eigenvector of the initial answer vector, respectively; performing weighted fusion on the first eigenvector and the second eigenvector to obtain a fused vector.
[0008] According to an embodiment of the present disclosure, a corresponding target answer is determined from multiple candidate answers based on the matching probability corresponding to each reference answer vector, including: sorting the multiple candidate answers from large to small according to the matching probability to obtain a sorting result; based on a preset number of target answers, selecting a preset number of candidate answers ranked at the top of the sorting result as the target answer.
[0009] According to an embodiment of the present disclosure, the above method also includes: vectorizing the question to be processed and multiple candidate answers respectively to obtain a question to be processed vector and multiple candidate answer vectors; and fusing the question to be processed vector with multiple candidate answer vectors respectively to obtain multiple reference vectors.
[0010] According to an embodiment of the present disclosure, an answer generation model includes an encoder, a decoder and an attention mechanism; a problem to be processed is input into a pre-trained answer generation model to obtain an initial answer, including: encoding the problem to be processed using the encoder, and outputting a state sequence vector of the problem to be processed at each time step; performing weighted averaging processing on the state sequence vectors of all hidden layers using the attention mechanism to obtain a context vector; decoding using a decoder according to the state sequence vector and the context vector at each time step, and outputting a predicted vocabulary at each time step; and determining the initial answer based on the predicted vocabulary output at each time step.
[0011] According to an embodiment of the present disclosure, the answer generation model also includes a pointer network; decoding is performed using a decoder according to the state sequence vector and the context vector of each time step, and a predicted vocabulary at each time step is output, including: calculating using a decoder according to the state sequence vector and the context vector to obtain the probability of generating a new vocabulary at each time step; calculating using a pointer network according to the state sequence vector, the context vector and the problem to be processed to obtain the probability of copying vocabulary from the problem to be processed at each time step; when the probability of copying vocabulary is greater than the probability of generating new vocabulary, the copied vocabulary is used as the predicted vocabulary for each time step.
[0012] The second aspect of the present disclosure provides a device for determining an answer to a question, including: an acquisition module, used to acquire multiple candidate answers matching the question to be processed from a question and answer knowledge base; a generation module, used to input the question to be processed into a pre-trained answer generation model to obtain an initial answer; a fusion module, used to perform feature fusion on the question to be processed and the initial answer to obtain a fusion vector; a matching module, used to perform similarity matching on the fusion vector with multiple reference vectors respectively to obtain a matching probability corresponding to each reference vector, wherein the multiple reference vectors are obtained based on multiple candidate answers; and a determination module, used to determine the corresponding target answer from multiple candidate answers according to the matching probability corresponding to each reference answer vector.
[0013] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.
[0014] The fourth aspect of the present disclosure further provides a computer-readable storage medium having a computer program or instructions stored thereon, which implements the steps of the above method when the above computer program or instructions are executed by a processor.
[0015] The fifth aspect of the present disclosure further provides a computer program product, including a computer program or instructions, which implement the steps of the above method when the above computer program or instructions are executed by a processor.
[0016] According to the method for determining answers to questions provided by the present invention, by first inputting the question to be processed into a pre-trained answer generation model, an initial answer can be quickly provided for the question to be processed, and then the features of the question to be processed and the initial answer are fused to obtain a fusion vector, and then the fusion vector is matched with multiple reference vectors obtained based on multiple candidate answers for similarity, and a target answer is determined from multiple candidate answers based on the matching probability. By combining the question-answering knowledge base and the answer generation model, it is possible to fully utilize existing knowledge and data, and at the same time, combined with the actual situation of the problem, the determined target answer is more accurate and reliable. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above contents and other purposes, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0018] Figure 1 A diagram schematically illustrates an application scenario of a method, apparatus, device, medium, and program product for determining a question answer according to an embodiment of the present disclosure;
[0019] Figure 2 A flowchart schematically shows a method for determining an answer to a question according to an embodiment of the present disclosure;
[0020] Figure 3 A flowchart of a method for generating an initial answer according to an embodiment of the present disclosure is schematically shown;
[0021] Figure 4 The schematic diagram of the principle of generating an initial answer according to an embodiment of the present disclosure is shown;
[0022] Figure 5 A structural block diagram schematically shows a device for determining an answer to a question according to an embodiment of the present disclosure; and
[0023] Figure 6A block diagram of an electronic device suitable for implementing a method for determining an answer to a question according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0024] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0025] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0026] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0027] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0028] In the technical solution of the present disclosure, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0029] In the scenario of using personal information for automated decision-making, the methods, devices, and systems provided by the embodiments of the present disclosure provide users with corresponding operation portals for users to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered. The expression "automated decision-making" here refers to the activity of automatically analyzing and evaluating a person's behavioral habits, interests and hobbies, or economic, health, credit status, etc. through computer programs, and making decisions. The expression "expert decision-making" here refers to the activity of making decisions by people who specialize in a certain field, have specialized experience, knowledge and skills, and have reached a certain level of professionalism.
[0030] The inventors found that the data on existing production problems is huge, and it is difficult for staff to quickly adapt to suitable solutions. When faced with numerous and complex problems, in order to adapt to efficient solutions, staff have to screen, judge and process problems in the face of huge data, which is time-consuming and labor-intensive. Therefore, how to quickly improve the speed of adapting to suitable production problem solutions has become a problem that needs to be solved urgently.
[0031] In view of this, an embodiment of the present disclosure provides a method for determining an answer to a question, including: obtaining multiple candidate answers that match the question to be processed from a question and answer knowledge base; inputting the question to be processed into a pre-trained answer generation model to obtain an initial answer; performing feature fusion on the question to be processed and the initial answer to obtain a fusion vector; performing similarity matching on the fusion vector with multiple reference vectors respectively to obtain a matching probability corresponding to each reference vector, wherein the multiple reference vectors are obtained based on multiple candidate answers; and determining a corresponding target answer from the multiple candidate answers according to the matching probability corresponding to each reference answer vector.
[0032] Figure 1 The application scenario diagram of the method, apparatus, device, medium and program product for determining the answer to a question according to an embodiment of the present disclosure is schematically shown.
[0033] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0034] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0035] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0036] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0037] It should be noted that the method for determining the answer to the question provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the apparatus for determining the answer to the question provided in the embodiment of the present disclosure can generally be set in the server 105. The method for determining the answer to the question provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the apparatus for determining the answer to the question provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.
[0038] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0039] The following will be based on Figure 1 The scene described by Figure 2~Figure 4 The question answer determination method of the disclosed embodiment is described in detail.
[0040] Figure 2 The flowchart of the method for determining the answer to a question according to an embodiment of the present disclosure is schematically shown.
[0041] like Figure 2 As shown, the question answer determination method of this embodiment includes operations S210 to S250, and the transaction processing method can be executed by a terminal device or a server.
[0042] In operation S210, a plurality of candidate answers matching the question to be processed are obtained from the question-answering knowledge base.
[0043] In operation S220, the question to be processed is input into a pre-trained answer generation model to obtain an initial answer.
[0044] In operation S230, feature fusion is performed on the question to be processed and the initial answer to obtain a fusion vector.
[0045] In operation S240, the fusion vector is matched with a plurality of reference vectors respectively for similarity, so as to obtain a matching probability corresponding to each reference vector, wherein the plurality of reference vectors are obtained based on a plurality of candidate answers.
[0046] In operation S250, a corresponding target answer is determined from a plurality of candidate answers according to the matching probability corresponding to each reference answer vector.
[0047] According to an embodiment of the present disclosure, a question set that is close, similar or associated with the problem to be processed and a set of answers corresponding to the question set are stored in the question and answer knowledge base. Based on keyword matching or semantic matching, multiple candidate answers related to the problem to be processed can be quickly screened out from the question and answer knowledge base.
[0048] According to an embodiment of the present disclosure, the answer generation model may be a deep learning model pre-trained based on a training set of questions and their corresponding answers.
[0049] According to the embodiments of the present disclosure, the initial answer obtained by the answer generation model can be a basic answer framework, which is a corresponding question answer generated based on the semantic description of the problem to be processed. It may be similar or close to the standard answer matching the problem to be processed in the document knowledge base, but may not be complete and accurate enough. Therefore, the initial answer can be used as a matching basis to screen out a complete and accurate answer from multiple candidate answers.
[0050] According to an embodiment of the present disclosure, the initial answer can characterize part and main features of the standard answer, and a fusion vector is obtained by extracting features from the problem to be processed and the initial answer and fusing them. The fusion vector combines the feature information of the problem to be processed and the initial answer.
[0051] According to the embodiment of the present disclosure, the similarity scores between the fusion vector and the multiple reference vectors can be calculated by cosine similarity, and then the similarity scores can be converted into probability values by normalization (such as softmax function). Each reference vector will get a probability value between 0 and 1 to indicate the similarity (or matching degree) between each reference vector and the fusion vector. The final target answer is determined according to the size of the matching probability.
[0052] According to the method for determining answers to questions provided by the present invention, by first inputting the question to be processed into a pre-trained answer generation model, an initial answer can be quickly provided for the question to be processed, and then the features of the question to be processed and the initial answer are fused to obtain a fusion vector, and then the fusion vector is matched with multiple reference vectors obtained based on multiple candidate answers for similarity, and a target answer is determined from multiple candidate answers based on the matching probability. By combining the question-answering knowledge base and the answer generation model, it is possible to fully utilize existing knowledge and data, and at the same time, combined with the actual situation of the problem, the determined target answer is more accurate and reliable.
[0053] According to an embodiment of the present disclosure, the answer generation model includes an encoder, a decoder, and an attention mechanism.
[0054] Figure 3 The flowchart of the method for generating an initial answer according to an embodiment of the present disclosure is schematically shown.
[0055] like Figure 3 As shown, the method includes operations S310 to S340.
[0056] In operation S310, the problem to be processed is encoded by using an encoder, and a state sequence vector of the problem to be processed is output at each time step.
[0057] In operation S320, the state sequence vectors of all hidden layers are weighted averaged using an attention mechanism to obtain a context vector.
[0058] In operation S330, decoding is performed using a decoder according to the state sequence vector and the context vector at each time step, and a predicted vocabulary at each time step is output.
[0059] In operation S340, an initial answer is determined based on the predicted vocabulary output at each time step.
[0060] According to an embodiment of the present disclosure, the encoder part may use a single-layer bidirectional long short-term memory network (LSTM) to read the input sequence (such as the text of the problem to be processed). At each time step, the encoder reads a word (or word embedding) in the input sequence and updates its internal state to generate a state sequence vector h i , these state sequence vectors hi Contains partial information about pending issues.
[0061] According to an embodiment of the present disclosure, the attention mechanism allows the answer generation model to focus on different parts of the input sequence when decoding. The attention mechanism calculates a weight distribution that determines how much attention should be given to each word in the input sequence when generating each output word. According to the attention weights, the state sequence vector h generated by the encoder is i Perform weighted averaging to obtain a context vector This context vector Contains the most relevant information about the current output word.
[0062] According to an embodiment of the present disclosure, in order to avoid duplication problems in the attention mechanism model, Coverage Loss can be added to the loss function to reduce the probability of duplication.
[0063] According to an embodiment of the present disclosure, the decoder part may adopt a single-layer unidirectional LSTM. The decoder receives a state sequence vector h at each step i , and combined with the context vector to generate the state sequence of the current time step The decoder uses the state sequence of the current time step and context vector To calculate the output probability distribution for the current time step, and sample or select the most likely word from the probability distribution as the output.
[0064] According to the embodiments of the present disclosure, the conversion from input sequence to output sequence is effectively achieved through the encoder-decoder architecture and the attention mechanism, and the initial answer matching the question is quickly generated.
[0065] Figure 4 The schematic diagram shows a principle diagram of initial answer generation according to an embodiment of the present disclosure.
[0066] like Figure 4 As shown, the encoder reads the input sequence h of the problem to be processed new A word in generates a state sequence vector h i .
[0067] The input of each step of the decoder is the word vector of the word predicted in the previous step, and the output is a decoded state sequence s t ,s 0 represents the state sequence at the initial moment, s t-1 Represents the state sequence at the moment before time t.
[0068] The attention mechanism can calculate a weight distribution through the Softmax function , this weight distribution determines how much attention should be given to each word in the input sequence when generating each output word. For details, see formula (1):
[0069] (1)
[0070] Among them, the softmax function is used to convert the activation value into a probability distribution, and the tanh function is used for the activation value after linear transformation. T , W h , W s 、b attn , W c are the parameters obtained through training; It means the cumulative sum of the answer vocabulary distribution at time t-1 before time t, which represents the vocabulary distribution at time t-1, that is, the coverage of the generated answer vocabulary at time t. When generating the answer vocabulary required at time t, the attention distribution of the answer vocabulary generated at time t-1 is required. No answer vocabulary is covered at the first moment, so is a zero vector.
[0071] Use attention distribution to the state sequence vector h of all hidden layers of the input sequence i Weighted average to generate context vector For details, please refer to formula (2):
[0072] (2)
[0073] Finally, and After two linear mappings, P is generated. vocab , which represents the probability distribution of all words in the vocabulary. For details, please refer to formula (3):
[0074] (3)
[0075] Among them, V', V, b, b' are parameters that can be obtained through training.
[0076] According to an embodiment of the present disclosure, the answer generation model also includes a pointer network. The decoder is used to decode the state sequence vector and the context vector of each time step, and the predicted vocabulary at each time step is output, including: the decoder is used to calculate according to the state sequence vector and the context vector to obtain the probability of generating a new vocabulary at each time step. The pointer network is used to calculate according to the state sequence vector, the context vector and the problem to be processed to obtain the probability of copying vocabulary from the problem to be processed at each time step. When the probability of copying vocabulary is greater than the probability of generating new vocabulary, the copied vocabulary is used as the predicted vocabulary for each time step.
[0077] Specifically, at each time step of the prediction, a generation probability P is dynamically calculated gen To determine whether to copy words or generate words, the calculation process is as follows:
[0078] (4)
[0079] in, is the input sequence; , , 、b ptr is the parameter obtained through training, and σ is the sigmoid function. Finally, As the model output, the probability distribution of the generated word ω can be obtained, see formula (5):
[0080] (5)
[0081] Finally, the loss function uses the cross entropy function and introduces a hyperparameter λ. In addition, in order to pay more attention to information that has not been noticed before, Get a minimum value between them, see formula (6):
[0082] (6)
[0083] According to an embodiment of the present disclosure, the pointer network has the ability to directly copy elements from the input sequence to the output sequence. Through the direct pointer mechanism, the pointer network reduces the possibility of error generation, thereby improving the accuracy of output sequence prediction.
[0084] According to an embodiment of the present disclosure, feature fusion is performed on the question to be processed and the initial answer to obtain a fusion vector, including: vectorizing the question to be processed and the initial answer respectively to obtain a question to be processed vector and an initial answer vector; fusing the question to be processed vector and the initial answer vector to obtain a fusion vector.
[0085] According to an embodiment of the present disclosure, a skip-gram model can be used to vectorize the question to be processed and the initial answer to obtain a question vector to be processed and an initial answer vector. The Skip-gram model adopts negative sampling optimization, and the formula of the objective function is shown in formula (7):
[0086] (7)
[0087] in, is the vocabulary of the problem to be processed, A training set for the problem description; Indicates contextual vocabulary; Indicates context; The words that indicate successful negative sampling, Represents the negative sample set sampled from the corpus; label Represents the probability function of successful negative sampling. In the negative sampling process, the known context Under the condition of is positive sampling, non is negative sampling, The calculation formula (8) is as follows:
[0088] (8)
[0089] The part-of-speech information is integrated into the classification discriminant function. The discriminant function formula (9) is as follows:
[0090] (9)
[0091] in, Representation context Any word in The transpose of the word vector; Represents the parameters of the classifier, which are the parameters to be sought after optimizing the objective function, and are used to assist in solving the optimization problem; negative sampling vocabulary The part of speech is , any word in the context is The part of speech is ,vocabulary and The word-part association relationship is , Represents the comprehensive part-of-speech association weight matrix Line Column elements.
[0092] Finally, the training set of the entire problem description is optimized to maximize the objective function and solve the word vector of the problem description. .
[0093] Similarly, according to the above formula, the word vector ν(p ̃) of the initial answer can be obtained.
[0094] According to an embodiment of the present disclosure, other pre-trained word embedding models (such as Word2Vec, GloVe, FastText, etc.) can also be used to map the question to be processed and the initial answer into a fixed-length vector space, while retaining the semantic information in the text.
[0095] According to the embodiments of the present disclosure, the semantic information of the question to be processed and the initial answer is effectively retained in the vector through vectorization processing. The fused vector contains more contextual information about the current task, which helps to make more accurate predictions in subsequent matching with the reference vector.
[0096] According to an embodiment of the present disclosure, the problem vector to be processed and the initial answer vector are fused to obtain a fused vector, including: inputting the problem vector to be processed and the initial answer vector into a fully connected layer network with a nonlinear activation function to obtain a first eigenvector of the problem vector to be processed and a second eigenvector of the initial answer vector, respectively; performing weighted fusion on the first eigenvector and the second eigenvector to obtain a fused vector.
[0097] According to an embodiment of the present disclosure, the nonlinear activation function can be processed by introducing a nonlinear activation function. The nonlinear activation function includes ReLU (Rectified Linear Unit), sigmoid, etc.
[0098] According to an embodiment of the present disclosure, the question vector to be processed and the initial answer vector are respectively input into a fully connected layer and processed by a nonlinear activation function, thereby extracting deep semantic features of the two vectors, which are more representative of their semantic content than the original vectors.
[0099] According to an embodiment of the present disclosure, the extracted first feature vector (feature of the problem to be processed) and the second feature vector (feature of the initial answer) are weighted fused. Weighted fusion can be implemented in many ways, such as simple weighted summation, weighting based on attention mechanism, etc. The fused vector (i.e., fused vector) contains comprehensive information of the problem to be processed and the initial answer.
[0100] According to the embodiments of the present disclosure, the combination of the fully connected layer network and the nonlinear activation function can extract high-level features of the problem to be processed and the initial answer. Through feature extraction and weighted fusion, the information of the problem to be processed and the initial answer can be understood and processed more accurately.
[0101] According to an embodiment of the present disclosure, a reference vector can be obtained based on the following methods: vectorizing the question to be processed and multiple candidate answers respectively to obtain a question to be processed vector and multiple candidate answer vectors; and fusing the question to be processed vector with multiple candidate answer vectors respectively to obtain multiple reference vectors.
[0102] According to the embodiments of the present disclosure, the vectorization and fusion processing of the pending question and multiple candidate answers can be performed in the same manner as the aforementioned processing of the pending question and the initial answer, which will not be described in detail here.
[0103] According to an embodiment of the present disclosure, multiple reference vectors can be obtained by fusing the problem vector to be processed with multiple candidate answer vectors. These reference vectors not only contain information about the problem to be processed, but also incorporate the characteristics of each candidate answer. By comparing the fused vector with these reference vectors, the candidate answer that best matches the problem to be processed can be selected, thereby improving the accuracy of answer selection.
[0104] According to an embodiment of the present disclosure, a corresponding target answer is determined from multiple candidate answers based on the matching probability corresponding to each reference answer vector, including: sorting the multiple candidate answers from large to small according to the matching probability to obtain a sorting result; based on a preset number of target answers, selecting a preset number of candidate answers ranked at the top of the sorting result as the target answer.
[0105] According to the embodiments of the present disclosure, by sorting the candidate answers by the probability of matching, the answer most relevant to the problem to be processed can be preferentially selected. The selection of a preset number of target answers can be convenient for adapting to different application scenarios. For example, in an application scenario that requires detailed explanation, a larger preset number can be set to obtain multiple matching answers with high relevance. In an application scenario that only requires rapid acquisition of key information, a smaller preset number, such as 1, can be set to obtain the most accurate answer.
[0106] According to the embodiments of the present disclosure, users can find the information they need more easily through sorting. The flexibility of application scenarios can be improved by presetting a number of target answers, and reasonable answers can be provided in different situations.
[0107] Based on the above-mentioned method for determining the answer to a question, the present disclosure also provides a device for determining the answer to a question. Figure 5 The device is described in detail.
[0108] Figure 5 The structural block diagram of the apparatus for determining the answer to a question according to an embodiment of the present disclosure is schematically shown.
[0109] like Figure 5 As shown, the device 500 for determining the answer to a question in this embodiment includes an acquisition module 510, a generation module 520, a fusion module 530, a matching module 540 and a determination module 550.
[0110] The acquisition module 510 is used to acquire multiple candidate answers matching the question to be processed from the question-answering knowledge base. In one embodiment, the acquisition module 510 can be used to perform the operation S210 described above, which will not be described in detail here.
[0111] The generation module 520 is used to input the problem to be processed into the pre-trained answer generation model to obtain an initial answer. In one embodiment, the generation module 520 can be used to perform the operation S220 described above, which will not be repeated here.
[0112] The fusion module 530 is used to perform feature fusion on the question to be processed and the initial answer to obtain a fusion vector. In one embodiment, the fusion module 530 can be used to perform the operation S230 described above, which will not be described in detail here.
[0113] The matching module 540 is used to perform similarity matching between the fusion vector and multiple reference vectors respectively to obtain a matching probability corresponding to each reference vector, wherein the multiple reference vectors are obtained based on multiple candidate answers. In one embodiment, the matching module 540 can be used to perform the operation S230 described above, which will not be repeated here.
[0114] The determination module 550 is used to determine the corresponding target answer from multiple candidate answers according to the matching probability corresponding to each reference answer vector. In one embodiment, the determination module 550 can be used to perform the operation S230 described above, which will not be described in detail here.
[0115] According to an embodiment of the present disclosure, the generation module 520 includes an encoding submodule, an attention submodule, a decoding submodule and a determination submodule.
[0116] The encoding submodule is used to encode the problem to be processed by using an encoder and output a state sequence vector of the problem to be processed at each time step.
[0117] The attention submodule is used to use the attention mechanism to perform weighted averaging on the state sequence vectors of all hidden layers to obtain the context vector.
[0118] The decoding submodule is used to decode the state sequence vector and the context vector at each time step using a decoder, and output the predicted vocabulary at each time step.
[0119] The determination submodule is used to determine the initial answer based on the predicted vocabulary output at each time step.
[0120] According to an embodiment of the present disclosure, the decoding submodule includes:
[0121] The first calculation unit is used to calculate using a decoder according to the state sequence vector and the context vector to obtain the probability of generating a new word at each time step.
[0122] The second calculation unit is used to calculate using a pointer network according to the state sequence vector, the context vector and the problem to be processed, so as to obtain the probability of copying words from the problem to be processed at each time step.
[0123] A determination unit is used to use the copied vocabulary as the predicted vocabulary at each time step when the probability of copying the vocabulary is greater than the probability of generating a new vocabulary.
[0124] According to an embodiment of the present disclosure, the fusion module 530 includes a vectorization submodule and a fusion submodule.
[0125] The vectorization submodule is used to vectorize the problem to be processed and the initial answer respectively to obtain the problem vector to be processed and the initial answer vector.
[0126] The fusion submodule is used to fuse the question vector to be processed and the initial answer vector to obtain a fusion vector.
[0127] According to an embodiment of the present disclosure, the fusion submodule includes a feature extraction unit and a fusion unit.
[0128] The feature extraction unit is used to input the question vector to be processed and the initial answer vector into a fully connected layer network with a nonlinear activation function to obtain a first feature vector of the question vector to be processed and a second feature vector of the initial answer vector respectively.
[0129] The fusion unit performs weighted fusion on the first eigenvector and the second eigenvector to obtain a fusion vector.
[0130] According to an embodiment of the present disclosure, the device for determining the answer to a question also includes a second vectorization module and a second fusion module.
[0131] The second vectorization module is used to perform vectorization processing on the problem to be processed and the multiple candidate answers respectively, to obtain a problem vector to be processed and multiple candidate answer vectors.
[0132] The second fusion module is used to fuse the question vector to be processed with multiple candidate answer vectors respectively to obtain multiple reference vectors.
[0133] According to an embodiment of the present disclosure, the determination module 550 includes a sorting unit and a selection unit.
[0134] The sorting unit is used to sort the multiple candidate answers from large to small according to the matching probability to obtain a sorting result.
[0135] The selection unit is used to select a preset number of candidate answers ranked top as target answers from the sorting results according to a preset number of target answers.
[0136] According to an embodiment of the present disclosure, any multiple modules of the acquisition module 510, the generation module 520, the fusion module 530, the matching module 540 and the determination module 550 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the acquisition module 510, the generation module 520, the fusion module 530, the matching module 540 and the determination module 550 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in a suitable combination of any of them. Alternatively, at least one of the acquisition module 510 , the generation module 520 , the fusion module 530 , the matching module 540 , and the determination module 550 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be performed.
[0137] Figure 6 A block diagram of an electronic device suitable for implementing a method for determining an answer to a question according to an embodiment of the present disclosure is schematically shown.
[0138] like Figure 6 As shown, the electronic device 600 according to an embodiment of the present disclosure includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 to a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0139] In RAM 603, various programs and data required for the operation of electronic device 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other via bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in one or more memories.
[0140] According to an embodiment of the present disclosure, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the input / output (I / O) interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 609 including a network interface card such as a LAN card, a modem, etc. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.
[0141] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0142] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 602 and / or RAM 603 described above and / or one or more memories other than ROM 602 and RAM 603.
[0143] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method for determining the answer to the question provided by the embodiment of the present disclosure.
[0144] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 601. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0145] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 609, and / or installed from a removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0146] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, apparatus, module, unit, etc. described above can be implemented by a computer program module.
[0147] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0148] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0149] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0150] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A method for determining an answer to a question, characterized in that: The method comprises: Obtain multiple candidate answers matching the question to be processed from the question-answering knowledge base; Inputting the problem to be processed into a pre-trained answer generation model to obtain an initial answer; Performing feature fusion on the problem to be processed and the initial answer to obtain a fusion vector; Performing similarity matching between the fusion vector and a plurality of reference vectors respectively to obtain a matching probability corresponding to each of the reference vectors, wherein the plurality of reference vectors are obtained based on a plurality of the candidate answers; and According to the matching probability corresponding to each of the reference answer vectors, a corresponding target answer is determined from the multiple candidate answers.
2. The method according to claim 1, characterized in that The step of fusing the features of the problem to be processed and the initial answer to obtain a fusion vector includes: Vectorizing the problem to be processed and the initial answer respectively to obtain a problem vector to be processed and an initial answer vector; The question vector to be processed and the initial answer vector are fused to obtain the fused vector.
3. The method according to claim 2, characterized in that The step of fusing the question vector to be processed and the initial answer vector to obtain the fused vector includes: Inputting the to-be-processed question vector and the initial answer vector into a fully connected layer network with a nonlinear activation function to obtain a first eigenvector of the to-be-processed question vector and a second eigenvector of the initial answer vector respectively; The first feature vector and the second feature vector are weightedly fused to obtain the fused vector.
4. The method according to claim 1, characterized in that: Determining a corresponding target answer from a plurality of candidate answers according to the matching probability corresponding to each of the reference answer vectors includes: Sort the plurality of candidate answers from largest to smallest according to the matching probability to obtain a sorting result; According to a preset number of the target answers, a preset number of candidate answers ranked top are selected from the sorting results as the target answers.
5. The method according to claim 1, characterized in that: The method further comprises: Performing vectorization processing on the problem to be processed and the plurality of candidate answers respectively to obtain the problem vector to be processed and the plurality of candidate answer vectors; and The question vector to be processed is merged with the multiple candidate answer vectors respectively to obtain multiple reference vectors.
6. The method according to claim 1, characterized in that The answer generation model includes an encoder, a decoder, and an attention mechanism; The step of inputting the problem to be processed into a pre-trained answer generation model to obtain an initial answer includes: Encoding the problem to be processed by using the encoder, and outputting a state sequence vector of the problem to be processed at each time step; Using the attention mechanism to perform weighted averaging on the state sequence vectors of all hidden layers to obtain a context vector; Decoding with the decoder according to the state sequence vector and the context vector at each time step, and outputting a predicted vocabulary at each time step; and The initial answer is determined according to the predicted vocabulary output at each time step.
7. The method according to claim 6, characterized in that The answer generation model also includes a pointer network; The step of decoding the state sequence vector and the context vector at each time step by using the decoder and outputting the predicted vocabulary at each time step comprises: Calculating using the decoder according to the state sequence vector and the context vector to obtain a probability of generating a new word at each time step; Calculating using the pointer network according to the state sequence vector, the context vector and the problem to be processed, to obtain a probability of copying vocabulary from the problem to be processed at each time step; In the case where the probability of the copied vocabulary is greater than the probability of generating a new vocabulary, the copied vocabulary is used as the predicted vocabulary for each time step.
8. A device for determining an answer to a question, characterized in that: The device comprises: An acquisition module is used to acquire multiple candidate answers matching the question to be processed from the question-answering knowledge base; A generation module, used for inputting the problem to be processed into a pre-trained answer generation model to obtain an initial answer; A fusion module, used for fusing features of the problem to be processed and the initial answer to obtain a fusion vector; a matching module, configured to perform similarity matching between the fusion vector and a plurality of reference vectors respectively, to obtain a matching probability corresponding to each of the reference vectors, wherein the plurality of reference vectors are obtained based on a plurality of the candidate answers; and A determination module is used to determine a corresponding target answer from a plurality of candidate answers according to a matching probability corresponding to each reference answer vector.
9. An electronic device, comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
11. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
