Plain Transformers are Surprisingly Powerful Link Predictors

Quang Truong, Yu Song, Donald Loveland, Mingxuan Ju, Tong Zhao, Neil Shah, Jiliang Tang

TL;DR: PENCIL (Plain ENCoder for Inferring Links) demonstrates that a vanilla, BERT-style Transformer can outperform complex, hand-engineered Graph Neural Networks (GNNs) for link prediction. By applying attention over sampled local subgraphs, it achieves state-of-the-art performance with up to 146x fewer parameters and 40x faster convergence than leading methods.

Link prediction—the task of inferring missing edges between nodes—is a cornerstone of graph machine learning, powering applications from social network recommendations to drug discovery. Historically, Message-Passing Neural Networks (MPNNs) have been the standard solution. However, MPNNs suffer from a fundamental "node-centric" flaw: if two different pairs of nodes share symmetric local neighborhoods, an MPNN cannot distinguish between them.

To circumvent this, researchers typically rely on complex engineering "hacks," such as hand-crafted structural heuristics (e.g., counting common neighbors), memory-intensive node IDs, or intricate positional encodings. These additions severely limit scalability, complicate deployment on massive graphs, and fail to leverage modern hardware optimized for standard Transformers.

Enter PENCIL: A Plain Transformer Approach

To challenge these sophisticated paradigms, researchers introduce PENCIL (Plain ENCoder for Inferring Links), an encoder-only plain Transformer that treats a local subgraph as a sequence of tokens. PENCIL replaces hand-crafted priors with attention over sampled local subgraphs, retaining the scalability and hardware efficiency of standard Transformers.

Graph Encoding Scheme

Instead of relying on global coordinates, PENCIL utilizes a purely local tokenization strategy. Each node within a sampled subgraph is represented by a token comprising three elements:

  1. Local Identifier: A one-hot encoded local ID.
  2. Adjacency Indicator: A row indicating the node's connections within that specific subgraph.
  3. Role Flag: A marker distinguishing general context nodes from the specific "task nodes" whose link is being predicted.

Architecture and Invariance

PENCIL employs a standard BERT-style architecture. A crucial addition is the Multiplicative Residual connection—an explicit matrix-multiplication branch that acts as a single-hop message-passing layer alongside the attention mechanism.

Because local IDs are assigned randomly, the model is not deterministically invariant to node relabeling. However, theoretical analysis proves it is permutation invariant in distribution. The randomness of the assignment ensures that, over time, the model processes isomorphic graphs identically.

Key Insights: Why Simple Transformers Work

Extensive evaluation across diverse benchmarks—including Planetoid, the Open Graph Benchmark (OGB), the rigorous HeaRT protocol, and synthetic latent-space graphs—revealed several surprising insights about Transformer capabilities on graphs.

  • Implicit Heuristic Learning: PENCIL does not need explicit programming for heuristics like the Katz index or PageRank. Experiments demonstrate that it estimates these complex structural signals significantly better than GNNs, even with fewer layers.
  • Structural Sufficiency: On several datasets (such as Cora), incorporating node features actually decreased performance or increased variance. This implies that for many link prediction tasks, local graph structure provides a cleaner, more powerful signal than node attributes.
  • The "Data Hunger" Phenomenon: Much like Vision Transformers (ViTs), PENCIL exhibits "data hunger." It thrives on large-scale datasets where it can learn structural patterns from scratch, though it can underperform on tiny datasets where the hard-coded inductive biases of GNNs act as a safety net.
  • Parameter Efficiency: By avoiding global node embeddings, PENCIL operates with 22x to 146x fewer learnable parameters than top ID-based competitors, while maintaining or exceeding their accuracy.

Empirical Results

PENCIL achieves state-of-the-art (SOTA) results on challenging datasets like ogbl-ppa and ogbl-ddi under the rigorous HeaRT evaluation protocol.

Furthermore, it boasts remarkable convergence speeds. On large-scale OGB datasets, PENCIL converges in just 0.5 to 15 epochs, whereas pure GNNs often require 20 to over 100 epochs to reach comparable performance. Finally, while GNNs notoriously suffer from "oversmoothing" as they get deeper, PENCIL demonstrates consistent performance gains with increased depth, effectively capturing long-range dependencies within subgraphs.

Limitations and Future Directions

Despite its impressive performance, PENCIL has limitations. Its primary bottleneck is inference overhead: the model must extract and process a context subgraph for every candidate link. This linear scaling makes real-time, all-pairs prediction computationally expensive on massive graphs. Additionally, its statistical efficiency drops in the small-data regime compared to specialized GNNs.

Future work points toward "hybrid" architectures, where a faster, simpler model retrieves top candidate links, and PENCIL is deployed for high-accuracy scoring. Pre-training on large graph collections is also a promising avenue to mitigate the model's data hunger, paving the way for even more robust, generalized graph Transformers.

Summary updated

BibTeX
@inproceedings{truong2026plain,
  author = {Quang Truong and Yu Song and Donald Loveland and Mingxuan Ju and Tong Zhao and Neil Shah and Jiliang Tang},
  title = {{Plain Transformers are Surprisingly Powerful Link Predictors}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=HUwssjEH2D},
}
Figure