ReasoNet: Learning to Stop Reading in Machine Comprehension

Yelong Shen, Po-Sen Huang, Jianfeng Gao, Weizhu Chen

Introduction

Teaching machines to read, process, and comprehend natural language documents is a coveted goal for artificial intelligence (Bottou, 2014; Richardson et al., 2013; Hermann et al., 2015). Genuine reading comprehension is extremely challenging, since effective comprehension involves thorough understanding of documents and sophisticated inference. Toward solving this machine reading comprehension problem, in recent years, several works have collected various datasets, in the form of question, passage, and answer, to test machine on answering a question based on the provided passage (Richardson et al., 2013; Hermann et al., 2015; Hill et al., 2016; Rajpurkar et al., 2016). Some large-scale cloze-style datasets (Hermann et al., 2015; Hill et al., 2016) have gained significant attention along with powerful deep learning models.

Recent approaches on cloze-style datasets can be separated into two categories: single-turn and multi-turn reasoning. Single turn reasoning models utilize attention mechanisms (Bahdanau et al., 2015) to emphasize specific parts of the document which are relevant to the query. These attention models subsequently calculate the relevance between a query and the corresponding weighted representations of document subunits (e.g. sentences or words) to score target candidates (Hill et al., 2016; Hermann et al., 2015; Kadlec et al., 2016). However, considering the sophistication of the problem, after a single-turn comprehension, readers often revisit some specific passage or the question to grasp a better understanding of the problem. With this motivation, recent advances in reading comprehension have made use of multiple turns to infer the relation between query, document and answer (Hill et al., 2016; Dhingra et al., 2016; Trischler et al., 2016; Sordoni et al., 2016). By repeatedly processing the document and the question after digesting intermediate information, multi-turn reasoning can generally produce a better answer and these existing works have demonstrated its superior performance consistently.

Existing multi-turn models have a pre-defined number of hops or iterations in their inference without regard to the complexity of each individual query or document. However, when human read a document with a question in mind, we often decide whether we want to stop reading if we believe the observed information is adequate already to answer the question, or continue reading after digesting intermediate information until we can answer the question with confidence. This behavior generally varies from document to document or question to question because it is related to the sophistication of the document or the difficulty of the question. Meanwhile, the analysis in (Chen et al., 2016) also illustrates the huge variations in the difficulty level with respect to questions in the CNN/Daily Mail datasets (Hermann et al., 2015). For a significant part of the datasets, this analysis shows that the problem cannot be solved without appropriate reasoning on both its query and document.

With this motivation, we propose a novel neural network architecture called Reasoning Network (ReasoNet). which tries to mimic the inference process of human readers. With a question in mind, ReasoNets read a document repeatedly, each time focusing on different parts of the document until a satisfying answer is found or formed. This reminds us of a Chinese proverb: “The meaning of a book will become clear if you read it hundreds of times.”. Moreover, unlike previous approaches using fixed number of hops or iterations, ReasoNets introduce a termination state in the inference. This state can decide whether to continue the inference to the next turn after digesting intermediate information, or to terminate the whole inference when it concludes that existing information is sufficient to yield an answer. The number of turns in the inference is dynamically modeled by both the document and the query, and can be learned automatically according to the difficulty of the problem.

One of the significant challenges ReasoNets face is how to design an efficient training method, since the termination state is discrete and not connected to the final output. This prohibits canonical back-propagation method being directly applied to train ReasoNets. Motivated by (Williams, 1992; Mnih et al., 2014), we tackle this challenge by proposing a reinforcement learning approach, which utilizes an instance-dependent reward baseline, to successfully train ReasoNets. Finally, by accounting for a dynamic termination state during inference and applying proposed deep reinforcement learning optimization method, ReasoNets achieve the state-of-the-art results in machine comprehension datasets, including unstructured CNN and Daily Mail datasets, and the proposed structured Graph Reachability dataset, when the paper is first publicly available on arXiv.https://arxiv.org/abs/1609.05284 At the time of the paper submission, we apply ReasoNet to the competitive Stanford Question Answering Dataset(SQuAD), ReasoNets outperform all existing published approaches and rank at second place on the test set leaderboard.http://www.stanford-qa.com

