Efficient Probabilistic Logic Reasoning with Graph Neural Networks
Abstract
Markov Logic Networks (MLNs), which elegantly combine logic rules and probabilistic graphical models, can be used to address many knowledge graph problems. However, inference in MLN is computationally intensive, making the industrialscale application of MLN very difficult. In recent years, graph neural networks (GNNs) have emerged as efficient and effective tools for largescale graph problems. Nevertheless, GNNs do not explicitly incorporate prior logic rules into the models, and may require many labeled examples for a target task. In this paper, we explore the combination of MLNs and GNNs, and use graph neural networks for variational inference in MLN. We propose a GNN variant, named ExpressGNN, which strikes a nice balance between the representation power and the simplicity of the model. Our extensive experiments on several benchmark datasets demonstrate that ExpressGNN leads to effective and efficient probabilistic logic reasoning.
1 Introduction
Knowledge graphs collect and organize relations and attributes about entities, which are playing an increasingly important role in many applications, including question answering and information retrieval. Since knowledge graphs may contain incorrect, incomplete or duplicated records, additional processing such as link prediction, attribute classification, and record deduplication is typically needed to improve the quality of knowledge graphs and derive new facts.
Markov Logic Networks (MLNs) were proposed to combine hard logic rules and probabilistic graphical models, which can be applied to various tasks on knowledge graphs (Richardson and Domingos, 2006). The logic rules incorporate prior knowledge and allow MLNs to generalize in tasks with small amount of labeled data, while the graphical model formalism provides a principled framework for dealing with uncertainty in data. However, inference in MLN is computationally intensive, typically exponential in the number of entities, limiting the realworld application of MLN. Also, logic rules can only cover a small part of the possible combinations of knowledge graph relations, hence limiting the application of models that are purely based on logic rules.
Graph neural networks (GNNs) have recently gained increasing popularity for addressing many graph related problems effectively (Dai et al., 2016; Li et al., 2016; Kipf and Welling, 2017; Schlichtkrull et al., 2018). GNNbased methods typically require sufficient labeled instances on specific end tasks to achieve good performance, however, knowledge graphs have the longtail nature (Xiong et al., 2018), i.e., a large portion the relations in only are a few triples. Such data scarcity problem among longtail relations poses tough challenge for purely datadriven methods.
In this paper, we explore the combination of the best of both worlds, aiming for a method which is datadriven yet can still exploit the prior knowledge encoded in logic rules. To this end, we design a simple variant of graph neural networks, named ExpressGNN, which can be efficiently trained in the variational EM framework for MLN. An overview of our method is illustrated in Fig. 1. ExpressGNN and the corresponding reasoning framework lead to the following desiderata:

Efficient inference and learning: ExpressGNN can be viewed as the inference network for MLN, which scales up MLN inference to much larger knowledge graph problems.

Combining logic rules and data supervision: ExpressGNN can leverage the prior knowledge encoded in logic rules, as well as the supervision from graph structured data.

Compact and expressive model: ExpressGNN may have small number of parameters, yet it is sufficient to represent meanfield distributions in MLN.

