Effective Instruction Parsing Plugin for Complex Logical Query Answering on Knowledge Graphs

Xingrui Zhuo, Jiapu Wang, Gongqing Wu, Shirui Pan, Xindong Wu

Abstract

Knowledge Graph Query Embedding (KGQE) models are essential for reasoning over incomplete knowledge graphs (KGs). However, these models often suffer from pattern-entity alignment bias, where they fail to generalize logical patterns due to noisy or redundant entity type information. We present the Query Instruction Parsing Plugin (QIPP), a novel "plug-and-play" tool that translates complex logical queries into "code-like" instructions. By utilizing the linguistic common sense of pre-trained language models (PLMs) like BERT, QIPP captures underlying query logic more accurately than traditional methods. Our evaluations across multiple benchmarks demonstrate that QIPP significantly boosts the performance of various base KGQE models, achieving improvements of up to 40%.

Introduction

Knowledge Graphs (KGs) serve as structured repositories of facts, typically represented as triples like (Jim Zorn, coaches, Seattle Seahawks). Despite their utility, KGs are often incomplete. Knowledge Graph Query Embedding (KGQE) addresses this by mapping complex logical queries into a low-dimensional vector space to predict missing answers.

A significant challenge in KGQE is pattern-entity alignment bias. Previous attempts to mitigate this, such as Query Pattern Learning (QPL), relied on external entity types. However, these types are frequently noisy. For instance, a query about a "coach" might be confounded by the entity's other labels like "person" or "celebrity," preventing the model from isolating the core "coaching" logic. This limitation hinders the model's ability to generalize to unseen questions.

The QIPP Framework

QIPP moves away from noisy entity types by treating logical queries as structured, "code-like" instructions. This approach leverages the inherent logical understanding found in modern pre-trained language models.

Code-like Instructions

Instead of relying on abstract First-Order Logic (FOL) symbols ($\exists, \wedge, \neg$), QIPP represents queries as nested textual tuples. For example, a query about a coach not hired by a specific team is represented as (Jim Zorn, (CoachesTeam, OrganizationHiredPerson, negative)). This format is more intuitive for AI models trained on large-scale text.

Overview of the QIPP framework, showing the translation from natural language to code-like instructions.

Instruction Encoding and Decoding

QIPP employs a shallow BERT model to encode these instructions. Pre-trained on massive corpora, BERT possesses a latent understanding of relationships between concepts (e.g., "coach" and "team"). The authors found that using only the initial layers of BERT is more effective for capturing logical structure than using the full, more abstract model. A multi-head attention decoder then allows the host KGQE model to extract and integrate these logic patterns.

Optimization and Normalization

To prevent overfitting and ensure fast convergence, QIPP uses Compressed Optimization Boundaries, fusing the logic pattern and query answer into a single supervised signal. Additionally, an Adaptive Normalization layer ensures compatibility with various KGQE architectures (e.g., those using boxes, cones, or distributions) by maintaining their specific geometric constraints.

Experimental Evaluation

The effectiveness of QIPP was evaluated on three standard KG benchmarks: FB15k-237, FB15k, and NELL995. The testing covered 14 distinct query types, including multi-hop projections, intersections, unions, and negations.

Key Results

  • Performance Boosts: QIPP provided massive gains for basic models. For the GQE model on the FB15k-237 dataset, performance increased by 40.55%.
  • State-of-the-Art Comparison: QIPP consistently outperformed existing QPL plugins like TEMP and CaQR across nearly all query types and datasets.
  • Robustness to Complexity: The plugin maintained high accuracy even for complex queries involving negation, a traditional weak point for many KGQE models.
  • Improved Logic Clustering: T-SNE visualizations revealed that QIPP creates distinct clusters for different query patterns, indicating a genuine understanding of question types rather than just entity memorization.

Insights and Conclusion

The success of QIPP highlights that text is a superior bridge for logic compared to noisy entity types. By converting mathematical queries into a format resembling code or natural language, researchers can tap into the "latent" logic of PLMs. Furthermore, the "plug-and-play" nature of QIPP makes it highly versatile, as demonstrated by its successful integration with eight different base models, ranging from geometric to iterative reasoning architectures.

While QIPP introduces some computational overhead due to the BERT-based encoder, the use of shallow layers mitigates this cost. Future research may explore deeper integration between PLMs and KG structures during pre-training and scaling the approach to massive KGs with millions of relations.

Summary updated

BibTeX
@inproceedings{zhuo2024effective,
  author = {Xingrui Zhuo and Jiapu Wang and Gongqing Wu and Shirui Pan and Xindong Wu},
  title = {{Effective Instruction Parsing Plugin for Complex Logical Query Answering on Knowledge Graphs}},
  booktitle = {The Web Conference},
  year = {2024},
}
Figure