This paper is organized as follows. In Section 2, we review and compare recent work on machine reading comprehension tasks. In Section 3, we introduce our proposed ReasoNet model architecture and training objectives. Section 4 presents the experimental setting and results on unstructured and structured machine reading comprehension tasks .

Related Work

Recently, with large-scale datasets available and the impressive advance of various statistical models, machine reading comprehension tasks have attracted much attention. Here we mainly focus on the related work in cloze-style datasets (Hermann et al., 2015; Hill et al., 2016). Based on how they perform the inference, we can classify their models into two categories: single-turn and multi-turn reasoning.

Single-turn reasoning: Single turn reasoning models utilize an attention mechanism to emphasize some sections of a document which are relevant to a query. This can be thought of as treating some parts unimportant while focusing on other important ones to find the most probable answer. Hermann et al. (Hermann et al., 2015) propose the attentive reader and the impatient reader models using neural networks with an attention over passages to predict candidates. Hill et al. (Hill et al., 2016) use attention over window-based memory, which encodes a window of words around entity candidates, by leveraging an end-to-end memory network (Sukhbaatar et al., 2015). Meanwhile, given the same entity candidate can appear multiple times in a passage, Kadlec et al. (Kadlec et al., 2016) propose the attention-sum reader to sum up all the attention scores for the same entity. This score captures the relevance between a query and a candidate. Chen et al. (Chen et al., 2016) propose using a bilinear term similarity function to calculate attention scores with pretrained word embeddings. Trischler et al. (Trischler et al., 2016) propose the EpiReader which uses two neural network structures: one extracts candidates using the attention-sum reader; the other reranks candidates based on a bilinear term similarity score calculated from query and passage representations.

Multi-turn reasoning: For complex passages and complex queries, human readers often revisit the given document in order to perform deeper inference after reading a document. Several recent studies try to simulate this revisit by combining the information in the query with the new information digested from previous iterations (Hill et al., 2016; Dhingra et al., 2016; Sordoni et al., 2016; Weissenborn, 2016; Kumar et al., 2016). Hill et al. (Hill et al., 2016) use multiple hops memory network to augment the query with new information from the previous hop. Gated Attention reader (Dhingra et al., 2016) is an extension of the attention-sum reader with multiple iterations by pushing the query encoding into an attention-based gate in each iteration. Iterative Alternative (IA) reader (Sordoni et al., 2016) produces a new query glimpse and document glimpse in each iteration and utilizes them alternatively in the next iteration. Cui et al. (Cui et al., 2016) further propose to extend the query-specific attention to both query-to-document attention and document-to-query attention, which is built from the intermediate results in the query-specific attention. By reading documents and enriching the query in an iterative fashion, multi-turn reasoning has demonstrated their superior performance consistently.

Our proposed approach explores the idea of using both attention-sum to aggregate candidate attention scores and multiple turns to attain a better reasoning capability. Unlike previous approaches using a fixed number of hops or iterations, motivated by (Nogueira and Cho, 2016; Mnih et al., 2014), we propose a termination module in the inference. The termination module can decide whether to continue to infer the next turn after digesting intermediate information, or to terminate the whole inference process when it concludes existing information is sufficient to yield an answer. The number of turns in the inference is dynamically modeled by both a document and a query, and is generally related to the complexity of the document and the query.

Reasoning Networks

ReasoNets are devised to mimic the inference process of human readers. ReasoNets read a document repeatedly with attention on different parts each time until a satisfying answer is found. As shown in Figure 1, a ReasoNet is composed of the following components:

Memory: The external memory is denoted as MM. It is a list of word vectors, M={mi}i=1..DM=\{m_{i}\}_{i=1..D}, where mim_{i} is a fixed dimensional vector. For example, in the Graph Reachability, mim_{i} is the vector representation of each word in the graph description encoded by a bidirectional-RNN. Please refer to Section 4 for the detailed setup in each experiment.

Attention: The attention vector xtx_{t} is generated based on the current internal state sts_{t} and the external memory MM: xt=fatt(st,M;θx)x_{t}=f_{att}(s_{t},M;\theta_{x}). Please refer to Section 4 for the detailed setup in each experiment.

