---
title: 'GFMate: Test-Time Prompt Tuning for GFMs'
url: https://www.emergentmind.com/topics/gfmate
type: topic
---

# GFMate: Test-Time Prompt Tuning for GFMs

GFMate is a test-time prompt-tuning framework for Graph Foundation Models (GFMs) that is designed for cross-domain adaptation on a target graph using both few-shot labels and abundant unlabeled target-domain data. In the formulation introduced in "GFMate: Empowering Graph Foundation Models with Test-time Prompt Tuning" [2605.14809], the underlying GFM is pre-trained in a label-free manner and then frozen; adaptation occurs only through prompts introduced after pre-training. The method combines centroid prompts, layer prompts, and a complementary learning objective, with the stated aim of avoiding prompt entanglement with specific source domains or pre-training strategies while exploiting unlabeled target nodes during test-time tuning [2605.14809].

## 1. Problem setting and motivation

GFMate is defined in a setting where a Graph Foundation Model $f_\theta$ has been pre-trained in a label-free manner, for example via link prediction or contrastive learning, on a set of source-domain graphs $\mathcal{G}_{pre}$. At downstream time, one observes a single target graph $G_{tar}=(V,A,X)$, where $V$ is the node set, $A\in\{0,1\}^{|V|\times |V|}$ is the adjacency matrix, and $X\in\mathbb{R}^{|V|\times d}$ contains node features. A few-shot subset $V_{FS}\subset V$ has labels $y_i$, while the remaining nodes form the unlabeled set $V_{UL}=V\setminus V_{FS}$ [2605.14809].

The paper places GFMate against earlier graph prompt tuning methods that tune prompts learned during source pre-training. In that standard few-shot setting, one tunes a prompt set $B_{pre}$ by solving
\[
\arg\min_{B_{FS}} \mathcal{L}_{FS}(f_\theta,B_{FS};V_{FS},y_{FS}).
\]
Two limitations are identified. First, there is **pre-training entanglement**: prompts specialized to a source domain or to a particular pre-training objective may not generalize to unseen target domains or to GFMs pre-trained by different objectives. Second, there is **neglect of unlabeled data**: abundant unlabeled nodes in the target graph are not actively used, leaving a substantial train-test distribution shift unaddressed [2605.14809].

GFMate addresses these issues by introducing prompts only after pre-training is fixed. The test-time objective is written as
\[
\min_B \;\mathcal{L}_{Te}(f_\theta,B;V_{FS},y_{FS},V_{UL}),
\]
with $\theta$ frozen. In the terminology of the paper, this makes the prompts **pre-training-agnostic**, because they do not participate in source pre-training and therefore are not tied to a particular source-domain set or self-supervised pre-training loss [2605.14809].

## 2. Prompt parameterization: centroid prompts and layer prompts

The method assumes that the pre-trained GFM consists of $L$ layers of a GNN backbone, such as GCN or GAT. Layer-wise embeddings are denoted
\[
H^{(\ell)} = f_\theta^{(\ell)}(X,A)\in\mathbb{R}^{|V|\times d}, \qquad \ell=0,\dots,L,
\]
where the row $h_i^{(\ell)}\in\mathbb{R}^d$ is the embedding of node $i$ at layer $\ell$ [2605.14809].

For each class $c$, GFMate first computes a **few-shot centroid** at each layer:
\[
e_c^{(\ell)}=\frac{1}{|V_{FS,c}|}\sum_{i\in V_{FS,c}} h_i^{(\ell)},
\]
where $V_{FS,c}=\{i\in V_{FS}: y_i=c\}$. A learnable additive prompt $\delta_c^{(\ell)}\in\mathbb{R}^d$ is then introduced, yielding the refined centroid
\[
\tilde e_c^{(\ell)} = e_c^{(\ell)} + \delta_c^{(\ell)}.
\]
The collection of centroid prompts is
\[
\Delta=\{\delta_c^{(\ell)}\}\in\mathbb{R}^{(L+1)\times C\times d}.
\]
These centroid prompts alter the class representatives directly in embedding space rather than modifying the pre-training process or encoding source-domain-specific prompt parameters [2605.14809].

In parallel, GFMate introduces a **layer prompt** in the form of a learnable scalar weight $\eta^{(\ell)}\in\mathbb{R}$ for each layer. The vector
\[
\eta=(\eta^{(0)},\dots,\eta^{(L)})\in\mathbb{R}^{L+1}
\]
controls how strongly each layer contributes to final classification. The paper describes these weights as adapting automatically to the “hop-aggregation” patterns of the target graph [2605.14809].

