A question and answer method and apparatus

By inputting the text to be detected and the question into a vector encoding model and constructing a graph structure, and then using the graph encoding model to process the encoded vector encoding model to construct a graph structure, the problem of insufficient accuracy in answer determination of the pre-trained model is solved, and higher accuracy in answer detection and evidence chain prediction is achieved.

CN114691843BActive Publication Date: 2025-12-30BEIJING KINGSOFT DIGITAL ENTERTAINMENT CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011637501.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-31
Publication Date
2025-12-30
Estimated Expiration
2040-12-31

AI Technical Summary

Technical Problem

The accuracy of existing pre-trained models in machine reading comprehension tasks, which rely solely on the starting and ending positions of the answer, needs improvement.

Method used

The text to be detected and the query question are used as input sets to input the vector encoding model to obtain the encoded vector. A graph structure is constructed through the graph encoding module. The answer is determined based on the graph structure. The attention mechanism of the Transformer model is used to process the encoded vector, establish the association and mapping relationship between the vector nodes, and determine the start and end positions of the answer.

Benefits of technology

It improves the accuracy of answer detection results, enhances the prediction accuracy of evidence chains in graph structures, and improves the overall effectiveness of question answering methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691843B_ABST
    Figure CN114691843B_ABST
Patent Text Reader

Abstract

The application provides a question and answer method and device, wherein the question and answer method comprises: inputting a to-be-detected text and a to-be-queried question into a vector encoding model as an input set to obtain an encoding vector of the input set; inputting the encoding vector into a graph encoding module for processing; constructing a graph structure according to a processing result; determining an answer detection result corresponding to the to-be-queried question according to the graph structure and outputting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a question-answering method and apparatus, a computing device, and a computer-readable storage medium. Background Technology

[0002] Natural Language Processing (NLP) is an important field in computer science and artificial intelligence. It studies various theories and methods that enable effective communication between humans and computers using natural language.

[0003] For natural language processing tasks, pre-trained models are typically used. The current common approach to machine reading comprehension involves inputting a question and text into a pre-trained model. The model then processes the question and text to determine the start and end positions of the answer to the question within the text. However, existing pre-trained models, when performing reading comprehension tasks, only determine the existence and nature of the answer by identifying its start and end positions. The accuracy of the answers output in this way needs improvement. Summary of the Invention

[0004] In view of this, embodiments of this application provide a question-answering method and apparatus, a computing device and a computer-readable storage medium to address the technical deficiencies existing in the prior art.

[0005] According to a first aspect of the embodiments of this application, a question-and-answer method is provided, including:

[0006] The text to be detected and the question to be queried are used as input sets to input vector encoding models to obtain the encoding vector of the input set;

[0007] The encoded vector is input into the graph encoding module for processing, and a graph structure is constructed based on the processing result;

[0008] The answer detection result corresponding to the query question is determined and output based on the graph structure.

[0009] Optionally, the step of inputting the encoded vector into the graph encoding module for processing and constructing a graph structure based on the processing result includes:

[0010] The encoded vector is input into the graph encoding module to divide the vector nodes, and the graph structure is constructed based on the association between at least two vector nodes in the division result.

[0011] Optionally, determining and outputting the answer detection result corresponding to the query question based on the graph structure includes:

[0012] Establish a mapping relationship between the at least two vector nodes and the encoded vector, and output the detection result based on the mapping relationship and the answer corresponding to the query question.

[0013] Optionally, the step of inputting the encoded vector into the graph encoding module for processing includes:

[0014] Based on the query question, the paragraph information and / or sentence information contained in the text to be detected, the encoding vector is divided into question vector nodes, paragraph vector nodes and / or sentence vector nodes.

[0015] Optionally, constructing the graph structure based on the processing result includes:

[0016] Attention calculations are performed on the question vector node, the paragraph vector node, and / or the sentence vector node respectively to obtain the attention calculation results corresponding to the question vector node, the paragraph vector node, and / or the sentence vector node;

[0017] The association between the question vector node, the paragraph vector node, and / or the sentence vector node is determined based on the attention calculation results.

[0018] The graph structure is constructed based on the relationships described.

[0019] Optionally, attention can be calculated for the problem vector nodes in the following manner:

[0020] Determine the weight of each word unit in the query question;

[0021] The weight corresponding to each word unit is multiplied by the word vector of the word unit;

[0022] The product results are summed, and the summation result is used as the attention calculation result corresponding to the problem vector node.

[0023] Optionally, establishing the mapping relationship between the at least two vector nodes and the encoded vector includes:

[0024] An attention mechanism is used to map the at least two vector nodes to the encoded vector to establish a mapping relationship between the at least two vector nodes and the encoded vector.

[0025] Optionally, determining and outputting the answer detection result corresponding to the query question based on the mapping relationship and the graph structure includes:

[0026] Based on the mapping relationship and the graph structure, determine the probability distribution of the start and end positions of the answer detection results corresponding to the query question;

[0027] The answer detection result corresponding to the query question is determined and output based on the probability distribution.

[0028] Optionally, determining and outputting the answer detection result corresponding to the query question based on the probability distribution includes:

[0029] The position of the word unit with the highest probability in the probability distribution of the starting position in the text to be detected is taken as the starting position of the answer detection result;