Internal State: The internal state is denoted as ss which is a vector representation of the question state. Typically, the initial state s1s_{1} is the last-word vector representation of query by an RNN. The tt-th time step of the internal state is represented by sts_{t}. The sequence of internal states are modeled by an RNN: st+1=RNN(st,xt;θs)s_{t+1}=\text{RNN}(s_{t},x_{t};\theta_{s}), where xtx_{t} is the attention vector mentioned above.

Termination Gate: The termination gate generates a random variable according to the current internal state; tt∼p(⋅∣ftg(st;θtg)))t_{t}\sim p(\cdot|f_{tg}(s_{t};\theta_{tg}))). ttt_{t} is a binary random variable. If ttt_{t} is true, the ReasoNet stops, and the answer module executes at time step tt; otherwise the ReasoNet generates an attention vector xt+1x_{t+1}, and feeds the vector into the state network to update the next internal state st+1s_{t+1}.

Answer: The action of answer module is triggered when the termination gate variable is true: at∼p(⋅∣fa(st;θa))a_{t}\sim p(\cdot|f_{a}(s_{t};\theta_{a})).

In Algorithm 1, we describe the stochastic inference process of a ReasoNet. The process can be considered as solving a Partially Observable Markov Decision Process (POMDP) (Kaelbling et al., 1998) in the reinforcement learning (RL) literature. The state sequence s1:Ts_{1:T} is hidden and dynamic, controlled by an RNN sequence model. The ReasoNet performs an answer action aTa_{T} at the TT-th step, which implies that the termination gate variables t1:T=(t1=0,t2=0,...,tT−1=0,tT=1)t_{1:T}=(t_{1}=0,t_{2}=0,...,t_{T-1}=0,t_{T}=1). The ReasoNet learns a stochastic policy π((tt,at)∣st;θ)\pi((t_{t},a_{t})|s_{t};\theta) with parameters θ\theta to get a distribution of termination actions, to continue reading or to stop, and of answer actions if the model decides to stop at the current step. The termination step TT varies from instance to instance.

The learnable parameters θ\theta of the ReasoNet are the embedding matrices θW\theta_{W}, attention network θx\theta_{x}, the state RNN network θs\theta_{s}, the answer action network θa\theta_{a}, and the termination gate network θtg\theta_{tg}. The parameters θ={θW,θx,θs,θa,θtg}\theta=\{\theta_{W},\theta_{x},\theta_{s},\theta_{a},\theta_{tg}\} are trained by maximizing the total expect reward. The expected reward for an instance is defined as:

The reward can only be received at the final termination step when an answer action aTa_{T} is performed. We define rT=1r_{T}=1 if tT=1t_{T}=1 and the answer is correct, and rT=0r_{T}=0 otherwise. The rewards on intermediate steps are zeros, {rt=0}t=1…T−1\{r_{t}=0\}_{t=1\dots T-1}. JJ can be maximized by directly applying gradient based optimization methods. The gradient of JJ is given by:

Motivated by the REINFORCE algorithm (Williams, 1992), we compute ∇θJ(θ)\nabla_{\theta}J(\theta):

In the machine reading comprehension tasks, a training dataset is a collection of triplets of query q\mathbf{q}, passage p\mathbf{p}, and answer a\mathbf{a}. Say ⟨qn,pn,an⟩\langle q_{n},p_{n},a_{n}\rangle is the nn-th training instance.

Experiments

In this section, we evaluate the performance of ReasoNets in machine comprehension datasets, including unstructured CNN and Daily Mail datasets, the Stanford SQuAD dataset, and a structured Graph Reachability dataset.

We examine the performance of ReasoNets on CNN and Daily Mail datasets.The CNN and Daily Mail datasets are available at https://github.com/deepmind/rc-data The detailed settings of the ReasoNet model are as follows.

Vocab Size: For training our ReasoNet, we keep the most frequent ∣V∣=101k|{V}|=101k words (not including 584 entities and 1 placeholder marker) in the CNN dataset, and ∣V∣=151k|{V}|=151k words (not including 530 entities and 1 placeholder marker) in the Daily Mail dataset.

