Modality-free Graph In-context Alignment

Wei Zhuo, Siqiang Luo

TL;DR

Graph Foundation Models (GFMs) struggle to perform in-context learning across different domains because graph features and labels are often fundamentally incompatible. This paper introduces MF-GIA, a framework that aligns diverse, pre-vectorized graphs into a shared semantic space using "gradient fingerprints," allowing a single frozen model to adapt to entirely new graph domains using just a few examples. It achieves state-of-the-art few-shot performance without needing raw text data, modality conversions, or parameter fine-tuning.

Comparison of MF-GIA with existing methods

What Problem Does This Paper Address?

Large Language Models (LLMs) are famous for In-Context Learning (ICL): you show the frozen model a few examples of a new task in a prompt, and it immediately knows how to solve it without any parameter fine-tuning. Researchers want to achieve this same "foundation-level generality" for graph-structured data (like social networks, molecular structures, or citation networks).

However, graphs are incredibly heterogeneous. A node in a citation network might be represented by a 300-dimensional bag-of-words vector, while a node in a molecular graph might be a 1024-dimensional chemical fingerprint. Furthermore, their label IDs (e.g., "Class 0") mean completely different things.

Recent attempts to solve this involve converting all graphs into Text-Attributed Graphs (TAGs) and using LLMs to map everything into a shared language space. But this "modality-dependent" approach fails if the raw text is inaccessible due to privacy constraints (e.g., patient data, financial transactions) or if the data is already pre-vectorized by proprietary pipelines. The authors tackle the challenge of achieving true, parameter-update-free ICL on graphs without relying on text or modality-specific conversions.

Methods

To achieve "modality-free" alignment, the authors introduce MF-GIA (Modality-Free Graph In-context Alignment), which relies on three key innovations:

Overview of the MF-GIA framework
  1. Gradient Fingerprints for Domain Embedding: How do you know if two graphs are from similar domains without looking at their raw text? MF-GIA takes a shared, initialized Graph Neural Network (GNN) and performs a single gradient step using the new graph's data. The resulting weight displacement—the "gradient fingerprint"—captures exactly how the graph's unique features, labels, and structure interact with the model. This fingerprint is compressed into a dense "domain embedding."
  2. Domain-Conditioned Alignment: Using the domain embedding, MF-GIA generates lightweight transformations (using Feature-wise Linear Modulation, or FiLM). These transformations shift and scale the graph's pre-encoded features and local label IDs into a universal, shared semantic space. Similar domains naturally get mapped to neighboring subspaces.
  3. Episodic Pretraining with Dual Prompt-Aware Attention (DPAA): The model is trained on simulated few-shot tasks ("episodes"). The DPAA mechanism forces query nodes to attend to the aligned support examples (the prompt) and label prototypes to make predictions. This teaches the model how to match patterns in context.

At test time, the model's weights are completely frozen. It uses the few provided examples to compute the gradient fingerprint, aligns the new graph into the shared space, and makes predictions.

Datasets

  • Pretraining (Node Classification): WikiCS (web links), PubMed (citations), ogbn-Arxiv (citations), and Amazon-ratings (e-commerce).
  • Evaluation (Node Classification - Unseen Domains): Cora (citations), ogbn-Products (e-commerce), Computers (e-commerce), Physics (co-authorship), and BlogCatalog (social media).
  • Evaluation (Link Classification - Unseen Task): FB15K237 (encyclopedic knowledge graph) and WN18RR (lexical knowledge graph).

Key Insights and Ideas

  • Gradients are excellent domain descriptors: You don't need metadata or text to understand a graph's domain. The way a graph's data pulls the gradients of a vanilla neural network inherently describes its structural and feature distribution.
  • Alignment makes ICL beat fine-tuning: Traditionally, models are fine-tuned on target domains to achieve high performance. MF-GIA shows that if you properly align heterogeneous graphs into a shared semantic space, a frozen model doing pure in-context learning can actually outperform models that undergo extensive target-domain fine-tuning.
  • Modality independence unlocks privacy-preserving AI: Because MF-GIA operates directly on pre-encoded vectors, organizations (like different hospitals) can locally encode their graphs and use the foundation model without ever sharing raw, sensitive text.
  • Cross-task generalization: Even though MF-GIA was trained exclusively on node classification, the authors evaluated it on edge classification (by converting edges to nodes via line graphs). The model successfully generalized to this entirely unseen task format.

Key Results

  • State-of-the-Art Few-Shot Performance: MF-GIA consistently outperformed existing methods across 15 different configurations, boasting an average margin of improvement of 4.2%.
  • Massive Gains on Specific Datasets: On the Cora dataset (5-shot setting), MF-GIA achieved 63.98% accuracy, an impressive 11.34% absolute improvement over the second-best baseline.
  • Zero Parameter Updates: MF-GIA achieved these results using pure prompt-based inference, beating out baselines (like GFT and AutoGFM) that require extensive fine-tuning on the target datasets.

Limitations and Future Work

  • Limitations: Because MF-GIA is pretrained exclusively on node classification, its performance on highly complex, unseen task formats (like the 10-way WN18RR edge classification task) lagged slightly behind models that were explicitly pretrained on edge-level tasks.
  • Future Work: The authors suggest hooking up their "gradient fingerprints" to LLMs to generate human-interpretable text summaries of what these latent graph domains actually represent.
  • Future Work: They also propose using these fingerprints to automatically discover and cluster latent domain structures from massive, unlabeled graph databases, moving away from manually curated domain categories.

Summary updated

BibTeX
@inproceedings{zhuo2026modality,
  author = {Wei Zhuo and Siqiang Luo},
  title = {{Modality-free Graph In-context Alignment}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=cDc95lucVL},
}
Figure