Pathformer: Recursive Path Query Encoding for Complex Logical Query Answering

Chongzhi Zhang, Zhiping Peng, Junhao Zheng, Linghao Wang, Ruifeng Shi, Qianli MaarXiv 2024 · DOI

Abstract

Pathformer is a novel neural embedding method designed to answer complex logical queries over incomplete Knowledge Graphs (KGs). By decomposing tree-like query graphs into path sequences and using a Transformer to encode them recursively, it captures bidirectional dependencies that traditional sequential models miss, setting new performance benchmarks for multi-hop reasoning.

Introduction

Knowledge Graphs (KGs) such as Freebase or NELL provide structured representations of world knowledge but are often incomplete. Answering Complex Logical Queries (CLQA)—which involve multiple entities, relations, and logical operators like AND ($\wedge$), OR ($\vee$), and NOT ($\neg$)—requires robust reasoning over these missing links.

Existing Query Embedding (QE) methods typically map queries into a continuous vector space. However, many "historical" models process queries link-by-link, failing to capture the full context. While recent Transformer-based approaches attempt to address this, they often suffer from "structural information loss" by failing to preserve the underlying graph topology.

Methodology: The Pathformer Architecture

Pathformer addresses these challenges through a "divide and conquer" strategy that bridges graph structure and sequence modeling.

Query Tree Decomposition

The model views a complex logical query as a tree-like computation graph. It decomposes this tree into individual path query sequences (extending from anchor entities to intersection points) and fork queries (where multiple paths converge).

Figure 1: Decomposition of a complex logical query into a tree-like computation graph and path/fork queries.

Path Query Encoder (PQE) and Recursive Encoding

Instead of step-by-step processing, Pathformer employs a Path Query Encoder (PQE) based on a Transformer architecture. The bidirectional attention mechanism allows the representation of intermediate entities to incorporate context from both the starting anchor and the target goal.

When multiple paths meet at a "fork" (representing an intersection or conjunction), an MLP aggregates their embeddings. This process is applied recursively until the final answer node embedding is generated in the vector space.

Figure 2: The Pathformer architecture and workflow, illustrating the recursive encoding of path queries and the PQE structure.

Handling Negation

Pathformer handles logical negation by introducing a special [Negation] token into the sequence. This allows the model to learn set-complement operations directly within the embedding space, a capability often lacking in standard graph-based Transformers.

Experimental Evaluation

The model was evaluated on two standard KG reasoning benchmarks: FB15k-237 and NELL995. Testing covered both Existential Positive First Order (EPFO) queries and queries involving negation.

Key Results

  • State-of-the-Art Performance: Pathformer outperformed competitive neural QE methods (e.g., GQE, Query2box, BetaE). On FB15k-237, it achieved an average Mean Reciprocal Rank (MRR) of 24.2%, a new benchmark for one-point models.
  • Structural Advantage: It significantly outperformed BIQE, demonstrating that recursive path encoding is superior to whole-graph encoding with positional embeddings.
  • Scalability and Efficiency: Performance improved with the addition of Transformer layers (up to 8). Despite the complexity, training efficiency remained comparable to simpler MLP-based models.

Discussion and Future Work

A key insight of Pathformer is that "future context" is critical; knowing the constraints of a query's goal helps refine the search for intermediate entities. By combining sequence modeling with recursive merging, Pathformer preserves graph topology without complex positional encodings.

Currently, Pathformer is limited to tree-like computation graphs and cannot handle cyclic queries. Future research may focus on extending the architecture to cyclic structures and further refining the interaction between the [Negation] token and the embedding geometry.

Summary updated

BibTeX
@misc{zhang2024pathformer,
  author = {Chongzhi Zhang and Zhiping Peng and Junhao Zheng and Linghao Wang and Ruifeng Shi and Qianli Ma},
  title = {{Pathformer: Recursive Path Query Encoding for Complex Logical Query Answering}},
  year = {2024},
  eprint = {2406.14880},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.14880},
}
Figure