Embedding Layer: We choose 300300-dimensional word embeddings, and use the 300300-dimensional pretrained Glove word embeddings (Pennington et al., 2014) for initialization. We also apply dropout with probability 0.20.2 to the embedding layer.

Bi-GRU Encoder: We apply bidirectional GRU for encoding query and passage into vector representations. We set the number of hidden units to be 256256 and 384384 for the CNN and Daily Mail datasets, respectively. The recurrent weights of GRUs are initialized with random orthogonal matrices. The other weights in GRU cell are initialized from a uniform distribution between −0.01-0.01 and 0.010.01. We use a shared GRU model for both query and passage.

Memory and Attention: The memory of the ReasoNet on CNN and Daily Mail dataset is composed of query memory and passage memory. M=(Mquery,Mdoc)M=(M^{query},M^{doc}), where MqueryM^{query} and MdocM^{doc} are extracted from query bidirectional-GRU encoder and passage bidirectional-GRU encoder respectively. We choose projected cosine similarity function as the attention module. The attention score at,idoca^{doc}_{t,i} on memory midocm^{doc}_{i} given the state sts_{t} is computed as follows: at,idoc=softmaxi=1,...,∣Mdoc∣γcos⁡(W1docmidoc,W2docst)a^{doc}_{t,i}=\text{softmax}_{i=1,...,|M^{doc}|}\gamma\cos({W^{doc}_{1}}m^{doc}_{i},{W^{doc}_{2}}s_{t}), where γ\gamma is set to 10. W1doc{W^{doc}_{1}} and W2doc{W^{doc}_{2}} are weight vectors associated with midocm^{doc}_{i} and sts_{t}, respectively, and are joint trained in the ReasoNet. Thus, the attention vector on passage is given by xtdoc=∑i∣Mdoc∣at,idocmidocx^{doc}_{t}=\sum_{i}^{|M^{doc}|}a^{doc}_{t,i}m^{doc}_{i}. Similarly, the attention vector on query is xtquery=∑i∣Mquery∣at,iquerymiqueryx^{query}_{t}=\sum_{i}^{|M^{query}|}a^{query}_{t,i}m^{query}_{i}. The final attention vector is the concatenation of the query attention vector and the passage attention vector xt=(xtquery,xtdoc)x_{t}=(x^{query}_{t},x^{doc}_{t}). The attention module is parameterized by θx=(W1query,W2query,W1doc,W2doc)\theta_{x}=({W^{query}_{1}},{W^{query}_{2}},{W^{doc}_{1}},{W^{doc}_{2}});

Internal State Controller: We choose GRU model as the internal state controller. The number of hidden units in the GRU state controller is 256256 for CNN and 384384 for Daily Mail. The initial state of the GRU controller is set to be the last-word of the query representation by a bidirectional-GRU encoder.

Termination Module: We adopt a logistical regression to model the termination variable at each time step:

where WtgW_{tg} and btgb_{tg} are the weight matrix and bias vector, respectively.

Answer Module: We apply a linear projection from GRU outputs and make predictions on the entity candidates. Following the settings in AS Reader (Kadlec et al., 2016), we sum up scores from the same candidate and make a prediction. Thus, AS Reader can be viewed as a special case of ReasoNets with Tmax=1T_{\text{max}}=1.When ReasoNet is set with Tmax=1T_{\text{max}}=1 in CNN and Daily Mail, it directly applies s0s_{0} to make predictions on the entity candidates, without performing attention on the memory module. The prediction module in ReasoNets is the same as in AS Reader. It sums up the scores from the same entity candidates, where the scores are calculated by the inner product between sts_{t} and medocm^{doc}_{e}, where medocm^{doc}_{e} is an embedding vector of one entity candidate in the passage.

