Abstract
We demonstrate a declarative differentiable programming framework based on the language of Lifted Relational Neural Networks (LRNNs), where small parameterized logic programs are used to encode relational learning scenarios. When presented with relational data, such as various forms of graphs, the program interpreter dynamically unfolds differentiable computational graphs to be used for program parameter optimization. Following from the used declarative Datalog abstraction, this results in compact and elegant learning programs, in contrast with existing procedural approaches operating directly on the computational graph level. We illustrate how this idea can be used for an efficient encoding of a diverse range of existing advanced neural architectures, with a particular focus on Graph Neural Networks (GNNs). Additionally, we show how contemporary GNN models can be easily extended towards higher relational expressiveness. In experiments, we demonstrate correctness and computation efficiency through comparison against specialized GNN deep learning frameworks, while shedding light on the learning performance of existing GNN models.
Introduction
Deep learning on structured data—such as molecules, social networks, or knowledge bases—is currently dominated by Graph Neural Networks (GNNs). However, building these models in standard procedural frameworks like PyTorch or TensorFlow requires significant engineering effort. Developers must manually wire up tensor operations, manage sparse matrices, and define complex message-passing loops.
If a researcher wants to extend a standard GNN to handle richer data—such as edge features, multiple relation types, or hypergraphs—it often requires substantial custom data transformations. This paper introduces a declarative, differentiable programming framework using Lifted Relational Neural Networks (LRNNs) to address these challenges. By writing simple logic programs instead of procedural code, researchers can prototype and extend GNNs to handle complex structures with minimal overhead.
Methods: Declarative Relational Programming
The authors utilize LRNNs to define neural architectures as "templates" using a weighted version of Datalog, a declarative logic programming language.
Declarative Templating
In the LRNN framework, neural architectures are defined as logical rules where literals have learnable tensor weights. For example, the core message-passing step of a Graph Convolutional Network (GCN) can be expressed in a single line of logic:
W :: h(V) :- h(U), edge(V,U).
This abstraction allows the user to focus on the relational structure rather than the underlying matrix mathematics.
Dynamic Unfolding
When the system is provided with an input graph (represented as logical facts), an underlying theorem prover dynamically "unfolds" these rules to construct a custom, differentiable computation graph specific to that exact input. This approach makes extending a GNN trivial; for instance, learning edge representations simply requires adding a variable to the rule: W :: h(V) :- h(U), edge(V,U,E).
Key Insights
- GNNs as Relational Logic: The "aggregate and combine" mechanism of GNNs maps perfectly to relational logic patterns. Viewing convolutions as logical rules abstracts away messy tensor manipulations.
- Native Flexibility: Because hypergraphs, heterogeneous networks, and multi-hop relationships are native concepts in relational logic, LRNNs can model them out-of-the-box without inventing new tensor operations.
- Efficiency in Sparsity: Modern frameworks rely on vectorization and padding for GPU processing. However, for small, irregular, and sparse graphs (like molecules), the overhead of these transformations can be slower than directly traversing the spatial graph structure, which LRNNs do natively on the CPU.
Experimental Evaluation
The authors evaluated the framework on the National Cancer Institute (NCI) molecular datasets, a collection of 73 datasets labeled for tumor growth inhibition. The task was graph-level structure property prediction.
Results
- Correctness: LRNNs perfectly matched the training curves of reference implementations in PyTorch Geometric (PyG) and Deep Graph Library (DGL) for standard models like GCN, GraphSAGE, and GIN.
- CPU Speed: When training on a CPU with a batch size of 1, LRNNs trained a GCN in 0.25 seconds per epoch, compared to PyG (3.24s) and DGL (23.25s). This 10x to 100x speedup is driven by avoiding Python overhead and sparse tensor transformation bottlenecks.
- Generalization: While complex models like GIN achieved lower training errors, they did not consistently outperform simpler models like GCNs on test accuracy across the NCI datasets, suggesting a plateau in the practical utility of increased model complexity for these tasks.
Limitations and Future Work
Despite its advantages, the LRNN framework has notable limitations. There is a significant startup compilation time (35–75 seconds) as the theorem prover builds the computation graphs. Furthermore, the current engine lacks native GPU support and mini-batching, which are necessary for scaling to massive datasets. Finally, while LRNNs excel at isotropic message passing, they cannot yet naturally express non-isotropic constructs like LSTMs or attention mechanisms without ad-hoc modifications.
Conclusion
LRNNs provide an elegant, declarative alternative to procedural GNN development. By leveraging the power of logic programming, the framework allows for rapid prototyping and extension of relational models, offering superior performance on small, sparse datasets while maintaining mathematical rigor.
Summary updated