LPFormer: An Adaptive Graph Transformer for Link Prediction
Abstract
Link prediction is a common task on graph-structured data that has seen applications in a variety of domains. Classically, hand-crafted heuristics were used for this task. Heuristic measures are chosen such that they correlate well with the underlying factors related to link formation. In recent years, a new class of methods has emerged that combines the advantages of message-passing neural networks (MPNN) and heuristics methods. These methods perform predictions by using the output of an MPNN in conjunction with a ``pairwise encoding'' that captures the relationship between nodes in the candidate link. They have been shown to achieve strong performance on numerous datasets. However, current pairwise encodings often contain a strong inductive bias, using the same underlying factors to classify all links. This limits the ability of existing methods to learn how to properly classify a variety of different links that may form from different factors. To address this limitation, we propose a new method, LPFormer, which attempts to adaptively learn the pairwise encodings for each link. LPFormer models the link factors via an attention module that learns the pairwise encoding that exists between nodes by modeling multiple factors integral to link prediction. Extensive experiments demonstrate that LPFormer can achieve SOTA performance on numerous datasets while maintaining efficiency. The code is available at The code is available at https://github.com/HarryShomer/LPFormer.
Benchmark Results
Tested on 3 datasets 2 baseline values reported too low
Tables show presented results in global context (best 3 papers + GCN + MLP).
OGB
| # | Model | Hits@50 ↑ | Paper |
|---|---|---|---|
| 1 | PROXI | 0.7650
±0.0027 | |
| 2 | OGB Leader | 0.7129
±0.0018 | |
| 3 | GIDN | 0.7096
±0.0055 | |
| 6 | LPFormer | 0.6814
±0.0051 | This paper |
| 9 | GCN | 0.6621
±0.0033 best reported | best at pub: GNNBenchmark (JMLR 2023) best today: On the Impact of Feature Heterophily on Link Prediction with Graph Neural Networks (NeurIPS 2024) |
| 23 | AA | 0.6435 | This paper |
| 26 | RA | 0.6400 | This paper |
| 28 | SAGE | 0.5944
±0.0137 best reported | best at pub: Pairwise Learning for Neural Link Prediction (2021) best today: PROXI: Challenging the GNNs for Link Prediction (TMLR 2024) |
| 41 | GraphSAGE | 0.5463
±0.0112 | |
| 94 | MLP | 0.4438
±0.0347 |
| # | Model | Hits@100 ↑ | Paper |
|---|---|---|---|
| 1 | OGB Leader | 0.6524
±0.0150 | |
| 2 | PRB | 0.6347
±0.0175 | |
| 3 | LPFormer | 0.6332
±0.0063 | This paper |
| 14 | SAGE | 0.5013
±0.0055 | |
| 23 | MLP | 0.4600 | |
| 39 | AA | 0.3245 | This paper |
| # | Model | MRR ↑ | Paper |
|---|---|---|---|
| 1 | CFG | 0.8997
±0.0015 | |
| 2 | SIEG | 0.8987
±0.0018 | |
| 3 | LPFormer | 0.8981
±0.0013 | This paper |
| 12 | GCN | 0.8705
±0.0004 | |
| 71 | MLP | 0.3917
±0.0044 |
