LukasZahradnik/PyNeuraLogic
PyNeuraLogic lets you use Python to create Differentiable Logic Programs
What it solves
Traditional deep learning requires designing fixed tensor operations, which makes it hard to express relational structures like graphs or databases. PyNeuraLogic lets you define neural networks as logic programs, so you can write declarative rules that describe how information flows. This makes it easier to build expressive models that go beyond standard graph neural networks, such as hypergraphs, relational databases, or subgraph patterns, without hand-coding every operation.
How it works
You write Python code that declares logical variables, relations, and rules. For example, a GNN propagation rule looks like msg2(X) <= (msg1(Y), edge(Y,X)). The NeuraLogic backend compiles these rules into differentiable computation graphs, making inference equivalent to forward propagation in deep learning. You can attach learnable weight matrices to rules and specify aggregation and activation functions, turning them into trainable neural layers. The backend automatically creates the underlying computation graphs, so you don't need to align everything into static tensor operations.
Who it's for
Researchers and practitioners working on graph neural networks, relational learning, neural-symbolic integration, or anyone who wants to define deep models at a high level of logical abstraction instead of low-level tensor manipulations. It's also useful for teaching and prototyping declarative model designs.
Highlights
- Declarative, readable model definitions using logic programming
- Predefined modules for common architectures: GCNConv, SAGEConv, GINConv, RGCNConv, MetaConv, Transformer, LSTM, GRU, RNN, and more
- Goes beyond graphs: hypergraphs, nested graphs, relational databases, subgraph patterns
- Automatic construction of differentiable computation graphs
- Benchmarks show it is considerably faster than popular GNN frameworks for tasks like molecular learning
- Optional PyTorch integration
- Jupyter notebook examples for XOR, molecular GNNs, recursive generalization, pattern matching, and visualization
Related
- Project
- Project
- Project
- Project
- Project