[0030] The position of the word unit with the highest probability in the probability distribution of the ending position in the text to be detected is taken as the ending position of the answer detection result;

[0031] The word units between the starting and ending positions are used as the answer detection results and output.

[0032] Optionally, after constructing the graph structure based on the processing result, the process further includes:

[0033] Based on the graph structure, determine the paragraph information of the paragraph to which the detection result of the answer to the query question belongs.

[0034] Optionally, the question-and-answer method further includes:

[0035] If the accuracy of the answer detection result is determined to be lower than a preset accuracy threshold, the answer is predicted based on the paragraph information of the paragraph to which the answer detection result belongs, and the prediction result is output.

[0036] According to a second aspect of the embodiments of this application, a question-answering device is provided, comprising:

[0037] The input module is configured to input the text to be detected and the query question as input sets into the vector encoding model to obtain the encoded vector of the input set;

[0038] The construction module is configured to input the encoded vector into the graph encoding module for processing, and construct a graph structure based on the processing result;

[0039] The output module is configured to determine and output the answer detection result corresponding to the query question based on the graph structure.

[0040] According to a third aspect of the embodiments of this application, a computing device is provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor executes the computer instructions to implement the steps of the question-and-answer method.

[0041] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided that stores computer instructions which, when executed by a processor, implement the steps of the question-and-answer method.

[0042] According to a fifth aspect of the present application, a chip is provided that stores computer instructions, which, when executed by the chip, implement the steps of the question-and-answer method.

[0043] In this embodiment, the input vector encoding model is used as the input set of the text to be detected and the query question to be queried to obtain the encoding vector of the input set. The encoding vector is then input into the graph encoding module for processing. A graph structure is constructed based on the processing result. The answer detection result corresponding to the query question is determined and output based on the graph structure.

[0044] By encoding the query question and the text to be detected in the above manner, and inputting the encoded vector into the graph encoding module for vector processing, a graph structure is constructed based on the processing result. This helps to improve the prediction accuracy of the evidence chain related to the query question in the graph structure, and the answer corresponding to the query question is determined through the evidence chain in the graph structure, which helps to improve the accuracy of the output answer detection result. Attached Figure Description

[0045] Figure 1 This is a structural block diagram of the computing device provided in the embodiments of this application;

[0046] Figure 2 This is a flowchart of the question-and-answer method provided in the embodiments of this application;

[0047] Figure 3 This is a schematic diagram of the question-and-answer process provided in the embodiments of this application;

[0048] Figure 4 This is a schematic diagram of the question-and-answer method provided in the embodiments of this application;

[0049] Figure 5 This is a schematic diagram of the question-and-answer device provided in the embodiments of this application. Detailed Implementation

[0050] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.

[0051] The terminology used in one or more embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this application. The singular forms “a,” “the,” and “the” used in one or more embodiments of this application and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” used in one or more embodiments of this application refers to and includes any or all possible combinations of one or more associated listed items.

[0052] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this application, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "in response to a determination".

[0053] First, for ease of understanding and without making any limitations, the terms and concepts involved in one or more embodiments of the present invention are explained.

[0054] Machine reading comprehension: Using models to answer reading comprehension questions.

[0055] Multi-hop question answering requires a model to integrate evidence fragments scattered across multiple documents and predict the correct answer based on these evidence fragments.

[0056] Transformer: A neural network module for processing natural language.

[0057] Pre-trained models: Models that are trained in advance on large datasets and are usually unrelated to specific tasks. Using the idea of ​​knowledge transfer, they are fine-tuned for specific tasks in downstream tasks for use.

[0058] Chain of evidence: Given a question and an article, the answer can be inferred from several key sentences, which constitute a chain of evidence.

[0059] This application provides a question-answering method and apparatus, a computing device and a computer-readable storage medium, which will be described in detail in the following embodiments.

[0060] Figure 1A structural block diagram of a computing device 100 according to an embodiment of this application is shown. The components of the computing device 100 include, but are not limited to, a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and a database 150 is used to store data.

[0061] The computing device 100 also includes an access device 140, which enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.

[0062] In one embodiment of this application, the aforementioned components of the computing device 100 and Figure 1 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 1 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.

[0063] The computing device 100 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 100 can also be a mobile or stationary server.

[0064] Among them, processor 120 can execute Figure 2 The steps in the question-and-answer method shown. Figure 2 A flowchart of a question-and-answer method according to an embodiment of this application is shown, including steps 202 to 206.

[0065] Step 202: Input the text to be detected and the query question into the input vector encoding model to obtain the encoding vector of the input set.

[0066] The vector encoding model described in the embodiments of this specification may be an Electra pre-trained model (Electra is an open-source model on TensorFlow that includes some pre-trained language representation models) or other models that can implement text encoding, such as the BERT pre-trained model.

[0067] BERT is a language representation model, standing for Bidirectional Encoder Representations from Transformers. BERT aims to pre-train deep bidirectional representations by jointly adjusting the left and right contexts across all layers. In practice, BERT uses a Masked Language Model (MLM) during training, randomly masking some words and predicting those words. BERT training requires a significant amount of computation.

