Reasoning method based on structural attention mechanism for knowledge-based question answering and computing apparatus for performing the same
Disclosed herein are a reasoning method based on a structural attention mechanism for knowledge-based question answering and a computing apparatus for performing the reasoning method. The reasoning method includes: recognizing one or more entities in a query including content and a question, and linking the recognized entities to a knowledge base; constructing a question hypergraph and a query-aware knowledge hypergraph by performing a multi-hop graph walk on a question graph and the knowledge base; and inferring a correct answer to the question by applying as attention mechanism to a query hyperedge and a knowledge hyperedge included in the question hypergraph and the query-aware knowledge hypergraph, respectively.
1 . A reasoning method based on a structural attention mechanism for knowledge-based question answering, the reasoning method being performed by a computing apparatus, by at least one processor executing instructions stored in a memory of the computing apparatus, the reasoning method comprising:
recognizing one or more entities in a query, the query including content and a question, and linking recognized entities to a knowledge base;
constructing a question hypergraph and a query-aware knowledge hypergraph by performing a multi-hop graph walk on a question graph and the knowledge base, the multi-hop graph walk being started from a node to which one of the recognized entities in the query is linked and then traversing other nodes linked on a per-triplet basis; and
inferring a correct answer to the question by applying an attention mechanism to a query hyperedge and a knowledge hyperedge included in the question hypergraph and the query-aware knowledge hypergraph, respectively,
wherein constructing the question hypergraph and the query-aware knowledge hypergraph comprises:
constructing the question hypergraph by setting a node sequence, recognized as a phrase, as a question hyperedge in a question graph structured by defining each word included in the question as a node and linking adjacent nodes by edges; and
constructing the query-aware knowledge hypergraph by, in the knowledge base to which the recognized entities are linked, performing the multi-hop graph walk from a knowledge node, to which each of the recognized entities is linked, to a tail node and then setting all nodes, traversed by the multi-hop graph walk, as one hyperedge, and
wherein inferring the correct answer comprises:
converting the question hyperedge into a dense representation of the question hyperedge by embedding the question hyperedge and applying a linear projection function using a projection matrix, and converting the knowledge hyperedge into a dense representation of the knowledge hyperedge by embedding the knowledge hyperedge and applying a linear projection function using a projection matrix;
obtaining single vector representations respectively corresponding to the knowledge hyperedge and the question hyperedge by passing the dense representations of the knowledge hyperedge and the question hyperedge through the attention mechanism, the attention mechanism sequentially comprising guided-attention blocks and self-attention blocks; and
predicting the correct answer to the question by using the single vector representations obtained from the self-attention blocks,
wherein each guided-attention block updates the dense representation corresponding to either the question hyperedge or the knowledge hyperedge based on an output of a guided-attention function that takes a query vector, a key vector, and a value vector as inputs, wherein the key vector and the value vector form a key-value pair, and the query vector inputted to the guided-attention function is a linear projection of one of the dense representations, and the key vector and value vector inputted to the guided-attention function are each linear projections of the other dense representation; and
wherein each self-attention block further updates a dense representation obtained from a guided-attention block based on an output of a self-attention function that takes a query vector, a key vector, and a value vector as inputs, and the query vector, key vector, and value vector inputted to the self-attention function are each linear projections of the same dense representation.
2 . The reasoning method of claim 1 , wherein the linking the recognized entities to the knowledge base comprises:
recognizing one or more entities in the content;
searching for knowledge nodes corresponding to the recognized entities in the knowledge base; and
linking the recognized entities to found knowledge nodes as new nodes.
3 . The reasoning method of claim 1 , wherein predicting the correct answer comprises predicting a correct answer to the question by using one of a similarity-based answer predictor and a multi-layer perceptron-based answer predictor.
4 . A non-transitory computer-readable storage medium having stored thereon a program that, when executed by a processor, causes the processor to execute the reasoning method set forth in claim 1 .
5 . A computer program that is executed by a computing apparatus and stored in a non-transitory computer-readable storage medium in order to perform the reasoning method set forth in claim 1 .
6 . A computing apparatus for implementing a hypergraph transformer model and performing reasoning based on a structural attention mechanism for knowledge-based question answering, the computing apparatus comprising:
a memory storing instructions for performing reasoning based on the structural attention mechanism for knowledge-based question answering and a program for implementing the hypergraph transformer model; and
at least one processor configured to execute the instructions stored in the memory to perform the reasoning based on the structural attention mechanism for knowledge-based question answering and to execute the program for implementing the hypergraph transformer model,
wherein the hypergraph transformer model comprises:
an entity linker configured to recognize one or more entities in a query and link recognized entities to knowledge nodes of a knowledge base;
a hypergraph constructor configured to construct a question hypergraph based on a question and also construct a query-aware knowledge hypergraph based on the knowledge base to which the recognized entities are linked; and
a transformer model configured to apply an attention mechanism to a query hyperedge and a knowledge hyperedge included in the question hypergraph and the query-aware knowledge hypergraph, respectively,
wherein the hypergraph constructor constructs the question hypergraph by setting a node sequence, recognized as a phrase, as a question hyperedge in a question graph structured by defining each word included in the question as a node and linking adjacent nodes by edges; and the hypergraph constructor constructs the query-aware knowledge hypergraph by, in the knowledge base to which the recognized entities are linked, performing a multi-hop graph walk from a knowledge node, to which each of the recognized entities is linked, to a tail node and then setting all nodes, traversed by the multi-hop graph walk, as one hyperedge, and
wherein the transformer model converts the question hyperedge into a dense representation of the question hyperedge by embedding the question hyperedge and applying a linear projection function using a projection matrix, and converts the knowledge hyperedge into a dense representation of the knowledge hyperedge by embedding the knowledge hyperedge and applying a linear projection function using a projection matrix,
and wherein the attention mechanism of the transformer model sequentially comprises guided-attention blocks and self-attention blocks, and is configured to obtain single vector representations respectively corresponding to the knowledge hyperedge and the question hyperedge by passing the dense representations of the knowledge hyperedge and the question hyperedge through the guided-attention blocks and the self-attention blocks, and
a correct answer predictor configured to predict a correct answer to the question by concatenating single vector representations obtained from the self-attention blocks,
wherein each guided-attention block updates the dense representation corresponding to either the question hyperedge or the knowledge hyperedge based on an output of a guided-attention function that takes a query vector, a key vector, and a value vector as inputs, wherein the key vector and the value vector form a key-value pair, and the query vector inputted to the guided-attention function is a linear projection of one of the dense representations, and the key vector and value vector inputted to the guided-attention function are each linear projections of the other dense representation; and
wherein each self-attention block updates a dense representation obtained from a guided-attention block based on an output of a self-attention function that takes a query vector, a key vector, and a value vector as inputs, and the query vector, key vector, and value vector inputted to the self-attention function are each linear projections of the same dense representation.