HetGPT: Harnessing the Power of Prompt Tuning in Pre-Trained
  Heterogeneous Graph Neural Networks
Graphs have emerged as a natural choice to represent and analyze the
intricate patterns and rich information of the Web, enabling applications such
as online page classification and social recommendation. The prevailing
"pre-train, fine-tune" paradigm has been widely adopted in graph machine
learning tasks, particularly in scenarios with limited labeled nodes. However,
this approach often exhibits a misalignment between the training objectives of
pretext tasks and those of downstream tasks. This gap can result in the
"negative transfer" problem, wherein the knowledge gained from pre-training
adversely affects performance in the downstream tasks. The surge in
prompt-based learning within Natural Language Processing (NLP) suggests the
potential of adapting a "pre-train, prompt" paradigm to graphs as an
alternative. However, existing graph prompting techniques are tailored to
homogeneous graphs, neglecting the inherent heterogeneity of Web graphs. To
bridge this gap, we propose HetGPT, a general post-training prompting framework
to improve the predictive performance of pre-trained heterogeneous graph neural
networks (HGNNs). The key is the design of a novel prompting function that
integrates a virtual class prompt and a heterogeneous feature prompt, with the
aim to reformulate downstream tasks to mirror pretext tasks. Moreover, HetGPT
introduces a multi-view neighborhood aggregation mechanism, capturing the
complex neighborhood structure in heterogeneous graphs. Extensive experiments
on three benchmark datasets demonstrate HetGPT's capability to enhance the
performance of state-of-the-art HGNNs on semi-supervised node classification.
Yihong Ma, Ning Yan, Jiayu Li, Masood Mortazavi, Nitesh V. Chawla
# HetGPT: Harnessing the Power of Prompt Tuning in Pre-Trained Heterogeneous Graph Neural Networks

###### Abstract.

Graphs have emerged as a natural choice to represent and analyze the intricate patterns and rich information of the Web, enabling applications such as online page classification and social recommendation. The prevailing _"pre-train, fine-tune"_ paradigm has been widely adopted in graph machine learning tasks, particularly in scenarios with limited labeled nodes. However, this approach often exhibits a misalignment between the training objectives of pre-text tasks and those of downstream tasks. This gap can result in the "negative transfer" problem, wherein the knowledge gained from pre-training adversely affects performance in the downstream tasks. The surge in prompt-based learning within Natural Language Processing (NLP) suggests the potential of adapting a "_pre-train, prompt_" paradigm to graphs as an alternative. However, existing graph prompting techniques are tailored to homogeneous graphs, neglecting the inherent heterogeneity of Web graphs. To bridge this gap, we propose HetGPT, a general post-training prompting framework to improve the predictive performance of pre-trained heterogeneous graph neural networks (HGNNs). The key is the design of a novel prompting function that integrates a virtual class prompt and a heterogeneous feature prompt, with the aim to re-formulate downstream tasks to mirror pretext tasks. Moreover, HetGPT introduces a multi-view neighborhood aggregation mechanism, capturing the complex neighborhood structure in heterogeneous graphs. Extensive experiments on three benchmark datasets demonstrate HetGPT's capability to enhance the performance of state-of-the-art HGNNs on semi-supervised node classification.

+
Footnote †: [leftmargin=*] *Work done as an intern at Futurewei Technologies Inc.

## 1. Introduction

The Web, an ever-expanding digital universe, has transformed into an unparalleled data warehouse. Within this intricate web of data, encompassing diverse entities and patterns, graphs have risen as an intuitive representation to encapsulate and examine the Web's multifaceted content, such as academic articles (Gordner et al., 2017), social media interactions (Gordner et al., 2017), chemical molecules (Gordner et al., 2017), and online grocery items (Gordner et al., 2017). In light of this, graph neural networks (GNNs) have emerged as the state of the art for graph representation learning, which enables a wide range of web-centric applications such as online page classification (Kolmogorov, 2017), social recommendation (Kolmogorov, 2017), pandemic trends forecasting (Kolmogorov, 2017), and dynamic link prediction (Kolmogorov, 2017; Kolmogorov, 2017).

A primary challenge in traditional supervised graph machine learning is its heavy reliance on labeled data. Given the magnitude and complexity of the Web, obtaining annotations can be costly and often results in data of low quality. To address this limitation, the _"pre-train, fine-tune"_ paradigm has been widely adopted, where GNNs are initially pre-trained with some self-supervised pretext tasks and are then fine-tuned with labeled data for specific downstream tasks. Yet, this paradigm faces the following challenges:

* **(C1)** Fine-tuning methods often overlook the inherent gap between the training objectives of the pretext and the downstream task. For example, while graph pre-training may utilize binary edge classification to draw topologically proximal node embeddings closer, the core of a downstream node classification task would be to ensure nodes with the same class cluster closely. Such misalignment makes the transferred node embeddings suboptimal for downstream tasks, _i.e._, negative transfer (Kolmogorov, 2017; Kolmogorov, 2017). The challenge arises: _how to reformulate the downstream node classification task to better align with the contrastive pretext task?_
* **(C2)** In semi-supervised node classification, there often exists a scarcity of labeled nodes. This limitation can cause fine-tuned networks to highly overfit these sparse (Kolmogorov, 2017) or potentially imbalanced (Kolmogorov, 2017) nodes, compromising their ability to generalize to new and unlabeled nodes. The challenge arises: _how to capture and generalize the intricate characteristics of each class in the embedding space to mitigate this overfitting?_
* **(C3)** Given the typically large scale of pre-trained GNNs, the attempt to recalibrate all their parameters during the fine-tuning phase can considerably slow down the rate of training convergence. The challenge arises: _how to introduce only a small number of trainable parameters in the fine-tuning stage while keeping the parameters of the pre-trained network unchanged?_

One potential solution that could partially address these challenges is to adapt the _"pre-train, prompt"_ paradigm from natural language processing (NLP) to the graph domain. In NLP, prompt-based learning has effectively generalized pre-trained language models across diverse tasks. For example, a sentiment classification task like _"The WebConf will take place in the scenic city of Singapore in 2024"_ can be reframed by appending a specific textual prompt "_I feel so_ [MASK]" to the end. It is highly likely that a language model pre-trained on next word prediction will predict "[MASK]"
as "_excited_" instead of "_frustrated_", without necessitating extensive fine-tuning. With this methodology, certain downstream tasks can be seamlessly aligned with the pre-training objectives. While few prior work (Devlin et al., 2018; Wang et al., 2019; Wang et al., 2020; Wang et al., 2021; Wang et al., 2021) has delved into crafting various prompting templates for graphs, their emphasis remains strictly on homogeneous graphs. This narrow focus underscores the last challenge inherent to the heterogeneous graph structures typical of the Web:

* (**C4**) Homogeneous graph prompting techniques typically rely on the pre-trained node embeddings of the target node or the aggregation of its immediate neighbors' embeddings for downstream node classification, which ignores the intricate neighborhood structure inherent to heterogeneous graphs. The challenge arises: _how to leverage the complex heterogeneous neighborhood structure of a node to yield more reliable classification decisions_?

