Neural Markov Logic Networks

We introduce Neural Markov Logic Networks ( NMLNs ) , a statistical relational learning system that borrows ideas from Markov logic . Like Markov Logic Networks ( MLNs ) , NMLNs are an exponential-family model for modelling distributions over possible worlds , but unlike MLNs , they do not rely on explicitly specified first-order logic rules . Instead , NMLNs learn an implicit representation of such rules as a neural network that acts as a potential function on fragments of the relational structure . Interestingly , any MLN can be represented as an NMLN . Similarly to recently proposed Neural theorem provers ( Rocktäschel & Riedel , 2017 ) , NMLNs can exploit embeddings of constants but , unlike NTPs , NMLNs work well also in their absence . This is extremely important for predicting in settings other than the transductive one . We showcase the potential of NMLNs on knowledge-base completion tasks and on generation of molecular ( graph ) data . 1 INTRODUCTION . Parameters for a statistical relational model are typically estimated from one or more examples of relational structures that typically consist of a large number of ground facts . Examples of such structures are social networks ( e.g . Facebook ) , protein-protein interaction networks , the Web , etc . A challenging task is to learn a probability distribution over such relational structures from one or few examples . One solution is based on the assumption that the relational structure has repeated regularities ; this assumption is implicitly or explicitly used in most works on statistical relational learning . Then , statistics about these regularities can be computed for small substructures of the training examples and used to construct a distribution over the relational structures . Together with the maximum-entropy principle , this leads to distributions such as Markov logic networks ( Richardson & Domingos , 2006 ; Kuželka et al. , 2018 ) In this paper , we propose Neural Markov Logic Networks ( NMLN ) . Here , the statistics which are used to model the probability distribution are not known in advance , but are modelled as neural networks trained together with the probability distribution model . This is very powerful when compared to classical MLNs , where either domain experts are required to design some useful statistics about the domain of interest by hand ( i.e . logical rules ) or structure learning based on combinatorial search needs to be performed . These requirements normally limit a wide application of these models as out-of-the box tools . It is worth noticing that overtaking the need of such “ feature-engineering ” is one of the reasons behind the massive adoption of deep learning techniques . However , not much has been done in the same direction by the statistical relational learning community . Moreover , designing statistics as neural networks allows a more fine-grained description of the data , opening the doors to applications of our model to the generative setting . CONTRIBUTIONS The main contributions of this work are : ( i ) we introduce a new statistical relational model , which overcomes actual limitations of both classical and recent related models such as ( Richardson & Domingos , 2006 ; Rocktäschel & Riedel , 2017 ; Sourek et al. , 2018 ) ; ( ii ) we propose a theoretical justification of the model as naturally emerging from a principle of Min-Max-entropy ; ( iii ) we provide a Tensorflow implementation of this model ; and ( iv ) we showcase its effectiveness on two quite diverse problems : knowledge-base completion and generative modelling of small molecules . RELATED WORK The need to extend relational models with neural components is a topic that has been receiving increasing attention in the last few years . An integration of logic reasoning and neural models was proposed based on fuzzy logic ( Serafini & Garcez , 2016 ; Diligenti et al. , 2017 ; Marra et al. , 2019 ) . Here , neural models implementing FOL relations are optimized in order to satisfy differentiable approximations of logical formulas obtained by means of fuzzy t-norm theory . However , the lack of probabilistic arguments allows a sound application of such fuzzy-logic based methods only to hard-constrained settings . In Manhaeve et al . ( 2018 ) , the probabilistic logic programming language ProbLog ( De Raedt et al. , 2007 ) is extended to allow probabilities of atoms to be predicted by neural networks and to exploit differentiable algebraic generalizations of decision diagrams to train these networks . Lifted relational neural networks ( Sourek et al. , 2018 ) unfold neural networks with shared weights , as in convolutional networks , using forward chaining . A semantically very similar approach was the one in Rocktäschel & Riedel ( 2017 ) , where the authors implemented the Prolog backward chaining with a soft unification scheme operating on constants and relations embeddings . The proposed Neural Theorem prover was able to exploit the geometry of the embedding space to improve its reasoning capabilities , but the need for embeddings prevents this model to be applicable to settings different from the transductive one . Most importantly , neither of these latter two works provides means for probabilistic modelling of relational structures . The idea of exploiting neural networks to extract regularities in non-euclidean settings has been recently revisited by the deep learning community in the context of Graph Neural Networks ( GNN ) models ( Scarselli et al. , 2009 ; Defferrard et al. , 2016 ; Xu et al. , 2018 ) . In GNNs , latent representations of nodes are obtained by an aggregation of neighboring nodes representation by means of an iterative diffusion mechanism . However , the inference is performed only on neighborhoods induced by the actual connections of the graph , preventing the exploitation of these models for modeling distributions of structural properties of the graph . Lippi & Frasconi ( 2009 ) was an early attempt to integrate MLNs with neural components . Here , an MLN was exploited to describe a conditional distribution over ground atoms , given some features of the constants . In particular , the MLN was reparametrized by a neural network evaluated on input features . However , this method still relied on hand-crafted logical rules for modelling the distribution . 2 PRELIMINARIES . This paper follows the setting of so-called Model A from Kuželka et al . ( 2018 ) . We consider a function-free first-order logic language L , which is built from a set of constants C and predicates R = ⋃ iRi , where Ri contains the predicates of arity i . For c1 , c2 , . . . , cm ∈ C and R ∈ Rm , we call R ( c1 , c2 , . . . , cm ) a ground atom . We define possible world ω ∈ Ω as the pair ( C , A ) , where C ⊆ C , A is a subset of the set of all ground atoms that can be built from the constants in C and any relation in R. We define the size of a possible world n = |C| and Ω is the set of all possible worlds . A fragment ω〈S〉 is defined as the restriction of ω to the constants in S. It is again a pair ω〈S〉 = ( S , B ) , with S the constants of the restriction and B a set of ground atoms which only use constants from S. Given a fragment ω〈S〉 and k = |S| , we can anonymize it by mapping the constants in S with a permutation Ŝ of the integer set { 1 , 2 , ... , k } . We call this an anonymized fragment γ . Suppose we have a given world ω̂ of size n , we define Γk ( ω̂ ) the collection of all the anonymized fragments of width k of ω̂ . It is easy to verify that |Γk ( ω̂ ) | = ( n k ) k ! . The collection Γk ( ω̂ ) is a multiset , since , after anonymization , multiple fragments could be identical . An example of the process of anonymization and of the identification of structural patterns among anonymized fragments is shown in Figure 1 . 3 NEURAL MARKOV LOGIC NETWORKS . 3.1 INTUITION AND FORMULATION . Given a world ω̂ ∈ Ω , we are interested in models of the probability Pω , for a generic ω ∈ Ω . To this end , we want to compute statistics on fragments of the given ω̂ and exploit them to construct a distribution on ( possibly larger and smaller ) relational structures ω . Let us define φ ( γ ) as a fragment potential function , which is simply a function from anonymized fragments of width k to real numbers . We can search for a maximum-entropy distribution p ( ω ) such that the following two expected values are the same : ( i ) the expected value of φ ( γ ) where γ is sampled uniformly from Γk ( ω̂ ) and ( ii ) the expected value of φ ( γ′ ) where γ′ is sampled uniformly from Γk ( ω ) and ω is sampled , in turn , from p ( ω ) . The intuition here is that , at least on average , the fragments of the given training example should look similar to the fragments of possible worlds sampled from the distribution . It follows from ( Kuželka et al. , 2018 ) that the resulting maximum-entropy distribution is an exponential-family distribution resembling Markov logic networks . The max-entropy setting provides us with a sound starting point for designing statistical relational models that generalize classical models such as Markov random fields . However , a necessary condition for these models to be designed is that one can provide a set of statistics φ ( ω ) describing the data . In this section , we show how to get rid of the need to provide statistics in advance and how to learn these statistics together with the probabilistic model in a differentiable manner . Let us consider a fragment neural potential function φ ( γ ; w ) . It is a parametric function with parameters w. Let Φ ( ω ; w ) = 1|Γk ( ω ) | ∑ γ∈Γk ( ω ) φ ( γ ; w ) be the corresponding global neural potential . We need a learning principle which would allow us to find a good φ ( γ ; w ) to describe our data . To this end , suppose we need to solve the maximum-entropy optimization problem , but without any constraint on the statistics . The maximum-entropy solution in this case is the uniform distribution , which assigns equal probability to all possble worlds ω . Now , suppose we add a single constraint on a potential Φ̃ ( ω ) . If this potential is informative and makes some worlds more likely than others , then the solution moves from the uniform distribution to another distribution with lower entropy . Using this intuition , we can have a scheme where we maximize entropy by selecting the maximumentropy distribution and minimize it at the same time by choosing the most informative statistics . The above considerations give rise to a Min-Max-Entropy model for the target probability distribution Pω , which we call Neural Markov Logic Network and which we describe in turn . Let us first define the Max-Entropy problem with the new neural potentials ( stated here as minimization of negative entropy ) : min Pω ∑ ω Pω logPω ( 1 ) subject to ∑ ω Pω = 1 , ∀ω : pω ≥ 0 ( 2 ) ∀i : EPω [ Φi ( ω ; wi ) ] = Φi ( ω̂ ; wi ) with 0 < i ≤M ( 3 ) For fixed wi ’ s , we can use Lagrangian duality to obtain the following solution of the maximum entropy problem : Pω = 1Z exp ( ∑ i βiΦ ( ω ; wi ) ) . Here , Z is a normalization constant and the pa- rameters βi are solutions of the dual problem max βi { ∑M i=1 βiΦi ( ω̂ ; wi ) − logZ } , which coincides with maximum-likelihood.1 Next we still need to incorporate the minimization of entropy by optimizing wi ’ s . Let us denote by H ( β1 , . . . , βM , w1 , . . . , wM ) the entropy of the distribution Pω . Now , as previously introduced , the selection of the optimal values wi is governed by the principle of minimization of entropy , leading to the optimization problem : min wi max βi H ( β1 , . . . , βM , w1 , . . . , wM ) = −max wi min βi − H ( β1 , . . . , βM , w1 , . . . , wM ) subject to the constraints ( 2 ) and ( 3 ) . Plugging in the dual problem and using strong duality , we obtain the following unconstrained optimization problem which is equivalent to the maximization of log-likelihood : maxwi , βi { ∑M i=1 βiΦi ( ω̂ ; wi ) − logZ } . The maximization of the log-likelihood will be carried out by a gradient-based optimization scheme . The gradients of the log-likelihood w.r.t . to both the parameters wi , j , where wi , j denotes the j-th component of wi , and βi are : ∂ log ( Pω̂ ) ∂wi , j = βi ( ∂Φi ( ω̂ ; wi ) ∂wi , j − Eω∼P [ ∂Φ ( ω ; wi ) ∂wi , j ] ) ( 4 ) ∂ log ( Pω̂ ) ∂βi = ( Φi ( ω̂ ; wi ) − Eω∼P [ Φi ( ω ; wi ) ] ) ( 5 ) At a stationary point , Eq . 5 recovers the initial constraint on statistics imposed in the maximization of the entropy . However , the minimization of the entropy is mapped to a new requirement : at stationary conditions , the expected value of the gradients of the Φi under the distribution must match the gradients of the Φi evaluated at the data points .

Summary: This paper presents Neural Markov Logic Networks  (NMLN), which is a generalization of Markov Logic Networks (MLN). Unlike MLN which relies on pre-specified first-order logic (FOL) rules, NMLN learns potential functions parameterized by neural networks on fragments of the graph. The potential function can possibly take into account the constants present using embeddings to better solve transductive problems（otherwise the potential can only use relational structure). To make computation tractable, the size of local potential functions is constrained. Training of this MRF is performed by solving a min-max entropy problem: conditioned on an informative potential, the uncertainties shall be decreased. Experiments on a knowledge base completion task and a graph generation task show superior performance compared to baselines like neural theorem provers.