[0068] Unlike the BERT pre-trained model, Electra proposes a novel pre-training method, Replaced Token Detection (RTD). The training process is similar to GANs, using a generator to replace words in a sentence, followed by a discriminator to determine which words have been replaced. Compared to BERT and RoBERTa, Electra achieves better training results, and its training computation is only one-quarter that of RoBERTa. Therefore, choosing Electra as the vector encoding model to encode the text and query question is beneficial for improving the efficiency of answer detection.

[0069] Specifically, the text to be detected and the query question can be concatenated, and the concatenation result can be input into a vector encoding model to vectorize the text to be detected and the query question, thereby obtaining the encoded vectors of the text to be detected and the query question.

[0070] It should be noted that the embodiments in this specification do not limit the type of vector coding model.

[0071] Taking the detection of the answer to question q in Article 1 and Article 2 as an example, the schematic diagram of the answer detection process is as follows: Figure 3 As shown, question q, article 1 and article 2 are first concatenated, and the concatenation result is input into a pre-trained vector encoding model for encoding to obtain the encoding vector corresponding to the concatenation result of question q, article 1 and article 2.

[0072] In practical applications, the text to be detected is a written text containing certain information content. The written text can be a sentence, a paragraph, multiple paragraphs, an article, or multiple articles of various lengths. This application does not impose any restrictions on this.

[0073] In the application phase, the query question and the text to be detected are used as input sets to the vector encoding model. The embedding layer in the vector encoding model performs word segmentation on the input set to obtain word units of the input set, and performs pre-embedding processing on the word units to obtain word vectors, sentence vectors and position vectors corresponding to the word units. Then, the word vectors, sentence vectors and position vectors are summed to generate the input vectors corresponding to the word units of the input set. The input vectors are input into the encoding layer of the encoding model to encode the input set and obtain the encoding vector.

[0074] After obtaining the encoded vectors of the query question and the text to be detected, the answer to the query question can be determined by constructing a graph structure to represent the relationship between the vector nodes.

[0075] Step 204: Input the encoded vector into the graph encoding module for processing, and construct the graph structure based on the processing result.

[0076] Specifically, the graph encoding module is used to construct a graph structure based on the encoded vectors. The graph structure is typically used to represent and store data with one-to-one, one-to-many, or many-to-many relationships, and is a very important data structure. In the embodiments of this specification, the graph structure is used to represent the association relationship between the at least two vector nodes.

[0077] In practice, the encoded vector can be input into the graph encoding module to divide the vector nodes, and the graph structure can be constructed based on the association between at least two vector nodes in the division result.

[0078] Specifically, the graph coding module described in the embodiments of this specification has a node partitioning unit and an attention calculation unit. The node partitioning unit partitions the coding vector into vector nodes, and the attention calculation unit calculates the correlation coefficients between the partitioned vector nodes to construct a graph structure based on the calculation results.

[0079] In specific implementation, the encoded vector is input into the graph encoding module and divided into vector nodes. That is, according to the question to be queried and the paragraph information and / or sentence information contained in the text to be detected, the encoded vector is divided into question vector nodes, paragraph vector nodes and / or sentence vector nodes.

[0080] Specifically, based on the paragraph information and / or sentence information contained in question q, article 1, and article 2, the encoding vector is divided into question vector node Q, at least one paragraph vector node P, and / or at least one sentence vector node S.

[0081] Furthermore, a graph structure is constructed based on the relationships between at least two vector nodes in the partitioning results. This can be achieved in the following ways:

[0082] Attention calculations are performed on the question vector node, the paragraph vector node, and / or the sentence vector node respectively to obtain the attention calculation results corresponding to the question vector node, the paragraph vector node, and / or the sentence vector node;

[0083] The association between the question vector node, the paragraph vector node, and / or the sentence vector node is determined based on the attention calculation results.

[0084] The graph structure is constructed based on the relationships described.

[0085] Specifically, after obtaining the encoded vectors of the text to be detected and the query question through the vector encoding model, question vectors, paragraph vectors, and sentence vectors can be extracted from the encoded vectors generated by the vector encoding model. The vector dimensions of the question vectors, paragraph vectors, and sentence vectors are compressed using the attention mechanism (self-attention structure) of the Transformer model to unify the vector dimensions of the question vectors, paragraph vectors, and sentence vectors. Then, the relationships between the compressed question vector nodes, paragraph vector nodes, and sentence vector nodes are learned, and a weighted calculation is performed on each vector node and its associated vector nodes. The weighted calculation result can be used to characterize the correlation coefficient between each vector node, and a graph structure of each vector node is constructed based on the correlation coefficient.

[0086] In practical applications, the attention mechanism of the Transformer model is used to process the question vector, paragraph vector, and sentence vector to construct a graph structure. Specifically, the Queries, Keys, and Values ​​of each question vector, paragraph vector, and sentence vector can be calculated according to formulas (1), (2), and (3).

[0087] Formula (1)

[0088] Formula (2)

[0089] Formula (3)

[0090] in, , , These are the parameters to be trained.

[0091] Then the score corresponding to each vector can be calculated according to formula (4);

[0092] Formula (4)

[0093] in, For any set of queries consisting of n question vectors, paragraph vectors, and sentence vectors, each vector can be used to calculate n scores. This means each vector corresponds to a (1, n) score vector. It is a hyperparameter (it can be set to 64).

[0094] After obtaining the correlation between each vector and other vectors (the score vector of (1, n)), the weights of all n vectors with respect to any one vector can be calculated according to formula (5);