Capability of zeroshot learning: ExpressGNN can deal with the zeroshot learning problem where the target predicate has few or zero labeled instances.
2 Related Work
Statistical relational learning. There is an extensive literature relating the topic of logic reasoning. Here we only focus on the approaches that are most relevant to statistical relational learning on knowledge graphs. Logic rules can compactly encode the domain knowledge and complex dependencies. Thus, hard logic rules are widely used for reasoning in earlier attempts, such as expert systems (Ignizio, 1991) and inductive logic programming (Muggleton and De Raedt, 1994). However, hard logic is very brittle and has difficulty in coping with uncertainty in both the logic rules and the facts in knowledge graphs. Later studies have explored to introduce probabilistic graphical model in logic reasoning, seeking to combine the advantages of relational and probabilistic approaches. Representative works including Relational Markov Networks (RMNs; Taskar et al. (2007)) and Markov Logic Networks (MLNs; Richardson and Domingos (2006)) were proposed in this background.
Markov Logic Networks. MLNs have been widely studied due to the principled probabilistic model and effectiveness in a variety of reasoning tasks, including entity resolution (Singla and Domingos, 2006a), social networks (Zhang et al., 2014), information extraction (Poon and Domingos, 2007), etc. MLNs elegantly handle the noise in both logic rules and knowledge graphs. However, the inference and learning in MLNs is computationally expensive due to the exponential cost of constructing the ground Markov network and the NPcomplete optimization problem. This hinders MLNs to be applied to industryscale applications. Many works appear in the literature to improve the original MLNs in both accuracy (Singla and Domingos, 2005; Mihalkova and Mooney, 2007) and efficiency (Singla and Domingos, 2006b, 2008; Poon and Domingos, 2006; Khot et al., 2011; Bach et al., 2015). Nevertheless, to date, MLNs still struggle to handle largescale knowledge bases in practice. Our framework ExpressGNN overcomes the scalability challenge of MLNs by efficient stochastic training algorithm and compact posterior parameterization with graph neural networks.
Graph neural networks. Graph neural networks (GNNs; Dai et al. (2016); Kipf and Welling (2017)) can learn effective representations of nodes by encoding local graph structures and node attributes. Due to the compactness of model and the capability of inductive learning, GNNs are widely used in modeling relational data (Schlichtkrull et al., 2018; Battaglia et al., 2018). Recently, Qu et al. (2019) proposed Graph Markov Neural Networks (GMNNs), which employs GNNs together with conditional random fields to learn object representations. These existing works are simply datadriven, and not able to leverage the domain knowledge or human prior encoded in logic rules. To the best of our knowledge, ExpressGNN is the first work that connects GNNs with firstorder logic rules to combine the advantages of both worlds.
Knowledge graph embedding. Another line of research for knowledge graph reasoning is in the family of knowledge graph embedding methods, such as TransE (Bordes et al., 2013), NTN (Socher et al., 2013), DistMult (Kadlec et al., 2017), ComplEx (Trouillon et al., 2016), and RotatE (Sun et al., 2019). These methods design various scoring functions to model relational patterns for knowledge graph reasoning, which are very effective in learning the transductive embeddings of both entities and relations. However, these methods are not able to leverage logic rules, which can be crucial in some relational learning tasks, and have no consistent probabilistic model. Compared to these methods, ExpressGNN has consistent probabilistic model built in the framework, and can incorporate knowledge from logic rules. A recent concurrent work Qu and Tang (2019) has proposed probabilistic Logic Neural Network (pLogicNet), which integrates knowledge graph embedding methods with MLNs with EM framework. Compared to pLogicNet which uses a flattened embedding table as the entity representation, our work explicitly captures the structure knowledge encoded in the knowledge graph with GNNs and supplement the knowledge from logic formulae for the prediction task.
3 Preliminary
Knowledge Graph. A knowledge graph is a tuple consisting of a set of entities, a set of relations, and a collection of observed facts. In the language of firstorder logic, entities are also called constants. For instance, a constant can be a person or an object. Relations are also called predicates. Each predicate is a logic function defined over , i.e., In general, the arguments of predicates are asymmetric. For instance, for the predicate (L for Like) which checks whether likes , the arguments and are not exchangeable.
With a particular set of entities assigned to the arguments, the predicate is called a ground predicate, and each ground predicate a binary random variable, which will be used to define MLN. For a ary predicate, there are ways to ground it. We denote an assignment as . For instance, with , we can simply write a ground predicate as . Each observed fact in knowledge bases is a truth value assigned to a ground predicate. For instance, a fact can be . The number of observed facts is typically much smaller than that of unobserved facts. We adopt the openworld paradigm and treat these unobserved facts latent variables.
As a clearer representation, we express a knowledge base by a bipartite graph , where nodes on one side of the graph correspond to constants and nodes on the other side correspond to observed facts , which is called factor in this case. The set of edges, , connect constants and the observed facts. More specifically, an edge between node and exists, if the ground predicate associated with uses as an argument in its th argument position (Fig. 2).
Markov Logic Networks. MLNs use logic formulae to define potential functions in undirected graphical models. A logic formula is a binary function defined via the composition of a few predicates. For instance, a logic formula can be
where is negation and the equivalence is established by De Morgan’s law. Similar to predicates, we denote an assignment of constants to the arguments of a formula as , and the entire collection of consistent assignments of constants as . A formula with constants assigned to all of its arguments is called a ground formula. Given these logic representations, MLN can be defined as a joint distribution over all observed facts and unobserved facts as
(1) 
where is the partition function summing over all ground predicates and is the potential function defined by a formula as illustrated in Fig. 2. One form of can simply be the truth value of the logic formula . For instance, if the formula is , then can simply take value when is true and otherwise. Other more sophisticated can also be designed, which have the potential to take into account complex entities, such as images or texts, but will not be the focus of this paper. The weight can be viewed as the confidence score of the formula : the higher the weight, the more accurate the formula is.
Difference between KG and MLN. We note that the graph topology of knowledge graphs and MLN can are very different, although MLN is defined on top of knowledge graphs. Knowledge graphs are typically very sparse, where the number of edges (observed relations) is typically linear in the number of entities. However, the graphs associated with MLN are much denser, where the number of nodes can be quadratic or more in the number of entities, and the number of edges (dependency between variables) is also highorder polynomials in the number of entities.
4 Variational EM for Markov Logic Networks
In this section, we introduce the variational EM framework for MLN inference and learning, where we will use ExpressGNN as a key component (detailed in Sec. 5). Markov Logic Networks model the joint probabilistic distribution of all observed and latent variables, as defined in Eq. 1. This model can be trained by maximizing the loglikelihood of all the observed facts . However, it is intractable to directly maximize the objective, since it requires to compute the partition function and integrate over all variables and . We instead optimize the variational evidence lower bound (ELBO) of the data loglikelihood, as follows
(2) 
where is a variational posterior distribution of the latent variables given the observed ones. The equality in Eq. 2 holds if the variational posterior equals to the true posterior . We then use the variational EM algorithm (Ghahramani and Beal, 2000) to effectively optimize the ELBO. The variational EM algorithm consists of an expectation step (Estep) and a maximization step (Mstep), which will be called in an alternating fashion to train the model: 1) In the Estep (Sec. 4.1), we infer the posterior distribution of the latent variables, where is fixed and is optimized to minimize the KL divergence between and ; 2) In the Mstep (Sec. 4.2), we learn the weights of the logic formulae in MLN, where is fixed and is optimized to maximize the data loglikelihood.
4.1 Estep: Inference
In the Estep, which is also known as the inference step, we are minimizing the KL divergence between the variational posterior distribution and the true posterior distribution . The exact inference of MLN is computationally intractable and proven to be NPcomplete (Richardson and Domingos, 2006). Therefore, we choose to approximate the true posterior with a meanfield distribution, since the meanfield approximation has been demonstrated to scale up large graphical models, such as latent Dirichlet allocation for modeling topics from large text corpus (Hoffman et al., 2013). In the meanfield variational distribution, each unobserved ground predicate is independently inferred as follows:
(3) 
where each factorized distribution follows the Bernoulli distribution. We parameterize the variational posterior with deep learning models as our neural inference network. The design of the inference network is very important and has a lot of considerations, since we need a compact yet expressive model to accurately approximate the true posterior distribution. We employ graph neural networks with tunable embeddings as our inference network (detailed in Sec. 5), which can tradeoff between the model compactness and expressiveness.
With the meanfield approximation, defined in Eq. 2 can be reorganized as below:
(4) 
where is fixed in the Estep and thus the partition function can be treated as a constant. We notice that the first term has the summation over all formulae and all possible assignments to each formula. Thus this double summation may involve a large number of terms. The second term is the sum of entropy of the variational posterior distributions , which also involves a large number of terms since the summation ranges over all possible latent variables. Typically, the number of latent facts in database is much larger than the number of observed facts. Thus, both terms in the objective function pose the challenge of intractable computational cost.
To address this challenge, we sample minibatches of ground formulae to break down the exponential summations by approximating it with a sequence of summations with a controllable number of terms. More specifically, in each optimization iteration, we first sample a batch of ground formulae. For each ground formula in the sampled batch, we compute the first term in Eq. 4 by taking the expectation of the corresponding potential function with respect to the posterior of the involved latent variables. The meanfield approximation enables us to decompose the global expectation over the entire MLN into local expectations over ground formulae. Similarly, for the second term in Eq. 4, we use the posterior of the latent variables in the sampled batch to compute a local sum of entropy.
For tasks that have sufficient labeled data as supervision, we can add a supervised learning objective to enhance the inference network, as follows:
(5) 
This objective is complementary to the ELBO on predicates that are not well covered by logic rules but have sufficient observed facts. Therefore, the overall Estep objective function becomes:
(6) 
where is a hyperparameter to control the weight. This overall objective essentially combines the knowledge in logic rules and the supervision from labeled data.
4.2 Mstep: Learning
In the Mstep, which is also known as the learning step, we are learning the weights of logic formulae in Markov Logic Networks with the variational posterior fixed. The partition function in Eq. 4 is not a constant anymore, since we need to optimize those weights in the Mstep. There are exponential number of terms in the partition function , which makes it intractable to directly optimize the ELBO. To tackle this problem, we adopt the widely used pseudologlikelihood (Richardson and Domingos, 2006) as an alternative objective for optimization, which is defined as:
(7) 
where is the Markov blanket of the ground predicate , i.e., the set of ground predicates that appear in some grounding of a formula with . For each formula that connects to its Markov blanket, we optimize the formula weight by gradient descent, with the derivative:
(8) 
where or if is an observed fact, and otherwise. With the independence property of Markov Logic Networks, the gradients of the logic formulae weights can be efficiently computed on the Markov blanket of each variable.
For the Mstep, we design a different sampling scheme to make it computationally efficient. For each variable in the Markov blanket, we take the truth value if it’s observed and draw a sample from the variational posterior if it’s latent. In the Mstep, the ELBO of a fully observed ground formula depends on the formula weight, thus we need to consider all the fully observed ground formulae. It is computationally intractable to use all possible ground predicates to compute the gradients in Eq. 8. To tackle this challenge, we simply consider all the ground formulae with at most one latent predicate, and pick up the ground predicate if its truth value determines the formula’s truth value. Therefore, we keep a small subset of ground predicates, each of which can directly determine the truth value of a ground formula. Intuitively, this small subset contains all representative ground predicates, and makes good estimation of the gradients with much cheaper computational cost.
5 Inference Network Design: ExpressGNN
In the neural variational EM framework, the key component is the posterior model, or the inference network. We need to design the inference network that is both expressive and efficient to approximate the true posterior distribution. A recent concurrent work Qu and Tang (2019) uses a flattened embedding table as the entity representation to model the posterior. However, such simple posterior model is not able to capture the structure knowledge encoded in the knowledge graph. We employ graph neural networks with tunable embeddings to design our inference network. We also investigate the expressive power of GNN from theoretical perspective, which justifies our design.
Our inference network, named ExpressGNN, consists of three parts: the first part is a vanilla graph neural network (GNN), the second part uses tunable embeddings, and the third part uses the embeddings to define the variational posterior. For simplicity, we assume that each predicate has two arguments (i.e., consider only ). We design each part as follows:

We build a GNN on the knowledge graph , which is much smaller than the ground graph of MLN (see comparison in Fig. 2). The computational graph of the GNN is given in Algorithm 1. The GNN parameters and are shared across the entire graph and independent of the number of entities. Therefore, the GNN is a compact model with parameters given dimensional embeddings, .

For each entity in the knowledge graph, we augment its GNN embedding with a tunable embedding as . The tunable embeddings increase the expressiveness of the model. As there are entities, the number of parameters in tunable embeddings is .

We use the augmented embeddings of and to define the variational posterior. Specifically, , where . The number of parameters in is .
In summary, ExpressGNN can be viewed as a twolevel encoding of the entities: the compact GNN assigns similar embeddings to similar entities in the knowledge graph, while the expressive tunable embeddings provide additional model capacity to encode entityspecific information beyond graph structures. The overall number of trainable parameters in ExpressGNN is . By tuning the embedding size and , ExpressGNN can tradeoff between the model compactness and expressiveness. For largescale problems with a large number of entities ( is large), ExpressGNN can save a lot of parameters by reducing .
5.1 Expressive power of GNN as inference network
The combination of GNN and tunable embeddings makes the model sufficiently expressive to approximate the true posterior distributions. Here we provide theoretical analysis on the expressive power of GNN in the meanfield inference problem, and discuss the benefit of combining GNN and tunable embeddings in ExpressGNN.
Recent studies (Shervashidze et al., 2011; Xu et al., 2018) show that the vanilla GNN embeddings can represent the results of graph coloring, but fail to represent the results of the more strict graph isomorphism check, i.e., GNN produces the same embedding for some nodes that should be distinguished. We first demonstrate this problem by a simple example:
Example. Fig. 3 involves four entities (A, B, E, F), two predicates (Friend: , Like: ), and one formula (). In this example, MLN variables have different posteriors, but GNN embeddings result in the same posterior representation. More specifically,

Entity and have opposite relations with , i.e., versus in the knowledge graph, but running GNN on the knowledge graph will always produce the same embeddings for and , i.e., .

and apparently have different posteriors. However, using GNN embeddings, is always identical to .
We can formally prove that solving the problem in the above example requires the graph embeddings to distinguish any nonisomorphic nodes in the knowledge graph. A formal statement is provided below (see Appendix E for the proof).
Definition 5.1.
Two ordered sequences of nodes and are isomorphic in a graph if there exists an isomorphism such that .
theoremthmautomorphism Two latent variables and have the same posterior distribution in any MLN if and only if the nodes and are isomorphic in the knowledge graph . Implied by the theorem, to obtain an expressive enough representation for the posterior, we need a more powerful GNN variant. A recent work has proposed a powerful GNN variant (Maron et al., 2019), which can handle small graphs such as chemical compounds and protein structures, but it is computationally expensive due to the usage of highdimensional tensors. As a simple yet effective solution, ExpressGNN augments the vanilla GNN with additional tunable embeddings, which is a tradeoff between the compactness and expressiveness of the model.
In summary, ExpressGNN has the following nice properties:

Efficiency: ExpressGNN directly works on the knowledge graph, instead of the huge MLN grounding graph, making it much more efficient than the existing MLN inference methods.

Compactness: The compact GNN model with shared parameters can be very memory efficient, making ExpressGNN possible to handle industryscale problems.

Expressiveness: The GNN model can capture structure knowledge encoded in the knowledge graph. Meanwhile, the tunable embeddings can encode entityspecific information, which compensates for GNN’s deficiency in distinguishing nonisomorphic nodes.

Generalizability: With the GNN embeddings, ExpressGNN may generalize to new entities or even different but related knowledge graphs unseen during training time without the need for retraining.
6 Experiments
Benchmark datasets. We evaluate ExpressGNN and other baseline methods on four benchmark datasets: UWCSE (Richardson and Domingos, 2006), Cora (Singla and Domingos, 2005), synthetic Kinship datasets, and FB15K237 (Toutanova and Chen, 2015) constructed from Freebase (Bollacker et al., 2008). Details and full statistics of the benchmark datasets are provided in Appendix B.
General settings. We conduct all the experiments on a GPUenabled (Nvidia RTX 2080 Ti) Linux machine powered by Intel Xeon Silver 4116 processors at 2.10GHz with 256GB RAM. We implement ExpressGNN using PyTorch and train it with Adam optimizer (Kingma and Ba, 2014). To ensure a fair comparison, we allocate the same computational resources (CPU, GPU and memory) for all the experiments. We use the default tuned hyperparameters for competitor methods, which can reproduce the experimental results reported in their original works.
Model hyperparameters. For ExpressGNN, we use 0.0005 as the initial learning rate, and decay it by half for every 10 epochs without improvement of validation loss. For Kinship, UWCSE and Cora, we run ExpressGNN with a fixed number of iterations, and use the smallest subset from the original split for hyperparameter tuning. For FB15K237, we use the original validation set to tune the hyperparameters. We use a twolayer MLP with ReLU activation function as the nonlinear transformation for each embedding update step in the GNN model. We learn different MLP parameters for different steps. To increase the model capacity of ExpressGNN, we also use different MLP parameters for different edge type, and for a different direction of embedding aggregation. For each dataset, we search the configuration of ExpressGNN on either the validation set or the smallest subset. The configuration we search includes the embedding size, the split point of tunable embeddings and GNN embeddings, the number of embedding update steps, and the sampling batch size. For the inference experiments, the weights for all the logic formulae are fixed as 1. For the learning experiments, the weights are initialized as 1. For the choice of in the combined objective in Eq. 6, we set for the inference experiments, since the query predicates are never seen in the training data and no supervision is available. For the learning experiments, we set .
6.1 Comparison to MLN inference methods and ablation study
We first evaluate the inference accuracy and efficiency of ExpressGNN. We compare our method with several strong MLN inference methods on UWCSE, Cora and Kinship datasets. We also conduct ablation study to explore the tradeoff between GNN and tunable embeddings.
Experiment settings. For the inference experiments, we fix the weights of all logic rules as 1. A key advantage of MLN is that it can handle openworld setting in a consistent probabilistic framework. Therefore, we adopt openworld setting for all the experiments, as opposed to closedworld setting where unobserved facts (except the query predicates) are assumed to be false. We also report the performance under closedworld setting in Appendix C.
Prediction tasks. The deductive logic inference task is to answer queries that typically involve single predicate. For example in UWCSE, the task is to predict the AdvisedBy(,) relation for all persons in the set. In Cora, the task is to deduplicate entities, and one of the query predicates is SameAuthor(,). As for Kinship, the task is to predict whether a person is male or female, i.e., Male(). For each possible substitution of the query predicate with different entities, the model is tasked to predict whether it’s true or not.
Evaluation metrics. Following existing studies (Richardson and Domingos, 2006; Singla and Domingos, 2005), we use area under the precisionrecall curve (AUCPR) to evaluate the inference accuracy. To evaluate the inference efficiency, we use wallclock running time in minutes.
Competitor methods. We compare our method with several strong MLN inference algorithms, including MCMC (Gibbs Sampling; Gilks et al. (1995); Richardson and Domingos (2006)), Belief Propagation (BP; Yedidia et al. (2001)), Lifted Belief Propagation (Lifted BP; Singla and Domingos (2008)), MCSAT (Poon and Domingos, 2006) and HingeLoss Markov Random Field (HLMRF; Bach et al. (2015); Srinivasan et al. (2019)).
Inference accuracy. The results of inference accuracy on three benchmark datasets are reported in Table 1. A hyphen in the entry indicates that it is either out of memory or exceeds the time limit (24 hours). We denote our method as ExpressGNNE since only the Estep is needed for the inference experiments. Note that since the lifted BP is guaranteed to get identical results as BP (Singla and Domingos, 2008), the results of these two methods are merged into one row. For these experiments, ExpressGNNE uses 64dim GNN embeddings and 64dim tunable embeddings. On Cora, all the baseline methods fail to handle the data scale under openworld setting, and ExpressGNNE achieves good inference accuracy. On UWCSE, ExpressGNNE consistently outperforms all baselines. The Kinship dataset is synthesized and noisefree, and the number of entities increases linearly on the five sets S1–S5. HLMRF achieves perfect accuracy for S1–S4, but is infeasible on the largest set S5. ExpressGNNE yields similar but not perfect results, which is presumably caused by the stochastic nature of our sampling and optimization procedure.
Method  Kinship  UWCSE  Cora  

