A Foundation Model for Zero-shot Logical Query Reasoning

Mikhail Galkin, Jincheng Zhou, Bruno Ribeiro, Jian Tang, Zhaocheng Zhu

TL;DR

ULTRAQUERY is the first foundation model for zero-shot complex logical query answering that generalizes to any knowledge graph, even those with entirely new entities and relations. By decoupling reasoning from specific vocabularies, a single model trained on one dataset can outperform specialized baselines across 23 diverse benchmarks.

What Problem Does This Paper Address?

Reasoning over Knowledge Graphs (KGs) typically involves answering complex logical queries—questions that require multiple steps of traversal (projections) and logical operations like "AND" (intersection), "OR" (union), and "NOT" (negation).

The major bottleneck in current Complex Logical Query Answering (CLQA) is transductivity. Most models learn specific embeddings for every entity and relation in a graph. If you want to apply a model trained on a medical KG to a music KG, it fails because the "vocabulary" (the set of entities and relations) is completely different. Even "inductive" models often only handle new entities, still requiring a fixed set of relations.

This paper tackles the "hardest" inductive setup: performing zero-shot reasoning on graphs where both entities and relations are entirely new at inference time.

Figure 2: The inductive logical query answering setup where training and inference graphs (and queries) have different entity and relation vocabu- laries. We propose a single model (ULTRAQUERY) that zero-shot generalizes to query answering on any graph with new entity or relation vocabulary at inference time.

Methods

The authors introduce ULTRAQUERY, which achieves vocabulary independence through two key components:

  1. Inductive Relation Projection: Instead of learning fixed IDs for relations, ULTRAQUERY uses a meta-graph approach (based on the ULTRA model). It represents relations by how they interact structurally (e.g., "head-to-tail" or "tail-to-head" patterns). This allows the model to understand the role of a new relation based on its local graph structure without ever having seen it before.
  2. Non-parametric Logical Operators: Rather than learning neural network parameters for "AND" or "OR," the model uses fuzzy logic (specifically product t-norms and co-norms). These are fixed mathematical operations that work on scalar scores between 0 and 1, making them naturally generalizable to any graph.

A significant challenge identified is the multi-source propagation issue. In simple link prediction, you start from one node. In complex queries, intermediate steps might yield multiple "likely" nodes, causing uncertainty to snowball. The authors address this by fine-tuning the projection operator on complex queries to handle multiple starting points.

Figure 3: (a) Example of ip query answering with ULTRAQUERY: the inductive parametric projection operator (Section 4.1) executes relation projections on any graph and returns a scalar score for each entity; the scores are aggregated by non-parametric logical operators (Section 4.2) implemented with fuzzy logics. Intermediate scores are used for weighted initializion of relation projections on the next hop. (b) The multi-source propagation issue with a pre-trained link predictor for relation projection: pre-training on 1p link prediction is done in the single-source labeling mode (top) where only one query node is labeled with a non-zero vector; complex queries at later intermediate hops might have several plausible sources with non-zero initial weights (bottom) where a pre-trained operator fails.

Datasets

The model was evaluated on a massive suite of 23 datasets:

  • 3 Transductive datasets: Standard benchmarks like FB15k-237 and NELL995.
  • 9 Inductive (entity) datasets: Where inference graphs have new entities but the same relations as training.
  • 11 Inductive (entity & relation) datasets: A new suite curated by the authors called WikiTopics-CLQA, derived from Wikipedia topics (e.g., Art, Health, Sport) to test the hardest generalization setup.

Key Insights and Ideas

  • Reasoning is Structural, Not Lexical: The core "aha moment" is that logical reasoning on graphs depends more on structural patterns than on the specific names of entities or relations. A model can learn "how to reason" independently of "what" it is reasoning about.
  • Zero-Shot Foundation Power: A single ULTRAQUERY model trained only on the FB15k-237 dataset can generalize to 22 other graphs, often outperforming models specifically trained on those graphs.
  • Multi-Source Shift: There is a significant distribution shift between simple link prediction (1-hop) and CLQA (multi-hop). Link predictors are "single-source" experts, but complex queries require "multi-source" expertise to manage the fuzzy sets of intermediate answers.

Key Results

  • Superior Performance: Across 23 datasets, a single zero-shot ULTRAQUERY model outperformed the best available baselines by 50% relative MRR on standard logical queries (EPFO) and by 70% on queries involving negation.
  • New State-of-the-Art: It set a new SOTA on 15 of the 23 datasets.
  • Faithfulness: The model maintains high "faithfulness," meaning it reliably recovers "easy" answers (those reachable by simple graph traversal) even in the zero-shot setting.
  • Scalability: Performance does not degrade as the inference graph grows larger (up to 550% more entities than the training graph).
Figure 1: Zero-shot query answering performance (MRR, higher is better) of a single ULTRAQUERY model trained on one FB15k237 queries dataset compared to the best available baselines and ablated ULTRAQUERY LP on 23 datasets. EPFO is the average of 9 query types with (∧, ∨) operators, Negation is the average of 5 query types with the negation operator (¬). On average, a single ULTRAQUERY model outperforms the best baselines trained specifically on each dataset. More results are presented in Table 2 and Appendix C.

Limitations and Future Work

  • Multi-Source Propagation: While addressed, this remains a difficult area. Better pre-training strategies or thresholding mechanisms could further improve how uncertainty flows through long query chains.
  • Scaling to Millions: While promising, the current GNN backbone might need to be replaced with more scalable architectures (like A*Net) to handle industrial-scale KGs with millions of nodes.
  • Query Complexity: Future work could extend this to even more complex query types, such as those involving numerical literals, temporal constraints, or non-tree structures.

Summary updated

Abstract

Complex logical query answering (CLQA) in knowledge graphs (KGs) goes beyond simple KG completion and aims at answering compositional queries comprised of multiple projections and logical operations. Existing CLQA methods that learn parameters bound to certain entity or relation vocabularies can only be applied to the graph they are trained on which requires substantial training time before being deployed on a new graph. Here we present UltraQuery, the first foundation model for inductive reasoning that can zero-shot answer logical queries on any KG. The core idea of UltraQuery is to derive both projections and logical operations as vocabulary-independent functions which generalize to new entities and relations in any KG. With the projection operation initialized from a pre-trained inductive KG reasoning model, UltraQuery can solve CLQA on any KG after finetuning on a single dataset. Experimenting on 23 datasets, UltraQuery in the zero-shot inference mode shows competitive or better query answering performance than best available baselines and sets a new state of the art on 15 of them.
BibTeX
@inproceedings{galkin2024foundation,
  author = {Mikhail Galkin and Jincheng Zhou and Bruno Ribeiro and Jian Tang and Zhaocheng Zhu},
  title = {{A Foundation Model for Zero-shot Logical Query Reasoning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=JRSyMBBJi6},
}
Figure