[0095] Formula (5)

[0096] Applying the softmax activation function to the n scores of any vector yields the weights of all vectors for that vector, represented by an (n, 1) weight vector. Then, multiplying the score vector corresponding to each vector with the weight vector (i.e., weighting each vector node and its associated vector nodes) yields the correlation coefficients among the n vectors. The specific calculation process is (1, n) * (n, 1). Finally, an n*n weight matrix, i.e., the attention matrix, is generated. The elements in the attention matrix represent the correlations between the n question vectors, paragraph vectors, and sentence vectors.

[0097] If a graph structure has 5 nodes, then a 5x5 attention matrix can be constructed.

[0098] With the attention matrix as For example, element a in the matrix 11 a 12 a 13 a 14 a 15 The corresponding values ​​represent the relationships between the first vector node and the first vector node, the first vector node and the second vector node, the first vector node and the third vector node, the first vector node and the fourth vector node, and the first vector node and the fifth vector node in the graph structure, respectively.

[0099] By using the attention mechanism of the Transformer model to learn the relationships between question vector nodes, paragraph vector nodes, and sentence vector nodes, and constructing the graph structure based on the learning results, it is beneficial to ensure the accuracy of the construction results of the evidence chain corresponding to the query question in the graph structure.

[0100] In addition, attention can be calculated for the problem vector nodes in the following way:

[0101] Determine the weight of each word unit in the query question;

[0102] The weight corresponding to each word unit is multiplied by the word vector of the word unit;

[0103] The product results are summed, and the summation result is used as the attention calculation result corresponding to the problem vector node.

[0104] Taking a query question containing 5 word units as an example, the 5 word units are t1, t2, t3, t4 and t5, and the encoding vector corresponding to the query question is [A1, A2, ..., A5]. If A1, A2, ..., A5 are all 10-dimensional vectors, and if the weights corresponding to t1, t2, t3, t4 and t5 are determined to be 0.1, 0.2, 0.3, 0.2 and 0.2 respectively, then the attention calculation result corresponding to the query question can be determined as A = 0.1*A1 + 0.2*A2 + 0.3A3 + 0.2A4 + 0.2A5.

[0105] The attention calculation process for paragraph vector node P and sentence vector node S is similar to that for question vector node Q, and will not be repeated here.

[0106] After obtaining the attention calculation results of the question vector node Q, paragraph vector node P, and sentence vector node S, the association between each vector node can be further learned, and the correlation coefficient between each vector node can be calculated. Based on the correlation coefficient, a graph structure of vector nodes can be constructed, which contains the evidence chain formed by the question vector node Q, paragraph vector node P, and sentence vector node S.

[0107] In practical applications, besides using the aforementioned weight matrix to represent the relationships between nodes in a graph structure, another method, the adjacency matrix, can also be used. For example, if a graph structure has 5 nodes, a 5x5 matrix can be constructed. If there is a relationship between nodes, the value representing the positions of the two nodes in the adjacency matrix can be recorded as 1; conversely, if there is no relationship between the two nodes, the value representing the positions of the two nodes in the adjacency matrix can be recorded as 0.

[0108] Using the matrix as For example, element a in the matrix 11 a 12 a 131 a 14 a 15 The corresponding values ​​represent the relationships between the first vector node and the first vector node, the first vector node and the second vector node, the first vector node and the third vector node, the first vector node and the fourth vector node, and the first vector node and the fifth vector node, respectively. 1 represents that a relationship exists, and 0 represents that no relationship exists; since element a 12 The corresponding value is 1, therefore, it can be concluded that there is a relationship between the first vector node and the second vector node.

[0109] Alternatively, the elements in the adjacency matrix may also correspond to the association weights between two nodes, which can be determined according to actual needs. This specification does not impose any restrictions on this aspect in the embodiments.

[0110] Step 206: Determine and output the answer detection result corresponding to the query question based on the graph structure.

[0111] In specific implementation, if the graph encoding module divides the encoded vector into vector nodes and constructs a graph structure based on the association between at least two vector nodes in the division result, a mapping relationship between the at least two vector nodes and the encoded vector can also be established, and the result of the detection of the answer corresponding to the query question can be output based on the mapping relationship and the answer.

[0112] Specifically, as mentioned above, after partitioning the encoded vector into vector nodes, since the vector dimensions corresponding to the question vector, paragraph vector, and sentence vector obtained from the partitioning are not uniform, it is necessary to compress the vector dimensions of the question vector, paragraph vector, and sentence vector during the process of constructing the graph structure based on the question vector, paragraph vector, and sentence vector to unify the vector dimensions of the question vector, paragraph vector, and sentence vector to the same dimension. This allows the attention mechanism to determine the correlation coefficient between each vector, and the graph structure to be constructed based on the correlation coefficient.

[0113] Furthermore, after constructing the graph structure, the answer detection result corresponding to the query question can be determined based on the evidence chain information contained in the graph structure. However, since the vector dimension of each vector node in the graph structure is a compressed dimension, which is inconsistent with the vector dimension of the encoded vector output by the vector coding model, in this embodiment of the specification, in order to ensure the accuracy of the predicted answer to the query question, a mapping relationship between vector nodes and encoded vectors can be established, and the answer detection result can be determined based on the mapping relationship and the evidence chain in the graph structure.