To comprehensively address all four aforementioned challenges, we propose HetGPT, a general post-training prompting framework tailored for heterogeneous graphs. Represented by the acronym Heterogeneous Graph Prompt Tuning, HetGPT serves as an auxiliary system for HGNNs that have undergone constrastive pre-training. At the core of HetGPT is a novel _graph prompting function_ that reformulates the downstream node classification task to align closely with the pretext contrastive task. We begin with the the _virtual class prompt_, which generalizes the intricate characteristics of each class in the embedding space. Then we introduce the _heterogeneous feature prompt_, which acts as a task-specific augmentation to the input graph. This prompt is injected into the feature space and the prompted node features are then passed through the pre-trained HGNN, with all parameters in a frozen state. Furthermore, a _multi-view neighborhood aggregation_ mechanism, that encapsulates the complexities of the heterogeneous neighborhood structure, is applied to the target node, generating a node token for classification. Finally, Pairwise similarity comparisons are performed between the node token and the class tokens derived from the virtual class prompt via the contrastive learning objectives established during pre-training, which effectively simulates the process of deriving a classification decision. In summary, our main contributions include:

* To the best of our knowledge, this is the first attempt to adapt the "_pre-train_, _prompt_" paradigm to heterogeneous graphs.
* We propose HetGPT, a general post-training prompting framework tailored for heterogeneous graphs. By coherently integrating a virtual class prompt, a heterogeneous feature prompt, and a multi-view neighborhood aggregation mechanism, it elegantly bridges the objective gap between pre-training and downstream tasks on heterogeneous graphs.
* Extensive experiments on three benchmark datasets demonstrate HetGPT's capability to enhance the performance of state-of-the-art HGNNs on semi-supervised node classification.

## 2. Related Work

**Heterogeneous graph neural networks.** Recently, there has been a surge in the development of heterogeneous graph neural networks (HGNNs) designed to learn node representations on heterogeneous graphs (Wang et al., 2019; Wang et al., 2020; Wang et al., 2021). For example, HAN (Wang et al., 2020) introduces hierarchical attention to learn the node-level and semantic-level structures. MAGNN (Chen et al., 2020) incorporates intermediate nodes along metapaths to encapsulate the rich semantic information inherent in heterogeneous graphs. HetGNN (Wang et al., 2020) employs random walk to sample node neighbors and utilizes LSTM to fuse heterogeneous features. HGT (Han et al., 2019) adopts a transformer-based architecture tailored for web-scale heterogeneous graphs. However, a shared challenge across these models is their dependency on high-quality labeled data for training. In real-world scenarios, obtaining such labeled data can be resource-intensive and sometimes impractical. This has triggered numerous studies to explore pre-training techniques for heterogeneous graphs as an alternative to traditional supervised learning.

**Heterogeneous graph pre-training.** Pre-training techniques have gained significant attention in heterogeneous graph machine learning, especially under the scenario with limited labeled nodes (Wang et al., 2019; Wang et al., 2021). Heterogeneous graphs, with their complex types of nodes and edges, require specialized pre-training strategies. These can be broadly categorized into generative and contrastive methods. Generative learning in heterogeneous graphs primarily focuses on reconstructing masked segments of the input graph, either in terms of the underlying graph structures or specific node attributes (Chen et al., 2020; Wang et al., 2021; Wang et al., 2021). On the other hand, contrastive learning on heterogeneous graphs aims to refine node representations by magnifying the mutual information of positive pairs while diminishing that of negative pairs. Specifically, representations generated from the same data instance form a positive pair, while those from different instances constitute a negative pair. Some methods emphasizes contrasting node-level representations (Wang et al., 2019; Wang et al., 2021; Wang et al., 2021), while another direction contrasts node-level representations with graph-level representations (Wang et al., 2019; Wang et al., 2021; Wang et al., 2021). In general, the efficacy of contrastive methods surpasses that of generative ones (Wang et al., 2021), making them the default pre-training strategies adopted in this paper.

**Prompt-based learning on graphs.** The recent trend in Natural Language Processing (NLP) has seen a shift from traditional fine-tuning of pre-trained language models (LMs) to a new paradigm: "_pre-train_, _prompt_" (Wang et al., 2021). Instead of fine-tuning LMs through task-specific objective functions, this paradigm reformulates downstream tasks to resemble pre-training tasks by incorporating textual prompts to input texts. This not only bridges the gap between pre-training and downstream tasks but also instigates further research integrating prompting with pre-trained graph neural networks (Wang et al., 2021). For example, GPPT (Wang et al., 2021) and GraphPrompt (Wang et al., 2021) introduce prompt templates to align the pretext task of link prediction with downstream classification. GPF (Chen et al., 2020) and VNT-GPPE (Wang et al., 2021) employ learnable perturbations to the input graph, modulating pre-trained node representations for downstream tasks. However, all these techniques cater exclusively to homogeneous graphs, overlooking the distinct complexities inherent to the heterogeneity in real-world systems.

## 3. Preliminaries

**Definition 1: Heterogeneous graph.** A heterogeneous graph is defined as \(\mathcal{G}=\{\mathcal{V},\mathcal{E}\}\), where \(\mathcal{V}\) is the set of nodes and \(\mathcal{E}\) is the set of edges. It is associated with a node type mapping function \(\phi:\mathcal{V}\rightarrow\mathcal{A}\) and an edge type mapping function \(\phi:\mathcal{E}\rightarrow\mathcal{R}\). \(\mathcal{A}\) and \(\mathcal{R}\) denote the node type set and edge type set, respectively. For heterogeneous graphs, we require \(|\mathcal{A}|+|\mathcal{R}|>2\). Let \(\mathcal{X}=\{\mathcal{X}_{A}\mid A\in\mathcal{A}\}\) be the set of all node feature matrices for different node types. Specifically, \(\mathcal{X}_{A}\in\mathbb{R}^{|\mathcal{V}_{A}|\times d_{A}}\) is the feature matrix where each row corresponds to a feature vector \(\mathbf{x}_{i}^{A}\) of node \(i\) of type \(A\). All
nodes of type \(A\) share the same feature dimension \(d_{A}\), and nodes of different types can have different feature dimensions.

Figure 1(a) illustrates an example heterogeneous graph with three types of nodes: author (A), paper (P), and subject (S), as well as two types of edges: "write" and "belong to".

Definition 2: Network schema.The network schema is defined as \(\mathcal{S}=(\mathcal{A},\mathcal{R})\), which can be seen as a meta template for a heterogeneous graph \(\mathcal{G}\). Specifically, network schema is a graph defined over the set of node types \(\mathcal{A}\), with edges representing relations from the set of edge types \(\mathcal{R}\).

Figure 1(b) presents the network schema for a heterogeneous graph. As per the network schema, we learn that a paper is written by an author and that a paper belongs to a subject.

Definition 3: Metapath.A metapath \(P\) is a path defined by a pattern of node and edge types, denoted as \(A_{1}\xrightarrow{R_{1}}A_{2}\xrightarrow{R_{2}}\ldots\xrightarrow{R_{J}}A_{ \mathcal{I}+1}\) (abbreviated as \(A_{1}A_{2}\cdots A_{\mathcal{I}+1}\)), where \(A_{i}\in\mathcal{A}\) and \(R_{i}\in\mathcal{R}\).

