# Multi-Hop Question Generation with Knowledge Graph-Enhanced Language Model
## 3 Methodology
### Context Understanding  
Let \(P\), \(Q\), \(A\) denote context passage, question to be generated, and answer, respectively; \(P=(p_{1},p_{2},p_{3},\ldots,p_{|P|})\), \(A=(a_{1},a_{2},a_{3},\ldots,a_{|A|})\), and \(Q=(q_{1},q_{2},q_{3},\ldots,q_{|Q|})\) are sequences of an arbitrary length, where \(p_{i}\), \(a_{i}\), and \(q_{i}\) denote a word at position \(i\) of the passage, answer, and question, respectively. In addition, \(|P|\), \(|A|\), and \(|Q|\) are the number of words in \(P\), \(A\), and \(Q\), respectively. Inspired by [PERSON] et al. [6], \(A\) is appended to \(P\), separated by a special \(SEP\) token. The concatenated sequence \([P,SEP,A]\) is fed into GPT-2 to obtain initial contextual representation matrices for \(P\) and \(A\), illustrated as \[M_{0}^{P},M_{0}^{A}=\text{GPT2}([P,\text{SEP},A]), \tag{1}\]  
where \(M_{0}^{P}\in\mathbb{R}^{|P|\times d_{G}}\) and \(M_{0}^{A}\in\mathbb{R}^{|A|\times d_{G}}\), and \(d_{G}\) is the dimension of the hidden state of GPT-2. The reasoning component of the proposed KGEL model is depicted in Figure 3. The aim of this component is to enhance the representations of both the context and answer by incorporating entity information from the knowledge graph. This is achieved through the use of an answer-aware graph attention network (GAT) to update the context representations and a bi-attention mechanism to update the answer representations. The workings of the reasoning component are detailed in the subsequent sub-sections. **Knowledge Graph Construction and Entity Encoding**. A BERT-based NER model is employed to identify entities in the context and to annotate their positions for ease of extracting their corresponding embeddings from the GPT-2 embedding sequence. The resulting knowledge graph is constructed with the entities in the context serving as its nodes and edges being established between entities within the same paragraphs and between entities in each paragraph and those in the title. With the context passage encoding \(M_{0}^{P}\) obtained from the GPT-2 encoder, a binary-valued context-entity mapping matrix \(M^{m}\) is used to obtain entity encoding, where \(M_{ij}^{m}=1\) if the corresponding position is within the span of the \(j\)th entity in the \(i\)th context, otherwise \(M_{ij,j}^{m}=0\). Context-to-graph operation, illustrated in the upper left corner of Figure 3, aims to obtain the entity embedding matrix \(M_{0}^{E}\), which is calculated by mean-max pooling over corresponding passage encoding span after the mapping operation:  
\[M_{0}^{E}=\text{Mean}-\text{maxpooling}(M_{0}^{P}M^{m}),M_{0}^{E}\in\mathbb{R }^{|E|\times 2d_{G}}, \tag{2}\]  
where \(d_{G}\) is the hidden size of GPT-2, and \(|E|\) is the number of entities extracted from the input passage. **Answer-aware GAT**. The answer-aware GAT is proposed to gather scattered answer-related entity information and mimic a human's ability to process information in each sequential manner to form a reasoning chain. Inspired by [PERSON] et al. [23], after obtaining entities' embedding matrix \(M_{0}^{E}\), a graph neural network is utilized to propagate answer-aware node information between answer related entities. To achieve this, a soft mask mechanism is applied to weigh the nodes considering the answer information as described  
Figure 3: The illustration of the reasoning module. We implement a dynamic procedure of Context2 Graph and Graph2 Context using a mapping matrix M. The entity representation is updated using an answer-aware GAT, and the answer representation is updated through a bi-attention mechanism.