Other Details: The maximum reasoning step, TmaxT_{\text{max}} is set to 55 in experiments on both CNN and Daily Mail datasets. We use ADAM optimizer (Kingma and Ba, 2015) for parameter optimization with an initial learning rate of 0.00050.0005, β1=0.9\beta_{1}=0.9 and β2=0.999\beta_{2}=0.999; The absolute value of gradient on each parameter is clipped within 0.0010.001. The batch size is 64 for both CNN and Daily Mail datasets. For each batch of the CNN and Daily Mail datasets, we randomly reshuffle the assignment of named entities (Hermann et al., 2015). This forces the model to treat the named entities as semantically meaningless labels. In the prediction of test cases, we randomly reshuffle named entities up to 4 times, and report the averaged answer. Models are trained on GTX TitanX 12GB. It takes 7 hours per epoch to train on the Daily Mail dataset and 3 hours per epoch to train on the CNN dataset. The models are usually converged within 6 epochs on both CNN and Daily Mail datasets.

Results: Table 1 shows the performance of all the existing single model baselines and our proposed ReasoNet. Among all the baselines, AS Reader could be viewed as a special case of ReasoNet with Tmax=1T_{\text{max}}=1. Comparing with the AS Reader, ReasoNet shows the significant improvement by capturing multi-turn reasoning in the paragraph. Iterative Attention Reader, EpiReader and GA Reader are the three multi-turn reasoning models with fixed reasoning steps. ReasoNet also outperforms all of them by integrating termination gate in the model which allows different reasoning steps for different test cases. AoA Reader is another single-turn reasoning model, it captures the word alignment signals between query and passage, and shows a big improvement over AS Reader. ReasoNet obtains comparable results with AoA Reader on CNN test set. We expect that ReasoNet could be improved further by incorporating the word alignment information in the memory module as suggested in AoA Reader.

We show the distribution of termination step distribution of ReasoNets in the CNN dataset in Figure 2. The distributions spread out across different steps. Around 70% of the instances terminate in the last step. Figure 3 gives a test example on CNN dataset, which illustrates the inference process of the ReasoNet. The model initially focuses on wrong entities with low termination probability. In the second and third steps, the model focuses on the right clue with higher termination probability. Interestingly, we also find its query attention focuses on the placeholder token throughout all the steps.

2. SQuAD Dataset

In this section, we evaluate ReasoNet model on the task of question answering using the SQuAD dataset (Rajpurkar et al., 2016).SQuAD Competition Website is https://rajpurkar.github.io/SQuAD-explorer/ SQuAD is a machine comprehension dataset on 536 Wikipedia articles, with more than 100,000 questions. Two metrics are used to evaluate models: Exact Match (EM) and a softer metric, F1 score, which measures the weighted average of the precision and recall rate at the character level. The dataset consists of 90k/10k training/dev question-context-answer tuples with a large hidden test set. The model architecture used for this task is as follows:

Vocab Size: We use the python NLTK tokenizerNLTK package could be downloaded from http://www.nltk.org/ to preprocess passages and questions, and obtain about 100K words in the vocabulary.

Embedding Layer: We use the 100100-dimensional pretrained Glove vectors (Pennington et al., 2014) as word embeddings. These Glove vectors are fixed during the model training. To alleviate the out-of-vocabulary issue, we adopt one layer 100100-dimensional convolutional neural network on character-level with a width size of 55 and each character encoded as an 88-dimensional vector following the work (Seo et al., 2016). The 100100-dimensional Glove word vector and the 100100-dimensional character-level vector are concatenated to obtain a 200200-dimensional vector for each word.

Bi-GRU Encoder: We apply bidirectional GRU for encoding query and passage into vector representations. The number of hidden units is set to 128.

Internal State Controller: We use a GRU model with 256256-dimensional hidden units as the internal state controller. The initial state of the GRU controller is the last-word representation of the query bidirectional-GRU encoder.

Termination Module: We use the same termination module as in the CNN and Daily Mail experiments.

Answer Module: SQuAD task requires the model to find a span in the passage to answer the query. Thus the answer module requires to predict the start and end indices of the answer span in the passage. The probability distribution of selecting the start index over the passage at state sts_{t} is computed by :

where StS_{t} is given via tiling sts_{t} by TT times across the column and wp1w_{p^{1}} is a trainable weight vector. The probability distribution of selecting the end index over passage is computed in a similar manner:

Other Details: The maximum reasoning step TmaxT_{\text{max}} is set to 1010 in SQuAD experiments. We use AdaDelta optimizer (Zeiler, 2012) for parameter optimization with an initial learning rate of 0.50.5 and a batch size of 32. Models are trained on GTX TitanX 12GB. It takes about 40 minutes per epoch for training, with 18 epochs in total.

Results : In the Table 2, we report the performance of all models in the SQuAD leaderboard.Results shown here reflect the SQuAD leaderboard (stanford-qa.com) as of 17 Feb 2017, 9pm PST. We include the reference in the camera-ready version. α:\alpha: Fudan University. In the upper part of the Table 2, we compare ReasoNet with all published baselines at the time of submission. Specifically, BiDAF model could be viewed as a special case of ReasoNet with Tmax=1T_{max}=1. It is worth noting that this SQuAD leaderboard is highly active and competitive. The test set is hidden to all models and all the results on the leaderboard are produced and reported by the organizer; thus all the results here are reproducible. In Table 2, we demonstrate that ReasoNet outperforms all existing published approaches. While we compare ReasoNet with BiDAF, ReasoNet exceeds BiDAF both in single model and ensemble model cases. This demonstrates the importance of the dynamic multi-turn reasoning over a passage. In the bottom part of Table 2, we compare ReasoNet with all unpublished methods at the time of this submission, ReasoNet holds the second position in all the competing approaches in the SQuAD leaderboard.

3. Graph Reachability Task

Recent analysis and results (Chen et al., 2016) on the cloze-style machine comprehension tasks have suggested some simple models without multi-turn reasoning can achieve reasonable performance. Based on these results, we construct a synthetic structured Graph Reachability datasetThe dataset is available at https://github.com/MSRDL/graph_reachability_dataset to evaluate longer range machine inference and reasoning capability, since we anticipate ReasoNets to have the capability to handle long range relationships.

We generate two synthetic datasets: a small graph dataset and a large graph dataset. In the small graph dataset, it contains 500K500K small graphs, where each graph contains 99 nodes and 1616 direct edges to randomly connect pairs of nodes. The large graph dataset contains 500K500K graphs, where each graph contains 1818 nodes and 3232 random direct edges. Duplicated edges are removed. Table 3 shows the graph reachability statistics on the two datasets.

In Table 4, we show examples of a small graph and a large graph in the synthetic dataset. Both graph and query are represented by a sequence of symbols. The details settings of the ReasoNet are listed as follows in the reachability tasks.

Embedding Layer We use a 100100-dimensional embedding vector for each symbol in the query and graph description.

Bi-LSTM Encoder: We apply a bidirectional-LSTM layer with 128128 and 256256 cells on query embeddings in the small and large graph datasets, respectively. The last states of bidirectional-LSTM on query are concatenated to be the initial internal state s1=[q→∣q∣,q←1]s_{1}=[\overrightarrow{q}^{|q|},\overleftarrow{q}^{1}] in the ReasoNet.

Memory: We apply another bidirectional-LSTM layer with 128128 and 256256 cells on graph description embeddings in the small and large graph datasets, respectively. It maps each symbol gig^{i} to a contextual representation given by the concatenation of forward and backward LSTM hidden states mi=[g→i,g←∣g∣−i+1]m_{i}=[\overrightarrow{g}^{i},\overleftarrow{g}^{|g|-i+1}].

Internal State Controller: We use a GRU model with 128128-dimensional and 256256-dimensional hidden units as the internal state controller for the small and large graph datasets, respectively. The initial state of the GRU controller is s1s_{1}.

Answer Module: The final answer is either “Yes” or “No” and hence logistical regression is used as the answer module: at=σ(Wast+ba)a_{t}=\sigma({W_{a}}s_{t}+{b_{a}}); θa=(Wa,ba)\theta_{a}=({W_{a}},{b_{a}}).

Termination Module: We use the same termination module as in the CNN and Daily Mail experiments.

Other Details: The maximum reasoning step TmaxT_{\text{max}} is set to 1515 and 2525 for the small graph and large graph dataset, respectively. We use AdaDelta optimizer (Zeiler, 2012) for parameter optimization with an initial learning rate of 0.50.5 and a batch size of 32.

