QA - GNN : Reasoning with Language Models and Knowledge Graphs for Question Answering (2021)

Abstract: The problem of answering questions using knowledge from pre-trained language models (LMs) and knowledge graphs (KGs) presents two challenges: given a QA context (question and answer choice), methods need to (i) identify relevant knowledge from large KGs, and (ii) perform joint reasoning over the QA context and KG. Here we propose a new model, QA-GNN, which addresses the above challenges through two key innovations: (i) relevance scoring, where we use LMs to estimate the importance of KG nodes relative to the given QA context, and (ii) joint reasoning, where we connect the QA context and KG to form a joint graph, and mutually update their representations through graph-based message passing. We evaluate QA-GNN on the CommonsenseQA and OpenBookQA datasets, and show its improvement over existing LM and LM+KG models, as well as its capability to perform interpretable and structured reasoning, e.g., correctly handling negation in questions.

## introduction question answering systems must be able to access relevant knowledge and reason over it. typically, knowledge can be implicitly encoded in large language models (lms) pre-trained on unstructured text @xcite , or explicitly represented in structured knowledge graphs (kgs), such as freebase @xcite and conceptnet @xcite , where entities are represented as nodes and relations between them as edges. recently, pre-trained lms have demonstrated remarkable success in many question answering tasks @xcite . however, while lms have a broad coverage of knowledge, they do not empirically perform well on structured reasoning (e.g., handling negation) @xcite . on the other hand, kgs are more suited for structured reasoning @xcite and enable explainable predictions e.g., by providing reasoning paths @xcite , but may lack coverage and if it is not used for hair, a round brush is an example of what? a. hair brush b. bathroom c. art supplies* d. shower e. hair salon painting atlocation round brush hair brush r e l a t e d t o atlocation us ed fo r us ed fo r choice entity answer question entity qa context knowledge graph art supply qa context node hair graph connection ( §3.1) dev acc. no edge between z and kg nodes 74.11 connect z to all kg nodes 76.38 connect z to qa entity nodes (final) 76.54 relevance scoring ( §3.2) dev acc. nothing 75.15 w/ contextual embedding 76.31 w/ relevance score (final) 76.54 w/ both 76.52 gnn attention & message ( §3.3) dev acc. node type, relation, score-aware (final) 76.54 -type-aware 75.11 -relation-aware 75.23 -score-aware 75.15 gnn layers ( §3.3) dev acc. @xmath0.53 @xmath1.34 @xmath2.54 @xmath3.21 @xmath4.96 graph connection ( §3.1) dev acc. no edge between z and kg nodes 74.81 connect z to all kg nodes 76.38 connect z to qa entity nodes (final system) 76.54 contextualization ( §3.2) dev ac no contextualization 75.56 w/ contextual embedding 76.31 w/ relevance score (final system) 76.54 w/ both 76.52 gnn attention & message ( §3.3) dev acc. node type, relation, score-aware (final system) 76.54 -type-aware 75.41 -relation-aware 75.61 -score-aware 75.56 gnn layers ( §3.3) dev acc. @xmath5.53 @xmath6.34 @xmath7.54 @xmath8.21 @xmath9.96 graph connection ( §3.1) dev acc. no edge between z and kg nodes 74.81 connect z to all kg nodes 76.38 connect z to qa entity nodes (final) 76.54 relevance scoring ( §3.2) dev acc. nothing 75.56 w/ contextual embedding 76.31 w/ relevance score (final) 76.54 w/ both 76.52 gnn attention & message ( §3.3) dev acc. node type, relation, score-aware (final) 76.54 -type-aware 75.41 -relation-aware 75.61 -score-aware 75.56 gnn layers ( §3.3) dev acc. @xmath10.53 @xmath11.34 @xmath12.54 @xmath13.21 @xmath14.96 if it is not used for hair, a round brush is an example of what? a. hair brush b. bathroom c. art supplies* d. shower e. hair salon painting atlocation round brush hair brush r e l a t e d t o atlocation us ed fo r us ed fo r choice entity answer question entity qa context knowledge graph art supply qa context node hair figure 1: given the qa context (question and answer choice; purple box), we aim to derive the answer by performing joint reasoning over the language and the knowledge graph (green box). figure 2 : overview of our approach. given a qa context (z), we connect it with the retrieved kg to form a joint graph (working graph; §3.1), compute the relevance of each kg node conditioned on z ( §3.2; node shading indicates the relevance score), and perform reasoning on the working graph ( §3.3). here we propose qa-gnn, an end-to-end lm+kg model for question answering that addresses the above two challenges. we first encode the qa context using an lm, and retrieve a kg subgraph following prior works @xcite . our qa-gnn has two key insights: (i) relevance scoring: since the kg subgraph consists of all few-hop neighbors of the topic entities, some entity nodes are more relevant than others with respect to the given qa context. we hence propose kg node relevance scoring: we score each entity on the kg subgraph by concatenating the entity with the qa context and calculating the likelihood using a pretrained lm. this presents a general framework to weight information on the kg; (ii) joint reasoning: we design a joint graph representation of the qa context and kg, where we explicitly view the qa context as an additional node (qa context node) and connect it to the topic entities in the kg subgraph as shown in figure 1 . this joint graph, which we term the working graph, unifies the two modalities into one graph. we then augment the feature of each node with the relevance score, and design a new attention-based gnn module for reasoning. our joint reasoning algorithm on the working graph simultaneously updates the representation of both the kg entities and the qa context node, bridging the gap between the two sources of information. we evaluate qa-gnn on two question answering datasets that require reasoning with knowledge: commonsenseqa @xcite and openbookqa @xcite , using the conceptnet kg @xcite . qa-gnn outperforms strong fine-tuned lm baselines as well as the existing best lm+kg model (with the same lm) by up to 5.7% and 3.7% respectively. in particular, qa-gnn exhibits improved performance on some forms of structured reasoning (e.g., correctly han-dling negation and entity substitution in questions): it achieves 4.6% improvement over fine-tuned lms on questions with negation, while existing lm+kg models are +0.6% over fine-tuned lms. we also show that one can extract reasoning processes from qa-gnn in the form of general kg subgraphs, not just paths @xcite , suggesting a general method for explaining model predictions. ## problem statement we aim to answer natural language questions using knowledge from a pre-trained lm and a structured kg. we use the term language model broadly to be any composition of two functions, f head (f enc (x)), where f enc , the encoder, maps a textual input x to a contextualized vector representation h lm , and f head uses this representation to perform a desired task (which we discuss in §3.2). in this work, we specifically use masked language models (e.g., roberta) as f enc , and let h lm denote the output representation of a @xcite token that is prepended to the input sequence x, unless otherwise noted. we define the knowledge graph as a multi-relational graph @xmath15,e). here v is the set of entity nodes in the kg; e ⊆ v ×r×v is the set of edges that connect nodes in v, where r represents a set of relation types. given a question q and an answer choice @xmath16, we follow prior work @xcite to link the entities mentioned in the question and answer choice to the given kg g. we denote v q ⊆ v and v a ⊆ v as the set of kg entities mentioned in the question (question entities; blue entities in figure1) and answer choice (answer choice entities; red entities in figure1), respectively, and use v q,a := v q ∪v a to denote all the entities that appear in either the question or answer choice, which we call topic entities. we then extract a subgraph from g for a question-choice pair, g q,a @xmath17,a sub , e q,a sub ), foot_0 which comprises all nodes on the k-hop paths between nodes in v q,a . qa context retrieved kg travel door security go run human lock place holiday close safe money robber bank bank holiday river bank a revolving door is convenient for two direction travel, but also serves as a security measure at what? a. bank* b. library c. department store d. mall e. new york kg node scored language model relevance ( entity | qa context ) travel door security go run human lock place holiday close safe money robber bank bank holiday river bank entity some entities are more relevant than others given the context. entity relevance estimated. darker color indicates higher score. graph connection ( §3.1) dev acc. no edge between z and kg nodes 74.11 connect z to all kg nodes 76.38 connect z to qa entity nodes (final system) 76.54 contextualization ( §3.2) dev acc. no contextualization 75.15 w/ contextual embedding 76.31 w/ relevance score (final system) 76.54 w/ both 76.52 gnn attention & message ( §3.3) dev acc. node type, relation, score-aware (final system) 76.54 -type-aware 75.11 -relation-aware 75.23 -score-aware 75.15 gnn layers ( §3.3) dev acc. @xmath18.53 @xmath19.34 @xmath20.54 @xmath21.21 @xmath22.96 inference ( §3.4) dev acc. final states of z and kg (final system) 76.54 -z 74.91 -kg 75.15 ## approach: qa-gnn as shown in figure 2 , given a question and an answer choice a, we concatenate them to get the qa context [q; a]. to reason over a given qa context using knowledge from both the lm and the kg, qa-gnn works as follows. first, we use the lm to obtain a representation for the qa context, and retrieve the subgraph g sub from the kg. then we introduce a qa context node z that represents the qa context, and connect z to the topic entities v q,a so that we have a joint graph over the two sources of knowledge, which we term the working graph, g w ( §3.1). to adaptively capture the relationship between the qa context node and each of the other nodes in g w , we calculate a relevance score for each pair using the lm, and use this score as an additional feature for each node ( §3.2). we then propose an attention-based gnn module that does message passing on the g w for multiple rounds ( §3.3). finally, we make the final prediction using the lm representation, qa context node representation and a pooled working graph representation ( §3.4). ## related work and discussion knowledge-aware methods for nlp. various works have studied methods to augment nlp systems with knowledge. existing works @xcite @xcite study pre-trained lms' potential as latent knowledge bases. to provide more explicit and interpretable knowledge, several works integrate structured knowledge (kgs) into lms @xcite @xcite @xcite . question answering with lm+kg. in particular, a line of works propose lm+kg methods for question answering. most closely related to ours are works by lin et al. (2019); feng et al. (2020); lv et al. (2020). our novelties are (1) the joint graph of qa context and kg, on which we mutually update the representations of the lm and kg; and (2) language-conditioned kg node relevance scoring. other works on scoring or pruning kg nodes/paths rely on graph-based metrics such as pagerank, centrality, and off-the-shelf kg embeddings @xcite @xcite , without reflecting the qa context. other qa tasks. several works study other forms of question answering tasks, e.g., passagebased qa, where systems identify answers using given or retrieved documents @xcite @xcite , and kbqa, where systems perform semantic parsing of a given question and execute the parsed queries on knowledge bases @xcite @xcite . different from these tasks, we approach question answering using knowledge available in lms and kgs. knowledge representations. several works study joint representations of external textual knowledge (e.g., wikipedia articles) and structured knowledge (e.g., kgs) @xcite @xcite @xcite . the primary distinction of our joint graph representation is that we construct a graph connecting each question and kg rather than textual and structural knowledge, approaching a complementary problem to the above works. graph neural networks (gnns). gnns have been shown to be effective for modeling graphbased data. several works use gnns to model the structure of text @xcite @xcite or kgs @xcite . in contrast to these works, qa-gnn jointly models the language and kg. graph attention networks (gats) @xcite perform attention-based message passing to induce graph representations. we build on this framework, and further condition the gnn on the language input by introducing a qa context node ( §3.1), kg node relevance scoring ( §3.2), and joint update of the kg and language representations ( §3.3). ## conclusion we presented qa-gnn, an end-to-end question answering model that leverages lms and kgs. our key innovations include (i) relevance scoring, where we compute the relevance of kg nodes conditioned on the given qa context, and (ii) joint reasoning over the qa context and kgs, where we connect the two sources of information via the working graph, and jointly update their representations through gnn message passing. through both quantitative and qualitative analyses, we showed qa-gnn's improvements over existing lm and lm+kg models on question answering tasks, as well as its capability to perform interpretable and structured reasoning, e.g., correctly handling negation in questions.