TensorLog: Deep Learning Meets Probabilistic DBs

William W. Cohen, Fan Yang, Kathryn MazaitisarXiv 2017

Abstract

TensorLog is a framework that compiles probabilistic first-order logic into differentiable functions, enabling the seamless integration of symbolic reasoning with deep learning. By restricting logic programs to "polytree-limited" structures, TensorLog facilitates efficient, large-scale inference on standard neural network infrastructure such as TensorFlow.

Introduction

Artificial intelligence has historically been divided between two paradigms: connectionism (neural networks) and symbolism (logic). While deep learning excels at pattern recognition from raw data, it often struggles with complex relational reasoning. Conversely, probabilistic logics are adept at reasoning but suffer from the "grounding bottleneck"—the combinatorial explosion that occurs when converting logical rules into a format computers can process. This makes traditional symbolic systems too slow for large-scale data and incompatible with GPU-accelerated hardware.

TensorLog addresses this gap by creating a probabilistic logic designed to be "born" as a neural network.

Methodology

The core innovation of TensorLog lies in translating logical queries into matrix operations.

Polytree-Limited Logic

The authors identify a specific subset of logic termed polytree-limited stochastic deductive knowledge graphs (ptree-SDKGs). By ensuring the influence graph of variables in a rule forms a polytree (lacks cycles), inference becomes mathematically tractable.

Example of probabilistic logic rules and facts with associated weights in TensorLog.

Numeric Encoding and Belief Propagation

In TensorLog, entities are represented as one-hot vectors, and predicates (relationships) are represented as sparse matrices. For instance, a "parent" relationship is a matrix where entry $(i, j)$ denotes the probability that entity $i$ is the parent of entity $j$.

Instead of traditional theorem proving, TensorLog employs a message-passing algorithm called Belief Propagation. Because the logic is restricted to polytrees, this process can be "unrolled" into a fixed sequence of differentiable operations, such as matrix-vector multiplications and Hadamard products. This allows TensorLog to be embedded as a layer within larger neural architectures, enabling end-to-end training via backpropagation. This hybrid power allows for "soft" predicates, where the system learns weights for facts rather than just binary truth values.

Evaluation and Results

The framework was evaluated across several domains to test its speed, accuracy, and scalability, including social influence (Citeseer), relational learning (CORA, UMLS, WordNet), and large-scale question answering (WikiMovies).

Key Results

TensorLog demonstrated significant performance gains over traditional logic systems and specialized neural architectures:

  • Massive Speedups: On the "friends and smokers" task, TensorLog processed 3,327 nodes in 9.2 milliseconds, whereas ProbLog2 (a mature probabilistic logic system) required 40–50 seconds for only 20 nodes.
  • State-of-the-Art Accuracy: On the WikiMovies QA task, TensorLog achieved 95.0% accuracy, outperforming specialized architectures like Key-Value Memory Networks (93.9%).
  • Scalability: The system successfully scaled to problems involving hundreds of thousands of knowledge-base triples, a feat previously difficult for most probabilistic logic frameworks.

Discussion and Limitations

The primary insight of TensorLog is the tractability trade-off: by sacrificing a small amount of logical expressiveness (the polytree restriction), logical inference moves from #P-complete complexity to linear time. This allows logic to be treated as a giant, sparse neural network layer.

However, limitations remain. The polytree constraint prevents the representation of certain complex, loopy relational structures without approximation. Additionally, deep reasoning paths can lead to vanishing gradients, making optimization difficult and requiring careful tuning. Finally, compiling complex logic into TensorFlow can result in massive computational graphs that challenge GPU memory limits; for example, a 64x64 grid with deep recursion exceeded the memory of a 4GB GPU.

Conclusion

TensorLog represents a significant step toward unifying symbolic reasoning and deep learning. By making logic differentiable and efficient, it opens new avenues for hybrid AI systems capable of both high-level reasoning and robust pattern recognition.

Summary updated

BibTeX
@misc{cohen2017tensorlog,
  author = {William W. Cohen and Fan Yang and Kathryn Mazaitis},
  title = {{TensorLog: Deep Learning Meets Probabilistic DBs}},
  year = {2017},
  eprint = {1707.05390},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1707.05390},
}
Figure