S1  S2  S3  S4  S5  AI  Graphics  Language  Systems  Theory  (avg)  
MCMC  0.53                     
BP / Lifted BP  0.53  0.58  0.55  0.55  0.56  0.01  0.01  0.01  0.01  0.01   
MCSAT  0.54  0.60  0.55  0.55    0.03  0.05  0.06  0.02  0.02   
HLMRF  1.00  1.00  1.00  1.00    0.06  0.06  0.02  0.04  0.03   
ExpressGNNE  0.97  0.97  0.99  0.99  0.99  0.09  0.19  0.14  0.06  0.09  0.64 
Inference efficiency. The inference time corresponding to the experiments in Table 1 is summarized in Fig. 4. On UWCSE (left table), ExpressGNNE uses much shorter time for inference compared to all the baseline methods, and meanwhile ExpressGNNE achieves the best inference performance. On Kinship (right figure), as the data size grows linearly from S1 to S5, the inference time of most baseline methods grows exponentially, while ExpressGNNE maintains a nearly constant time cost, demonstrating its nice scalability. Some baseline methods such as MCMC and MCSAT become infeasible for larger sets. HLMRF maintains a comparatively short inference time, however, it has a huge increase of memory cost and is not able to handle the largest set S5.

Configuration  Cora  

S1  S2  S3  S4  S5  
Tune64  0.57  0.74  0.34  0.55  0.70 
GNN64  0.57  0.58  0.38  0.54  0.53 
GNN64+Tune4  0.61  0.75  0.39  0.54  0.70 
Tune128  0.62  0.76  0.42  0.60  0.73 
GNN128  0.60  0.59  0.45  0.55  0.61 
GNN64+Tune64  0.62  0.79  0.46  0.57  0.75 
Ablation study. ExpressGNN can tradeoff the compactness and expressiveness of model by tuning the dimensionality of GNN and tunable embeddings. We perform ablation study on the Cora dataset to investigate how this tradeoff affects the inference accuracy. Results of different configurations of ExpressGNNE are shown in Table 2. It is observed that GNN64+Tune4 has comparable performance with Tune64, but is consistently better than GNN64. Note that the number of parameters in GNN64+Tune4 is , while that in Tune64 is . When the number of entities is large, GNN64+Tune4 has much less parameters to train. This is consistent with our theoretical analysis result: As a compact model, GNN saves a lot of parameters, but GNN alone is not expressive enough. A similar conclusion is observed for GNN64+Tune64 and Tune128. Therefore, ExpressGNN seeks a combination of two types of embeddings to possess the advantage of both: having a compact model and being expressive. The best configuration of their embedding sizes can be varied on different tasks, and determined by the goal: getting a portable model or better performance.
6.2 Comparison to knowledge base completion methods
We evaluate ExpressGNN in the knowledge base completion task on the FB15K237 dataset, and compare it with stateoftheart knowledge base completion methods.
Experiment settings. To generate logic rules, we use Neural LP (Yang et al., 2017) on the training set and pick up the candidates with top confidence scores. See Appendix D for examples of selected logic rules. We evaluate both inferenceonly and inferenceandlearning version of ExpressGNN, denoted as ExpressGNNE and ExpressGNNEM, respectively.
Prediction task. For each test query with respect to relation , the model is tasked to generate a rank list over all possible instantiations of and sort them according to the model’s confidence on how likely this instantiation is true.
Evaluation metrics. Following existing studies (Bordes et al., 2013; Sun et al., 2019), we use filtered ranking where the test triples are ranked against all the candidate triples not appearing in the dataset. Candidate triples are generated by corrupting the subject or object of a query . For evaluation, we compute the Mean Reciprocal Ranks (MRR), which is the average of the reciprocal rank of all the truth queries, and Hits@10, which is the percentage of truth queries that are ranked among the top 10.
Competitor methods. Since none of the aforementioned MLN inference methods can scale up to this dataset, we compare ExpressGNN with a number of stateoftheart methods for knowledge base completion, including Neural Tensor Network (NTN; Socher et al. (2013)), Neural LP (Yang et al., 2017), DistMult (Kadlec et al., 2017), ComplEx (Trouillon et al., 2016), TransE (Bordes et al., 2013), RotatE (Sun et al., 2019) and pLogicNet (Qu and Tang, 2019). The results of MLN and pLogicNet are directly taken from the paper Qu and Tang (2019). For all the other baseline methods, we use publicly available code with the provided best hyperparameters to run the experiments.
Model  MRR  Hits@10  

0%  5%  10%  20%  100%  0%  5%  10%  20%  100%  
MLN          0.10          16.0 
NTN  0.09  0.10  0.10  0.11  0.13  17.9  19.3  19.1  19.6  23.9 
Neural LP  0.01  0.13  0.15  0.16  0.24  1.5  23.2  24.7  26.4  36.2 
DistMult  0.23  0.24  0.24  0.24  0.31  40.0  40.4  40.7  41.4  48.5 
ComplEx  0.24  0.24  0.24  0.25  0.32  41.1  41.3  41.9  42.5  51.1 
TransE  0.24  0.25  0.25  0.25  0.33  42.7  43.1  43.4  43.9  52.7 
RotatE  0.25  0.25  0.25  0.26  0.34  42.6  43.0  43.5  44.1  53.1 
pLogicNet          0.33          52.8 
ExpressGNNE  0.42  0.42  0.42  0.44  0.45  53.1  53.1  53.3  55.2  57.3 
ExpressGNNEM  0.42  0.42  0.43  0.45  0.49  53.8  54.6  55.3  55.6  60.8 
Model  MRR  Hits@10 