Prediction is performed by a multi-layer ensemble score. For any node $i$ and class $c$,
\[
s_{i,c}=\sum_{\ell=0}^L \eta^{(\ell)} \; \mathrm{sim}\bigl(h_i^{(\ell)},\tilde e_c^{(\ell)}\bigr),
\]
where cosine similarity is used:
\[
\mathrm{sim}(u,v)=\frac{u^\top v}{\|u\|_2\|v\|_2}.
\]
Class probabilities are then obtained through a temperature-scaled softmax,
\[
p(c\mid i)=\frac{\exp\bigl(s_{i,c}/T\bigr)}{\sum_{c'=1}^C \exp\bigl(s_{i,c'}/T\bigr)},
\]
with $T>0$ [2605.14809].

## 3. Complementary learning at test time

The optimization objective combines ordinary few-shot supervision with an unlabeled-data term derived from **complementary labels**. On the labeled set $V_{FS}$, GFMate uses the standard cross-entropy
\[
\mathcal{L}_{FS}(\Delta,\eta)
= -\sum_{i\in V_{FS}} \log p(y_i\mid i).
\]
This term anchors the prompt tuning to the observed few-shot labels [2605.14809].

For unlabeled nodes, the method first computes a per-layer confidence statistic. For each layer $\ell$, the average entropy over $V_{UL}$ is
\[
H^{(\ell)} = -\frac{1}{|V_{UL}|}\sum_{i\in V_{UL}} \sum_{c=1}^C p^{(\ell)}(c\mid i)\log p^{(\ell)}(c\mid i),
\]
where $p^{(\ell)}$ is defined using only layer $\ell$ in the score. The **pivot layer** is then selected as
\[
\ell^*=\arg\min_\ell H^{(\ell)},
\]
that is, the layer with highest confidence on the unlabeled target nodes [2605.14809].

Using that pivot layer, each unlabeled node $i\in V_{UL}$ is assigned a complementary label
\[
c_i^{comp}=\arg\min_c \mathrm{sim}\bigl(h_i^{(\ell^*)},\tilde e_c^{(\ell^*)}\bigr),
\]
namely the class least similar to the node representation at the pivot layer. The corresponding loss is
\[
\mathcal{L}_{Te}(\Delta,\eta)
= -\sum_{i\in V_{UL}} \log\bigl[1-p(c_i^{comp}\mid i)\bigr].
\]
This explicitly pushes the probability of the complementary class toward zero [2605.14809].

The full objective is a convex combination:
\[
\mathcal{L}(\Delta,\eta)
= \alpha\,\mathcal{L}_{Te}(\Delta,\eta) + (1-\alpha)\,\mathcal{L}_{FS}(\Delta,\eta),
\qquad \alpha\in(0,1).
\]
Only $\Delta$ and $\eta$ are learnable; the GFM parameters $\theta$ remain fixed. Updates are performed by gradient descent,
\[
\delta_c^{(\ell)} \leftarrow \delta_c^{(\ell)} - \gamma \frac{\partial \mathcal{L}}{\partial \delta_c^{(\ell)}},\qquad
\eta^{(\ell)} \leftarrow \eta^{(\ell)} - \gamma \frac{\partial \mathcal{L}}{\partial \eta^{(\ell)}},
\]
with learning rate $\gamma>0$, and optimization stops when the validation loss on a small held-out part of $V_{UL}\cup V_{FS}$ converges or after a fixed number of steps [2605.14809].

## 4. Algorithmic workflow and computational profile

The test-time procedure begins by computing layer embeddings $\{H^{(\ell)}\}_{\ell=0}^L=f_\theta(X,A)$ on the target graph. Centroid prompts $\Delta$ and layer prompts $\eta$ are initialized randomly, and the few-shot centroids $e_c^{(\ell)}$ are computed for all layers and classes. Each optimization step then refines the centroids, computes per-layer probabilities and entropies on unlabeled nodes, selects the pivot layer, determines complementary labels, evaluates $\mathcal{L}_{FS}$ and $\mathcal{L}_{Te}$, forms the total loss, and updates $\Delta$ and $\eta$ by SGD. Final predictions on $V_{UL}$ are given by
\[
\hat y_i = \arg\max_c \sum_\ell \eta^{(\ell)} \cdot \mathrm{sim}(h_i^{(\ell)},\tilde e_c^{(\ell)}).
\]
This is the complete workflow described as the GFMate test-time prompt tuning algorithm [2605.14809].

