Abstract
Link prediction is a crucial task in graph machine learning, where the goal is to infer missing or future links within a graph. Traditional approaches leverage heuristic methods based on widely observed connectivity patterns, offering broad applicability and generalizability without the need for model training. Despite their utility, these methods are limited by their reliance on human-derived heuristics and lack the adaptability of data-driven approaches. Conversely, parametric link predictors excel in automatically learning the connectivity patterns from data and achieving state-of-the-art but fail short to directly transfer across different graphs. Instead, it requires the cost of extensive training and hyperparameter optimization to adapt to the target graph. In this work, we introduce the Universal Link Predictor (UniLP), a novel model that combines the generalizability of heuristic approaches with the pattern learning capabilities of parametric models. UniLP is designed to autonomously identify connectivity patterns across diverse graphs, ready for immediate application to any unseen graph dataset without targeted training. We address the challenge of conflicting connectivity patterns—arising from the unique distributions of different graphs—through the implementation of In-context Learning (ICL). This approach allows UniLP to dynamically adjust to various target graphs based on contextual demonstrations, thereby avoiding negative transfer. Through rigorous experimentation, we demonstrate UniLP's effectiveness in adapting to new, unseen graphs at test time, showcasing its ability to perform comparably or even outperform parametric models that have been finetuned for specific datasets. Our findings highlight UniLP's potential to set a new standard in link prediction, combining the strengths of heuristic and parametric methods in a single, versatile framework.
Introduction
Link Prediction (LP)—predicting whether two nodes should be connected—is a foundational task in graph machine learning. Currently, researchers face a trade-off between two suboptimal paths: simple heuristics and parametric models like Graph Neural Networks (GNNs). While heuristics are broadly applicable, they are often too simplistic. Conversely, GNNs are powerful but "brittle"; a model trained on a social network often performs poorly on a biological network because the underlying connectivity patterns differ. This phenomenon, known as negative transfer, typically necessitates a full cycle of retraining and hyperparameter optimization for every new graph.
To address this, we introduce UniLP (Universal Link Predictor). UniLP treats link prediction as an In-Context Learning (ICL) task, allowing a single model to adapt to any graph's unique rules on the fly using a small set of example links as context.
Methodology
UniLP adapts to target graphs by conditioning its predictions on local demonstrations. The framework follows a structured pipeline to encode and compare structural patterns.
- Context Sampling: For any query link, the model samples known positive and negative links from the same graph to serve as demonstrations.
- Subgraph Encoding: Each link is represented by its "ego-subgraph." We utilize an enhanced labeling technique called DRNL+ to mark node positions relative to the target link, helping the model capture structural nuances.
- Label-Free Attention: A GraphSAGE GNN encodes these subgraphs. An attention mechanism then compares the query link's structure to the context examples. Crucially, this mechanism is "label-free," focusing purely on structural similarity to prevent the model from "cheating" during training.
- Prediction: The final prediction is a weighted combination of the context labels, allowing the model to dynamically "learn" the connectivity rules of the specific graph it is currently processing.
Theoretical Motivation: Overcoming Conflicting Patterns
A primary reason traditional transfer learning fails in link prediction is the existence of conflicting connectivity patterns across different graph topologies.
As illustrated above, structurally similar graphs can have opposite rules: in a grid, 2-hop neighbors never connect, while in a triangular lattice, they are highly likely to connect. By using in-context learning, UniLP performs "implicit optimization." It doesn't need to change its weights to understand that "in this specific graph, 2-hop neighbors are important."
Experimental Results
UniLP was tested in a "Zero-Shot" style, pretrained on one set of graphs and evaluated on entirely different domains (Biology, Transport, Social, Academic, and OGB benchmarks) without any fine-tuning.
- Superiority over Baselines: UniLP outperformed traditional heuristics and "Pretrain-Only" GNNs in the majority of major benchmarks.
- Beating Fine-tuned Models: Most impressively, UniLP often performed as well as—or better than—state-of-the-art models (like SEAL or NCNC) that were explicitly fine-tuned on the target datasets.
- The Power of Negative Examples: Research indicated that providing more negative context samples (non-links) often improved performance more than providing more positive ones, suggesting that learning what doesn't constitute a link is vital for defining a graph's unique structure.
Conclusion
UniLP demonstrates that the In-Context Learning revolution can be successfully brought to graph machine learning. By combining the generalizability of heuristics with the pattern-learning capabilities of parametric models, UniLP offers a versatile, training-free solution for link prediction on unseen graphs. Future work will focus on incorporating node attributes and improving the computational efficiency of subgraph extraction for large-scale applications.
Summary updated