Figure 1(c) shows two metapaths for a heterogeneous graph: "PAP" represents that two papers are written by the same author, while "PSP" indicates that two papers share the same subject.

Definition 4: Semi-supervised node classification.Given a heterogeneous graph \(\mathcal{G}=\{\mathcal{V},\mathcal{E}\}\) with node features \(\mathcal{X}\), we aim to predict the labels of the target node set \(\mathcal{V}_{T}\) of type \(T\in\mathcal{A}\). Each target node \(v\in\mathcal{V}_{T}\) corresponds to a class label \(y_{v}\in\mathcal{Y}\). Under the semi-supervised learning setting, while the node labels in the labeled set \(\mathcal{V}_{L}\subset\mathcal{V}_{T}\) are provided, our objective is to predict the labels for nodes in the unlabeled set \(\mathcal{V}_{U}=\mathcal{V}_{T}\setminus\mathcal{V}_{L}\).

Definition 5: Pre-train, fine-tune.We introduce the "_pre-train, fine-tune_" paradigm for heterogeneous graphs. During the pre-training stage, an encoder \(f_{\theta}\) parameterized by \(\theta\) maps each node \(v\in\mathcal{V}\) to a low-dimensional representation \(\mathbf{h}_{v}\in\mathbb{R}^{d}\). Typically, \(f_{\theta}\) is an HGNN that takes a heterogeneous graph \(\mathcal{G}=\{\mathcal{V},\mathcal{E}\}\) and its node features \(\mathcal{X}\) as inputs. For each target node \(v\in\mathcal{V}_{T}\), we construct its positive \(\mathcal{P}_{v}\) and negative sample sets \(\mathcal{N}_{v}\) for contrastive learning. The contrastive head \(g_{\psi}\), parameterized by \(\psi\), discriminates the representations between positive and negative pairs. The pre-training objective can be formulated as:

\[\theta^{*},\psi^{*}=\operatorname*{arg\,min}_{\theta,\psi}\mathcal{L}_{con} \left(g_{\psi},f_{\theta},\mathcal{V}_{T},\mathcal{P},\mathcal{N}\right), \tag{1}\]

where \(\mathcal{L}_{con}\) denotes the contrastive loss. Both \(\mathcal{P}=\{\mathcal{P}_{v}\mid v\in\mathcal{V}_{T}\}\) and \(\mathcal{N}=\{\mathcal{N}_{v}\mid v\in\mathcal{V}_{T}\}\) can be nodes or graphs. They may be direct augmentations or distinct views of the corresponding data instances, contingent on the contrastive learning techniques employed.

In the fine-tuning stage, a prediction head \(h_{\eta}\), parameterized by \(\eta\), is employed to optimize the learned representations for the downstream node classification task. Given a set of labeled target nodes \(\mathcal{V}_{L}\) and their corresponding label set \(\mathcal{Y}\), the fine-tuning objective can be formulated as:

\[\theta^{**},\eta^{*}=\operatorname*{arg\,min}_{\theta^{*},\eta}\mathcal{L}_{ sup}\left(h_{\eta},f_{\theta^{*}},\mathcal{V}_{L},\mathcal{Y}\right), \tag{2}\]

where \(\mathcal{L}_{sup}\) is the supervised loss. Notably, the parameters \(\theta\) are initialized with those obtained from the pre-training stage, \(\theta^{*}\).

## 4. Method

In this section, we introduce HetGPT, a novel graph prompting technique specifically designed for heterogeneous graphs, to address the four challenges outlined in Section 1. In particular, HetGPT consists of the following key components: (1) _prompting function design_; (2) _virtual class prompt_; (3) _heterogeneous feature prompt_; (4) _multi-view neighborhood aggregation_; (5) _prompt-based learning and inference_. The overall framework of HetGPT is shown in Figure 2.

### Prompting Function Design (C1)

Traditional fine-tuning approaches typically append an additional prediction head and a supervised loss for downstream tasks, as depicted in Equation 2. In contrast, HetGPT pivots towards leveraging and tuning prompts specifically designed for node classification.

In prompt-based learning for NLP, a prompting function employs a pre-defined template to modify the textual input, ensuring its alignment with the input format used during pre-training. Meanwhile, within graph-based pre-training, contrastive learning has overshadowed generative learning, especially in heterogeneous graphs (Han et al., 2017; Wang et al., 2018; Wang et al., 2019), as it offers broader applicability and harnesses overlapping task subspaces, which are optimal for knowledge transfer. Therefore, these findings motivate us to reformulate the downstream node classification task to align with contrastive approaches. Subsequently, a good design of graph prompting function becomes pivotal in matching these contrastive pre-training strategies.

Central to graph contrastive learning is the endeavor to maximize mutual information between node-node or node-graph pairs. In light of this, we propose a graph prompting function, denoted as \(l(\cdot)\). This function transforms an input node \(v\) into a pairwise template that encompasses a node token \(\mathbf{z}_{v}\) and a class token \(\mathbf{q}_{c}\):

\[l(v)=\left[\mathbf{z}_{v},\mathbf{q}_{c}\right]. \tag{3}\]

Within the framework, \(\mathbf{q}_{c}\) represents a trainable embedding for class \(c\) in the downstream node classification task, as explained in Section 4.2. Concurrently, \(\mathbf{z}_{v}\) denotes the latent representation of node \(v\), derived from the pre-trained HGNN, which will be further discussed in Section 4.3 and Section 4.4.

### Virtual Class Prompt (C2)

Instead of relying solely on direct class labels, we propose the concept of a virtual class prompt, a paradigm shift from traditional node classification. Serving as a dynamic proxy for each class, the prompt bridges the gap between the abstract representation of nodes and the concrete class labels they are affiliated with. By leveraging the virtual class prompt, we aim to reformulate downstream node classification as a series of mutual information calculation tasks,

Figure 1. A example of a heterogeneous graph.
thereby refining the granularity and adaptability of the classification predictions. This section delves into the design and intricacies of the virtual class prompt, illustrating how it can be seamlessly integrated into the broader contrastive pre-training framework.

#### 4.2.1. Class tokens

We introduce class tokens, the building blocks of the virtual class prompt, which serve as representative symbols for each specific class. Distinct from discrete class labels, these tokens can capture intricate class-specific semantics, providing a richer context for node classification. We formally define the set of class tokens, denoted as \(\mathcal{Q}\), as follows:

\[\mathcal{Q}=\{\mathbf{q}_{1},\mathbf{q}_{2},\ldots,\mathbf{q}_{C}\}\,, \tag{4}\]

where \(C\) is the total number of classes in \(\mathcal{Y}\). Each token \(\mathbf{q}_{c}\in\mathbb{R}^{d}\) is a trainable vector and shares the same embedding dimension \(d\) with the node representations from the pre-trained network \(f_{\theta^{*}}\).

#### 4.2.2. Prompt initialization

Effective initialization of class tokens facilitates a smooth knowledge transfer from pre-trained heterogeneous graphs to the downstream node classification. We initialize each class token, \(\mathbf{q}_{c}\), by computing the mean of embeddings for labeled nodes that belong to the respective class. Formally,

