TL;DR
GILT (Graph In-context Learning Transformer) is a Graph Foundational Model (GFM) that enables true zero-gradient in-context learning (ICL) on graphs without relying on Large Language Models (LLMs) or task-specific fine-tuning. By reframing few-shot node, link, and graph classification into a token-based reasoning problem, GILT achieves state-of-the-art few-shot performance on unseen numerical graphs while running orders of magnitude faster (sub-second inference) than existing tuning-based and LLM-based baselines.
What Problem Does This Paper Address?
Graph foundational models strive for cross-dataset transferability, but graph data suffers from extreme heterogeneity: graphs vary widely in feature dimensions, topological scale, and label spaces. Existing GFMs typically tackle this in two flawed ways:
- LLM-based models: Convert graph attributes into text to leverage language backbones. While useful for citation networks, this strategy falls flat on purely numerical, structural, or categorical domains (e.g., molecular graphs, traffic networks).
- Graph Prompting / Tuning-based models: Train graph neural network (GNN) backbones and adapt to new datasets via prompt tuning or lightweight parameter updates. However, running backpropagation per test task creates a substantial latency bottleneck, abandoning the dream of "out-of-the-box" inference.
GILT bridges this gap by offering a genuinely LLM-free and tuning-free foundational model that handles raw numerical features and adapts to unseen graphs in a single forward pass.
Methods
GILT separates the adaptation process into a two-phase architecture:
[Raw Graph Task: S (Support) & Q (Query)]
│
▼
Phase 1: Graph-Native Tokenization
├─ Dimension Alignment: Non-parametric PCA projects features to d = 512 + standard scaling
├─ Multi-hop Structure Extraction: 5-layer parameter-free Linear GCN + LayerNorm
└─ Asymmetric Tokenization: Form tokens [item || class prototype] for support, [item || 0] for query
│
▼
Phase 2: In-Context Reasoning (ICL Transformer)
├─ Stage 1 (Context Refinement): Self-attention strictly among support tokens
└─ Stage 2 (Information Gathering): Cross-attention from query tokens to support tokens
│
▼
Prototypical Head: Cosine similarity between query embeddings and support class prototypes
- Graph-Native Tokenization (Syntactic Unification):
- Feature Alignment: PCA projects arbitrary input features into a shared $d=512$ space, avoiding parameter overfitting.
- Linear Structural Encoder: A 5-layer simplified GCN without learned weight matrices or non-linear activations (retaining only learnable affine parameters in LayerNorm). Stripping out non-linearities prevents the encoder from memorizing the pre-training feature semantics, delegating representation reasoning entirely to the downstream Transformer.
- Asymmetric Tokens: To support any $N$-way classification task without changing token dimensions, each item embedding $h_i$ is concatenated with an $L_2$-normalized mean class prototype $p_c$ for support examples ($t_s = [h_i \parallel p_c]$) and zero-padded for query examples ($t_q = [h_j \parallel \mathbf{0}]$).
- In-Context Reasoning (Semantic Unification):
- A 5-layer Transformer uses a causal-style two-stage attention block sharing attention weights and FFNs. Support tokens refine each other via self-attention; query tokens then query the refined support tokens via cross-attention without contaminating the support representations.
- A non-parametric prototypical head classifies query tokens by computing cosine similarities against the transformed support class prototypes.
Datasets
- Pre-training (15 datasets): A multi-domain corpus (~450k nodes, 4M edges) covering citation (
ogbn-arxiv,DBLP), co-authorship (CS,Physics), co-purchase (Computers,Photo), social (Flickr,BlogCatalog,FacebookPagePage), transportation (USA,Brazil,Europe), web graphs (Wiki), and molecular graphs (ogbg-bace,ogbg-bbbp). - Evaluation (Held-out & Unseen):
- Node Classification:
Cora,Citeseer,Pubmed,WikiCS. - Link Prediction:
Cora,Citeseer,Pubmed,ogbl-collab, and zero-shot cross-task transfers onComputerandPhoto. - Graph Classification:
ogbg-molhiv,ogbg-molpcba.
Key Insights and Ideas
- Linear encoders generalize better for ICL: Standard supervised learning favors non-linear GNNs. However, ablations revealed that non-linear or shallow GNN encoders harm cross-domain transfer because they overfit pre-training feature spaces. A deep, parameter-free linear GCN acts purely as a multi-hop structural diffuser, letting the Transformer handle semantic induction.
- Asymmetric prototypes eliminate prompt constraints: Instead of variable one-hot encodings or splitting multi-class setups into binary tasks, embedding class prototypes directly into support tokens creates a unified representation space capable of handling arbitrary $N$-way setups on the fly.
- True cross-task transferability: When trained only on node classification, GILT can predict links on unseen graphs out of the box, demonstrating that it learns fundamental topological reasoning rather than dataset-specific correlations.
Key Results
- Node Classification: GILT sets state-of-the-art few-shot accuracy across benchmarks, averaging 50.12% (1-shot) and 66.60% (5-shot), outperforming both tuning-based models (GCOPE: 43.63% / 60.76%) and ICL methods (GraphAny: 49.89% / 65.54%). On WikiCS 1-shot, GILT reaches 61.44%, leading the next best baseline by over 10 percentage points.
- Link Prediction: Outperforms fully supervised GCN and GraphSAGE models. On small graphs like Cora (85.27% Hits@100) and Citeseer (88.53% Hits@100), GILT even outperforms specialized, fully supervised methods like SEAL (81.71% / 83.89%) and MaskGAE (82.48% / 86.11%).
- Graph Classification: Reaches 63.10% ROC-AUC on
ogbg-molhivin 5-shot mode, topping OFA (57.60%) and GFT (58.70%). - Inference Speed: GILT completes Cora 5-shot inference in ~0.03 seconds, comparable to GraphAny (~0.02s) but ~1,000× faster than prompt-tuning models (RiemannGFM: ~8.4s, GCOPE: ~29s) and up to 100,000× faster than generative LLM baselines (ZeroG: ~1633s, GOFA: ~57.6 min).
Limitations and Future Work
- Feature Alignment Constraints: The non-parametric PCA projection simplifies dimension alignment, but can drop non-linear semantic signals. Developing learnable, universal feature compressors remains an open direction.
- Pre-training Scale: Current pre-training covers 15 datasets (~450k nodes). Scaling corpus diversity and volume could further enhance generalist capabilities.
- Pre-training Objectives: The model relies on supervised few-shot cross-entropy; incorporating self-supervised contrastive learning could improve foundational representation quality.
Summary updated