NTN  0.001  0.0 
Neural LP  0.010  2.7 
DistMult  0.004  0.8 
ComplEx  0.013  2.2 
TransE  0.003  0.5 
RotatE  0.006  1.5 
ExpressGNNE  0.181  29.3 
ExpressGNNEM  0.185  29.6 
Performance analysis. The experimental results on the full training data are reported in Table 4 (100% columns). Both ExpressGNNE and ExpressGNNEM significantly outperform all the baseline methods. With learning the weights of logic rules, ExpressGNNEM achieves the best performance. Compared to MLN, ExpressGNN achieves much better performance since MLN only relies on the logic rules while ExpressGNN can also leverage the labeled data as additional supervision. Compared to knowledge graph embedding methods such as TransE and RotatE, ExpressGNN can leverage the prior knowledge in logic rules and outperform these purely datadriven methods.
Data efficiency. We investigate the data efficiency of ExpressGNN and compare it with baseline methods. Following (Yang et al., 2017), we split the knowledge base into facts / training / validation / testing sets, and vary the size of the training set from 0% to 100% to feed the model with complete facts set for training. From Table 4, we see that ExpressGNN performs significantly better than the baselines on smaller training data. With more training data as supervision, datadriven baseline methods start to close the gap with ExpressGNN. This clearly shows the benefit of leveraging the knowledge encoded in logic rules when there data is insufficient for supervised learning.
Zeroshot relational learning. In practical scenarios, a large portion of the relations in the knowledge base are longtail, i.e., most relations may have only a few facts (Xiong et al., 2018). Therefore, it is important to investigate the model performance on relations with insufficient training data. We construct a zeroshot learning dataset based on FB15K237 by forcing the training and testing data to have disjoint sets of relations. Table 4 shows the results. As expected, the performance of all the supervised relational learning methods drop to almost zero. This shows the limitation of such methods when coping with sparse longtail relations. Neural LP is designed to handle new entities in the test set (Yang et al., 2017), but still struggles to perform well in zeroshot learning. In contrast, ExpressGNN leverages both the prior knowledge in logic rules and the neural relational embeddings for reasoning, which is much less affected by the scarcity of data on longtail relations. Both variants of our framework (ExpressGNNE and ExpressGNNEM) achieve significantly better performance.
7 Conclusion
This paper studies the probabilistic logic reasoning problem, and proposes ExpressGNN to combine the advantages of Markov Logic Networks in logic reasoning and graph neural networks in graph representation learning. ExpressGNN addresses the scalability issue of Markov Logic Networks with efficient stochastic training in the variational EM framework. ExpressGNN employs GNNs to capture the structure knowledge that is implicitly encoded in the knowledge graph, which serves as supplement to the knowledge from logic formulae. ExpressGNN is a general framework that can tradeoff the model compactness and expressiveness by tuning the dimensionality of the GNN and the embedding part.
Acknowledgements
We acknowledge grants from NSF IIS1218749, NIH BIGDATA 1R01GM108341, NSF CAREER IIS1350983, NSF IIS1639792 EAGER, NSF IIS1841351 EAGER, NSF CNS1704701, ONR N000141512340, Intel ISTC, Nvidia, Google, Amazon AWS and Siemens. We thank Hyunsu Park for his insightful discussions and help on experiments. We thank the anonymous reviewers for their helpful and thoughtful comments. Yuyu Zhang is supported by the Siemens FutureMaker Fellowship.
Appendix
Appendix A Counter Examples
We provide more examples in this section to show that it is more than a rare case that GNN embeddings alone are not expressive enough.
a.1 Example 1
Unlike the example shown in main text, where A and B have OPPOSITE relation with E, Fig. 5 shows a very simple example where A and B have exactly the same structure which makes A and B indistinguishable and isomorphic. However, since (A,E) and (B,E) are not isomorphic, it can be easily seen that has different posterior from .
a.2 Example 2
Fig. 6 shows an example which is the same as in Fig. 3. However, in this example, it is already revealed in the knowledge base that and have different local structures as they are connected by different observations. That is, and can be distinguished by GNN.
Now, we use another example in Fig. 7 to show that even when the local structures are the same, the posteriors can still be different, which is caused by the formulae.
In Fig. 7, and have the same local structure, so that the tuple and can NOT be distingushed by GNN. However, we can make use of subgraph to define a formula, and then the resulting MLN gives different posterior to and , as can be seen from the figure. Note that this construction of MLN is the same as the construction steps stated in the proof in Sec. E.
Appendix B Dataset Details
For our experiments, we use the following benchmark datasets:

The social network dataset UWCSE (Richardson and Domingos, 2006) contains publicly available information of students and professors in the CSE department of UW. The dataset is split into five sets according to the home department of the entities.

The entity resolution dataset Cora (Singla and Domingos, 2005) consists of a collection of citations to computer science research papers. The dataset is also split into five subsets according to the field of research.

We introduce a synthetic dataset that resembles the popular Kinship dataset (Denham, 1973). The original dataset contains kinship relationships (e.g., Father, Brother) among family members in the Alyawarra tribe from Central Australia. The synthetic dataset closely resembles the original Kinship dataset but with a controllable number of entities. To generate a dataset with entities, we randomly split entities into two groups which represent the first and second generation respectively. Within each group, entities are grouped into a few subgroups representing the sister and brotherhood. Finally, entities from different subgroups in the first generation are randomly coupled and a subgroup in the second generation is assigned to them as their children. To generate the knowledge base, we traverse this family tree, and record all kinship relations for each entity. We generate five kinship datasets (Kinship S1–S5) by linearly increasing the number of entities.

The knowledge base completion benchmark FB15K237 (Toutanova and Chen, 2015) is a generic knowledge base constructed from Freebase (Bollacker et al., 2008), which is designed to a more challenging variant of FB15K. More specifically, FB15K237 is constructed by removing nearduplicate and inverse relations from FB15K. The dataset is split into training / validation / testing and we use the same split of facts from training as in prior work (Yang et al., 2017).
The complete statistics of these datasets are shown in Table 5. Examples of logic formulae used in four benchmark datasets are listed in Table 7.
Dataset  # entity  # relation  # fact  # query  # ground  # ground 

predicate  formula  
FB15K237  15K  237  272K  20K  50M  679B 
KinshipS1  62  15  187  38  50K  550K 
KinshipS2  110  15  307  62  158K  3M 
KinshipS3  160  15  482  102  333K  9M 
KinshipS4  221  15  723  150  635K  23M 
KinshipS5  266  15  885  183  920K  39M 
UWCSEAI  300  22  731  4K  95K  73M 
UWCSEGraphics  195  22  449  4K  70K  64M 
UWCSELanguage  82  22  182  1K  15K  9M 
UWCSESystems  277  22  733  5K  95K  121M 
UWCSETheory  174  22  465  2K  51K  54M 
CoraS1  670  10  11K  2K  175K  621B 
CoraS2  602  10  9K  2K  156K  431B 
CoraS3  607  10  18K  3K  156K  438B 
CoraS4  600  10  12K  2K  160K  435B 
CoraS5  600  10  11K  2K  140K  339B 
Appendix C Inference with ClosedWorld Semantics for Baseline Methods
Method  Cora  UWCSE  