\[\mathbf{q}_{c}=\frac{1}{N_{c}}\sum_{\begin{subarray}{c}\mathbf{p}\in\mathcal{V}_{ \mathcal{I}}\\ y_{\theta}=c\end{subarray}}\mathbf{h}_{o},\quad\forall c\in\{1,2,\ldots,C\}, \tag{5}\]

where \(N_{c}\) denotes the number of nodes with class \(c\) in the labeled set \(\mathcal{V}_{\mathcal{I}}\), and \(\mathbf{h}_{o}\) represents the pre-trained embedding of node \(v\). This initialization aligns each class token with the prevalent patterns of its respective class, enabling efficient prompt tuning afterward.

### Heterogeneous Feature Prompt (C3)

Inspired by recent progress with visual prompts in the vision domain (Bengio et al., 2018; Chen et al., 2019), we propose a heterogeneous feature prompt. This approach incorporates a small amount of trainable parameters directly into the feature space of the heterogeneous graph \(\mathcal{G}\). Throughout the training phase of the downstream task, the parameters of the pre-trained network \(f_{\theta^{*}}\) remain unchanged. The key insight behind this feature prompt lies in its ability to act as task-specific augmentations to the original graph. It implicitly tailors the pre-trained node representations for an effective and efficient transfer of the learned knowledge from pre-training to the downstream task.

Prompting techniques fundamentally revolve around the idea of augmenting the input data to better align with the pretext objectives. This makes the design of a graph-level transformation an important factor for the efficacy of prompting. To illustrate, let's consider a homogeneous graph \(\mathcal{G}\) with its adjacency matrix \(\mathbf{A}\) and node feature matrix \(\mathbf{X}\). We introduce \(t_{\xi}\), a graph-level transformation function parameterized by \(\xi\), such as changing node features, adding or removing edges, _etc_. Prior research (Chen et al., 2018; Wang et al., 2019) has proved that for any transformation function \(t_{\xi}\), there always exists a corresponding feature prompt \(\mathbf{p}^{*}\) that satisfies the following property:

\[f_{\theta^{*}}(\mathbf{A},\mathbf{X}+\mathbf{p}^{*})\equiv f_{\theta^{*}}(t_{\xi}(\mathbf{A}, \mathbf{X}))+O_{\rho\theta}, \tag{6}\]

where \(O_{\rho\theta}\) represents the deviation between the node representations from the graph that's augmented by \(t_{\xi}\) and the graph that's prompted by \(\mathbf{p}^{*}\). This discrepancy is primarily contingent on the quality of the learned prompt \(\mathbf{p}^{*}\) as the parameters \(\theta^{*}\) of the pre-trained model are fixed. This perspective further implies the feasibility and significance of crafting an effective feature prompt within

Figure 2. Overview of the HetGPT architecture: Initially, an HGNN is pre-trained alongside a contrastive head using a contrastive learning objective, after which their parameters are frozen. Following this, a _heterogeneous feature prompt_ (Sec. 4.3) is injected into the input graph’s feature space. These prompted node features are then processed by the pre-trained HGNN, producing the prompted node embeddings. Next, a _multi-view neighborhood aggregation_ mechanism (Sec. 4.4) captures both local and global heterogeneous neighborhood information of the target node, generating a node token. Finally, pairwise similarity comparisons are performed between this node token and class tokens derived from the _virtual class prompt_ (Sec. 4.2) via the same contrastive learning objective from pre-training. As an illustrative example of employing HetGPT for node classification: consider a target node \(P_{2}\) associated with class \(1\), its positive samples during prompt tuning are constructed using the class token of class \(1\), while negative samples are drawn from class tokens of classes \(2\) and \(3\) (_i.e., all remaining classes_).
the graph's input space, which emulates the impact of learning a specialized augmentation function tailored for downstream tasks.

However, in heterogeneous graphs, nodes exhibit diverse attributes based on their types, and each type has unique dimensionalities and underlying semantic meanings. Take a citation network for instance: while paper nodes have features represented by word embeddings derived from their abstracts, author nodes utilize one-shot encoding as features. Given this heterogeneity, the approach used in homogeneous graph prompting methods may not be effective or yield optimal results when applied to heterogeneous graphs, as it uniformly augments node features for all node types via a single and all-encompassing feature prompt.

#### 4.3.1. Type-specific feature tokens

To address the above challenge, we introduce type-specific feature tokens, which are a set of designated tokens that align with the diverse input features inherent to each node type. Given the diversity in scales and structures across various graphs, equating the number of feature tokens to the node count is often sub-optimal. This inefficiency is especially obvious in large-scale graphs, as this design demands extensive storage due to its \(O(|\mathcal{V}|)\) learnable parameters. In light of this, for each node type, we employ a feature prompt consisting of a limited set of independent basis vectors of size \(K\), _i.e._, \(f_{k}^{A}\in\mathbb{R}^{d_{A}}\), with \(d_{A}\) as the feature dimension associated with node type \(A\in\mathcal{A}\):

\[\mathcal{F}=\{\mathcal{F}_{A}\mid A\in\mathcal{A}\},\quad\quad\quad\mathcal{F} _{A}=\left\{f_{1}^{A},f_{2}^{A},\ldots,f_{K}^{A}\right\}, \tag{7}\]

where \(K\) is a hyperparameter and its value can be adjusted based on the specific dataset in use.

#### 4.3.2. Prompted node features

For each node \(i\) of type \(A\in\mathcal{A}\), its node feature vector \(\mathbf{x}_{i}^{A}\) is augmented by a linear combination of feature token \(f_{k}^{A}\) through an attention mechanism, where the attention weights are denoted by \(w_{i,k}^{A}\). Consequently, the prompted node feature vector evolves as:

\[\tilde{\mathbf{x}}_{i}^{A}=\mathbf{x}_{i}^{A}+\sum_{k=1}^{K}w_{i,k}^{A} \cdot f_{k}^{A}, \tag{9}\] \[w_{i,k}^{A}=\frac{\exp\left(\sigma\left((f_{k}^{A})^{\top}\cdot \mathbf{x}_{i}^{A}\right)\right)}{\sum_{j=1}^{K}\exp\left(\sigma\left((f_{j}^{A}) ^{\top}\cdot\mathbf{x}_{i}^{A}\right)\right)}, \tag{8}\]

where \(\sigma(\cdot)\) represents a non-linear activation function. Subsequently, we utilize these prompted node features, represented as \(\tilde{\mathcal{X}}\), together with the heterogeneous graph, \(\mathcal{G}\). They are then passed through the pre-trained HGNN \(f_{0}\). during the prompt tuning phase to obtain a prompted node embedding matrix \(\tilde{\mathbf{H}}\):

\[\tilde{\mathbf{H}}=f_{0^{\star}}(\mathcal{G},\tilde{\mathcal{X}})\in\mathbb{R}^{| \mathcal{V}|\times d}. \tag{10}\]

### Multi-View Neighborhood Aggregation (C4)

