NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

A Theory of Link Prediction via Relational Weisfeiler-Leman on Knowledge Graphs

Xingyue Huang, Miguel Romero Orth, Ismail Ilkan Ceylan, Pablo Barcelo

Graph neural networks (GNNs) are the go-to models for representation learning on graph-structured data. However, while their capabilities on simple graphs are well-understood, their application to knowledge graphs (KGs)—particularly for link prediction—has lacked a rigorous theoretical foundation. This paper bridges that gap by introducing a unifying framework called Conditional Message Passing Neural Networks (C-MPNNs). By linking these networks to the Weisfeiler-Leman (WL) isomorphism test and first-order logic, the authors mathematically prove why conditioning message passing on a source node is the secret to computing highly expressive pairwise representations.

Standard GNNs applied to knowledge graphs, often referred to as Relational Message Passing Neural Networks (R-MPNNs) like RGCN or CompGCN, are fundamentally designed to compute representations for individual nodes. However, link prediction is a pairwise task (e.g., "Is node A connected to node B via relation R?"). It is a known issue that simply combining two independently computed node embeddings often fails to capture the complex relational paths between them.

Recently, path-based models like NBFNets have achieved state-of-the-art results by computing pairwise representations directly, using algorithms inspired by Bellman-Ford shortest-path routing. While empirically successful, the theoretical landscape explaining why they work so well, and what their limitations are, has remained murky.

Introducing Conditional Message Passing (C-MPNNs)

To build a comprehensive theory, the authors introduce a unifying abstraction: Conditional Message Passing Neural Networks (C-MPNNs).

Comparison of R-MPNN and C-MPNN architectures

Instead of standard message passing, C-MPNNs compute representations of a target node conditioned on a specific source node and a query relation. As illustrated above, standard R-MPNNs compute independent node features ($h_u, h_v$) and decode them. In contrast, C-MPNNs use a clever initialization step (INIT) where the source node $u$ is labeled differently from the rest of the graph. Messages are then passed to compute a conditional representation $h_{v|u,q}$ at the target node $v$, which is directly decoded.

Theoretical Foundations: WL Tests and Logic

To measure the expressive power of C-MPNNs, the authors design a novel graph isomorphism test: the relational asymmetric local 2-WL (rawl2) algorithm. They mathematically prove that C-MPNNs are exactly as expressive as this test. Furthermore, they map the power of these networks to specific fragments of first-order logic, proving exactly which logical binary classifiers can be captured by C-MPNNs (specifically, a logic fragment denoted as $\text{rFO}^3_{\text{cnt}}$).

Key Theoretical Insights & Empirical Validation

The theoretical framework yields several practical insights that explain common design choices, which the authors validate across standard KG benchmarks (WN18RR, FB15k-237), biomedical KGs (Hetionet, ogbl-biokg), and a newly introduced synthetic dataset (TRI-SQR):

  • The Secret Sauce is Conditioning: The leap from standard GNNs to powerful link predictors relies on initialization. By initializing the source node with a unique identifier, the network shifts from computing unary invariants (node features) to binary invariants (pairwise features). In transductive tasks, C-MPNNs vastly outperformed standard R-MPNNs. On the massive Hetionet biomedical graph, a basic C-MPNN achieved a Mean Reciprocal Rank (MRR) of 0.479, compared to RGCN's 0.120.
  • History Doesn't Matter: NBFNets use a path-based update rule that ignores the target node's previous state ($f(t)=0$), while standard GNNs update based on the previous layer ($f(t)=t$). The authors prove that both approaches have the exact same expressive power. Empirically, C-MPNNs using standard history updates performed just as well as those using path-based updates, perfectly validating the theorem.
  • Inverse Relations are Provably Better: Practitioners often augment KGs with inverse edges (e.g., adding "is-child-of" if "is-parent-of" exists). This paper provides the formal proof that doing so strictly increases the model's expressive power.
  • Readouts Add Logical Power: Adding a global or relation-specific "readout" (aggregating features from the whole graph) allows the network to capture a strictly larger class of logical formulas. On FB15k-237, adding a relation-specific readout significantly boosted performance, pushing the architecture to state-of-the-art levels.

Limitations and Future Directions

While powerful, the C-MPNN framework is specifically tailored for binary tasks (pairs of nodes) and does not directly extend to higher-arity tasks like predicting links on relational hypergraphs or predicting the existence of larger substructures. Additionally, moving to even higher-order conditional variations of the WL algorithm to gain more expressive power becomes computationally prohibitive, highlighting the need for scalable approximations in future work.

Summary updated

BibTeX
@inproceedings{huang2023theory,
  author = {Xingyue Huang and Miguel Romero Orth and Ismail Ilkan Ceylan and Pablo Barcelo},
  title = {{A Theory of Link Prediction via Relational Weisfeiler-Leman on Knowledge Graphs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=7hLlZNrkt5},
}
Figure