Plain Transformers are Surprisingly Powerful Link Predictors
Organizations: Department of Computer Science and Engineering, Michigan State University, East Lansing, MI, USA. · Snap Inc., Bellevue, WA, USA.
Abstract
Link prediction is a core challenge in graph machine learning, demanding models that capture rich and complex topological dependencies. While Graph Neural Networks (GNNs) are the standard solution, state-of-the-art pipelines often rely on explicit structural heuristics or memory-intensive node embeddings -- approaches that struggle to generalize or scale to massive graphs. Emerging Graph Transformers (GTs) offer a potential alternative but often incur significant overhead due to complex structural encodings, hindering their applications to large-scale link prediction. We challenge these sophisticated paradigms with PENCIL, an encoder-only plain Transformer that replaces hand-crafted priors with attention over sampled local subgraphs, retaining the scalability and hardware efficiency of standard Transformers. Through experimental and theoretical analysis, we show that PENCIL extracts richer structural signals than GNNs, implicitly generalizing a broad class of heuristics and subgraph-based expressivity. Empirically, PENCIL outperforms heuristic-informed GNNs and is far more parameter-efficient than ID-embedding--based alternatives, while remaining competitive across diverse benchmarks -- even without node features. Our results challenge the prevailing reliance on complex engineering techniques, demonstrating that simple design choices are potentially sufficient to achieve the same capabilities. Our code is publicly available at https://github.com/quang-truong/pencil.
Figures & tables
| Type | Model | cora | citeseer | pubmed | ogbl-collab | ogbl-ppa | ogbl-citation2 |
|---|---|---|---|---|---|---|---|
| MRR | MRR | MRR | H@50 | H@100 | MRR | ||
| SEAL | 26.69 ± 5.89 | 39.36 ± 4.99 | 38.06 ± 5.18 | 63.37 ± 0.69 | 48.80 ± 5.61 | 86.93 ± 0.43 | |
| Neo-GNN | 22.65 ± 2.60 | 53.97 ± 5.88 | 31.45 ± 3.17 | 66.13 ± 0.61 | 48.45 ± 1.01 | 83.54 ± 0.32 | |
| BUDDY | 26.40 ± 4.40 | 59.48 ± 8.96 | 23.98 ± 5.11 | 64.59 ± 0.46 | 47.33 ± 1.96 | 87.86 ± 0.18 | |
| NCN | 32.93 ± 3.80 | 54.97 ± 6.03 | 35.65 ± 4.60 | 63.86 ± 0.51 | 62.63 ± 1.15 | 89.27 ± 0.05 | |
| NCNC | 29.01 ± 3.83 | 64.03 ± 3.67 | 25.70 ± 4.48 | 65.97 ± 1.03 | 62.61 ± 0.76 | 89.82 ± 0.43 |
| Type | Model | cora | citeseer | pubmed | ogbl-collab | ogbl-ppa | ogbl-ddi | ogbl-citation2 |
|---|---|---|---|---|---|---|---|---|
| SEAL | 10.67 ± 3.46 | 13.16 ± 1.66 | 5.88 ± 0.53 | 6.43 ± 0.32 | 29.71 ± 0.71 | 9.99 ± 0.90 | 20.60 ± 1.28 | |
| Neo-GNN | 13.95 ± 0.39 | 17.34 ± 0.84 | 7.74 ± 0.30 | 5.23 ± 0.90 | 21.68 ± 1.14 | 10.86 ± 2.16 | 16.12 ± 0.25 | |
| BUDDY | 13.71 ± 0.59 | 22.84 ± 0.36 | 7.56 ± 0.18 | 5.67 ± 0.36 | 27.70 ± 0.33 | 12.43 ± 0.50 | 19.17 ± 0.20 | |
| NCN | 14.66 ± 0.95 | 28.65 ± 1.21 | 5.84 ± 0.22 | 5.09 ± 0.38 | 35.06 ± 0.26 | 12.86 ± 0.78 | 23.35 ± 0.28 | |
| NCNC | 14.98 ± 1.00 | 24.10 ± 0.65 | 8.58 ± 0.59 | 4.73 ± 0.86 | 33.52 ± 0.26 | N/A | 19.61 ± 0.54 | |
| LPFormer | 16.80 ± 0.52 | 26.34 ± 0.67 | 9.99 ± 0.52 | 7.62 ± 0.26 | 40.25 ± 0.24 | 13.20 ± 0.54 | 24.70 ± 0.55 |
Appendix figures & tables17 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | COMB | AGG | ||||||
|---|---|---|---|---|---|---|---|---|
| Pure GNN | / | 1-WL | / | / | / | / | / | |
| NCN | 1-WL | 1-WL | 1 | |||||
| ELPH | 1-WL | 1-WL | m | |||||
| Neo-GNN | 1-WL | with | 1-WL | m | ||||
| SEAL | / | / | / | m | ||||
| PENCIL | / | / | / | with | m |
| Hyperparameter | GNNs | PENCIL |
|---|---|---|
| Sampling Configuration | (2, 20) | (2, 20) |
| Hidden Size | 512 | 256 |
| Intermediate Size | N/A | 512 |
| # Attention Heads | N/A | 4 |
| Effective Batch Size | 2048 | 2048 |
| Learning Rate | 2.0E-04 | 2.0E-04 |
| Hyperparameter | cora | citeseer | pubmed | ogbl-collab | ogbl-ppa | ogbl-citation2 |
|---|---|---|---|---|---|---|
| Sampling Configuration | (2, 20) | (2, 20) | (2, 16) | (1, 75) | (1, 150) | (1, 40) |
| Hidden Size | 512 | 1024 | 512 | 512 | 512 | 512 |
| Intermediate Size | 2048 | 2048 | 2048 | 2048 | 2048 | 2048 |
| # Layers | 8 | 2 | 8 | 8 | 4 | 3 |
| # Attention Heads | 8 | 8 | 8 | 8 | 8 | 8 |
| Effective Batch Size | 2048 | 2048 | 4096 | 8192 | 16384 | 65536 |
| Hyperparameter | cora | citeseer | pubmed | ogbl-collab | ogbl-ppa | ogbl-citation2 | ogbl-ddi |
|---|---|---|---|---|---|---|---|
| Sampling Configuration | (2, 20) | (2, 20) | (2, 20) | (1, 75) | (1, 150) | (1, 40) | (1, 350) |
| Hidden Size | 512 | 1024 | 512 | 512 | 512 | 512 | 512 |
| Intermediate Size | 2048 | 2048 | 2048 | 2048 | 2048 | 2048 | 2048 |
| # Layers | 4 | 2 | 4 | 8 | 4 | 3 | 8 |
| # Attention Heads | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
| Effective Batch Size | 2048 | 2048 | 2048 | 8192 | 16384 | 65536 | 4096 |
| Type | Model | cora | citeseer | pubmed | ogbl-collab | ogbl-ppa | ogbl-citation2 |
|---|---|---|---|---|---|---|---|
| MRR | MRR | MRR | H@50 | H@100 | MRR | ||
| CN | 20.99 ± 0.00 | 28.34 ± 0.00 | 14.02 ± 0.00 | 61.37 ± 0.00 | 27.65 ± 0.00 | 74.30 ± 0.00 | |
| AA | 31.87 ± 0.00 | 29.37 ± 0.00 | 16.66 ± 0.00 | 64.17 ± 0.00 | 32.45 ± 0.00 | 75.96 ± 0.00 | |
| RA | 30.79 ± 0.00 | 27.61 ± 0.00 | 15.63 ± 0.00 | 63.81 ± 0.00 | 49.33 ± 0.00 | 76.04 ± 0.00 | |
| SEAL | 26.69 ± 5.89 | 39.36 ± 4.99 | 38.06 ± 5.18 | 63.37 ± 0.69 | 48.80 ± 5.61 | 86.93 ± 0.43 | |
| Neo-GNN | 22.65 ± 2.60 | 53.97 ± 5.88 | 31.45 ± 3.17 | 66.13 ± 0.61 | 48.45 ± 1.01 | 83.54 ± 0.32 |
| Type | Model | cora | citeseer | pubmed | ogbl-collab | ogbl-ppa | ogbl-ddi | ogbl-citation2 |
|---|---|---|---|---|---|---|---|---|
| CN | 9.78 ± 0.00 | 8.42 ± 0.00 | 2.28 ± 0.00 | 4.20 ± 0.00 | 25.70 ± 0.00 | 6.71 ± 0.00 | 17.11 ± 0.00 | |
| AA | 11.91 ± 0.00 | 10.82 ± 0.00 | 2.63 ± 0.00 | 5.07 ± 0.00 | 26.85 ± 0.00 | 6.97 ± 0.00 | 17.83 ± 0.00 | |
| RA | 11.81 ± 0.00 | 10.84 ± 0.00 | 2.47 ± 0.00 | 6.29 ± 0.00 | 28.34 ± 0.00 | 8.70 ± 0.00 | 17.79 ± 0.00 | |
| SEAL | 10.67 ± 3.46 | 13.16 ± 1.66 | 5.88 ± 0.53 | 6.43 ± 0.32 | 29.71 ± 0.71 | 9.99 ± 0.90 | 20.60 ± 1.28 | |
| Neo-GNN | 13.95 ± 0.39 | 17.34 ± 0.84 | 7.74 ± 0.30 | 5.23 ± 0.90 | 21.68 ± 1.14 | 10.86 ± 2.16 | 16.12 ± 0.25 | |
| BUDDY | 13.71 ± 0.59 | 22.84 ± 0.36 | 7.56 ± 0.18 | 5.67 ± 0.36 | 27.70 ± 0.33 | 12.43 ± 0.50 | 19.17 ± 0.20 |
| Model | cora (2, 20) | pubmed (2, 16) | ogbl-collab (1, 75) | ||||||
|---|---|---|---|---|---|---|---|---|---|
| MRR | H@3 | H@20 | MRR | H@3 | H@20 | H@20 | H@50 | H@100 | |
| PENCIL \MR | 34.64 ± 1.99 | 35.98 ± 3.97 | 58.67 ± 2.57 | 21.49 ± 4.30 | 21.81 ± 2.81 | 31.81 ± 2.32 | 49.52 ± 3.01 | 53.43 ± 1.92 | 56.04 ± 1.24 |
| PENCIL | 42.23 ± 1.98 | 43.34 ± 1.03 | 67.32 ± 3.56 | 38.28 ± 2.59 | 43.61 ± 1.48 | 57.49 ± 0.94 | 53.47 ± 0.85 | 66.88 ± 0.34 | 69.75 ± 0.45 |
| Performance Gain | +7.59 | +7.36 | +8.65 | +16.79 | +21.80 | +25.68 | +3.95 | +13.45 | +13.71 |
| Model | cora (2, 20) | citeseer (2, 20) | ogbl-collab (1, 75) |
|---|---|---|---|
| MRR | MRR | H@50 | |
| PENCIL | |||
| PENCIL + LRP-3 | 39.18 | 42.17 | 67.05 |
| Model | ||||
|---|---|---|---|---|
| CN | 1.58 | 4.78 | 4.48 | 4.48 |
| AA | 2.85 | 5.43 | 7.37 | 7.37 |
| GCN | 75.48 | 70.08 | 83.68 | 40.67 |
| GAT | 71.44 | 81.29 | 82.11 | 6.27 |
| PENCIL | 77.63 | 74.37 | 93.59 | 36.01 |
| Model | ||||
|---|---|---|---|---|
| CN | 4.78 | 4.78 | 4.78 | 1.58 |
| AA | 5.43 | 5.43 | 5.43 | 2.85 |
| GCN | 10.09 | 71.04 | 73.85 | 77.05 |
| GAT | 5.36 | 83.57 | 83.04 | 76.01 |
| PENCIL | 17.21 | 84.90 | 92.05 | 95.34 |
| Model | # Params | ogbl-collab (1, 75) | pubmed (1, 75) | ||
|---|---|---|---|---|---|
| Training Time Per Batch | Inference Time Per Batch | Training Time Per Batch | Inference Time Per Batch | ||
| PENCIL-3L | 10.2M | 0.019 ± 0.045 | 0.012 ± 0.039 | 0.016 ± 0.036 | 0.010 ± 0.029 |
| PENCIL-8L | 27.3M | 0.035 ± 0.049 | 0.020 ± 0.043 | 0.029 ± 0.038 | 0.016 ± 0.031 |
| GAT-3L | 1.32M | 0.021 ± 0.078 | 0.015 ± 0.070 | 0.011 ± 0.033 | 0.007 ± 0.026 |
| GAT-8L | 3.95M | 0.032 ± 0.079 | 0.017 ± 0.047 | 0.020 ± 0.034 | 0.011 ± 0.027 |
| Sampling config | Maximum # nodes | No labeling | DRNL | RWPE | LapPE | ||||
|---|---|---|---|---|---|---|---|---|---|
| Time | Mem. | Time | Mem. | Time | Mem. | Time | Mem. | ||
| 42 | 0.109 | 0.07 | 0.430 | 0.19 | 0.161 | 0.05 | 0.270 | 0.07 | |
| 62 | 0.132 | 0.05 | 0.454 | 0.05 | 0.184 | 0.05 | 0.387 | 0.11 | |
| 842 | 1.392 | 0.07 | 2.225 | 0.35 | 6.980 | 0.07 | 6.889 | 0.24 | |
| 1862 | 4.155 | 0.17 | 5.676 | 1.10 | 60.371 | 0.17 | 20.846 | 0.50 | |