We denote “ReasoNet” as the standard ReasoNet with termination gate, as described in Section 3.1. To study the effectiveness of the termination gate in ReasoNets, we remove the termination gate and use the prediction from the last state, a^=aTmax\hat{a}=a_{T_{\text{max}}} (TmaxT_{\text{max}} is the maximum reasoning step), denoted as “ReasoNet-Last”. To study the effectiveness of multi-turn reasoning, we choose “ReasoNet-Tmax=2T_{\text{max}}=2”, which only has single-turn reasoning. We compare ReasoNets with a two layer deep LSTM model (Hermann et al., 2015) with 128128 hidden units, denoted as “Deep LSTM Reader”, as a baseline. Table 5 shows the performance of these models on the graph reachability dataset. Deep LSTM Reader achieves 90.92%90.92\% and 71.55%71.55\% accuracy in the small and large graph dataset, respectively, which indicates the graph reachibility task is not trivial. The results of ReasoNet-Tmax=2T_{\text{max}}=2 are comparable with the results of Deep LSTM Reader, since both Deep LSTM Reader and ReasoNet-Tmax=2T_{\text{max}}=2 perform single-turn reasoning. The ReasoNet-Last model achieves 100%100\% accuracy on the small graph dataset, while the ReasoNet-Last model achieves only 78.95%78.95\% accuracy on the large graph dataset, as the task becomes more challenging. Meanwhile, the ReasoNet model converges faster than the ReasoNet-Last model. The ReasoNet model converges in 20 epochs in the small graph dataset, and 40 epochs in the large graph dataset, while the ReasoNet-Last model converges around 40 epochs in the small graph dataset, and 70 epochs in the large graph dataset. The results suggest that the termination gate variable in the ReasoNet is helpful when training with sophisticated examples, and makes models converge faster. Both the ReasoNet and ReasoNet-Last models perform better than the ReasoNet-Tmax=2T_{\text{max}}=2 model, which demonstrates the importance of the multi-turn reasoning.

To further understand the inference process in ReasoNets, Figures 4 and 5 show test examples of the large graph dataset. In Figure 4, we can observe that the model does not make a firm prediction till step 99. The highest attention word at each step shows the reasoning process of the model. Interestingly, the model starts from the end node (1717), traverses backward till finding the starting node (1010) in step 99, and makes a firm termination prediction. On the other hand, in Figure 5, the model learns to stop in step 22. In step 11, the model looks for neighbor nodes (1212, 66, 1616) to 44 and 99. Then, the model gives up in step 22 and predict “No". All of these demonstrate the dynamic termination characteristic and potential reasoning capability of ReasoNets.

To better grasp when ReasoNets stop reasoning, we show the distribution of termination steps in ReasoNets on the test set. The termination step is chosen with the maximum termination probability p(k)=tk∏i=1k−1(1−ti)p(k)=t_{k}\prod_{i=1}^{k-1}{(1-t_{i})}, where tit_{i} is the termination probability at step ii. Figure 6 shows the termination step distribution of ReasoNets in the graph reachability dataset. The distributions spread out across different steps. Around 16% and 35% of the instances terminate in the last step for the small and large graph, respectively. We study the correlation between the termination steps and the complexity of test instances in Figure 7. Given the query, we use the Breadth-First Search (BFS) algorithm over the target graph to analyze the complexity of test instances. For example, BFS-Step =2=2 indicates that there are two intermediate nodes in the shortest reachability path. Test instances with larger BFS-Steps are more challenging. We denote BFS-Step =−1=-1 as there is no reachable path for the given query. Figure 7 shows that test instances with larger BFS-Steps require more reasoning steps.

Conclusion

In this paper, we propose ReasoNets that dynamically decide whether to continue or to terminate the inference process in machine comprehension tasks. With the use of the instance-dependent baseline method, our proposed model achieves superior results in machine comprehension datasets, including unstructured CNN and Daily Mail datasets, the Stanford SQuAD dataset, and a proposed structured Graph Reachability dataset.

Acknowledgments

We thank Ming-Wei Chang, Li Deng, Lihong Li, and Xiaodong Liu for their thoughtful feedback and discussions.

References