Join-Chain Network: A Logical Reasoning View of the Multi-head Attention in Transformer

Jianyi Zhang, Yiran Chen, Jianshu Chen

Abstract

This paper introduces the Join-Chain Network to bridge the gap between the expressive power of deep neural networks and the interpretability of symbolic logic. By demonstrating that Multi-Head Self-Attention (MHSA) is a neural implementation of a logical "join" operator, the authors provide a formal reasoning framework for the Transformer's success in natural language processing. They prove that Transformers are naturally "pre-wired" to handle the tree-structured logic inherent in human language.

Introduction

While Deep Neural Networks (DNNs) like Transformers have revolutionized artificial intelligence, they are frequently criticized as "black boxes" due to their lack of inherent interpretability. Conversely, traditional symbolic logic systems, such as Inductive Logic Programming, offer high interpretability but struggle to scale because the search for logical rules is computationally expensive.

This research seeks to bridge this divide by designing a neural architecture that is as expressive as a DNN yet as interpretable as a logical system. The authors investigate whether the success of the Transformer architecture stems from a hidden ability to perform logical reasoning on the structures found in natural language.

The Join-Chain Network and FOET

The authors introduce two foundational concepts to facilitate this bridge:

  1. The Join-Chain Network: A symbolic reasoning architecture that chains together "join operators." In logic, a join operation—for example, $P(x) = \exists y W(x, y) \wedge P(y)$—allows a system to derive new information by linking a binary relationship ($W$) with a unary property ($P$).
  2. First-Order Tree-structured expressions (FOET): A specific subset of first-order logic that can be represented as trees. The authors mathematically prove that the Join-Chain Network can express any logical statement within the FOET class.

Re-interpreting Multi-Head Self-Attention as Logic

The core of the paper is a logical re-interpretation of Multi-Head Self-Attention (MHSA). The authors map the standard attention formula ($Z = AV$) directly to the logical join operation:

  • The Attention Matrix ($A$): Acts as a learned binary predicate, representing the relationships between words or tokens.
  • The Value Tensor ($V$): Acts as a learned unary predicate, representing the properties of those tokens.
  • The Output ($Z$): Represents the result of the logical join.

This mapping suggests that the matrix multiplication in self-attention is mathematically equivalent to calculating the "union bound" of a logical join within a probabilistic space.

Key Insights

Why Transformers Excel at Language

Human language is often represented by dependency trees. Because the Join-Chain Network (and by extension, the Transformer) is optimized for tree-structured logic (FOET), it is naturally suited to handle the syntax and hierarchical nature of natural language.

The Logic of Skip Connections

While residual (skip) connections are typically justified by "gradient flow" in deep learning, this framework provides a logical justification: they are necessary to pass intermediate reasoning results forward to later stages of the chain.

Multi-Head Parallelism

Multi-head attention allows the model to evaluate multiple different logical relationships (predicates) simultaneously at the same position, increasing the breadth of the reasoning process.

Theoretical Results

The authors provide formal proofs in Theorems 3.1 and 3.2, showing that a Join-Chain Network with $H$ heads and $L$ layers can express any logical predicate in the FOET class with a specific width and height. This structural mapping provides a formal "logical reasoning view" of the Transformer that explains its expressiveness through the lens of symbolic reasoning.

Limitations and Future Work

Despite the breakthrough in interpretability, several challenges remain:

  • Tree-Structure Constraint: The current theory is limited to tree-structured logic, whereas real-world reasoning often involves complex graph structures with cycles.
  • Variable Complexity: The model currently handles binary predicates (relationships between two variables). Processing relationships between three or more variables remains a significant challenge.
  • Model Compression: The authors suggest that because logical operations often decrease in number as one moves up a reasoning tree, it may be possible to compress Transformers by reducing the number of attention heads in deeper layers.
  • New Operators: The mapping suggests that there may be even more efficient neural operators specifically designed for the "join" task that could eventually replace standard attention mechanisms.

Summary updated

BibTeX
@inproceedings{zhang2022join,
  author = {Jianyi Zhang and Yiran Chen and Jianshu Chen},
  title = {{Join-Chain Network: A Logical Reasoning View of the Multi-head Attention in Transformer}},
  booktitle = {Workshops @ ICDM},
  year = {2022},
  url = {https://openreview.net/forum?id=qZiWWibPnM},
}
Figure