[Paper Review] A Prompt-Based Knowledge Graph Foundation Model for Universal In-Context Reasoning
This paper proposes KG-ICL, a prompt-based knowledge graph foundation model that enables universal in-context reasoning across diverse, unseen knowledge graphs. By constructing query-relevant prompt graphs and using a unified tokenizer to generalize across entities and relations, KG-ICL employs two message-passing networks for prompt encoding and KG reasoning, achieving state-of-the-art performance on 43 datasets in both transductive and inductive settings.
Extensive knowledge graphs (KGs) have been constructed to facilitate knowledge-driven tasks across various scenarios. However, existing work usually develops separate reasoning models for different KGs, lacking the ability to generalize and transfer knowledge across diverse KGs and reasoning settings. In this paper, we propose a prompt-based KG foundation model via in-context learning, namely KG-ICL, to achieve a universal reasoning ability. Specifically, we introduce a prompt graph centered with a query-related example fact as context to understand the query relation. To encode prompt graphs with the generalization ability to unseen entities and relations in queries, we first propose a unified tokenizer that maps entities and relations in prompt graphs to predefined tokens. Then, we propose two message passing neural networks to perform prompt encoding and KG reasoning, respectively. We conduct evaluation on 43 different KGs in both transductive and inductive settings. Results indicate that the proposed KG-ICL outperforms baselines on most datasets, showcasing its outstanding generalization and universal reasoning capabilities. The source code is accessible on GitHub: https://github.com/nju-websoft/KG-ICL.
Motivation & Objective
- To address the lack of generalization and transferability in existing KG reasoning models across diverse knowledge graphs.
- To enable inductive reasoning over unseen entities and relations without requiring retraining or pre-trained embeddings.
- To overcome limitations of global relation graphs by focusing on local, query-relevant contexts through prompt graphs.
- To develop a unified representation framework that generalizes across different KGs using a shared tokenization scheme.
- To achieve zero-shot or few-shot reasoning capability across previously unseen KGs through in-context learning.
Proposed method
- Constructs a prompt graph centered on a query-related example fact, including neighboring entities and relational paths between subject and object.
- Introduces a unified tokenizer that maps entities and relations into shared token classes based on shortest-path distances to the query subject and object.
- Employs an entity-centric and relation-centric message passing mechanism in the prompt encoder to update representations using local context.
- Uses the learned prompt representations to initialize relation and entity embeddings in the target KG for downstream reasoning.
- Performs message passing over the full KG using the initialized representations to score candidate entities for the query.
- Leverages in-context learning by providing few-shot examples within the prompt graph, enabling zero-shot transfer to unseen KGs without fine-tuning.

Experimental results
Research questions
- RQ1Can a single foundation model generalize to reasoning over diverse, previously unseen knowledge graphs without retraining?
- RQ2How can local, query-relevant context be effectively captured to improve relation representation beyond global relation graphs?
- RQ3To what extent can a unified tokenization scheme enable transferability across KGs with different entity and relation vocabularies?
- RQ4Does in-context learning with prompt graphs outperform traditional inductive reasoning models on unseen entities and relations?
- RQ5Can the model maintain high performance across both transductive and inductive reasoning settings on a wide range of real-world KGs?
Key findings
- KG-ICL outperforms existing baselines on 43 different knowledge graphs across both transductive and inductive settings, demonstrating strong generalization.
- The model achieves an average MRR of 0.473 and H@10 of 0.638 across 43 datasets under the full candidate setting, indicating robust performance.
- On the NELL-995 dataset, KG-ICL achieves an MRR of 0.534 and H@10 of 0.672, outperforming prior methods in inductive reasoning.
- In the Metafam dataset, KG-ICL reaches 1.000 MRR and H@10, showing exceptional performance on a challenging, open-world benchmark.
- The model maintains strong performance on large-scale datasets with millions of facts, confirming its scalability and efficiency.
- Ablation studies show that the prompt graph and unified tokenizer are critical for generalization, with performance dropping significantly when removed.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.