The paper gives the per-step complexity as
\[
O((N+E)dL + NCL),
\]
which is stated to be linear in graph size. It also emphasizes parameter efficiency: GFMate tunes only $O(CLd+L)$ parameters, in contrast to $O(NdL)$ parameters in instance-level prompt methods [2605.14809].

A practical consequence is reported in downstream adaptation on Arxiv-year. SAMGPT requires $1\,200$ s, $1.3$ M tunable parameters, and $10$ GB GPU memory, while GFMate requires $19$ s, $0.4$ k parameters, and $0.3$ GB GPU memory, corresponding to **98% faster** adaptation and **97% less memory** in that experiment [2605.14809].

## 5. Experimental evaluation

GFMate is evaluated on **12 benchmarks across node and graph classification**. The node-classification portion includes Cornell, Texas, Wisconsin, Chameleon, Squirrel, Cora, Citeseer, Arxiv-year, and Amazon-Photo in a one-versus-all cross-domain setting; the graph-classification portion includes BZR, COX2, and PROTEINS. The task range is from one-shot to full-shot classification with **5 random runs** [2605.14809].

The baseline suite spans several categories. Supervised GNNs include GCN, GAT, GraphSAGE, H2GCN, and GPR. Self-supervised pre-train plus fine-tune baselines include LP+FT, DGI+FT, and GCL+FT. Single-domain prompt-tuning baselines include GPPT, ProNoG, GraphPrompt, GPF, DAGPrompt, and All-In-One. Cross-domain GFM baselines include GCOPE, MDGPT, SAMGPT, MDGFM, BRIDGE, and RiemannGFM, while GraphAny and GTrans are considered in the full-shot setting [2605.14809].

For one-shot node classification, the paper reports the following accuracies in a representative table: GFMate attains $59.7$ on Cora, $56.3$ on Cite, $47.3$ on Chameleon, and $27.0$ on Squirrel. The stated **average improvement over the best baseline** is **up to +30.63% (relative) on Chameleon** [2605.14809]. Across varying few-shot sizes $(1,3,5,10,\text{full})$, GFMate is reported to consistently outperform GFMs. When plugged into different pre-training strategies—LP, DGI, and GCL—and different backbones—GCN, SAGE, GAT, and H2GCN—the method is reported to yield **always +10–30% gain** [2605.14809].

Ablation studies attribute the performance to all three main components. On one- versus three-shot node classification averaged over five graphs, removing centroid prompts causes a **$-6.2\%$** drop, removing layer prompts causes a **$-4.8\%$** drop, and removing complementary learning so that only few-shot supervision remains causes a **$-9.4\%$** drop [2605.14809]. In the binary classification setting, the paper reports even larger relative gains, described as being in line with the $O(1/N)$ risk bound in Proposition 1 [2605.14809].

## 6. Scope, interpretation, and limitations

The central claim about generalization is that GFMate’s prompts are agnostic to both the source pre-training domain set and the GFM’s self-supervised loss. The method is said to plug seamlessly into any GNN-based GFM backbone and pre-training objective, and the active use of unlabeled testing data through complementary labels is presented as a mechanism for mitigating train-test distribution shifts [2605.14809].

The term **pre-training-agnostic** has a precise meaning in this framework. It does not denote adaptation without optimization; rather, it denotes that prompt parameters are introduced only after the source pre-training stage and are therefore not entangled with a particular source-domain prompt design. The learnable objects are the centroid prompts $\Delta$ and layer prompts $\eta$, while the foundation model parameters $\theta$ remain fixed [2605.14809].

The paper also identifies clear limitations. GFMate is designed for **GNN-based GFMs on text-free graphs** and does not immediately extend to **LLM-based GFMs on text-attributed graphs**. Its test-time tuning protocol requires access to the **full target graph**, so the setting is transductive; inductive test-time tuning is explicitly left as an open direction. In addition, the complementary labeling mechanism is characterized as **heuristic**, and the authors suggest that more robust uncertainty-based or self-training mechanisms could be investigated in future work [2605.14809].

Within the graph prompt-tuning literature, GFMate is therefore best understood as a target-domain adaptation mechanism that relocates prompt optimization from pre-training or source-domain transfer into inference-time adjustment on the target graph itself. This suggests a distinct design principle for GFMs: rather than encoding source-domain knowledge into prompt parameters in advance, one can leave the foundation model frozen and use structurally lightweight prompts plus unlabeled target-domain signals to specialize predictions at test time [2605.14809].

Source: https://www.emergentmind.com/topics/gfmate