S1  S2  S3  S4  S5  AI  Graphics  Language  Systems  Theory  
MCMC  0.43  0.63  0.24  0.46  0.56  0.19  0.04  0.03  0.15  0.08 
BP / Lifted BP  0.44  0.62  0.24  0.45  0.57  0.21  0.04  0.01  0.14  0.05 
MCSAT  0.43  0.63  0.24  0.46  0.57  0.13  0.04  0.03  0.11  0.08 
HLMRF  0.60  0.78  0.52  0.70  0.81  0.26  0.18  0.06  0.27  0.19 
In Sec. 6.1 we compare ExpressGNN with five probabilistic inference methods under openworld semantics. This is different from the original works, where they generally adopt the closedworld setting due to the scalability issues. More specifically, the original works assume that the predicates (except the ones in the query) observed in the knowledge base is closed, meaning for all instantiations of these predicates that do not appear in the knowledge base are considered false. Note that only the query predicates remain openworld in this setting.
For sanity checking, we also conduct these experiments with a closedworld setting. We found the results summarized in Table 6 are close to those reported in the original works. This shows that we have a fair setup (including memory size, hyperparameters, etc.) for those competitor methods. Additionally, one can find that the AUCPR scores compared to those (Table 1) under openworld setting are actually better. This is due to the way the datasets were originally collected and evaluated generally complies with the closedworld assumption. But this is very unlikely to be true for realworld and largescale knowledge base such as Freebase and WordNet, where many true facts between entities are not observed. Therefore, in general, the openworld setting is much more reasonable, which we follow throughout this paper.
Appendix D Logic Formulae
We list some examples of logic formulae used in four benchmark datasets in Table 7. The full list of logic formulae is available in our source code repository. Note that these formulae are not necessarily as clean as being always true, but are typically true.
For UWCSE and Cora, we use the logic formulae provided in the original dataset. UWCSE provides 94 handcoded logic formulae, and Cora provides 46 handcoded rules. For Kinship, we handcode 22 firstorder logic formulae. For FB15K237, we first use Neural LP (Yang et al., 2017) on the full data to generate candidate rules. Then we select the ones that have confidence scores higher than 90% of the highest scored formulae sharing the same target predicate. We also deduplicate redundant rules that can be reduced to other rules by switching the logic variables. Finally, we have generated 509 logic formulae for FB15K237.
Dataset  Firstorder Logic Formulae 

Kinship  
UWCSE  
Cora  
FB15K237  
Appendix E Proof of Theorem
First, we restate the definition and theorem in a more mathematical form:
Definition. [Isomorphic Nodes] Two ordered sequences of nodes and are isomorphic in a graph if there exists an isomorphism from to itself, i.e., , such that . Further, we use the following notation
Theorem. Consider a knowledge base and any . Two latent random variables and have the same posterior distribution in any MLN if and only if .
Then we give the proof as follows.
Proof.
A graph isomorphism from to itself is called automorphism, so in this proof, we will use the terminology  automorphism  to indicate such a selfbijection.
We first prove the sufficient condition:
If automorphism on the graph such that ,  
then for any , and have the same posterior in any MLN. 
MLN is a graphical model that can also be represented by a factor graph where ground predicates (random variables) and ground formulae (potential) are connected. We will show that an automorphism on MLN such that . Then the sufficient condition is true. This automorphism is easy to construct using the automorphism on . More precisely, we define as
(9) 
for any predicate , any assignments to its arguments, any formula , and any assignments to its arguments. It is easy to see is an automorphism:

Since is a bijection, apparently is also a bijection.

The above definition preserves the biding of the arguments. and are connected if and only if and are connected.

Given the definition of , we know that and have the same observation value. Therefore, in MLN, .
This completes the proof of the sufficient condition.
To prove the necessary condition, it is equivalent to show the following assumption
(A 1): there is no automorphism on the graph such that , 
can imply:
there must exists a MLN and a predicate in it such that  
and have different posterior. 
Before showing this, let us first introduce the factor graph representation of a single logic formula .
A logic formula can be represented as a factor graph, , where nodes on one side of the graph is the set of distinct constants needed in the formula, while nodes on the other side is the set of predicates used to define the formula. The set of edges, , will connect constants to predicates or predicate negation. That is, an edge between node and predicate exists, if the predicate use constant in its th argument. We note that the set of distinctive constants used in the definition of logic formula are templates where actual constant can be instantiated from . An illustration of logic formula factor graph can be found in Fig. 8. Similar to the factor graph for the knowledge base, we also differentiate the type of edges by the position of the argument.
Therefore, every single formula can be represented by a factor graph. We will construct a factor graph representation to define a particular formula, and show that the MLN induced by this formula will result in different posteriors for and . The factor graph for the formula is constructed in the following way (see Fig. 7 as an example of the resulting formula constructed using the following steps):

Given the above assumption (A 1), we claim that:
a subgraph such that all subgraphs satisfy:
(Condition) if there exists an isomorphism satisfying after the observation values are IGNORED (that is, and are treated as the SAME type of nodes), then the set of fact nodes (observations) in these two graphs are different (that is, ).
The proof of this claim is given at the end of this proof.

Next, we use to define a formula . We first initialize the definition of the formula value as
(10) Then, we change in this formula to the negation if the observed value of is 0 in .
We have defined a formula using the above two steps. Suppose the MLN only contains this formula . Then
the two nodes and in this MLN must be distinguishable.
The reason is, in MLN, is connected to a ground formula , whose factor graph representation is . In this formula, all variables are observed in the knowledge base except for and and the observation set is . The formula value is
(11) 
Clarification: Eq. 10 is used to define a formula and in this equation can be replaced by other constants, while Eq. 11 represents a ground formula whose arguments are exactly . Based on (Condition), there is NO formula that contains has an observation set the same as . Therefore, and are distinguishable in this MLN.
Proof of claim:
We show the existence by constructing the subgraph in the following way:

First, we initialize the subgraph as . Given assumption (A 1) stated above, it is clear that
(S 1) subgraph , there is no isomorphism satisfying .

Second, we need to check wether the following case occurs:
(C 1) a subgraph such that (1) there EXISTS an isomorphism satisfying after the observation values are IGNORED (that is, and are treated as the same type of nodes); and (2) the set of factor nodes (observations) in these two graphs are the same (that is, ).