[0114] In practice, an attention mechanism can be used to map the at least two vector nodes to the encoding vector to establish a mapping relationship between the at least two vector nodes and the encoding vector.

[0115] Specifically, in the embodiments of this specification, an attention computing network can be used to establish a mapping relationship between vector nodes and encoding vectors. In particular, an attention mechanism can be introduced into a Long Short-Term Memory (LSTM) network to form the attention computing network, and the attention computing network can be used to perform attention computing on the at least two vector nodes and the encoding vector, thereby establishing a mapping relationship between the at least two vector nodes and the encoding vector based on the attention computing results.

[0116] The embodiments in this specification utilize the gate mechanism inside LSTM, specifically using the input gate to filter input information and the forget gate to select forgotten information. Furthermore, an attention mechanism is added to LSTM, thereby establishing a mapping relationship between vector nodes and encoding vectors based on some useful information. This is beneficial for improving the accuracy of the mapping relationship establishment results and also for improving network performance.

[0117] In addition, the answer detection result corresponding to the query question is determined and output based on the mapping relationship and the graph structure, which can be implemented in the following ways:

[0118] Based on the mapping relationship and the graph structure, determine the probability distribution of the start and end positions of the answer detection results corresponding to the query question;

[0119] The answer detection result corresponding to the query question is determined and output based on the probability distribution.

[0120] Furthermore, the answer detection result corresponding to the query question is determined and output based on the probability distribution, which can be achieved in the following ways:

[0121] The position of the word unit with the highest probability in the probability distribution of the starting position in the text to be detected is taken as the starting position of the answer detection result;

[0122] The position of the word unit with the highest probability in the probability distribution of the ending position in the text to be detected is taken as the ending position of the answer detection result;

[0123] The word units between the starting and ending positions are used as the answer detection results and output.

[0124] Specifically, after establishing the mapping relationship between the at least two vector nodes and the encoding vector through the attention mechanism, the answer to the query question can be determined based on the mapping relationship and the evidence chain in the graph structure corresponding to the query question.

[0125] Specifically, the probability distribution of the start and end positions of the answer detection result corresponding to the query question in the text to be detected can be calculated. The position of the word unit with the highest probability in the probability distribution of the start position in the text to be detected is taken as the start position of the answer detection result, and the position of the word unit with the highest probability in the probability distribution of the end position in the text to be detected is taken as the end position of the answer detection result. The word units between the start and end positions are taken as the answer detection result and output.

[0126] In practical applications, we can first determine the vector nodes in the evidence chain corresponding to the query question in the graph structure, and then determine the target encoding vector that has a mapping relationship with each vector node based on the mapping relationship between the vector nodes and the encoding vector. We can then perform linear mapping and nonlinear transformation on the word encoding vector corresponding to each word unit in the target text to be detected, and obtain the probability of each word unit as the start position and end position of the answer corresponding to the question.

[0127] A linear mapping is a mapping from one vector space V to another vector space W. Linear mapping is used to transform the dimension of word encoding vectors to that of sentence encoding vectors.

[0128] Nonlinear transformation is to perform a nonlinear transformation on the original feature vector to obtain a new feature vector. Using this new feature vector to perform linear classification corresponds to a nonlinear classification in the original feature space.

[0129] Linear mapping and nonlinear transformation can be implemented through fully connected layers of the attention computation network.

[0130] The embodiments in this specification calculate the probability of each word unit being the start or end position of the answer, and filter according to the calculation results. The word unit with the highest probability is used as the start or end position of the answer in the answer extraction result, and the word units between the start and end positions are used as the answer extraction result. This helps to improve the answer prediction effect and the prediction accuracy of the evidence chain.

[0131] Furthermore, after constructing a graph structure based on the association between at least two vector nodes in the partitioning results, the paragraph information of the paragraph to which the detection result of the answer to the query question belongs can also be determined based on the graph structure.

[0132] In addition, if the accuracy of the answer detection result is determined to be lower than a preset accuracy threshold, the answer is predicted based on the paragraph information of the paragraph to which the answer detection result belongs, and the prediction result is output.

[0133] Specifically, such as Figure 3 As shown, after using the graph encoding module to partition vector nodes and constructing a graph structure based on the association between at least two vector nodes in the partitioning result, the paragraph information (predicting relevant paragraphs) of the paragraph to which the answer detection result corresponding to the query question belongs in the text to be detected can be output. The paragraph information can be used to characterize that the paragraph contains at least one vector node in the evidence chain, or the paragraph information can be used to characterize whether the sentence contained in the paragraph is an evidence chain. In addition, the paragraph information can also be output to show whether it contains information on supporting facts related to the answer detection result (playing an auxiliary role).

[0134] After establishing a mapping relationship between vector nodes and encoding vectors through an attention computing network, and outputting the predicted answer corresponding to the query question based on the mapping relationship and the graph structure, if it is determined that the accuracy of the predicted answer is lower than a preset accuracy threshold, the answer detection result corresponding to the query question can be re-determined based on the paragraph information of the paragraph to which the answer detection result corresponding to the query question belongs in the text to be detected, and / or whether the paragraph information contains supporting fact information related to the answer detection result.

