Differentiable Learning of Logical Rules for Knowledge Base Reasoning

Fan Yang, Zhilin Yang, William W. Cohen

This NIPS 2017 paper by Fan Yang, Zhilin Yang, and William W. Cohen introduces Neural Logic Programming (Neural LP), a framework that bridges the gap between symbolic logic and deep learning. It represents a significant milestone in Statistical Relational Learning (SRL) by providing a method to learn logical rules from data using end-to-end gradient-based optimization.

TL;DR

Neural LP is the first end-to-end differentiable framework capable of learning both the structure (the rules themselves) and the parameters (the confidence of those rules) for knowledge base reasoning. By relaxing discrete logical steps into "soft" attention mechanisms over matrix operations, the model achieves state-of-the-art performance while remaining human-interpretable.

The Challenge of Knowledge Base Reasoning

Reasoning within a Knowledge Base (KB)—predicting new facts based on existing ones—traditionally falls into two distinct camps:

Example of logical rule reasoning
  1. Symbolic Logic: This approach involves learning first-order rules (e.g., inferring that a company has an office in a country if it has an office in a city located within that country). These rules are highly interpretable and generalize well to new entities. However, learning them is a "discrete" nightmare, typically requiring heuristic searches through an astronomical number of possible rule combinations.
  2. Knowledge Base Embeddings: Methods like TransE map entities and relations into continuous vector spaces. These are easy to optimize with standard gradient descent but act as "black boxes." Furthermore, they often fail in inductive settings—they cannot easily reason about new entities they didn't observe during training.

The authors tackle the challenge of combining the interpretability and generalization of symbolic logic with the efficient optimization of neural networks.

Methods: Differentiable Logical Inference

The core innovation of Neural LP is making the process of logical inference fully differentiable.

Neural LP Architecture
  • TensorLog Foundations: The model builds on TensorLog, which represents KB relations as sparse matrices. If you have a relation $R$, it becomes a matrix $M_R$. A logical "chain" of relations is then mathematically expressed as a sequence of matrix-vector multiplications.
  • The Neural Controller: Instead of hard-coding which relations to multiply, the authors use an LSTM-based controller. At each step $t$, the controller produces two key outputs:
  • Operator Attention ($a_t$): A "soft" selection (weighted sum) of all possible relation matrices in the KB.
  • Memory Attention ($b_t$): A "soft" selection of which previous intermediate results to use from memory.
  • Recurrent Formulation: By using these attention weights, the model can "softly" compose rules of varying lengths. Because every operation is a weighted sum of linear transformations, the entire path from the input query to the output answer is differentiable.
  • Rule Recovery: After training, the authors provide an algorithm to "de-compile" the high-attention weights back into standard, human-readable first-order logical rules.

Key Insights

  • Differentiable Structure Learning: The most profound insight is that you don't need to perform a discrete search to find a rule's structure. By using attention to "softly" choose relations, the gradient naturally pushes the model toward the most predictive logical paths.
  • Inductive Generalization: Because the model learns rules (relational patterns) rather than entity embeddings, it can perform "zero-shot" reasoning. If it learns a rule about how cities and countries relate, it can apply that rule to a brand-new city it has never seen before.
  • The "Soft" Logic Advantage: Unlike traditional Inductive Logic Programming (ILP), which often struggles with noisy data, Neural LP’s probabilistic nature allows it to assign confidences to rules, making it much more robust to real-world KB inconsistencies.

Key Results

The authors evaluated Neural LP across several diverse benchmarks, including biomedical data (UMLS), WordNet (WN18), Freebase (FB15K), and natural language QA (WikiMovies).

  • Superior Accuracy: On the UMLS dataset, Neural LP achieved a 93.2% Hits@10, more than doubling the performance of previous state-of-the-art rule learners like Iterative Structural Gradient (43.3%).
  • Robustness to Rule Length: In a synthetic Grid Path task requiring long-range rules, Neural LP successfully learned rules of length 6-8, whereas previous methods saw their accuracy plummet as path length increased.
  • Inductive Success: In tests where the training and testing entities were completely disjoint, Neural LP maintained high performance (e.g., 94.49% on WN18), while embedding models like TransE dropped to near 0%.
  • State-of-the-Art QA: On the WikiMovies dataset, it outperformed Key-Value Memory Networks, reaching 94.6% accuracy.

Limitations and Future Work

  • Scalability: While the authors used a heuristic to limit the search space (top 128 relations), applying this to KBs with millions of distinct relations remains a computational challenge due to the memory requirements of large sparse matrix multiplications.
  • Rule Complexity: The current framework is optimized for "chain-like" rules. It is less clear how it would handle more complex logical structures involving multiple variables or recursion.
  • Natural Language Integration: While it performed well on WikiMovies, the mapping from natural language to the neural controller's input was relatively simple (mean of word embeddings). More sophisticated NLP front-ends could further enhance its utility.

Summary updated

BibTeX
@inproceedings{yang2017differentiable,
  author = {Fan Yang and Zhilin Yang and William W. Cohen},
  title = {{Differentiable Learning of Logical Rules for Knowledge Base Reasoning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2017},
  url = {https://openreview.net/forum?id=r1biGvZd-S},
}
Figure