Third, we need to modify the subgraph if the case (C 1) is observed. Since , the only subgraph that will lead to the case is the maximal subgraph . The isomorphism is defined by ignoring the observation values, while the isomorphism in (S 1) is not ignoring them. Thus,
(S 1) and (C 1) a set of nodes such that for any isomorphism satisfying the conditions in (C 1), the range contains at least one node which has observation value 1.
Otherwise, it is easy to see a contradiction to statement (S 1).
(M 1) Modify the subgraph by . The nodes (and also their edges) in the set are removed.
For the new subgraph after the modification (M 1), the case (C 1) will not occur. Thus, we’ve obtained a subgraph that satisfies the conditions stated in the claim. Finally, we can remove the nodes that are not connected with (that is, there is no path between this node and any one of ). The remaining graph is connected to and still satisfies the conditions that we need.
∎
References
 Hingeloss markov random fields and probabilistic soft logic. arXiv preprint arXiv:1505.04406. Cited by: §2, §6.1.
 Relational inductive biases, deep learning, and graph networks. arXiv preprint arXiv:1806.01261. Cited by: §2.
 Freebase: a collaboratively created graph database for structuring human knowledge. In Proceedings of the 2008 ACM SIGMOD international conference on Management of data, pp. 1247–1250. Cited by: 4th item, §6.
 Translating embeddings for modeling multirelational data. In Advances in neural information processing systems, pp. 2787–2795. Cited by: §2, §6.2, §6.2.
 Discriminative embeddings of latent variable models for structured data. In International conference on machine learning, pp. 2702–2711. Cited by: §1, §2.
 The detection of patterns in alyawara nonverbal behavior. Ph.D. Thesis, University of Washington, Seattle.. Cited by: 3rd item.
 Graphical models and variational methods. Advanced mean field methodstheory and practice. MIT Press. Cited by: §4.
 Markov chain monte carlo in practice. Chapman and Hall/CRC. Cited by: §6.1.
 Stochastic variational inference. The Journal of Machine Learning Research 14 (1), pp. 1303–1347. Cited by: §4.1.
 Introduction to expert systems. Vol. 21. Cited by: §2.
 Knowledge base completion: baselines strike back. arXiv preprint arXiv:1705.10744. Cited by: §2, §6.2.
 Learning markov logic networks via functional gradient boosting. In 2011 IEEE 11th International Conference on Data Mining, pp. 320–329. Cited by: §2.
 Adam: a method for stochastic optimization. arXiv preprint arXiv:1412.6980. Cited by: §6.
 Semisupervised classification with graph convolutional networks. In ICLR, Cited by: §1, §2.
 Gated graph sequence neural networks. In ICLR, Cited by: §1.
 Provably powerful graph networks. arXiv preprint arXiv:1905.11136. Cited by: §5.1.
 Bottomup learning of markov logic network structure. In Proceedings of the 24th international conference on Machine learning, pp. 625–632. Cited by: §2.
 Inductive logic programming: theory and methods. The Journal of Logic Programming 19, pp. 629–679. Cited by: §2.
 Sound and efficient inference with probabilistic and deterministic dependencies. In AAAI, Vol. 6, pp. 458–463. Cited by: §2, §6.1.
 Joint inference in information extraction. In AAAI, Vol. 7, pp. 913–918. Cited by: §2.
 GMNN: graph Markov neural networks. In Proceedings of the 36th International Conference on Machine Learning, Long Beach, California, USA, pp. 5241–5250. Cited by: §2.
 Probabilistic logic neural networks for reasoning. arXiv preprint arXiv:1906.08495. Cited by: §2, §5, §6.2.
 Markov logic networks. Machine learning 62 (12), pp. 107–136. Cited by: 1st item, §1, §2, §4.1, §4.2, §6.1, §6.1, §6.
 Modeling relational data with graph convolutional networks. In European Semantic Web Conference, pp. 593–607. Cited by: §1, §2.
 Weisfeilerlehman graph kernels. Journal of Machine Learning Research 12 (Sep), pp. 2539–2561. Cited by: §5.1.
 Lifted firstorder belief propagation.. In AAAI, Vol. 8, pp. 1094–1099. Cited by: §2, §6.1, §6.1.
 Discriminative training of markov logic networks. In AAAI, Vol. 5, pp. 868–873. Cited by: 2nd item, §2, §6.1, §6.
 Entity resolution with markov logic. In Data Mining, 2006. ICDM’06. Sixth International Conference on, pp. 572–582. Cited by: §2.
 Memoryefficient inference in relational domains. In AAAI, Vol. 6, pp. 488–493. Cited by: §2.
 Reasoning with neural tensor networks for knowledge base completion. In Advances in neural information processing systems, pp. 926–934. Cited by: §2, §6.2.
 Lifted hingeloss markov random fields. Cited by: §6.1.
 Rotate: knowledge graph embedding by relational rotation in complex space. arXiv preprint arXiv:1902.10197. Cited by: §2, §6.2, §6.2.
 Relational markov networks. Introduction to statistical relational learning, pp. 175–200. Cited by: §2.
 Observed versus latent features for knowledge base and text inference. In Proceedings of the 3rd Workshop on Continuous Vector Space Models and their Compositionality, pp. 57–66. Cited by: 4th item, §6.
 Complex embeddings for simple link prediction. In International Conference on Machine Learning, pp. 2071–2080. Cited by: §2, §6.2.
 Oneshot relational learning for knowledge graphs. arXiv preprint arXiv:1808.09040. Cited by: §1, §6.2.
 How powerful are graph neural networks?. arXiv preprint arXiv:1810.00826. Cited by: §5.1.
 Differentiable learning of logical rules for knowledge base completion. CoRR, abs/1702.08367. Cited by: 4th item, Appendix D, §6.2, §6.2, §6.2, §6.2.
 Generalized belief propagation. In Advances in neural information processing systems, pp. 689–695. Cited by: §6.1.
 Identifying network public opinion leaders based on markov logic networks. The scientific world journal 2014. Cited by: §2.