[0135] The question-answering method provided in this application involves inputting the text to be detected and the question to be queried into a vector encoding model as input sets to obtain the encoded vector of the input set. The encoded vector is then input into a graph encoding module for vector node partitioning. A graph structure is constructed based on the association between at least two vector nodes in the partitioning result. A mapping relationship is established between the at least two vector nodes and the encoded vector. Finally, the answer detection result corresponding to the question to be queried is determined and output based on the mapping relationship and the graph structure.

[0136] In the process of detecting the answer to the query question in the text to be detected, the query question and the text to be detected are encoded, and the graph encoding module constructs a graph structure corresponding to the text to be detected and containing the evidence chain related to the query question based on the generated encoding vector. It can also generate graph structures containing different evidence chains according to different query questions. Compared with the current process of manually constructing graph structures, the method of constructing the graph structure by the graph encoding module in this embodiment of the specification is beneficial to improving the construction efficiency of the graph structure, improving the accuracy of the evidence chain related to the query question contained in the constructed graph structure, and determining the answer to the query question through the evidence chain in the graph structure is beneficial to improving the accuracy of the output answer detection result.

[0137] Figure 4 A flowchart of a question-and-answer method according to an embodiment of this application is shown, including steps 402 to 410.

[0138] Step 402: Input the text to be detected and the query question into the input vector encoding model to obtain the encoding vector of the input set.

[0139] Step 404: Input the encoded vector into the graph encoding module to divide the vector nodes, and construct a graph structure based on the association relationship between at least two vector nodes in the division result.

[0140] Specifically, the relationships between vector nodes in the graph structure together constitute the evidence chain for the query question.

[0141] Step 406: Input the graph structure into the answer prediction model, and determine the answer detection result corresponding to the query question based on the graph structure.

[0142] Specifically, the answer prediction model is used to output the answer corresponding to the query question based on the graph structure. If the relationship between vector nodes in the graph structure (evidence chain information) is insufficient, the answer prediction model may not be able to output a predicted answer; while if the answer prediction model can output a predicted answer, the terminator in the encoded vector can be fused with the text to be detected.

[0143] Step 408: Determine whether the answer prediction model can output the predicted answer. If yes, continue to step 410; otherwise, return to step 402.

[0144] Specifically, if the answer prediction model cannot output a predicted answer, it is considered that the answer extraction conditions have not been met, indicating that the content in the current graph structure is not sufficient and it is necessary to continue to determine more relationships between vector nodes to expand the content of the graph structure. At this time, we can return to step 402, input the text to be detected and the text to be queried into the vector encoding model, and have the vector encoding model re-execute the encoding process.

[0145] Since the answer to the query question cannot be obtained from the selected text to be detected, in the next loop, new unselected text to be detected can be chosen from other unselected text to be detected and fused with the selected text to obtain an updated text to be detected. This updated text to be detected and the query question are then used to generate new evidence chain information. This process is repeated until the answer prediction model can output a predicted answer based on the generated evidence chain information.

[0146] Step 410: Determine whether the text to be detected contains a terminator. If it does, the process ends; otherwise, return to step 402.

[0147] Specifically, when the answer prediction model can output a predicted answer, since the vector coding model cannot accurately determine when to stop encoding during the cyclic encoding phase, a terminator EOE can be added to the text to be detected as a new text to be detected, i.e., the new text to be detected is [p1, p2, p3, p4, EOE]. However, if the updated text to be detected does not include the terminator, it is still considered that the conditions for extracting evidence chain information are not met, and it is still necessary to return to step 502 for the vector coding model to re-execute the encoding process. However, since the remaining unselected text to be detected may be text unrelated to the query question, that is, these unselected texts may interfere with the answer prediction model's output of the predicted answer, when the answer prediction model can output a predicted answer, the terminator in the text to be detected can be directly selected and merged with the selected text to be detected without continuing to filter new unselected text to be detected; but when the vector coding model selects the terminator, it means that the evidence chain information is already sufficient to predict the answer, and the filtered text to be detected is sufficient. At this time, the text extraction process to be detected can end, i.e., the cyclic termination.

[0148] In one embodiment of this application, since the text to be detected is continuously updated during the encoding process performed by the vector coding model, the answer prediction process in each round actually refers to the previous prediction results. Furthermore, since the encoding process performed by the vector coding model can adjust the number of iterations according to the actual situation of whether the question can be answered, and can generate evidence chain information of different lengths according to different questions, the evidence chain information required for the answer is effectively extracted, thereby improving the accuracy of answer prediction.

[0149] Corresponding to the above method embodiments, this application also provides a question-answering device embodiment. Figure 5 A schematic diagram of the structure of a question-and-answer device according to an embodiment of this application is shown. Figure 5 As shown, the device 500 includes:

[0150] The input module 502 is configured to input the text to be detected and the query question as input sets into the vector encoding model to obtain the encoding vector of the input set;

[0151] The construction module 504 is configured to input the encoded vector into the graph encoding module for processing, and construct a graph structure based on the processing result;

[0152] The output module 506 is configured to determine and output the answer detection result corresponding to the query question based on the graph structure.

[0153] Optionally, the construction module 504 includes:

[0154] The first construction submodule is configured to input the encoded vector into the graph encoding module to divide the vector nodes, and construct the graph structure based on the association relationship between at least two vector nodes in the division result.

[0155] Optionally, the output module 506 includes:

