KGPFN: Unlocking the Potential of Knowledge Graph Foundation Model via In-Context Learning
Knowledge graphs (KGs) are essential for representing complex relational data, but traditional models often struggle to generalize to new, unseen graphs without being retrained from scratch. While recent foundation models have made progress in learning transferable relational patterns, they often overlook "in-context learning"—the ability of a model to adapt its predictions based on a few examples provided at inference time. KGPFN addresses this gap by introducing a framework that combines general relational knowledge with structured, context-aware reasoning, allowing the model to adapt to new graphs instantly without needing further fine-tuning.
Bridging Local and Global Context
To reason effectively, KGPFN treats context as a two-part system. First, it captures "local context," which consists of the immediate neighborhood around a query entity. This is crucial because the same relational pattern might be valid in one part of a graph but misleading in another; the local neighborhood provides the necessary evidence to decide whether a pattern should be applied or overridden. Second, it captures "global context" by retrieving a set of representative instances of the query relation from across the graph. This provides a broader view of how a relation typically behaves, helping the model understand the typical structural constraints associated with that specific relation.
The Prior-Data Fitted Network Approach
KGPFN utilizes the Prior-data Fitted Network (PFN) paradigm to process this context. Instead of relying on static, pre-learned entity embeddings, the model is trained to perform "amortized Bayesian inference." During inference, it takes the query and a set of labeled context examples—both local and global—and processes them through a series of attention mechanisms. By combining feature-level and sample-level attention, the model learns to weigh the importance of different context examples, effectively "learning" the task at hand in a single forward pass.
Performance and Generalization
The model’s architecture includes a multi-layer NBFNet to encode local neighborhoods and a message-passing framework to learn transferable relation representations. By pretraining on a diverse set of knowledge graphs, KGPFN learns to identify when to rely on reusable structural patterns and when to prioritize the specific evidence provided in the context. Experiments across 57 different benchmarks demonstrate that this approach is highly effective, consistently outperforming competitive models that require fine-tuning. This confirms that incorporating structured in-context learning is a powerful strategy for building more flexible and capable knowledge graph foundation models.
Comments (0)
to join the discussion
No comments yet
Be the first to share your thoughts!