G O FOR A W ALK AND A RRIVE AT THE A NSWER : R EASONING O VER P ATHS IN K NOWLEDGE B ASES USING R EINFORCEMENT L EARNING
Anonymous authors
Paper under double-blind review
A BSTRACT
Knowledge bases (KB), both automatically and manually constructed, are often incomplete — many valid facts can be inferred from the KB by synthesizing existing information.
A popular approach to KB completion is to infer new relations by combinatory reasoning over the information found along other paths connecting a pair of entities.
Given the enormous size of KBs and the exponential number of paths, previous path-based models have considered only the problem of predicting a missing relation given two entities, or evaluating the truth of a proposed triple.
Additionally, these methods have traditionally used random paths between ﬁxed entity pairs or more recently learned to pick paths between them.
We propose a new algorithm, MINERVA , which addresses the much more difﬁcult and practical task of answering questions where the relation is known, but only one entity.
Since random walks are impractical in a setting with combinatorially many destinations from a start node, we present a neural reinforcement learning approach which learns how to navigate the graph conditioned on the input query to ﬁnd predictive paths.
Empirically, this approach obtains state-of-the-art results on several datasets, signiﬁcantly outperforming prior methods.
I NTRODUCTION
Automated reasoning, the ability of computing systems to make new inferences from observed evidence, has been a long standing goal of artiﬁcial intelligence.
We are interested in automated reasoning on large knowledge bases (KB) with rich and diverse semantics (Suchanek et al., 2007;
Bollacker et al., 2008; Carlson et al., 2010).
KBs are highly incomplete (Min et al., 2013), and facts not directly stored in a KB can often be inferred from those that are, creating exciting opportunities and challenges for automated reasoning.
For example, consider the small knowledge graph in ﬁgure 1.
We can infer the (unobserved fact) home stadium of Colin Kaepernick from the following reasoning path :
Colin Kaepernick → PlaysInTeam → 49ers → TeamHomeStadium → Levi’s Stadium .
Our goal is to automatically learn such reasoning paths in KBs.
We frame the learning problem as one of query answering, that is to say, answering questions of the form ( Colin Kaepernick , PlaysInLeague , ?).
From its early days, the focus of automated reasoning approaches has been to build systems which can learn crisp symbolic logical rules (McCarthy, 1960; Nilsson, 1991).
Symbolic representations have also been integrated with machine learning especially in statistical relational learning (Muggleton et al., 1992; Getoor & Taskar, 2007; Kok & Domingos, 2007; Lao et al., 2011), but due to poor generalization performance, these approaches have largely been superceded by distributed vector representations.
Learning embedding of entities and relations using tensor factorization or neural methods has been a popular approach (Nickel et al., 2011;
Bordes et al., 2013; Socher et al., 2013; inter alia), but these methods cannot capture chains of reasoning expressed by KB paths.
Neural multi-hop models (Neelakantan et al., 2015; Guu et al., 2015; Toutanova et al., 2016) address the aforementioned problems to some extent by operating on KB paths in vector space.
However, these models take as input a set of paths which are gathered by performing random walks independent of the query relation.
Additionally, models such as Neelakantan et al.
; Das et al.
(2017) use the same set of initially collected paths to answer a diverse set of query types (e.g. MarriedTo , Nationality ,
WorksIn etc.).
Colin Kaepernick
Football
AthletePlaysSports
Michael Crabtree (AthletePlaysSports) -
NFL
PlaysinLeague
PlaysinLeague? 49ers
A t h l e t e P l a ys I n T ea m
Levis Stadium
TeamHomeStadium
CA
LocatedIn
Milwaukee
USA
CityIn
StateIn
PlayerHomeStadium?
BornInCity
Nationality?
H a s S t a t e
H a s C
i t y
This paper presents a method for efﬁciently searching the graph for answer-providing paths using reinforcement learning (RL) conditioned on the input question, eliminating any need for precomputed paths.
Given a massive knowledge graph, we learn a policy, which, given the query ( entity 1 , relation , ? ) , starts from entity 1 and learns to walk to the answer node by choosing to take a labeled relation edge at each step, conditioning on the query relation and entire path history.
This formulates the query-answering task as a reinforcement learning (RL) problem where the goal is to take an optimal sequence of decisions (choices of relation edges) to maximize the expected reward (reaching the correct answer node).
We call the RL agent MINERVA for ”Meandering In Networks of
Entities to Reach Verisimilar Answers.”
Our RL-based formulation has many desirable properties.
First, MINERVA has the built-in ﬂexibility to take paths of variable length, which is important for answering harder questions that require complex chains of reasoning (Shen et al., 2017).
Secondly, MINERVA needs no pretraining and trains on the knowledge graph from scratch with reinforcement learning; no other supervision or ﬁne-tuning is required representing a signiﬁcant advance over prior applications of RL in NLP.
Third, our path-based approach is computationally efﬁcient, since by searching in a small neighborhood around the query entity it avoids ranking all entities in the KB as in prior work.
Finally, the reasoning paths found by our agent automatically form an interpretable provenance for its predictions.
The main contributions of the paper are: (a) We present agent MINERVA , which learns to do query answering by walking on a knowledge graph conditioned on an input query, stopping when it reaches the answer node.
The agent is trained using reinforcement learning, speciﬁcally policy gradients (§ 2).
(b) We evaluate MINERVA on several benchmark datasets and compare favorably to Neural Theorem
Provers (NTP) (Rockt¨aschel & Riedel, 2017) and Neural LP (Yang et al., 2017), which do logical rule learning in KBs, and also state-of-the-art embedding based methods such as DistMult (Yang et al., 2015) and ComplEx (Trouillon et al., 2016).
(c) We also extend MINERVA to handle partially structured natural language queries and test it on the WikiMovies dataset (§ 4.3) (Miller et al., 2016).
We also compare to DeepPath (Xiong et al., 2017) which uses reinforcement learning to pick paths between entity pairs.
The main difference is that the state of their RL agent includes the answer entity since it is designed for the simpler task of predicting if a fact is true or not.
As such their method cannot be applied directly to our more challenging query answering task where the second entity is unknown and must be inferred.
Nevertheless, MINERVA outperforms DeepPath on their benchmark
NELL -995 dataset when compared in their experimental setting (§ 4.1).
T ASK AND M ODEL
We formally deﬁne the task of query answering in a KB.
Let E denote the set of entities and R be the set of binary relations.
Then a KB is a collection of facts stored as triplets ( e 1 , r , e 2 ) where e 1 , e 2 ∈ E and r ∈ R .
Query answering seeks to answer questions of the form ( e 1 , r , ? ) , e.g. Toronto , locatedIn , ?.
We would also like to clearly point out the difference between query answering and the task of fact prediction.
Fact prediction involves predicting if a fact is true or not, e.g. ( Toronto , locatedIn ,
Canada )?.
This task is easier than predicting the correct entity as the answer in query answering since the latter require ﬁnding the answer entity among many possible entities.
Next we describe how we reduce the problem of query answering in a KB to a ﬁnite horizon sequential decision making problem and solve it using reinforcement learning.
We begin by representing the environment as a deterministic Markov decision process on a knowledge graph G derived from the KB (§2.1).
Our RL agent is given an input query of the form (cid:0) e 1q , r q , ?
(cid:1) .
Starting from vertex corresponding to e 1 q in the knowledge graph G , the agent learns to traverse the environment/graph to mine the answer and stop when it determines the answer (§ 2.2).
The agent is trained using policy gradient more speciﬁcally by REINFORCE (Williams, 1992) with control variates (§ 2.3).
Let us begin by describing the environment.
2. E NVIRONMENT - S TATES , A CTIONS , T RANSITIONS AND R EWARDS
Our environment is a ﬁnite horizon, deterministic and partially observed Markov decision process that lies on a knowledge graph derived from the KB.
Recall that a KB is collection of facts stored as triplets ( e 1 , r , e 2 ) where e 1 , e 2 ∈ E and r ∈ R .
From the KB, a knowledge graph G can be constructed where the entities e 1 , e 2 are represented as the nodes and relation r as labeled edge between them.
Formally, a knowledge graph is a directed labeled multigraph G =
( V , E , R ) , where V and E denote the vertices and edges of the graph respectively.
Note that V = E and E ⊆
V ×R× V .
Also, following previous approaches (Bordes et al., 2013; Neelakantan et al., 2015; Xiong et al., 2017), we add the inverse relation of every edge, i.e. for an edge ( e 1 , r , e 2 ) ∈
E , we add the edge ( e 2 , r − 1 , e 1 ) to the graph.
(If the set of binary relations R does not contain the inverse relation r − 1 , it is added to R as well.)
On this graph we will now specify a deterministic partially observable Markov decision process, which is a 5-tuple ( S , O , A , δ , R ) , each of which we elaborate below.
States .
The state space S consists of all possible query-answers cartesian product with the set of entities.
Intuitively, we want a state to encode the query (e 1q , r q ), the answer (e 2q ), and a location of exploration e t (current node of the entity).
Thus overall a state S ∈ S is represented by S =
( e t , e 1q , r q , e 2q ) and the state space consists of all valid combinations.
Observations .
The complete state of the environment is not observable, but only its current location of exploration and query can be observed but not the answer, i.e. only ( e t , e 1q , r q ) is observed.
Formally the observation function O : S → V × V ×R is deﬁned as O ( s = ( e t , e 1q , r q , e 2q ))
= ( e t , e 1q , r q ) .
Actions .
The set of possible actions A S from a state S =
( e t , e 1q , r q , e 2q ) consists of all outgoing edges of the vertex e t in G .
Formally A S
=
{ ( e t , r , v ) ∈ E : S =
( e t , e 1q , r q , e 2q ) , r ∈ R , v ∈ V }∪{ ( s , ∅ , s ) } .
Basically, this means an agent at each state has option to select which outgoing edge it wishes to take having the knowledge of the label of the edge r and destination vertex v .
During implementation, we unroll the computation graph up to a ﬁxed number of time steps T. We augment each node with a special action called ‘ NO OP ’ which goes from a node to itself.
Some questions are easier to answer and needs lesser steps of reasoning than others.
This design decision allows the agent to remain at a node for any number of time steps.
This is especially helpful when the agent has managed to reach a correct answer at a time step t < T and can continue to stay at the ‘answer node’ for the rest of the time steps.
Alternatively, we could have allowed the agent to take a special ‘ STOP ’ action, but we found the current setup to work sufﬁciently well.
As mentioned before, we also add the inverse relation of a triple, i.e. for the triple ( e 1 , r , e 2 ) , we add the triple ( e 2 , r − 1 , e 1 ) to the graph.
We found this important because this actually equips our agent to undo a potentially wrong decision as it can retract back to the current node in the next step.
Transition .
The environment evolves deterministically by just updating the state to the new vertex pointed by the edge selected by the agent through its action.
The query and answer remains the same.
Formally, the transition function is δ : S ×A → S deﬁned by δ ( S , A ) =
( v , e 1q , r q , e 2q ) , where
S =
( e t , e 1q , r q , e 2q ) and
A =
( e t , r , v )) .
Rewards .
We only have a terminal reward of +1 if the current location is the correct answer at the end and 0 otherwise.
To elaborate, if S T = ( e t , e 1q , r q , e 2q ) is the ﬁnal state, then we receive a reward of +1 if e t = e 2q else 0.=, i.e. R ( S T )
=
I { e t = e 2q } .
2. P OLICY N ETWORK
To solve the ﬁnite horizon deterministic partially observable Markov decision process described above, we aim to design a randomized history-dependent policy π = ( d 1 , d 2 ,..., d T − 1 ) , where d t :
H t → P ( A S t ) and history H t =
( H t − 1 , A t − 1 , O t ) is just the sequence of observations and actions taken.
We restrict ourselves to the function class expressed by long short-term memory network (LSTM) (Hochreiter & Schmidhuber, 1997) for learning the randomized history-dependent policy.
An agent based on LSTM encodes the history H t as a continuous vector h t ∈ R 2 d .
We also have embedding matrix r ∈ R | R |× d and e ∈ R | E |× d for the binary relations and entities respectively.
The history embedding for H t = ( H t − 1 , A t − 1 , O t ) is updated according to LSTM dynamics:
[Equation]
where a t − 1 ∈ R d and o t ∈ R d denote the vector representation for action/relation at time t −and observation/entity at time t respectively and [ ; ] denote vector concatenation.
To elucidate, a t − 1 =
r A t − 1 , i.e. the embedding of the relation corresponding to label of the edge the agent chose at time t − 1 and o t = e e t if O t = ( e t , e 1q , r q ) i.e. the embedding of the entity corresponding to vertex the agent is at time t .
Based on the history embedding h t , the policy network makes the decision to choose an action from all available actions ( A S t ) conditioned on the query relation.
Recall that each possible action represents an outgoing edge with information of the edge relation label l and destination vertex/entity d .
So embedding for each A ∈
A S t is [ r l ; e d ] , and stacking embeddings for all the outgoing edges we obtain the matrix A t .
The network taking these as inputs is parameterized as a two-layer feedforward network with ReLU nonlinearity which takes in the current history representation h t and the embedding for the query relation r q and outputs a probability distribution over the possible actions from which a discrete action is sampled.
In other words,
[Equation]
Note that the nodes in G do not have a ﬁxed ordering or number of edges coming out from them.
The size of matrix
A t is |A S t |× 2 d , so the decision probabilities d t lies on simplex of size |A
S t | .
Also the procedure above is invariant to order in which edges are presented as desired and falls in purview of neural networks designed to be permutation invariant Zaheer et al.
Finally, to summarise, the parameters of the LSTM, the weights W 1 , W 2 , the corresponding biases (not shown above for brevity), and the embedding matrices form the parameters θ of the policy network.
2. T RAINING
For the policy network ( π θ ) described above, we want to ﬁnd parameters θ that maximizes the expected reward:
[Equation]
where we assume there is a true underlying distribution ( e 1 , r , e 2 ) ∼ D .
To solve this optimization problem, we employ REINFORCE (Williams, 1992) as follows:
• The ﬁrst expectation is replaced with empirical average over the training dataset.
• For the second expectation, we approximate by running multiple rollouts for each training example.
The number of rollouts is ﬁxed and for all our experiments we set this number to 20.
• For variance reduction, a common strategy is to use an additive control variate baseline (Hammersley, 2013; Fishman, 2013; Evans & Swartz, 2000).
We use a moving average of the cumulative discounted reward as the baseline.
We tune the weight of this moving average as a hyperparameter.
Note that in our experiments we found that learnt baseline performed similarly, but we ﬁnally settled for cumulative discounted reward as the baseline owing to its simplicity.
• To encourage the policy to sample more diverse paths rather than sticking with a few, we add an entropy regularization term to our cost function after multiplying it by a constant ( β ) .
We treat β as a hyperparameter to control the exploration exploitation trade-off.
Experimental Details We choose the relation and embedding dimension size as 200.
The action embedding is formed by concatenating the entity and relation embedding.
We use a 3 layer LSTM with dimension size of 400.
The hidden layer size of MLP (weights W 1 and W 2 ) is set to 400.
We use Adam (Kingma & Ba, 2014) with the default parameters in REINFORCE for the update.
The best hyperparameter values can be found in appendix.
[Table] [Table]
D ATA
We test our model on the following query answering datasets.
(a) COUNTRIES (Bouchard et al., 2015), (b) Alyawarra kinship ( KINSHIP ), (c) Uniﬁed Medical Language Systems ( UMLS )
(Kok & Domingos, 2007)
(d) WN 18 RR (Dettmers et al., 2017), (e) NELL -995, (f) FB 15k-
(g) WikiMovies (Miller et al., 2016).
We also test on a synthetic grid world dataset released by Yang et al.
(2017) to test the ability of the model to learn rules of long length.
The COUNTRIES dataset is carefully designed to explicitly test the logical rule learning and reasoning capabilities of link prediction models.
The dataset has 3 tasks (S1-3 in table 2)
each requiring reasoning steps of increasing length and difﬁculty (see Rockt¨aschel & Riedel (2017) for more details about the tasks).
We also test our model on existing large and challenging KG datasets ((d) - (f)).
WN 18 RR is created from the original WORDNET 18 dataset by removing test triples which can be answered trivially, making the datasets more realistic and challenging.
Additionally, we test our model on a question answering dataset - WikiMovies (Miller et al., 2016) where the query is in natural language but the answers can be found in an accompanying KB.
Table 1 report the various statistics of the datasets.
E XPERIMENTS 4. K NOWLEDGE G RAPH Q UERY A NSWERING
This section describes the experimental results on the various knowledge graph query answering datasets.
During inference, we do beam search with a beam width of 40 and rank entities by the probability of the trajectory the model took to reach the entity.
Our evaluation metrics are various widely used ranking metrics for KB completion such as HITS @k, mean reciprocal rank (MRR), median rank (MR) and mean average precision (MAP).
For grid world and Wikimovies, we report accuracy (or HITS@1).
[Table]
[Table]
COUNTRIES , KINSHIP , UMLS .
We ﬁrst test MINERVA on the COUNTRIES dataset which is explicitly designed to test the ability of models to learn logical rules.
It contains countries, regions and subregions as entities.
The queries are of the form LocatedIn(c, ?) and the answer is a region.
For example, LocatedIn(Egypt, ?) with the answer as Africa .
Our experimental settings and scores are directly comparable to NTP and ComplEx (Trouillon et al., 2016).
NTP- λ is a NTP model trained with an additional objective function of ComplEx.
We also compare MINERVA against Neural LP
(Yang et al., 2017) on the UMLS and KINSHIP datasets.
The evaluation metric we report is HITS @k - which is the percentage of correct entities ranked in top-k. For the COUNTRIES dataset, we report the area under the precision-recall curve for comparing with the baselines.
Following the design of the COUNTRIES dataset, for task S1 and S2, we set the maximum path length T = 2 and for S3, we set T = 3.
Table 2 shows that MINERVA outperforms all the baseline models except on the task S2 of COUNTRIES , where the ensemble model NTP - λ outperforms it, albeit with a higher variance across runs.
Our gains are much more prominent in task S3, which is the hardest among all the tasks.
We similarly outperform NeuralLP on the UMLS and KINSHIP datasets.
N ELL
-995 We also compare MINERVA to DeepPath.
For a fair comparison, we only rank the answer entities against the negative examples in the dataset used in their experiments 1 and report the mean average precision (MAP) scores for each query relation.
DeepPath feeds the paths its agent gathers as input features to the path ranking algorithm (PRA) (Lao et al., 2011), which trains a per-relation classiﬁer.
But unlike them, we train one model which learns for all query relations.
If our agent is not able to reach the correct entity or one of the negative entities, the corresponding query gets a score of negative inﬁnity.
As show in table 5, we outperform them or achieve comparable performance for all the query relations For this experiment, we set the maximum length T = 3.
Query Answering on N ELL
-995: Since the task of query answering is more challenging than fact prediction, we also test MINERVA for query answering on N ELL
-995 where the target entity is unknown.
Since there are no published baselines on this task, we compare to a highly tuned implementation of DistMult (which achieves very high performance on other datasets).
DistMult achieves a HITS @10 performance of 79.504.
In comparison MINERVA achieves a score of 80.99.
Moreover, MINERVA is more efﬁcient at inference time since it does not have to compare against all the 75K entities in the dataset.
The wall-clock inference time on the test set of N ELL -995 for a GPU implementation of DistMult is 115s whereas that of MINERVA is 35s.
[Table]
WN 18 RR Next we test MINERVA on another large KB dataset – WN 18 RR .
On this dataset, we compare with three recently proposed latent factorization model – (a) ConvE (Dettmers et al., 2017), (b) DistMult (Yang et al., 2015), (c) ComplEx (Trouillon et al., 2016).
We report HITS at various k
and we compare favorably with the state-of-the-art results of ComplEx in all settings (table 4).
For this experiment, we set the maximum length T = 3.
[-FB15k-
-]
[Figure]
l u s t e r i n g C
o e ff
i
c
i e n
[Figure]
{+[Figure] FB15k-
 We test MINERVA on yet another popular KB dataset FB15K-237. The baselines are the same as before, however our implementation of DistMult gave a score of 56.8 HITS @10+} which, to our knowledge, is the highest score reported on this dataset [-
-]2 .The
performance of ConvE and ComplEx are taken from Dettmers et al.
Even though MINERVA performs comparably to ConvE and ComplEx, the results are signiﬁcantly behind the performance of DistMult. Model
[Table]
Upon delving more into the structure of knowledge graph derived from FB15K-237, we found few interesting characteristics of the dataset.
As a prelude, we would like to describe a long existing concept in graph theory – clustering coefﬁcient (Holland & Leinhardt, 1971; Watts & Strogatz, 1998).
Clustering coefﬁcient ( τ ) of a graph measures whether groups of nodes form ‘tightly knit’ communitiesi.e. whether groups of nodes tend to cluster together.
A high τ implies the presence of higher number of densely connected groups of nodes.
For instance, if we consider three nodes A , B and C , a high τ means with high probability whenever three nodes are connected as A — B — C , it implies nodes A — C are also connected forming a triangle.
Intuitively, MINERVA can use such closed shapes to learn paths such as ( A — B — C ) to predict the answer of the query, i.e. the third node ( C ).
The clustering coefﬁcient also extends from triangles to cliques of arbitrary size (Watts & Strogatz, 1998).
Figure 3 plots τ for various datasets.
We ﬁnd that FB15k-237 has the least clustering coefﬁcient (0.19) among all datasets.
This means that the dataset has sparse neighborhoods and hence MINERVA ﬁnds it difﬁcult to learn logical rules.
We also check the frequency of occurrence of various unique paths (types).
We deﬁne a path type as the sequence of relations (ignoring the entities) in a path.
Intuitively, a predictive path which generalizes across queries will occur many number of times in the graph.
Figure 4 shows the plot.
As we can see, the characteristics of FB15k-237 is quite different from other datasets.
Path types do not repeat often, making it hard for MINERVA to learn paths that generalizes.
We also do further analysis of the types of various query relations in FB15k-237 below.
Analysis of query relations of FB15k-237:
Next we analyzed the type of query relations on the
FB15k-237 dataset.
Following Bordes et al.
, we categorized the query relations into (M)any to 1 , 1 to M or 1 to 1 relations.
An example of a M to 1 relation would be ‘ /people/profession ’ (What is the profession of person ‘X’?).
An example of 1 to M relation would be /music/instrument/instrumentalists (‘Who plays the music instrument X?’) or ‘ /people/ethnicity/people ’ (‘Who are people with ethnicity
X?’).
From a query answering point of view, the answer to these questions is a list of entities.
However, during evaluation time, the model is evaluated based on whether it is able to predict the one target entity which is in the query triple.
Also, since MINERVA outputs the end points of the paths as target entities, it is sometimes possible that the particular target entity of the triple does not have a path from the source entity (however there are paths to other ‘correct’ answer entities).
Table 8 (in appendix) shows few other examples of relations belonging to different classes.
Following Bordes et al.
, we classify a relation as 1-to-M if the ratio of cardinality of tail to head entities is greater than 1.5 and as M-to-1 if it is lesser than 0.67.
In the validation set of FB15k-237, 54% of the queries are 1-to-M , whereas only 26% are M-to-1 .
Contrasting it with NELL -995, 27% are 1-to-M and 36% are M-to-1 or UMLS or KINSHIP where only 18% and 32% of the relations are 1-to-M .
Table 9 (in appendix) shows few relations from FB15k-237 dataset which have high tail-to-head ratio.
The average ratio for 1- TO -M relations in FB15k-237 is 13.39 (substantially higher than 1.5).
Pennies From Heaven
Louis Armstrong
NormalMcLeod
S t a rr ed A c t o r p = 1eD
i r ec t e d B y p
= 0 .
Pennies From Heaven
Louis Armstrong
NormalMcLeod
S t a rr e d A c t o r p = 0 .
D i r e c t ed B y p
=
2eWho directed the movie “Pennies from Heaven”?
Who starred in the movie “Pennies from Heaven”?
John Brady
LSU
WorksFor?
NBA
C o ac h es T ea m p = 0 .
John Brady
LSU
AthletePlaysSport ?
NBA
A t h l e t e P l ays i n L ea gu e p = 0 .
C o a c h e s T e a m p = 0 .
Basketball
A t h l e t e P l a ys i n Leaguep = 0 .
4. G RID W ORLD P ATH F INDING
As we empirically ﬁnd and also noted by previous work (Rockt ¨ aschel & Riedel, 2017; Das et al., 2017; Yang et al., 2017), often the reasoning chains required to answer queries in KB is not too long (restricted to 3 or 4 hops).
To test if our model can learn long reasoning paths, we test our model on a synthetic 16-by-16 grid world dataset created by Yang et al.
(2017), where the task is to navigate to a particular cell (answer entity) starting from a random cell (start entity) by following a set of directions (query relation).
The KB consists of atomic triples of the form (( 2,1 ), North , ( 1,1 ))
– entity (1,1) is north of entity (2,1) .
The queries consists of a sequence of directions (e.g. North, SouthWest,
East ).
The queries are classiﬁed into classes based on the path lengths.
Figure 2 shows the accuracy on varying path lengths.
Compared to Neural LP, MINERVA is much more robust for queries which require longer path lengths showing a very little degrade in performance for even the longest path length in the dataset.
4. P ARTIALLY S TRUCTURED Q UERIES
[Table]
Queries in KB datasets are structured in the form of triples.
However, this is unsatisfactory since for most real applications, the queries appear in natural language.
As a ﬁrst step in this direction, we extend MINERVA to take in “partially structured” queries.
We use the WikiMovies dataset (Miller et al., 2016) which contains questions in natural language albeit generated by templates created by human annotators.
An example question from the dataset is “Which is a ﬁlm written by Herb Freed ?”.
WikiMovies also has an accompanying KB which can be used to answer all the questions.
We link the entity occurring in the question to the KB via simple string matching.
To form the vector representation of the query relation, we design a simple question encoder which computes the average of the embeddings of the question words.
The word embeddings are learned from scratch and we do not use any pretrained embeddings.
We compare our results with those reported in Yang et al.
(2017) (table 6).
We got the best result using T = 1, suggesting that WikiMovies is not the best testbed for multihop reasoning, but this experiment is a promising ﬁrst step towards the realistic setup of having textual queries and knowledge bases.
A NALYSIS
Effectiveness of Remembering Path History.
MINERVA encodes the history of decisions it has taken in the past using LSTMs.
To test the importance of remembering the sequence of decisions,
[Table]
Can learn general rules:
[Table]
X,
[Table] [Table]
X, Z )
[Table] [Table]
[Table] [Table]
[Table] [Table]
we did an ablation study in which the agent chose the next action based on only local information
i
[Table]
e. current entity and query and did not have access to the history h t .
For the KINSHIP dataset, we observe a 27% points decrease in HITS @1 (0.184 v/s 0.46) and 13% decrease in HITS @10 (0.
v/s 0.76).
For grid-world, it is also not surprising that we see a big drop in performance.
The ﬁnal accuracy is 0.23 for path lengths 2-4 and 0.04 for lengths 8-10.
For NELL , the performance dropped from 0.576 to 0.564 and for FB15k-237 the HITS @10 performance dropped from 0.456 to 0.408.
NO-OP and Inverse Relations.
At each step, MINERVA can choose to take a NO - OP edge and remain at the same node.
This gives the agent the ﬂexibility of taking paths of variable lengths.
Some questions are easier to answer than others and require lesser steps of reasoning and if the agent reaches the answer early, it can choose to remain there.
Example (i) in table 7 shows such an example.
Similarly inverse relation gives the agent the ability to recover from a potentially wrong decision it has taken before.
Example (ii) shows such an example, where the agent took a incorrect decision at the ﬁrst step but was able to revert the decision because of the presence of inverted edges.
Query based Decision Making.
At each step before making a decision, our agent conditions on the query relation.
Figure 5 shows examples, where based on the query relation, the probabilities are peaked on different actions.
For example, when the query relation is WorksFor , MINERVA assigns a much higher probability of taking the edge CoachesTeam than AthletePlaysInLeague .
We also see similar behavior on the WikiMovies dataset where the query consists of words instead of ﬁxed schema relation.
Inference Time.
MINERVA is efﬁcient at inference time since it has to essentially search for answer entities in its local neighborhood, whereas previous methods rank all the entities in the dataset.
For instance, on the test dataset of WN 18 RR , the wall clock running time of MINERVA is 63 seconds whereas that of a GPU implementation of DistMult is 211 seconds (with the maximum batch size).
R ELATED W ORK
Learning vector representations of entities and relations using tensor factorization (Nickel et al., 2011; 2012; Bordes et al., 2013;
Riedel et al., 2013; Nickel et al., 2014;
Yang et al., 2015) or neural methods (Socher et al., 2013; Toutanova et al., 2015; Verga et al., 2016) has been a popular approach to reasoning with a knowledge base.
However, these methods cannot capture more complex reasoning patterns such as those found by following inference paths in KBs.
Multi-hop link prediction approaches (Lao et al., 2011; Neelakantan et al., 2015; Guu et al., 2015; Toutanova et al., 2016; Das et al., 2017) address the problems above, but the reasoning paths that they operate on are gathered by performing random walks independent of the type of query relation.
Lao et al.
(2011) further ﬁlters paths from the set of sampled paths based on the restriction that the path must end at one of the target entities in the training set and are within a maximum length.
These constraints make them query dependent but they are heuristic in nature.
Our approach eliminates any necessity to pre-compute paths and learns to efﬁciently search the graph conditioned on the input query relation.
Inductive Logic Programming (ILP) (Muggleton et al., 1992) aims to learn general purpose predicate rules from examples and background knowledge.
Early work in ILP such as FOIL (Quinlan, 1990),
PROGOL (Muggleton, 1995) are either rule-based or require negative examples which is often hard to ﬁnd in KBs (by design, KBs store true facts).
Statistical relational learning methods (Getoor & Taskar, 2007; Kok & Domingos, 2007; Schoenmackers et al., 2010) along with probabilistic logic (Richardson & Domingos, 2006; Broecheler et al., 2010; Wang et al., 2013) combine machine learning and logic but these approaches operate on symbols rather than vectors and hence do not enjoy the generalization properties of embedding based approaches.
Neural Theorem Provers (NTP) (Rockt¨aschel & Riedel, 2017) and Neural LP (Yang et al., 2017) are two recent methods in learning logical rules that can be trained end-to-end with gradient based learning.
NTPs are constructed by Prolog’s backward chaining inference method.
It operates on vectors rather than symbols, thereby providing a success score for each proof path.
However, since a score can be computed between any two vectors, the computation graph becomes quite large because of such soft-matching during substitution step of backward chaining.
For tractability, it resides to heuristics such as only keeping the top-K scoring proof paths, but it loses any guarantee of computing exact gradients.
Also the efﬁcacy of NTPs has yet to be shown on large KBs.
Neural LP introduces a differential rule learning system using operators deﬁned in TensorLog (Cohen, 2016) and has a
LSTM based controller and a differentiable memory component (Graves et al., 2014; Sukhbaatar et al., 2015) and the rule scores are calculated via attention.
Even though, differentiable memory allows the network to be trained end to end, it necessitates accessing the entire memory which can be computationally expensive.
RL approaches which can make hard selection of memory (Zaremba &
Sutskever, 2015) are computationally attractive.
MINERVA uses a similar hard selection of relation edges to walk on the graph.
More importantly, MINERVA outperforms both these methods on their respective benchmark datasets.
DeepPath (Xiong et al., 2017) uses RL based approaches to ﬁnd paths in KBs.
However, the state of their MDP requires the target entity to be known in advance and hence their path ﬁnding strategy is dependent on knowing the answer entity.
MINERVA does not need any knowledge of the target entity and instead learns to ﬁnd the answer entity among all entities.
DeepPath, additionally feeds its gathered paths to Path Ranking Algorithm (Lao et al., 2011), whereas MINERVA is a complete system trained to do query answering.
DeepPath also uses ﬁxed pretrained embeddings for its entity and relations.
Lastly, on comparing MINERVA with DeepPath in their experimental setting on the
NELL dataset, we match their performance or outperform them.
MINERVA is also similar to methods for learning to search for structured prediction (Collins & Roark, 2004; Daum ´ e III & Marcu, 2005;
Daum ´ e III et al., 2009; Ross et al., 2011; Chang et al., 2015).
These methods are based on imitating a reference policy (oracle) which make near-optimal decision at every step.
In our problem setting, it is unclear what a good reference policy would be.
For example, a shortest path oracle between two entities would be bad, since the answer providing path should depend on the query relation.
C ONCLUSION
We explored a new way of automated reasoning on large knowledge bases in which we use the knowledge graphs representation of the knowledge base and train an agent to walk to the answer node conditioned on the input query.
We achieve state-of-the-art results on multiple benchmark knowledge base completion tasks and we also show that our model is robust and can learn long chains-ofreasoning.
Moreover it needs no pretraining or initial supervision.
Future research directions include applying more sophisticated RL techniques and working directly on textual queries and documents.
A PPENDIX 8. H YPERPARAMETERS
In our experiments, we tune our model over two hyper parameters, viz., β which is the entropy regularization constant and λ which is the moving average constant for the REINFORCE baseline.
The table 10 lists the best hyper parameters for all the datasets.
[Table]