[0156] The output submodule is configured to establish a mapping relationship between the at least two vector nodes and the encoded vector, and output the result based on the mapping relationship and the answer detection result corresponding to the query question.

[0157] Optionally, the construction module 504 includes:

[0158] The segmentation submodule is configured to divide the encoding vector into question vector nodes, paragraph vector nodes, and / or sentence vector nodes according to the query question and the paragraph information and / or sentence information contained in the text to be detected.

[0159] Optionally, the construction module 504 further includes:

[0160] The calculation submodule is configured to perform attention calculations on the question vector node, the paragraph vector node, and / or the sentence vector node respectively, and obtain the attention calculation results corresponding to the question vector node, the paragraph vector node, and / or the sentence vector node;

[0161] The association determination submodule is configured to determine the association relationship between the question vector node, the paragraph vector node, and / or the sentence vector node based on the attention calculation result.

[0162] The second construction submodule is configured to construct the graph structure based on the association relationship.

[0163] Optionally, attention can be calculated for the problem vector nodes in the following manner:

[0164] Determine the weight of each word unit in the query question;

[0165] The weight corresponding to each word unit is multiplied by the word vector of the word unit;

[0166] The product results are summed, and the summation result is used as the attention calculation result corresponding to the problem vector node.

[0167] Optionally, the output module 506 includes:

[0168] The mapping relationship establishment submodule is configured to map the at least two vector nodes to the encoding vector through an attention mechanism to establish a mapping relationship between the at least two vector nodes and the encoding vector.

[0169] Optionally, the output module 506 includes:

[0170] The probability distribution determination submodule is configured to determine the probability distribution of the start and end positions of the answer detection results corresponding to the query question based on the mapping relationship and the graph structure.

[0171] The answer detection result determination submodule is configured to determine and output the answer detection result corresponding to the query question based on the probability distribution.

[0172] Optionally, the answer detection result determination submodule includes:

[0173] The starting position determination unit is configured to take the position of the word unit with the highest probability in the probability distribution of the starting position in the text to be detected as the starting position of the answer detection result;

[0174] The end position determination unit is configured to take the position of the word unit with the highest probability in the probability distribution of the end position in the text to be detected as the end position of the answer detection result;

[0175] The output unit is configured to output the word units between the start and end positions as the answer detection result.

[0176] Optionally, the question-and-answer device further includes:

[0177] The paragraph information determination module is configured to determine the paragraph information of the paragraph to which the detection result of the answer to the query question belongs based on the graph structure.

[0178] Optionally, the question-and-answer device further includes:

[0179] The answer prediction module is configured to predict the answer and output the prediction result based on the paragraph information of the paragraph to which the answer detection result belongs when the accuracy of the answer detection result is determined to be lower than a preset accuracy threshold.

[0180] The question-answering device provided in this application encodes both the query question and the text to be detected during the process of detecting the answer to the query question in the text to be detected. A graph encoding module then constructs a graph structure corresponding to the text to be detected, containing a chain of evidence related to the query question, based on the generated encoding vector. Furthermore, it can generate graph structures containing different chains of evidence based on different query questions. Compared to the current process of manually constructing graph structures, the method of using a graph encoding module to construct the graph structure in this embodiment improves both the efficiency of graph structure construction and the accuracy of the chain of evidence related to the query question contained in the constructed graph structure. Moreover, determining the answer to the query question through the chain of evidence in the graph structure improves the accuracy of the output answer detection results.

[0181] The above is an illustrative scheme of a question-and-answer device according to this embodiment. It should be noted that the technical solution of this question-and-answer device and the technical solution of the question-and-answer method described above belong to the same concept. For details not described in detail in the technical solution of the question-and-answer device, please refer to the description of the technical solution of the question-and-answer method described above.

[0182] It should be noted that each component in the device claim should be understood as a functional module necessary to implement each step of the program flow or method, and the functional modules are not actual functional divisions or separations. A device claim defined by such a set of functional modules should be understood as a functional module architecture that implements the solution primarily through the computer program described in the specification, and not as a physical device that implements the solution primarily through hardware.

[0183] In one embodiment of this application, a computing device is also provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor executes the computer instructions to implement the steps of the question-and-answer method.

[0184] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the question-and-answer method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the question-and-answer method described above.

[0185] An embodiment of this application also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the question-and-answer method as described above.

[0186] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the question-and-answer method described above belong to the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the question-and-answer method described above.

[0187] This application discloses a chip that stores computer instructions, which, when executed by a processor, implement the steps of the question-and-answer method as described above.

[0188] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0189] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.

[0190] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0191] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0192] The preferred embodiments disclosed above are merely illustrative of this application. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this application. These embodiments are selected and specifically described in this application to better explain the principles and practical applications of this application, thereby enabling those skilled in the art to better understand and utilize this application. This application is limited only by the claims and their full scope and equivalents.

Claims