In prompt-based learning for homogeneous graphs, the node token \(\mathbf{z}_{o}\) in Equation 3 for a given node \(v\in\mathcal{V}\) is directly equated to \(\mathbf{h}_{o}\), which is the embedding generated by the pre-trained network \(f_{0^{\star}}\)(Wang et al., 2017). Alternatively, it can also be derived from an aggregation of the embeddings of its immediate neighboring nodes (Wang et al., 2017). However, in heterogeneous graphs, such aggregations are complicated due to the inherent heterogeneity of neighboring structures. For example, given a target node with the type "paper", connections can be established either with other "paper" nodes through different metapaths (_e.g._, PAP, PSP) or with nodes of varied types (_i.e._, author or subject) based on the network schema. Furthermore, it is also vital to leverage the prompted pre-trained node embeddings \(\tilde{\mathbf{H}}\) (as detailed in Section 4.3) in the aggregation. Taking all these into consideration, we introduce a multi-view neighborhood aggregation mechanism. This strategy incorporates both type-based and metapath-based neighbors, ensuring a comprehensive representation that captures both local (_i.e._, network schema) and global (_i.e._, metapath) patterns.

#### 4.4.1. Type-based aggregation

Based on the network schema outlined in Definition 2, a target node \(i\in\mathcal{V}_{T}\) can directly connect to \(M\) different node types \(\{A_{1},A_{2},\ldots,A_{M}\}\). Given the variability in contributions from different nodes of the same type to node \(i\) and the diverse influence from various types of neighbors, we utilize a two-level attention mechanism (Wang et al., 2017) to aggregate the local information of node \(i\). For the first level, the information \(\mathbf{h}_{i}^{A_{m}}\) is fused from the neighbor set \(\mathcal{N}_{i}^{A_{m}}\) for node \(i\) using node attention:

\[\mathbf{h}_{i}^{A_{m}}=\sigma\left(\sum_{j\in\mathcal{N}_{i}^{A_{m}} \cup\{i\}}\alpha_{i,j}^{A_{m}}\cdot\tilde{\mathbf{h}}_{j}\right), \tag{12}\] \[\alpha_{i,j}^{A_{m}}=\frac{\exp\left(\sigma\left(\mathbf{a}_{A_{m}} ^{\top}\cdot[\tilde{\mathbf{h}}_{i}||\tilde{\mathbf{h}}_{j}]\right)\right)}{\sum_{k\in \mathcal{N}_{i}^{A_{m}}\cup\{i\}}\exp\left(\sigma\left(\mathbf{a}_{A_{m}}^{\top} \cdot[\tilde{\mathbf{h}}_{i}||\tilde{\mathbf{h}}_{k}]\right)\right)}, \tag{11}\]

where \(\sigma(\cdot)\) is a non-linear activation function, \(||\) denotes concatenation, and \(\mathbf{a}_{A_{m}}\in\mathbb{R}^{2d\times 1}\) is the node attention vector shared across all nodes of type \(A_{m}\). For the second level, the type-based embedding of node \(i\), denoted as \(\mathbf{z}_{i}^{\text{TP}}\), is derived by synthesizing all type representations \(\{\mathbf{h}_{i}^{A_{1}},\mathbf{h}_{i}^{A_{2}},\ldots,\mathbf{h}_{i}^{A_{M}}\}\) through semantic attention:

\[\mathbf{z}_{i}^{\text{TP}}=\sum_{i=1}^{M}\beta_{A_{m}}\cdot\mathbf{h}_{i}^ {A_{m}},\quad\beta_{A_{m}}=\frac{\exp(w_{A_{m}})}{\sum_{k=1}^{M}\exp(w_{A_{k}})}, \tag{14}\] \[w_{A_{m}}=\frac{1}{|\mathcal{V}_{T}|}\sum_{i\in\mathcal{V}_{T} }\mathbf{a}_{\text{TP}}^{\top}\cdot\tanh(\mathbf{W}_{\text{TP}}\cdot\mathbf{h}_{i}^{A_{m} }+\mathbf{b}_{\text{TP}}), \tag{13}\]

where \(\mathbf{a}_{\text{TP}}\in\mathbb{R}^{d\times 1}\) is the type-based semantic attention vector shared across all node types, \(\mathbf{W}_{\text{TP}}\in\mathbb{R}^{d\times d}\) is the weight matrix, and \(\mathbf{b}_{\text{TP}}\in\mathbb{R}^{d\times 1}\) is the bias vector.

#### 4.4.2. Metapath-based aggregation

In contrast to type-based aggregation, metapath-based aggregation provides a perspective to capture global information of a target node \(i\in\mathcal{V}_{T}\). This is attributed to the nature of metapaths, which encompass connections that are at least two hops away. Given a set of defined metapaths \(\{P_{1},P_{2},\ldots,P_{N}\}\), the information from neighbors of node \(i\) connected through metapath \(P_{n}\) is aggregated via node attention:

\[\mathbf{h}_{i}^{P_{n}}=\sigma\left(\sum_{j\in\mathcal{N}_{i}^{P_{n}} \cup\{i\}}\alpha_{i,j}^{P_{n}}\cdot\tilde{\mathbf{h}}_{i}\right), \tag{16}\] \[\alpha_{i,j}^{P_{n}}=\frac{\exp\left(\sigma\left(\mathbf{a}_{P_{n}}^{ \top}\cdot[\tilde{\mathbf{h}}_{i}||\tilde{\mathbf{h}}_{j}]\right)\right)}{\sum_{k\in \mathcal{N}_{i}^{P_{n}}\cup\{i\}}\exp\left(\sigma\left(\mathbf{a}_{P_{n}}^{\top} \cdot[\tilde{\mathbf{h}}_{i}||\tilde{\mathbf{h}}_{k}]\right)\right)}, \tag{15}\]
where \(\mathbf{a}_{P_{n}}\in\mathbb{R}^{2d\times 1}\) is the node attention vector shared across all nodes connected through metapath \(P_{n}\). To compile the global structural information from various metapaths, we fuse the node embeddings \(\{\mathbf{h}_{i}^{P_{n}},\mathbf{h}_{i}^{P_{2}},\ldots,\mathbf{h}_{i}^{P_{N}}\}\) derived from each metapath into a single embedding using semantic attention:

\[\mathbf{z}_{i}^{\text{MP}}=\sum_{i=1}^{N}\beta_{P_{n}}\cdot\mathbf{h}_{i}^ {P_{n}},\quad\beta_{P_{n}}=\frac{\exp(w_{P_{n}})}{\sum_{k=1}^{N}\exp(w_{P_{k}})}, \tag{18}\] \[w_{P_{n}}=\frac{1}{|\mathcal{V}_{T}|}\sum_{i\in\mathcal{V}_{T}} \mathbf{a}_{\text{MP}}^{\top}\cdot\tanh(\mathbf{W}_{\text{MP}}\cdot\mathbf{h}_{i}^{P_{ n}}+\mathbf{b}_{\text{MP}}), \tag{17}\]

