NLP ROLOG : R EASONING WITH W EAK U NIFICATION FOR N ATURAL L ANGUAGE Q UESTION A NSWERING
Anonymous authors
Paper under double-blind review
A BSTRACT
Symbolic logic allows practitioners to build systems that perform rule-based reasoning which is interpretable and which can easily be augmented with prior knowledge.
However, such systems are traditionally difﬁcult to apply to problems involving natural language due to the large linguistic variability of language.
Currently, most work in natural language processing focuses on neural networks which learn distributed representations of words and their composition, thereby performing well in the presence of large linguistic variability.
We propose to reap the beneﬁts of both approaches by applying a combination of neural networks and logic programming to natural language question answering.
We propose to employ an external, nondifferentiable Prolog prover which utilizes a similarity function over pretrained sentence encoders.
We ﬁne-tune these representations via Evolution Strategies with the goal of multi-hop reasoning on natural language.
This allows us to create a system that can apply rule-based reasoning to natural language and induce domainspeciﬁc natural language rules from training data.
We evaluate the proposed system on two different question answering tasks, showing that it complements two very strong baselines – BIDAF (Seo et al., 2016a) and F AST QA (Weissenborn et al., 2017) – and outperforms both when used in an ensemble.
I NTRODUCTION
We consider the problem of multi-hop reasoning on natural language input.
For instance, consider the statements Socrates was born in Athens and Athens belongs to Greece , together with the question
Where was Socrates born?
There are two obvious answers following from the given statements:
Athens and Greece .
While Athens follows directly from the single statement Socrates was born in
Athens , deducing Greece requires a reader to combine both provided statements using the knowledge that a person that was born in a city, which is part of a country, was also born in the respective country .
Most recent work that addresses such challenges leverages deep learning based methods (Sukhbaatar et al., 2015; Peng et al.,
; Seo et al., 2016b; Raison et al., 2018; Henaff et al., 2016; Kumar et al., 2016; Graves et al., 2016; Dhingra et al., 2018), capable of dealing with the linguistic variability and ambiguity of natural language text.
However, the black-box nature of neural networks makes it hard to interpret the exact reasoning steps leading to a prediction (local interpretation), as well as the induced model (global interpretation).
Logic programming languages like Prolog (Wielemaker et al., 2012), on the other hand, are built on the idea of using symbolic rules to reason about entities, which makes them highly interpretable both locally and globally.
The capability to use user-deﬁned logic rules allows users to incorporate external knowledge in a straightforward manner.
Unfortunately, because of their reliance on symbolic logic, systems built on logic programming need extensive preprocessing to account for the linguistic variability that comes with natural language (Moldovan et al., 2003).
We introduce NLP ROLOG , a system which combines a symbolic reasoner and a rule-learning method with pretrained sentence representations to perform rule-based multi-hop reasoning on natural language input.
1 Like inductive logic programming methods, it facilitates both global as well as local interpretation, and allows for straightforward integration of prior knowledge.
Similarly to deep learning based approaches, it can be applied to natural language text without the need to transforming it to formal logic.
At the core of the proposed method is an external non-differentiable theorem prover which can take similarities between symbols into account.
Speciﬁcally, we modify a Prolog interpreter to support weak-uniﬁcation as proposed by Sessa (2002).
To obtain similarities between symbols, we utilize sentence encoders initialized with pretrained sentence embeddings (Pagliardini et al., 2017) and then ﬁne-tune these for a downstream question answering task via gradient-based optimization methods.
Since the resulting system contains non-differentiable components, we propose using Evolution
Strategies (ES) (Eiben et al., 2003) as a gradient estimator (Williams, 1992) for training the system – enabling us to ﬁne-tune the sentence encoders and to learn domain-speciﬁc logic rules (e.g. that the relation is in is transitive) from natural language training data.
This results in a system where training can be trivially parallelized, and which allows to change the logic formalism by simply exchanging the external prover without the need for an intricate re-implementation as an end-to-end differentiable function.
In summary, our main contributions are: a) we show how Prolog-like reasoning can be applied to natural language input by employing a combination of pretrained sentence embeddings, an external logic prover, and ﬁne-tuning using Evolution Strategies, b) we extend a Prolog interpreter with weak uniﬁcation based on distributed representations, c) we present Gradual Rule Learning (GRL), a training algorithm that allows the proposed system to learn First-Order Logic (FOL) rules from entailment, and d) we evaluate the proposed system on two different Question Answering (QA) datasets and demonstrate that its performance is on par with state-of-the-art neural QA models in many cases, while having different failure modes.
This allows to build an ensemble of NLP ROLOG and a neural QA model that outperforms all individual models.
R ELATED W ORK
Our work touches in general on weak-uniﬁcation based fuzzy logic (Sessa, 2002) and focuses on multi-hop reasoning for QA, the combination of logic and distributed representations, and theorem proving for question answering.
Multi-hop Reasoning for QA.
One prominent approach for enabling multi-hop reasoning in neural
QA models is to iteratively update a query embedding by integrating information from embeddings of context sentences, usually using an attention mechanism and some form of recurrency (Sukhbaatar et al., 2015; Peng et al., 2015; Seo et al., 2016b; Raison et al., 2018).
These models have achieved state-of-the-art results in a number of reasoning-focused QA tasks.
Henaff et al.
(2016) employ a differentiable memory structure that is updated each time a new piece of information (usually a sentence) is processed.
The memory slots can be used to track the state of various entities, which can be considered as a form of temporal reasoning.
Similarly, the Neural Turing Machine (Graves et al., 2016) and the Dynamic Memory Network (Kumar et al., 2016), which are built on differentiable memory structures, have been used to solve synthetic QA problems requiring multi-hop reasoning.
Dhingra et al.
(2018) modify an existing neural QA model to additionally incorporate coreference information provided by a coreference resolution model in a preprocessing step, which improves performance on QA problems requiring multi-hop reasoning.
All of the methods above perform reasoning more or less implicitly by updating latent vector representations, which makes an unambiguous interpretation of the exact reasoning steps difﬁcult.
Additionally, it is not obvious how a strong prior, like user-deﬁned inference rules, could be imposed on the respective reasoning procedures.
Besides, many of them have been evaluated only on artiﬁcially generated data sets and thus it is unclear how they perform when on data that involves natural linguistic variability.
Combination of FOL and Distributed Representations.
Investigating the combination of formal logic and distributed representations has a long tradition, which is reviewed by Besold et al.
Strongly related to our approach is the combination of Markov Logic Networks (Richardson &
Domingos, 2006), Probabilistic Soft Logic (Bach et al., 2017), and word embeddings, which has been applied to Recognizing Textual Entailment (RTE) and Semantic Textual Similarity (STS)
(Garrette et al., 2011; 2014; Beltagy et al., 2013; 2014), and improves upon baselines utilizing either only logic or only distributed representations.
An area in which neural multi-hop reasoning models have been thoroughly investigated is Knowledge
Base Completion (Das et al., 2016; Cohen, 2016; Neelakantan et al., 2015; Das et al., 2017).
While
QA could be in principle modeled as a KB-completion task, the construction of a densely connected
KB from text is far from trivial, due to the inherent ambiguity of natural language.
Without any preprocessing, even the moderately sized QA tasks considered in this work would produce a very large and sparsely connected KB.
Closest to our approach is the Natural Theorem Prover (NTP) (Rocktäschel & Riedel, 2017), which obtains the ﬁnal proof score for a statement by constructing a neural network that represents all possible proofs.
The model is trained end-to-end using backward chaining and a differentiable uniﬁcation operator.
Since the number of possible proofs grows exponentially with the number of facts and rules, NTPs cannot scale even to moderately sized knowledge bases, and are thus not applicable to natural language problems in its current form.
We circumvent this issue by using a non-differentiable prover and ﬁne-tune the model using Evolution Strategies.
Theorem Proving for Question Answering.
Our work is not the ﬁrst to apply theorem proving to
QA problems.
Angeli et al.
(2016) employ a system based on Natural Logic to search a large KB for a single statement that entails the candidate answer.
This is somewhat orthogonal to our approach, as we aim to learn rules that combine multiple statements to answer a question.
More traditional systems like Watson (Ferrucci et al., 2010) or COGEX (Moldovan et al., 2003) utilize an integrated theorem prover, but require a transformation of the natural language input to logical form.
In the case of COGEX, this improves the accuracy of the underlying system by 30%, and increases its interpretability.
While this work is similar in spirit, we greatly simplify the preprocessing step by replacing the transformation of natural language to logic with the simpler approach of taking
Open Information Extraction (Open IE) (Etzioni et al., 2008) textual patterns.
Fader et al.
(2014) propose the O PEN QA system that utilizes a mixture of handwritten and automatically obtained operators that are able to parse, paraphrase and rewrite queries, which allows them to perform large-scale QA on KBs that include Open IE triples.
While this work shares the same goal – answering questions using facts extracted by Open IE – we choose a completely different approach to address the problem of linguistic variablity and focus on the combination of multiple facts by learning logical rules.
B ACKGROUND
In the following, we review the background relevant for the custom Prolog engine employed by our method.
Speciﬁcally, we brieﬂy introduce Prolog’s backward chaining algorithm and uniﬁcation procedure (Russell & Norvig, 2016).
We assume basic knowledge of formal logic and logic programming.
In a nutshell, a Prolog program consists of a set of rules in the form of Horn clauses
[Equation]
where h, p i are predicate symbols and f ij are either function (denoted in lower case) or variable (upper case) symbols.
The domain of function symbols is denoted by F and the domain of predicate symbols by P .
h ( f h 1 , . . .
, f hn ) is called the head and p 1 ( f 11 , . . .
, f
1 m ) ∧ . . .
∧ p B ( f B 1 , . . . ,
f Bl ) the body of the rule.
We call B the body size of the rule and rules with a body size of zero are named atoms (short for atomic formula ).
2 If an atom does not contain any variable symbols it is termed fact .
As in related work (Sessa, 2002; Julián-Iranzo et al., 2009), we disregard negation and disjunction.
The central procedure of Prolog is uniﬁcation .
It receives two atoms and attempts to ﬁnd variable substitutions that make both atoms syntactically equal.
For example, the input atoms country ( Greece , Socrates ) and country ( X , Y ) result in the following variable substitution after uniﬁcation: { X/ Greece , Y/ Socrates } .
The proof algorithm of Prolog is called backward-chaining .
It starts from a goal atom g and attempts to prove it by applying suitable rules, thereby generating subgoals that are proved next.
To ﬁnd applicable rules, it attempts to unify g with the heads of all available rules.
If this uniﬁcation succeeds, the resulting variable substitutions are applied to the atoms in the rule body and each of those atoms becomes a new subgoal.
For instance, the application of the rule country ( X, Y )
⇐ born_in ( Y, X ) to the goal country ( Greece , Socrates ) would yield the subgoal born_in ( Socrates , Greece ) .
Then the process is repeated for all subgoals until no subgoal is left, i.e., until all subgoals have been uniﬁed with a fact.
The result of this procedure is a set of rule applications and variable substitutions called proof.
Note, that the number of possible proofs is exponential in the number of predicate and entity symbols, as every rule might be used in the proof of each subgoal.
Pseudo code for weak uniﬁcation can be found in Appendix A.1 and we refer the reader to Russell & Norvig (2010) for more details.
To apply standard Prolog to a NLP problem like QA, one would have to account for semantic similarities and ambiguities with extensive and error-prone preprocessing, e.g. when transforming the natural language input to logical form.
NLP ROLOG
Our aim is to apply Prolog to natural language question answering where the same entity or relation can have different natural language surface forms.
Thus, we replace the equality-based uniﬁcation operator with similarity-based weak uniﬁcation (Sessa, 2002), which allows to unify two symbols x, y if they are sufﬁciently similar, as judged by a similarity function ∼ θ parameterized by θ .
Then, the result of uniﬁcation also contains a proof success score S that is the result of the symbols’ similarity and the previous success score S (cid:48) :
S = (cid:62) ( x ∼ y, S (cid:48) ) , where (cid:62) ∈ { min , ·} is an aggregation function.
The result of backward-chaining with weak uniﬁcation are (possibly) multiple proofs, each with an associated proof success score.
NLP ROLOG combines inference based on weak uniﬁcation and distributed representations to allow reasoning on natural language statements.
The natural language statements are ﬁrst transformed to triples using Open IE (Etzioni et al., 2008).
The symbols occurring in these triples and in the rules are then embedded into a vector space, which in turn is used to estimate similarities between symbols.
The resulting similarity function is subsequently used to perform a proof and consequently obtain a proof success score S .
The proof success score is then utilized as a training signal for ES.
An illustration of the process can be found in Fig. 1, where we visualize the interplay of the different components for our running example.
4. S IMILARITY C OMPUTATION
We embed symbols using an encoder E θ : F ∪ P (cid:55)→ R d parametrized by θ for entity and predicate symbols, where d denotes the embedding size.
The resulting embeddings are used to induce ∼ θ : ( F ∪ P ) 2 (cid:55)→ R :
[Equation]
[Equation]
where cos denotes the cosine similarity between two vectors.
There are alternative similarity functions such as Euclidean distance or RBF kernel, but in preliminary experiments we found cosine simlarity to work more robustly.
We use an encoder function that uses a embedding lookup table for predicate symbols and a different one for entities. All embeddings representing natural language phrases are populated with sentence vectors that were pretrained with SENT 2 VEC (Pagliardini et al., 2017).
Additionally, we introduce a third lookup table for the predicate symbols of rules and goals, because semantics of goal or rule predicates might differ from the semantics of fact predicates even if they share the same surface form.
For instance, the query ( X , parent , Y ) could be interpreted either as ( X , is the parent of , Y ) or as ( X , has the parent , Y ) which are fundamentally different things.
4. F INE - TUNING THE E NCODER TO A D OWNSTREAM T ASK
We propose to ﬁne-tune the similarity function on a downstream task by updating the symbol embeddings.
As NLP ROLOG involves the non-differentiable proof search step, we cannot apply backpropagation for optimization.
Instead, we propose to employ Evolution Strategies in conjunction with Adam (Kingma & Ba, 2014) to estimate the weight updates.
ES recently showed good results for Reinforcement Learning problems in Salimans et al.
; Mania et al.
More formally, the parameter update is computed as:
[Equation]
where J ( θ ) is the reward obtained by θ , σ tJ is the standard deviation of all rewards obtained at time t as proposed by Mania et al.
and α t are adaptive learning rates selected by ADAM (Kingma &
Ba, 2014).
The standard deviation σ of the distribution that is generating the perturbations is treated as a hyperparameter.
We train NLP ROLOG with ES using a learning from entailment setting (Muggleton & Raedt, 1994), in which the model is trained to decide whether a Prolog program R entails the truth of a candidate triple c .
The objective of the model is to assign high probabilities p ( c |R ; θ ) to true candidate triples and low probabilities to false triples.
To achieve this, we model the reward as J ( θ ) =
yp ( c |R ; θ ) , where y ∈ {− 1 , 1 } is the gold label.
To estimate p ( c |R ; θ ) , we exhaustively search for all proofs for the triple c , up to a given depth D which we treat as a hyperparameter.
This search yields a number of proofs each with a success score S
i .
We set p ( c |R ; θ ) to be the maximum of these scores
S max = max
i S i .
4. G RADUAL R ULE L EARNING
The reasoning process of NLP ROLOG crucially depends on rules that describe the relations between predicates.
While it is possible to write down rules in natural language, this approach is hardly scalable.
Thus, we follow Rocktäschel & Riedel (2017) and use rule templates to perform Inductive
Logic Programming (ILP) (Muggleton, 1991) which allows NLP ROLOG to learn rules from training data.
For this, a user has to deﬁne a set of rules with a given structure as input.
Then, NLP ROLOG randomly initializes the predicates of these rules.
For instance, to induce a rule that can model transitivity, one would add a rule template of the form p 1 ( X, Z )
⇐ p 2 ( X, Y )
∧ p 3 ( Y, Z ) , and
NLP ROLOG would instantiate multiple rules with randomly initialized embeddings for p 1 , p 2 , and p 3 .
The exact number and structure of the rule templates is treated as a hyper-parameter.
If not explicitly stated otherwise, the experiments were performed with the same set of rule templates containing two rules for each of the forms p 1 ( X, Y )
⇐ p 2 ( X, Y ) , p 1 ( X, Y )
⇐ p 2 ( Y, X ) and p 1 ( X, Z )
⇐ p 2 ( X, Y ) ∧ p 3 ( Y, Z ) . In preliminary experiments, we observed that uniﬁcation with such randomly initialized embeddings always leads to a stark drop of the proof success score.
This implies in turn that proofs involving rule templates rarely yield the highest score S max and thus, might have no impact on the value of the reward function.
Due to that, the expected gradient estimate for the rule embeddings is zero, and they will remain close to their initialization.
The main reason for this behavior is that the monotonicity of the aggregation functions implies that each sub-goal created by an application of a rule will only decrease the success score of the proof.
Thus, all other things being equal, rules with a small number of body atoms (and facts in particular) will be preferred over more complex rules with a higher number of body atoms.
Note that this problem is particularly severe in our setting where rules are initialized randomly while the remaining predicate symbols are instantiated using pretrained sentence embeddings.
We propose a Gradual Rule Learning (GRL) algorithm which counteracts this effect during training.
GRL segments the training process into B max + 1 phases, where B max is the maximum body size of all available rules.
In the k -th phase of GRL, only proofs which employ at least one rule with a body size of B max + 1 − k are considered to estimate p ( t | F ; θ ) .
Thus, it is guaranteed that in each training step in phase k at least one rule with a body size of B max + 1 − k receives a training signal.
E VALUATION
We evaluate our method on two different QA data sets: B A B I-1 K - STATIC (Weston et al., 2015) and different subsets of W IKIHOP (Welbl et al., 2017).
The used hyperparameter conﬁgurations can be found in Section B.
5. S UBSETS OF W IKIHOP
We evaluate on different subsets of W IKIHOP (Welbl et al., 2017), each containing a single query predicate.
We consider the predicates publisher , developer , and country , because their semantics ensure that the annotated answer is unique and they contain a relatively high amount of questions that are annotated as requiring true multi-hop reasoning.
For publisher , this yields 509 training and 54 validation questions, for developer 267 and 29, and for country 742 and 194.
As the test set of
W IKIHOP is not publicly available, and splitting the small train set would lead to a far too small validation set, we report scores for the validation set and refrain from hyperparameter optimization and early stopping.
Each data point consists of a query p ( q, X ) where q is some query entity, X is the entity that has to be predicted, C is a list of candidates entities, a ∈ C is an answer entity and p ∈ { publisher , developer , country } is the query predicate.
In addition, every query is accompanied by a set of support documents which can be used to decide which candidate is the correct answer.
To transform the support documents to natural language triples, we use the Open IE system
M IN IE (Gashteovski et al., 2017).
We use the publicly available version of M IN IE 3 in the dictionary mode, and use a list of all WIKIHOP candidate entities as our dictionary of multi-token entities.
Following Welbl et al.
(2017), we use the two neural QA models BIDAF (Seo et al., 2016a) and
F AST QA (Weissenborn et al., 2017) as baselines for the selected predicates of W IKIHOP .
We employ the implementation provided by the QA framework JACK 4 (Weissenborn et al., 2018) with the same hyperparameters as used by Welbl et al.
and train a separate model for each predicate.
In order to compensate for the fact that both models are extractive QA models which cannot make use of the candidate entities, we additionally evaluate modiﬁed versions which transform both the predicted answer and all candidates to vectors using the wiki-unigrams model 5 of SENT 2 VEC (Pagliardini et al., 2017).
Consequently, we return the candidate entity which has the highest cosine similarity to the predicted entity.
5. B A B I-1 K - STATIC
We utilize a subset of B A B I-1 K to study the behavior of NLP ROLOG in a very controlled environment.
Note however, that the experiments on W IKIHOP are much more signiﬁcant, as they involve natural linguistic variability.
B A B I-1 K - STATIC consists of the tasks QA4,QA15,QA17, and QA18 from
These tasks were selected because, unlike the other tasks of B A B I, they do not require reasoning about a dynamically changing world state, which is not supported by the current implementation of
NLP ROLOG .
We automatically transform all statements and queries of the respective tasks to triples and use the resulting KB as input to NLP ROLOG .
We train and evaluate on each problem individually.
The tasks QA4 and QA15 require entities as an output, thus we consider every entity that occurs at least once in any problem of the task as a candidate for all problems.
Tasks QA17 and QA18 are binary classiﬁcation tasks, and thus we determine the optimal threshold on the training set, after the training of NLP ROLOG has ﬁnished.
We refrain from systematically comparing results on the individual B A B I tasks to competing methods like Seo et al.
(2016b)
; Peng et al.
; Dhingra et al.
; Henaff et al.
; Sukhbaatar et al.
, since our non-negligible preprocessing and evaluation on only four out of 20 tasks does not allow us to match the relevant evaluation protocols.
We therefore utilize B A B I-1 K - STATIC only for ablation experiments, but note that NLP ROLOG achieves similar or better accuracy values than the mentioned methods in all instances we studied, except on QA4 .
5. D EALING WITH C ANDIDATES
All questions of W IKIHOP and some of B A B I-1 K - STATIC include a set of answer candidates C .
For those cases, we modify our reward function to leverage this information, taking inspiration from
Bayesian Personalized Ranking (Rendle et al., 2009):
[Equation]
where a ∈ C is the true answer.
We observed that this reward function does not work well with the minimum aggregation function.
Therefore, we employ this modiﬁed reward only when using the product aggregation and utilize the reward described in Section 4.2 with the minimum aggregation.
5. R ESULTS
The results for the selected predicates of W IKIHOP can be found in Table 1.
While there is no single best performing model, NLP ROLOG is outperformed by at least one neural QA model on every predicate.
For country , this only holds true when considering the versions of the neural models that have been augmented to consider candidate entities.
For all three predicates, only a single transitive rule is utilized across all validation questions.
Since we observe a more diverse set of induced rules on
B A B I-1 K , we partly attributed this lack of diverse rules to the multi-hop characteristic of the W IKIHOP data.
It seems that NLP ROLOG struggles to ﬁnd meaningful rules for the predicates developer and publisher , which leads to very few proofs involving rules on the development set: 1 out of 54 for publisher and 2 out of 29 for developer , compared with 159 out of 194 for country .
We partially attribute this to the fact, that the semantics of country suggest a straightforward rule (transitivity of location), which is not true for developer or publisher .
Additionally, the annotations regarding the neccessity of multi-hop reasoning provided for the validation set (Welbl et al., 2017) suggest that publisher and developer contain signiﬁcantly fewer training examples involving multi-hop reasoning.
Exemplary proofs generated by NLP ROLOG on the predicates developer and country can be found in Fig.
As we are especially interested in assessing the capability for multi-hop reasoning, we additionally evaluate on a subset of problems which have been unanimously labelled as requiring multi-hop reasoning.
On this subset of the development data, which is denoted as Countryhop (mh) in Table 1, NLP ROLOG outperforms all other single models.
5. N EURAL QA AND NLP ROLOG E NSEMBLE
If the proof of NLP ROLOG producing the prediction does not employ any rules, the prediction is essentially the result of performing a simple nearest neighbor search among the embeddings of all fact triples.
We hypothesize that the neural QA models F AST QA and BIDAF are better suited for ﬁnding the most predictive single support statement, which motivates an ensemble of a neural QA model and NLP ROLOG .
We built a system which predicts the output of NLP ROLOG when it used at
[Table]
country (mh) only considers the problems that have been unanimously judged to require multi-hop reasoning.
The upper part lists single models and the bottom part ensembles.
least one rule and the output of the neural QA model otherwise.
This allows to employ the multihop reasoning of NLP ROLOG when possible and to utilize the pattern matching capabilities of the neural
QA models in the remaining cases.
The results for these ensembles are given in the bottom part of
Table 1.
In all instances, ensembling a neural QA model with NLP ROLOG improved upon all single models, indicating that they complement each other well.
We analyze reasons for the success of this ensembling strategy in Section 5.6.
5. E RROR A NALYSIS
We conducted an extensive error analysis, in which we manually classiﬁed all errors of NLP ROLOG on the selected W IKI H OP predicates into predeﬁned categories.
The results are depicted in Figure 2.
For the developer predicate, in the majority of cases, errors were caused by O PEN IE during the fact extraction step: in all but one case, O PEN IE did not produce the necessary facts, or a necessary facts was not stated in the support text, or there were multiple correct candidates and NLP ROLOG selected the wrong one.
As a consequence, for both the publisher and developer predicates, the majority of queries would not answerable, even when the necessary rules were correctly induced.
The predictive accuracy was signiﬁcantly higher for the country predicate, where errors were mostly due to entitities not having SENT 2 VEC embeddings and a few missing rules.
Fig.
2 indicates that F AST QA can produce the correct answer, even if crucial information is missing from the supporting documents.
To analyze this further, we evaluated F AST QA and NLP ROLOG on a test set of the country predicate in which all documents mentioning the query entity were removed.
Remarkably, the accuracy of F AST QA increased by approximately 1% , while the accuracy of NLP ROLOG decreased by approx.
Furthermore, we evaluated both F AST QA and NLP ROLOG on the hard subset of country as deﬁned by Sugawara et al.
(2018): on these 62 problems which cannot be solved with a simple heuristic,
NLP ROLOG achieved an accuracy of 51 .
61% , as opposed to 46 .
77% by F AST QA.
We conjecture that – besides NLP ROLOG ’s multi-hop reasoning capability – this is one reason why the neural models and NLP ROLOG complement each other nicely: neural models can compensate for missing information, while NLP ROLOG is less susceptible for spurious correlations between the query and supporting texts.
The complementary nature of both approaches is further supported by the error analysis, described in Fig.
5. A BLATION E XPERIMENTS
We perform experiments on B A B I-1 K - STATIC to investigate the effect of the GRL training procedure.
Speciﬁcally, we perform experiments on B A B I-1 K - STATIC with only the last phase of GRL (i.e. training without GRL), with the last and the penultimate phase, and with all three phases, corresponding to full GRL as we limit the rule complexity to two body atoms in rule templates.
To maintain comparability between runs, we keep the number of SGD steps constant across all experiments. [Table]
Additionally [Table] we experiment with manually deﬁned rules, which we deem sufﬁcient for solving each of the four tasks.
For these, we report results before and after training, as well as for a run without any rule templates.
The accuracy scores for all experiments on B A B I are provided in Table [Table]
To assess the impact of the choice of rule templates, we evaluate NLP ROLOG on bAbI-1k-static with a different set of rule templates containing two rules of the form p 1 ( X, Y )
⇐ p 2 ( X, Y ) , four with the form p 1 ( X, Y )
⇐ p 2 ( Y, X ) and another four for p 1 ( X, Z )
⇐ p 2 ( X, Y ) ∧ p 3 ( Y, Z ) . Clearly, the full GRL is necessary to obtain acceptable results in any of the problems.
Interestingly, phase 1 of GRL does not contribute anything for QA4, which is perfectly solvable using only rules of body size 1 .
On the other hand, QA15 and QA18 both require a rule of body size 2 , which makes phase 1 strongly improve the results.
Only for QA 17 the results are inconclusive.
Nevertheless, this indicates that GRL works as intended, with the earlier phases encouraging the induction of rules with a higher number of conjuncts in the body.
The results using manually deﬁned rules suggest that even when sufﬁcient rules are provided, training with ES is helpful nevertheless.
Interestingly, the model using no rules is able to solve over 90% of the problems in QA18 , indicating that this problem is not well suited for evaluating reasoning capabilities of QA models.
Using ten instead of six templates leads to worse performance on all B A B I problems
but QA15 , which is solved perfectly with a much faster convergence rate.
This result indicates that the choice of rule templates might be an important hyperparameter which should be optimized for a given problem.
D ISCUSSION AND F UTURE W ORK
We have developed NLP ROLOG , a system that is able to perform rule-based reasoning on natural language input, and can learn domain-speciﬁc natural language rules from training data.
To this end, we have proposed to combine a symbolic prover with pretrained sentence embeddings and to train the resulting system with Evolution Strategies.
We have evaluated NLP ROLOG on two different QA tasks, showing that it can learn domain-speciﬁc rules and produce predictions which complement those of the two strong baselines BIDAF and F AST QA.
This allows to build an ensemble of a baseline and
ROLOG which all single models.
While we have focused on a subset of First Order Logic in this work, the expressiveness of NLP ROLOG could be extended by incorporating a different symbolic prover.
For instance, a prover for temporal logic (Orgun & Ma, 1994) would allow to model temporal dynamics in natural language and enable us to evaluate NLP ROLOG on the full set of B A B I tasks.
We are also interested in incorporating future improvements of symbolic provers, Open IE systems and pretrained sentence representations to further enhance the performance of NLP ROLOG .
To study the performance of the proposed method without the noise introduced by the Open IE step, it would be useful to evaluate it on tasks like knowledge graph reasoning.
Additionally, it would be interesting to study the behavior of NLP ROLOG in the presence of multiple WIKIHOP query predicates.
A A LGORITHMS A. W EAK U NIFICATION
fun unify ( x, y, θ, S )
Input: x : function f ( . . . ) | atom p ( . . . ) | variable | list x 1 :: x 2 :: . . . :: x n y : function f (cid:48)
| atom p (cid:48) ( . . . )
| variable | list y 1 :: y 2 :: . . y m θ : current substitutions, default = {} S : current success score, default = 1 . Output: (Unifying substitution θ (cid:48) or failure , Updated success score S (cid:48) ) if θ = failure then return ( failure , 0 ) else if S < λ then return ( failure , 0 ) else if x = y then return ( θ , S ) else if x is Var then return unify_var ( x, y, θ, S ) else if y is Var then return unify_var ( y, x, θ, S ) else if x is f ( x 1 , . . .
, x n ) , y is f (cid:48)
( y 1 , . .
y n ) , and f ∼ f (cid:48) ≥ λ then
S (cid:48) :
= S ∧ f ∼ f (cid:48) return unify ( x 1 :: . . .
:: x n , y 1 :: . . .
:: y n , θ, S (cid:48) )
endelse if x is p ( x 1 , . .
, x n ) , y is p (cid:48)
( y 1 , . .
y n ) , and p ∼ p (cid:48) ≥ λ then
S (cid:48) :
= S ∧ f ∼ f (cid:48) return unify ( x 1 :: . . .
:: x n , y 1 :: . . .
:: y n , θ, S (cid:48) )
endelse if x is x 1 :: . .
:: x n and y is y 1 :: . . .
:: y n then ( θ return endelse if list return
, S ) else return failure , 0 ) fun unify_var ( v, o, θ, S ) if { v / val } ∈ θ then return unify ( val , o, θ, S ) else if { o/ val } ∈ θ then return unify ( var , val , θ, S ) else return ( { v/o } + θ, S )
The worst case complexity vanilla logic programming is exponential in the depth of the proof (Russell & Norvig, 2010). However, in our case this is a particular problem because weak uniﬁcation requires the prover to attempt uniﬁcation between all entity/predicate symbols.
To keep things tractable, NLP ROLOG only attempts to unify symbols with a similarity greater than some user-deﬁned threshold λ . Furthermore, in the search step for one statement q , for the rest of the search, λ is set to λ := max( λ, S ) whenever a proof for q with success score S is found.
Due to the monotonicity of the employed aggregation functions, this allows to prune the search tree without losing the guarantee to ﬁnd the proof yielding the maximum success score. We found this optimization to be crucial to make the proof search scale for the studied wikihop predicates. B H YPERPARAMETER C ONFIGURATION
On B A B I-1 K we optimize the embeddings of predicate symbols of rules and query triples, as well as of entities.
W IKIHOP has a large number of unique entity symbols and thus, optimizing their embeddings is prohibitive.
Thus, we only train the predicate symbols of rules and query triples on this data set.
The embeddings for entities and predicate symbols of fact and query triples are initialized using the WIKI - UNIGRAMS model of SENT 2 VEC , while the embeddings of rule predicates are intialized by uniformly sampling from the interval [ − 1 √ 600 , 1 √ 600 ] .
All experiments were performed with the same set of rule templates containing two rules for each of the forms p ( X, Y )
⇐ q ( X, Y ) , p ( X, Y )
⇐ q ( Y, X ) and p ( X, Z )
⇐ q ( X, Y )
∧ r ( Y, Z ) and set the similarity threshold λ to 0 .
At each optimization step, we evaluate 100 perturbations sampled from N (0 , 0 . 04) on a mini-batch of 16 training problems and use all of the directions in the generation of the next weight vector.
If not stated otherwise, we use GRL with three phases training for 500 mini-batches in each phase.
For the predicates publisher and developer , we used 1,000 mini-batches in the ﬁnal phase of GRL.
To further encourage rule usage, we use the minimum aggregation function in all but the last phases of GRL, in which we switch to product .
C E RROR S ETS