1. A question and answer method, characterized by, The method comprises: inputting the to-be-detected text and the to-be-queried question as an input set into a vector encoding model to obtain an encoding vector of the input set; inputting the encoding vector into a graph encoding module for processing, and constructing a graph structure according to a processing result, wherein the graph encoding module has a node division unit and an attention calculation unit, and the inputting the encoding vector into the graph encoding module for processing and constructing the graph structure according to the processing result comprises: dividing the encoding vector into question vector nodes, paragraph vector nodes and / or sentence vector nodes according to the to-be-queried question, paragraph information and / or sentence information contained in the to-be-detected text by the node division unit, calculating correlation coefficients between the vector nodes obtained by the division by the attention calculation unit, constructing a graph structure according to the calculation result, and outputting paragraph information of a paragraph in which an answer detection result belongs in the to-be-detected text and information about whether the paragraph information contains supporting facts related to the answer detection result, wherein the paragraph information represents that at least one vector node in an evidence chain is contained in the paragraph, or whether a sentence contained in the paragraph is an evidence chain; determining and outputting an answer detection result corresponding to the to-be-queried question according to the graph structure, and wherein, in a case where an accuracy of the answer detection result is lower than a preset accuracy threshold, the answer detection result corresponding to the to-be-queried question is determined again according to the paragraph information and / or the information about the supporting facts.

2. The question and answer method of claim 1, wherein, The determining and outputting the answer detection result corresponding to the to-be-queried question according to the graph structure comprises: establishing a mapping relationship between at least two vector nodes and the encoding vector, and determining and outputting the answer detection result corresponding to the to-be-queried question according to the mapping relationship and the graph structure.

3. The question and answer method of claim 1, wherein, The constructing the graph structure according to the processing result comprises: performing attention calculation on the question vector nodes, the paragraph vector nodes and / or the sentence vector nodes respectively to obtain attention calculation results corresponding to the question vector nodes, the paragraph vector nodes and / or the sentence vector nodes; determining an association relationship between the question vector nodes, the paragraph vector nodes and / or the sentence vector nodes according to the attention calculation results; constructing the graph structure according to the association relationship.

4. The question answering method of claim 3, wherein, The attention calculation on the question vector nodes is performed in the following manner: determining weights corresponding to each word unit in the to-be-queried question; performing product operation on the weights corresponding to each word unit and a word vector of the word unit; performing summation operation on the product operation result, and taking the summation operation result as the attention calculation result corresponding to the question vector node.

5. The question answering method of claim 2, wherein, The establishing the mapping relationship between the at least two vector nodes and the encoding vector comprises: mapping the at least two vector nodes to the encoding vector through an attention mechanism to establish the mapping relationship between the at least two vector nodes and the encoding vector.

6. The question answering method of claim 2, wherein, The determining and outputting the answer detection result corresponding to the to-be-queried question according to the mapping relationship and the graph structure comprises: According to the mapping relationship and the graph structure, a probability distribution of a start position and an end position of an answer detection result corresponding to the query question is determined; According to the probability distribution, the answer detection result corresponding to the query question is determined and output.

7. The question answering method of claim 6, wherein, The determination of the answer detection result corresponding to the query question according to the probability distribution and the outputting thereof comprise: The position of a word unit with the maximum probability in the probability distribution of the start position in the text to be detected is taken as the start position of the answer detection result; The position of a word unit with the maximum probability in the probability distribution of the end position in the text to be detected is taken as the end position of the answer detection result; The word units between the start position and the end position are taken as the answer detection result and output.

8. The question answering method of claim 1, wherein, After the construction of the graph structure according to the processing result, the following step is further included: According to the graph structure, paragraph information of a paragraph to which the answer detection result corresponding to the query question belongs is determined.

9. The question answering method of claim 8, wherein, The following step is further included: In a case where the accuracy of the answer detection result is lower than a preset accuracy threshold, answer prediction is performed according to the paragraph information of the paragraph to which the answer detection result belongs, and a prediction result is output.

10. A question answering apparatus characterized by comprising: The following steps are included: An input module is configured to input a text to be detected and a query question into a vector encoding model as an input set to obtain an encoding vector of the input set; A construction module is configured to input the encoding vector into a graph encoding module for processing, and construct a graph structure according to a processing result, wherein the graph encoding module has a node division unit and an attention calculation unit; The construction module includes a division sub-module configured to divide the encoding vector into a question vector node, a paragraph vector node and / or a sentence vector node according to the query question, paragraph information and / or sentence information contained in the text to be detected, wherein the attention calculation unit calculates a correlation coefficient between each vector node obtained by the division, constructs a graph structure according to a calculation result, and outputs paragraph information of a paragraph to which an answer detection result belongs in the text to be detected based on the graph structure, and outputs information about whether the paragraph information contains supporting facts related to the answer detection result, wherein the paragraph information represents that the paragraph contains at least one vector node in an evidence chain, or whether a sentence contained in the paragraph is an evidence chain; An output module is configured to determine an answer detection result corresponding to the query question according to the graph structure and output the answer detection result, wherein in a case where the accuracy of the answer detection result is lower than a preset accuracy threshold, the answer detection result corresponding to the query question is re-determined according to the paragraph information and / or the information about the supporting facts.

11. A computing device comprising a memory, a processor, and computer instructions stored on the memory and executable on the processor, wherein, The processor executes the computer instructions to implement the steps of the question and answer method of any one of claims 1-9.

12. A computer-readable storage medium storing computer instructions, wherein, The computer instructions are executed by the processor to implement the steps of the question and answer method of any one of claims 1-9.

Citation Information

Patent Citations

  • Data processing method and device and computer readable storage medium

    CN111488460A