where \(\mathbf{a}_{\text{MP}}\in\mathbb{R}^{d\times 1}\) is the metapath-based semantic- attention vector shared across all metapaths, \(\mathbf{W}_{\text{MP}}\in\mathbb{R}^{d\times d}\) is the weight matrix, and \(\mathbf{b}_{\text{MP}}\in\mathbb{R}^{d\times 1}\) is the bias vector. Integrating the information from both aggregation views, we obtain the final node token, \(\mathbf{z}_{i}\), by concatenating the type-based and the metapath-based embedding:

\[\mathbf{z}_{i}=\sigma\left(\mathbf{W}[\mathbf{z}_{i}^{\text{MP}}\|\mathbf{z}_{i}^{\text{TP}}] +\mathbf{b}\right), \tag{19}\]

where \(\sigma(\cdot)\) is a non-linear activation function, \(\mathbf{W}\in\mathbb{R}^{2d\times d}\) is the weight matrix, and \(\mathbf{b}\in\mathbb{R}^{d\times 1}\) is the bias vector.

### Prompt-Based Learning and Inference

Building upon our prompt design detailed in the preceding sections, we present a comprehensive overview of the prompt-based learning and inference process for semi-supervised node classification. This methodology encompasses three primary stages: (1) _prompt addition_, (2) _prompt tuning_, and (3) _prompt-assisted prediction_.

#### 4.5.1. Prompt addition

Based on the graph prompting function \(I(\cdot)\) outlined in Equation (3), we parameterize it using the trainable virtual class prompt \(\mathcal{Q}\) and the heterogeneous feature prompt \(\mathcal{F}\). To ensure compatibility during the contrastive loss calculation, which we detail later, we use a single-layer Multilayer Perceptron (MLP) to project both \(\mathbf{z}_{0}\) and \(\mathbf{q}_{c}\), onto the same embedding space. Formally:

\[\mathbf{z}_{v}^{\prime}=\text{MLP}(\mathbf{z}_{v}),\quad\quad\mathbf{q}_{c}^{\prime}= \text{MLP}(\mathbf{q}_{c}),\quad\quad l_{\mathcal{Q},\mathcal{F}}(v)=[\mathbf{z}_{v}^{ \prime},\mathbf{q}_{c}^{\prime}]. \tag{20}\]

#### 4.5.2. Prompt tuning

Our prompt design allows us to reuse the contrastive head from Equation 1 for downstream node classification without introducing a new prediction head. Thus, the original positive \(\mathcal{P}_{p}\) and negative samples \(\mathcal{N}_{0}\) of a labeled node \(v\in\mathcal{V}_{L}\) used during pre-training are replaced with the virtual class prompt corresponding to its given class label \(y_{v}\).

\[\mathcal{P}_{v}=\left\{\mathbf{q}_{y_{v}}\right\},\quad\quad\quad\quad\quad \mathcal{N}_{0}=\mathcal{Q}\setminus\left\{\mathbf{q}_{y_{v}}\right\}, \tag{21}\]

Consistent with the contrastive pre-training phase, we employ the InfoNCE (Liu et al., 2019) loss to replace the supervised classification loss \(\mathcal{L}_{\text{sup}}\):

\[\mathcal{L}_{\text{con}}=-\sum_{v\in\mathcal{V}_{L}}\log\left(\frac{\exp(\text {sim}(\mathbf{z}_{v}^{\prime},\mathbf{q}_{y_{v}}^{\prime})/\tau)}{\sum_{c=1}^{C}\exp( \text{sim}(\mathbf{z}_{v}^{\prime},\mathbf{q}_{c}^{\prime})/\tau)}\right). \tag{22}\]

Here, \(\text{sim}(\cdot)\) denotes a similarity function between two vectors, and \(\tau\) denotes a temperature hyperparameter. To obtain the optimal prompts, we utilize the following prompt tuning objective:

\[\mathcal{Q}^{*},\mathcal{F}^{*}=\operatorname*{arg\,min}_{\mathcal{Q},\mathcal{ F}}\mathcal{L}_{\text{con}}\left(\mathbf{g}_{\psi^{*}},\mathbf{f}_{\theta^{*}},\mathbf{l}_{ \mathcal{Q},\mathcal{F}},\mathcal{V}_{L}\right)+\lambda\mathcal{L}_{\text{orth}}, \tag{23}\]

where \(\lambda\) is a regularization hyperparameter. The orthogonal regularization (Bang et al., 2019) loss \(\mathcal{L}_{\text{orth}}\) is defined to ensure the label tokens in the virtual class prompt remain orthogonal during prompt tuning, fostering diversified representations of different classes:

\[\mathcal{L}_{orth}=\left\|\mathbf{QQ}^{\top}-\mathbf{I}\right\|_{F}^{2}, \tag{24}\]

where \(\mathbf{Q}=[\mathbf{q}_{1},\mathbf{q}_{2},\ldots,\mathbf{q}_{C}]^{\top}\in\mathbb{R}^{C \times d}\) is the matrix form of the virtual class prompt \(\mathcal{Q}\), and \(\mathbf{I}\in\mathbb{R}^{C\times C}\) is an identity matrix.

#### 4.5.3. Prompt-assisted prediction

During the inference phase, for an unlabeled target node \(v\in\mathcal{V}_{U}\), the predicted probability of node \(v\) belonging to class \(c\) is given by:

\[P(y_{v}=c)=\frac{\exp(\text{sim}(\mathbf{z}_{v}^{\prime},\mathbf{q}_{c}^{\prime}))}{ \sum_{k=1}^{C}\exp(\text{sim}(\mathbf{z}_{v}^{\prime},\mathbf{q}_{k}^{\prime}))}. \tag{25}\]

This equation computes the similarity between the projected node token \(\mathbf{z}_{v}^{\prime}\) and each projected class token \(\mathbf{q}_{c}^{\prime}\), using the softmax function to obtain class probabilities. The class with the maximum likelihood for node \(v\) is designated as the predicted class \(\hat{y}_{v}\):

\[\hat{y}_{v}=\operatorname*{arg\,max}_{c}P(y_{v}=c), \tag{26}\]

## 5. Experiments

In this section, we conduct a thorough evaluation of our proposed HetGPT to address the following research questions:

* **(RQ1)** Can HetGPT improve the performance of pre-trained heterogeneous graph neural networks on the semi-supervised node classification task?
* **(RQ2)** How does HetGPT perform under different settings, _i.e._, ablated models and hyperparameters?
* **(RQ3)** How does the prompt tuning efficiency of HetGPT compare to its fine-tuning counterpart?
* **(RQ4)** How interpretable is the learned prompt in HetGPT?

### Experiment Settings

#### 5.1.1. Datasets

We evaluate our methods using three benchmark datasets: ACM (Yang et al., 2019), DBLP (Chen et al., 2019), and IMDB (Chen et al., 2019). Detailed statistics and descriptions of these datasets can be found in Table 1. For the semi-supervised node classification task, we randomly select 1, 5, 20, 40, or 60 labeled nodes per class as our training set. Additionally, we set aside 1,000 nodes for validation and another 1,000 nodes for testing. Our evaluation metrics include Macro-F1 and Micro-F1.

#### 5.1.2. Baseline models

We compare our approach against methods belonging to three different categories:

* **Supervised HGNNs:** HAN (Liu et al., 2019), HGT (Chen et al., 2019), MAGNN (Chen et al., 2019);

\begin{table}
\begin{tabular}{c|c|c|c|c} \hline \hline
**Dataset** & **\# Nodes** & **\# Edges** & **Metapaths** & **\# Classes** \\ \hline \multirow{3}{*}{ACM} & Paper: 4,019 & \multirow{3}{*}{P-A: 13,407} & \multirow{3}{*}{PSP} & \multirow{3}{*}{3} \\  & Author: 7,167 & & \multirow{3}{*}{P-S: 4,019} & \multirow{3}{*}{APCA} \\  & Subject: 60 & & & \\ \hline \multirow{3}{*}{DBLP} & Author: 4,057 & \multirow{3}{*}{P-A: 19,645} & \multirow{3}{*}{APA} & \multirow{3}{*}{4} \\  & Paper: 14,328 & & \multirow{3}{*}{P-T: 85,810} & \multirow{3}{*}{APCPA} \\  & Term: 7,723 & & \multirow{3}{*}{P-C: 14,328} & \multirow{3}{*}{APTPA} \\  & Conference: 20 & & & \\ \hline \multirow{3}{*}{IMDB} & Movie: 4,278 & \multirow{3}{*}{M-D: 4,278} & \multirow{3}{*}{MAM} \\  & Director: 2,081 & & \multirow{3}{*}{M-A: 12,828} & \multirow{3}{*}{MDM} \\  & Actor: 5,257 & & & \\ \hline \hline \end{tabular}
\end{table}
Table 1. Detailed statistics of the benchmark datasets. Underlined node types are the target nodes for classification.
* **HGNNs with "pre-train, fine-tune"**:
* **Generative**: HGMAE [(30)];
* **Contrastive (our focus)**: DMGI [(24)],HeCo [(37)],HDMI [(15)];
* **GNNs with"pre-train, prompt"**: GPPT [(27)].

#### 5.1.3. Implementation details

For the homogeneous method GPPT, we evaluate using all the metapaths and present the results with the best performance. Regarding the parameters of other baselines, we adhere to the configuration specified in their original papers.

In our HetGPT model, the heterogeneous feature prompt is initialized using Kaiming initialization [(9)]. During the prompt tuning phase, we employ the Adam optimizer [(16)] and search within a learning rate ranging from 1e-4 to 5e-3. We also tune the patience for early stopping from 20 to 100. The regularization hyperparameter \(\lambda\) is set to 0.01. We experiment with the number of feature tokens \(K\), searching values from {1, 5, 10, 15, 20}. Lastly, for our non-linear activation function \(\sigma(\cdot)\), we use LeakyReLU.

### Performance on Node Classification (RQ1)

Experiment results for semi-supervised node classification on three benchmark datasets are detailed in Table 2. Compared to the pre-trained DMGI, HeCo, and HDMI models, our post-training prompting framework, HetGPT, exhibits superior performance in 88 out of the 90 comparison pairs. Specifically, we observe a relative improvement of 3.00% in Macro-F1 and 2.62% in Micro-F1. The standard deviation of HetGPT aligns closely with that of the original models, indicating that the improvement achieved is both substantial and robust. It's crucial to note that the three HGNNs with _"pre-train, fine-tune"_ - DMGI, HeCo, and HDMI, are already among the state-of-the-art methods for semi-supervised node classification. By integrating them with HetGPT, we push the envelope even further, setting a new performance pinnacle. Furthermore, HetGPT's edge becomes even more significant in scenarios where labeled nodes are extremely scarce, achieving an improvement of 6.60% in Macro-F1 and 6.88% in Micro-F1 under the 1-shot setting. Such marked improvements in few-shot performance strongly suggest HetGPT's efficacy in mitigating the overfitting issue. The strategic design of our prompting function, especially the virtual class prompt, effectively captures the intricate characteristics of each class, which can potentially obviate the reliance on costly annotated data. Additionally, GPPT lags considerably on all datasets, which further underscores the value of HetGPT's effort in tackling the unique challenges inherent to heterogeneous graphs.

### Performance under Different Settings (RQ2)

#### 5.3.1. Ablation study

To further demonstrate the effectiveness of each module in HetGPT, we conduct an ablation study to evaluate our full framework against the following three variants:

* **w/o VCP**: the variant of HetGPT without the virtual class prompt from Section 4.2;
* **w/o HFP**: the variant of HetGPT without the heterogeneous feature prompt from Section 4.3;

\begin{table}
\begin{tabular}{c|c|c|c c c c|c c c|c c c} \hline \hline Dataset & Metric & \# Train & HAN & HGT & MAGNN & HGMAE & GPPT & DMGI & **+HetGPT** & HeCo & **+HetGPT** & HDMI & **+HetGPT** \\ \hline \multirow{8}{*}{ACM} & \multirow{8}{*}{Ma-F1} & 1 & 27.08\(\pm\)4.09 & 49.74\(\pm\)3.88 & 36.24\(\pm\)2.38 & 28.00\(\pm\)7.12 & 21.85\(\pm\)4.09 & 47.28\(\pm\)5.12 & 52.07\(\pm\)3.82 & 54.24\(\pm\)4.04 & 55.90\(\pm\)4.04 & 65.58\(\pm\)5.47 & **71.00\(\pm\)**3.32 \\  & & 5 & 84.84\(\pm\)6.93 & 84.40\(\pm\)4.98 & 84.45\(\pm\)4.79 & 87.34\(\pm\)1.42 & 71.77\(\pm\)8.61 & 86.24\(\pm\)6.97 & 87.91\(\pm\)7.04 & 86.55\(\pm\)5.36 & 87.03\(\pm\)1.11 & 88.88\(\pm\)1.73 & **91.08\(\pm\)**3.37 \\  & & 20 & 84.37\(\pm\)3.15 & 84.03\(\pm\)5.13 & 85.13\(\pm\)1.62 & 88.09\(\pm\)8.04 & 86.64\(\pm\)4.05 & 88.65\(\pm\)5.04 & 88.09\(\pm\)1.21 & 88.63\(\pm\)5.03 & 90.67\(\pm\)7.92 & **92.15\(\pm\)**3.03 \\  & & 40 & 86.33\(\pm\)4.86 & 86.74\(\pm\)4.83 & 85.12\(\pm\)1.81 & 81.18\(\pm\)5.71 & 87.52\(\pm\)4.78 & 87.58\(\pm\)4.04 & 87.03\(\pm\)8.04 & 86.86\(\pm\)5.04 & 90.62\(\pm\)5.21 & **91.31\(\pm\)**3.99 \\  & & 60 & 86.31\(\pm\)4.16 & 86.56\(\pm\)4.56 & 86.56\(\pm\)5.15 & 88.81\(\pm\)1.07 & 84.15\(\pm\)5.08 & 87.14\(\pm\)5.09 & 90.35\(\pm\)4.04 & 88.95\(\pm\)4.05 & 91.34\(\pm\)5.9 & 91.29\(\pm\)**3.95 \\ \cline{2-13}  & & 1 & 49.76\(\pm\)4.58 & 58.52\(\pm\)4.53 & 51.27\(\pm\)4.05 & 40.82\(\pm\)2.38 & 34.23\(\pm\)2.19 & 49.63\(\pm\)5.24 & 52.49\(\pm\)4.09 & 54.81\(\pm\)4.08 & 65.01\(\pm\)4.08 & 64.89\(\pm\)4.02 & **73.41\(\pm\)**3.51 \\  & & 5 & 84.96\(\pm\)1.14 & 85.31\(\pm\)4.14 & 85.31\(\pm\)4.73 & 74.73\(\pm\)4.31 & 85.16\(\pm\)4.08 & 88.05\(\pm\)4.07 & 86.85\(\pm\)5.13 & 87.26\(\pm\)5.09 & 89.01\(\pm\)4.07 & **91.09\(\pm\)**3.07 \\  & & 20 & 83.33\(\pm\)5.05 & 83.85\(\pm\)4.05 & 83.88\(\pm\)1.09 & 88.11\(\pm\)5.11 & 82.00\(\pm\)8.54 & 85.94\(\pm\)4.08 & 87.87\(\pm\)3.81 & 88.60\(\pm\)5.09 & 90.53\(\pm\)**9.05 & **91.05\(\pm\)**9.05 \\  & & 40 & 86.24\(\pm\)4.04 & 86.21\(\pm\)4.86 & 86.39\(\pm\)4.98 & 88.29\(\pm\)1.88 & 82.02\(\pm\)1.87 & 80.97\(\pm\)5.78 & 86.56\(\pm\)5.15 & 86.64\(\pm\)5.15 & 89.04\(\pm\)4.12 & **91.11\(\pm\)**3.99 \\  & & 60 & 85.56\(\pm\)4.84 & 85.49\(\pm\)4.58 & 86.03\(\pm\)4.80 & 88.59\(\pm\)4.17 & 84.16\(\pm\)6.08 & 83.44\(\pm\)6.09 & 90.13\(\pm\)0.30 & 88.48\(\pm\)6.04 & 88.91\(\pm\)6.05 & 91.16\(\pm\)6.05 & **91.94\(\pm\)**3.93 \\ \hline \multirow{8}{*}{DBLP} & \multirow{8}{*}{Ma-F1} & 1 & 50.28\(\pm\)4.84 & 70.86\(\pm\)4.82 & 52.52\(\pm\)4.87 & 82.75\(\pm\)5.39 & 39.17\(\pm\)7.12 & 76.00\(\pm\)3.21 & 83.33\(\pm\)1.90 & 88.79\(\pm\)4.04 & 89.44\(\pm\)4.54 & 88.28\(\pm\)5.39 & **90.25\(\pm\)**9.09 \\  & & 5 & 82.85\(\pm\)4.88 & 82.70\(\pm\)3.03 & 82.24\(\pm\)3.85 & 83.47\(\pm\)4.05 & 54.13\(\pm\)1.81 & 81.12\(\pm\)5.18 & 81.55\(\pm\)1.91 & 91.65\(\pm\)5.03 & **91.87\(\pm\)**7.01 & 91.00\(\pm\)**9.39 \\  & & 20 & 89.91\(\pm\)4.81 & 89.61\(\pm\)5.12 & 89.36\(\pm\)5.88 & 89.81\(\pm\)5.71 & 71.06\(\pm\)5.03 & 84.03\(\pm\)5.41 & 89.03\(\pm\)5.41 & 89.90\(\pm\)5.17 & 91.00\(\pm\)**5.14 \\  & & 40 & 89.25\(\pm\)5.48 & 89.59\(
* **w/o MNA:** the variant of HetGPT without the multi-view neighborhood aggregation from Section 4.4.

Experiment results on ACM and DBLP, shown in Figure 3, highlight the substantial contributions of each module to the overall effectiveness of HetGPT. Notably, the virtual class prompt emerges as the most pivotal component, indicated by the significant performance drop when it's absent. This degradation mainly stems from the overfitting issue linked to the negative transfer problem, especially when labeled nodes are sparse. The virtual class prompt directly addresses this issue by generalizing the intricate characteristics of each class within the embedding space.

#### 5.3.2. Hyper-parameter sensitivity

We evaluate the sensitivity of HetGPT to its primary hyperparameter: the number of basis feature tokens \(K\) in Equation (7). As depicted in Figure 4, even a really small value of \(K\) (_i.e._, 5 for ACM, 20 for DBLP, and 5 for IMDB) can lead to satisfactory node classification performance. This suggests that the prompt tuning effectively optimizes performance without the need to introduce an extensive number of new parameters.

### Prompt Tuning Efficiency Analysis (RQ3)

Our HetGPT, encompassing the virtual class prompt and the heterogeneous feature prompt, adds only a few new trainable parameters (_i.e._, comparable to a shallow MLP). Concurrently, the parameters of the pre-trained HGNNs and the contrastive head remain unchanged during the entire prompt tuning phase. Figure 5 illustrates that HetGPT converges notably faster than its traditional "_pre-train_, _fine-tune_" counterpart, both recalibrating the parameters of the pre-trained HGNNs and introducing a new prediction head. This further demonstrates the efficiency benefits of our proposed framework, allowing for effective training with minimal tuning iterations.

### Interpretability Analysis (RQ4)

To gain a clear understanding of how the design of the virtual class prompt facilitates effective node classification without relying on the traditional classification paradigm, we employ a t-SNE plot to visualize the node representations and the learned virtual class prompt on ACM and DBLP, as shown in Figure 6. Within this visualization, nodes are depicted as colored circles, while the class tokens from the learned virtual class prompt are denoted by colored stars. Each color represents a unique class label. Notably, the embeddings of these class tokens are positioned in close vicinity to clusters of node embeddings sharing the same class label. This immediate spatial proximity between a node and its respective class token validates the efficacy of similarity measures inherited from the contrastive pretext for the downstream node classification task. This observation further reinforces the rationale behind our node classification approach using the virtual class prompt, _i.e._, a node is labeled as the class that its embedding is most closely aligned with.

## 6. Conclusion

In this paper, we propose HetGPT, a general post-training prompting framework to improve the node classification performance of pre-trained heterogeneous graph neural networks. Recognizing the prevalent issue of misalignment between the objectives of pretext and downstream tasks, we craft a novel prompting function that integrates a virtual class prompt and a heterogeneous feature prompt. Furthermore, our framework incorporates a multi-view neighborhood aggregation mechanism to capture the complex neighborhood structure in heterogeneous graphs. Extensive experiments on three benchmark datasets demonstrate the effectiveness of HetGPT. For future work, we are interested in exploring the potential of prompting methods in tackling the class-imbalance problem on graphs or broadening the applicability of our framework to diverse graph tasks, such as link prediction and graph classification.

Figure 4. Performance of HetGPT with the different number of basis feature vectors on ACM, DBLP, and IMDB.

Figure 5. Comparison of training losses over epochs between HetGPT and its fine-tuning counterpart on DBLP and IMDB.

Figure 3. Ablation study of HetGPT on ACM and IMDB.

Figure 6. Visualization of the learned node tokens and class tokens in virtual class prompt on ACM and DBLP.