Method and apparatus for few-shot node classification on a text-attributed graph
The integration of LMs and GNNs through self-supervised learning and mixed prompt methods addresses the limitations of independent pre-training on TAGs, enhancing node classification performance by aligning pre-training with downstream tasks and reducing costs.
Patent Information
- Application Number
- PCT/CN2024/096067
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2025-12-04
AI Technical Summary
Existing methods for node classification on Text-Attributed Graphs (TAGs) suffer from independent pre-training of language models (LMs) and graph neural networks (GNNs), leading to information loss and high dependency on pre-processing, and face challenges in aligning pre-training objectives with downstream tasks due to inconsistent label spaces.
A unified masked learning framework integrates LMs and GNNs through self-supervised learning, using masked language modeling and mini-batch sub-graphs, and a new graph-text mixed prompt learning method to align pre-training with downstream tasks.
This approach effectively leverages both textual and structural information, reducing overfitting and labeling costs, enabling better adaptation to downstream tasks like few-shot node classification.
Smart Images

Figure CN2024096067_04122025_PF_FP_ABST
Abstract
Description
METHOD AND APPARATUS FOR FEW-SHOT NODE CLASSIFICATION ON A TEXT-ATTRIBUTED GRAPHFIELD
[0001] Aspects of the present disclosure relate generally to artificial intelligence, and more particularly, to method and apparatus provided for node classification on a Text-Attributed Graph (TAG) , by pre-training a language model (LM) and a graph neural network (GNN) encoder jointly in a self-supervised manner and performing joint prompting learning with the pre-trained LM and GNN encoder.BACKGROUND
[0002] Text-Attributed Graph (TAG) is one genre of important graph-structured data with each node contains rich textual information and edges representing relationships between the nodes. A wide variety of real-world application data can be depicted by TAG, to name a few, online shopping site, social network, citation network, intelligent manufacturing system, etc.
[0003] For these graphs, a language model (LM) is usually first pre-trained to encode the raw texts in the TAG to obtain numerical representations of nodes. After that, a graph neural network (GNN) would be pre-trained based on the numerical representations of nodes and the structure of TAG.
[0004] In one aspect, independent pre-training of LM and GNN results in the performance highly dependent on the choice of the pre-processing LM. In one aspect, the independent pre-training of the LM and the GNN does not fully utilize the potential of TAG and can bring non-negligible information loss. In another aspect, obtaining labels for graph-structured data is usually costly in real-world applications. Therefore, it is desirable to integrate the LM and GNN effectively with joint pre-training on a TAG in a self-supervised way.
[0005] Prompts may be designed to mitigate the gap between the pre-train objective and the downstream tasks. On TAG, there are both text (e.g., LM side) and structure (e.g., GNN side) information. However, some prompts are conventionally constructed solely based on the text information but lack analysis of the structure attribute. For example, such prompts may be hand-crafted or designed by processing raw text solely from the LM side. On the other hand, some prompts may be constructed at the graph level, but such prompts neglect text information and are not directly applicable to TAGs. Therefore, it is desired to design a prompt learning method on TAG to mitigate the gap between pre-training and downstream tasks on TAG.SUMMARY
[0006] The following presents a simplified summary of one or more aspects to provide a basic understanding of such aspects. This summary is not an extensive overview of all contemplated aspects, and is intended to neither identify key or critical elements of all aspects nor delineate the scope of any or all aspects. Its sole purpose is to present some concepts of one or more aspects in a simplified form as a prelude to the more detailed description that is presented later.
[0007] In an aspect, a method of prompt learning for a pre-trained model on a first Text-Attributed Graph (TAG) , wherein the pre-trained model comprises a pre-trained language model (LM) and a pre-trained graph neural network (GNN) encoder, and wherein the first TAG comprises multiple nodes and multiple edges, each node of the first TAG representing a text sequence and each edge of the first TAG representing a relation between two nodes, the method comprising: obtaining an ego TAG for a target node of the multiple nodes of the first TAG; obtaining a second TAG by combining the ego TAG and a prompt TAG, wherein each node of the prompt TAG is initialized randomly or based on a representation of a label text sequence through the pretrained LM, wherein the label text sequence is associated with a label of a downstream classification task of the pre-trained model; obtaining a first representation of the second TAG through the GNN encoder; predicting a label for the target node based on the first representation and a text prompt through a multilayer perceptron (MLP) network, the text prompt initialized based on a second representation of a text sequence of the target node through the LM; and updating the prompt TAG and the text prompt in accordance with a loss function based on the predicted label and a label of the target node.
[0008] In an aspect, a method for label prediction by using the pre-trained model comprising the language model (LM) and the graph neural network (GNN) encoder, the prompt TAG and the text prompt learnt in accordance with the aspects described herein on a third Text-Attributed Graph (TAG) , comprising: obtaining a sub TAG comprising a node for label prediction based on the third TAG; obtaining a fourth TAG by combining the sub TAG and the prompt TAG; obtaining a fifth representation of the fourth TAG through the GNN encoder; and predicting a label for the target node based on the fifth representation and the text prompt through the multilayer perceptron (MLP) network.
[0009] In an aspect, a computer system is disclosed. The computer system comprises one or more processors; and one or more storage devices storing computer-executable instructions that, when executed, cause the one or more processors to perform the operations of one of the methods disclosed herein.
[0010] In an aspect, a computer readable storage media storing computer-executable instructions that, when executed, cause one or more processors to perform the operations of one of the methods disclosed herein is disclosed.
[0011] In an aspect, a computer program product comprising computer-executable instructions that, when executed, cause one or more processors to perform the operations of one of the methods disclosed herein is disclosed.BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The disclosed aspects will be described in connection with the appended drawings that are provided to illustrate and not to limit the disclosed aspects.
[0013] Fig. 1 illustrates an exemplary a Text-Attributed Graph (TAG) , in accordance with various aspects of the present disclosure.
[0014] Fig. 2 illustrates an exemplary framework of independently training language models (LMs) and graph neural networks (GNNs) on a TAG, in accordance with various aspects of the present disclosure.
[0015] Fig. 3 illustrates an exemplary framework of jointly training language models (LMs) and graph neural networks (GNNs) on a TAG, in accordance with various aspects of the present disclosure.
[0016] Fig. 4 illustrates an exemplary framework of applying a prompt to an input to align to the downstream label space, in accordance with various aspects of the present disclosure.
[0017] Fig. 5 illustrates an exemplary framework of joint prompt learning in a pre-trained language models (LMs) and graph neural networks (GNNs) on a TAG, in accordance with various aspects of the present disclosure.
[0018] Fig. 6 illustrates an exemplary flow chart for joint prompt learning in a pre-trained model comprising a language model (LM) and a graph neural network (GNN) encoder on a first TAG, in accordance with various aspects of the present disclosure.
[0019] Fig. 7 illustrates an exemplary flow chart for using the pre-trained LM and GNN encoder and the learnt prompt for a classification task on a third TAG, in accordance with various aspects of the present disclosure.
[0020] Fig. 8 illustrates an exemplary computer system, in accordance with various aspects of the present disclosure.DETAILED DESCRIPTION
[0021] The present disclosure will now be discussed with reference to several example implementations. It is to be understood that these implementations are discussed only for enabling those skilled in the art to better understand and thus implement the embodiments of the present disclosure, rather than suggesting any limitations on the scope of the present disclosure.
[0022] Various embodiments will be described in detail with reference to the accompanying drawings. Wherever possible, the same reference numbers will be used throughout the drawings to refer to the same or like parts. References made to examples and embodiments are for illustrative purposes, and are not intended to limit the scope of the disclosure. It is noted that “based on” used in the disclosure should be understood as “based at least on” , rather than “solely based on” or “merely based on” .
[0023] It is anticipated that applying the disclosed framework may involve the use of user-related information, such as users’ account information and behavior records. It should be noted that the use of user-related information requires user authorization and may not exceed the scope of users’ authorization.
[0024] Graph structures can express the relationships between entities or objects and widely exists in all kinds of data. Many existing graph learning methods generalize traditional deep learning algorithms to graph-structured data by combining graph propagation and neural networks. Graph neural networks (GNNs) have achieved breakthroughs in different downstream applications, such as recommendation system, and social network analysis.
[0025] The text-attributed graph (TAG) is one genre of important graph-structured data with each node associated with raw texts. The semantics and graph topology of TAGs can express real-world relationships between entities or objects. A wide variety of real-world application data can be illustrated by TAG, to name a few, online shopping site, social network, citation network, intelligent manufacturing system, etc.
[0026] The TAG represents graph-structured data with each node contains rich textual information and edges representing relationships between the nodes. Generally, there are two steps to perform pre-training on a Text-Attributed Graph (TAG) , namely text encoding and graph learning. The text sequences associated with nodes in the TAG are first processed through the text encoder to obtain the numerical representation corresponding to each text sequence. After that, graph learning methods utilize the numerical representations generated by the text encoder as the initial attributes of the nodes to train GNNs by a loss function of GNNs’ own. When the GNNs are pre-trained, the final representation of nodes in TAGs can be obtained.
[0027] Previous methods implement learning on TAG through separated text encoders and GNNs, which directly deal with the original texts and the topological structure in the graph, making the data information not fully leveraged and the performance dependent highly on the pre-processing text encoders. Thus, an approach to jointly pre-train LMs and GNNs on a TAG is needed.
[0028] However, the integration of LMs and GNNs is not straightforward and has several challenges. First, the joint model of LMs and GNNs tends to fall into over-fitting since LMs have a much larger number of parameters than GNNs. Besides, large-scale TAGs need enormous memory requirements of GPUs and LMs require significant pre-training costs, pre-training all the corpus and graph topology jointly is not realistic. Additionally, the graph data suffers from high labeling costs in real applications.
[0029] Due to the inconsistency between the pre-training objectives and the downstream tasks, the pre-trained model might perform sub-optimally when directly used for downstream tasks. For example, the label space for the pre-trained model might not be the same (e.g., partially overlapping or non-overlapping) with the label space for a downstream classification task. Prompts may be designed to mitigate the gap between the pre-train objective and the downstream tasks.
[0030] Conventionally, prompts may be constructed solely based on text information but lack analysis of the structure attribute. For example, such prompts may be hand-crafted or designed by processing raw text solely from the LM side. Other prompts may be constructed at the graph level, but such prompts neglect text information and are not directly applicable to TAGs. Therefore, it is desired to design a prompt learning method on TAG to mitigate the gap between pre-training and downstream tasks on TAG.
[0031] An approach for addressing one or more aspects of the above issues are proposed. It is disclosed a unified masked learning framework that the LMs and GNNs are combined to achieve self-supervised learning on TAGs. Specifically speaking, by incorporating the encoder of GNNs as a supplement to LMs and keep the original self-supervised loss of the LM model, i.e., the masked language modeling (MLM) objective, which is a very hard pretext task and can alleviate the over-fitting issue, and also by the self-supervised manner high labeling costs could be avoided. Moreover, to jointly pre-train the graph neural networks and the language models effectively, mini-batch sub-graphs can be sampled and fed to the framework to enhance the scalability to apply them to large-scale graph structures. In addition, a new graph-text mixed prompt learning framework is also proposed to enable the pre-trained model on TAG to better adapt to downstream tasks (e.g., classification tasks) .
[0032] Fig. 1 illustrates an exemplary a Text-Attributed Graph (TAG) , in accordance with various aspects of the present disclosure. As shown in Fig. 1, the TAG comprises multiple nodes and multiple edges, each node in the TAG representing a text sequence and each edge representing a relation between two nodes. Different scenarios below are merely given as examples but not limiting the scope of disclosure.
[0033] As an example, data from an online shopping site can be illustrated by a TAG. Nodes in the TAG may represent products sold on the online shopping site, and edges between two products may indicate that the products tend to be purchased together. The properties of the products like name, brand, category, price, etc. can be described by a corresponding text sequence.
[0034] As another example, data from a citation network can be illustrated by a TAG. Nodes in the TAG may represent papers or articles, and edges between two nodes may indicate that the papers or articles share at least one common attributes, such as authors, affiliations, references, or citations. The properties of the papers or articles like title, authors, abstract, affiliations, etc. can be described by a corresponding text sequence.
[0035] Mathematically, a TAG can be expressed as where each node is associated with a text sequence and ε represents the set of edges between nodes. Given a TAG, the problem of learning on TAG is to learn a unified low-dimensional space representation of each text-attributed node with corresponding text sequence si.
[0036] In general, two steps are involved to address the problem, which are text encoding and graph learning. Fig. 2 illustrates an exemplary framework of independently pre-training language models (LMs) and graph neural networks (GNNs) on a TAG, in accordance with various aspects of the present disclosure.
[0037] The text sequences in the TAG are first processed through the text encoder 201 to obtain the numerical representation corresponding to each text sequence. That is, given the text sequence a text encoder fT will encode the sequence to the node feature xi=fT (si) . As an example, the raw texts may be encoded to node features using bag-of-words. As another example, with the prosperity of pre-trained language models, for example BERT, RNN, Transformer and GPT, etc., they can be utilized to encode the texts for better representations, which may be formulated as where θLM are model parameters. Different rules can be used to obtain the final numerical representation X of the text sequence according to employed language models. Taking BERT an example, X can be obtained by weighting the vectors corresponding to the words contained in each sequence or by selecting the [CLS] representation from each sequence.
[0038] After that, graph learning methods may utilize the numerical representations generated by the text encoder 201 as the initial attributes of the nodes to train GNNs 202. The graph learning can be formulated as where θE, θD are the parameters of the encoder and decoder. The is the loss function to optimize the GNN model. After the GNNs 202 are trained, the final representations of nodes in the TAG can be obtained as
[0039] As shown in Fig. 2 and as described above, utilizing features inferred by LMs or simply obtained by heuristic feature extraction as initial node attributes of GNNs separates the text encoding part and the graph propagation, in other words, the text encoder 201 and GNNs 202 are pre-trained independently, do not fully leverage the data information.
[0040] Therefore, a framework of integrating pre-training of LMs and GNNs on a TAG is proposed. The joint pre-training for the LMs and GNNs on a TAG can be formulated as where and are the GNN encoder, LM encoder and the prediction head for graph learning respectively. In one example, the graph learning is self-supervised learning (SSL) . More details of implementations would be discussed below.
[0041] Fig. 3 illustrates an exemplary framework of jointly pre-training language models (LMs) and graph neural networks (GNNs) on a TAG, in accordance with various aspects of the present disclosure.
[0042] Generally speaking, an end-to-end self-supervised framework to pre-train directly on the TAGs is disclosed, to be more specific, the framework consists of two core modules, a language model (LM) 301 and a GNN encoder 302. For example, a model to be pre-trained may comprise a LM 301 and a GNN 302, the GNN encoder 302 is to help make better node representations.
[0043] In an embodiment, effective LM can be utilized as LM 301 to encode the raw texts, for example, BERT, De-BERTa, RNN, Transformer and GPT family, etc., the choice of LMs does not limiting the scope of the invention.
[0044] In an embodiment, to model the relations between nodes (texts) , powerful GNNs can be used, for example, graph convolutional networks (GCNs) , graph attention networks, graph autoencoders, graph generative networks, etc., the choice of GNNs does not limiting the scope of the invention.
[0045] Referring to Fig. 3, text sequences of a TAG may be input to LM 301. Similar to TAG described with Fig. 1, it can be expressed as where each node is associated with a text sequence and ε represents the set of edges between nodes. Given a node vi, the text sequence is fed into the LM 301 to get the hidden representation associated with node vi, where Tt is t-th basic unit of si which can also be called a token and ni is the length of si, a token could be a word, a character, or an identifier. As an example, a TAG may include a first node vi, as denoted by the solid circle as shown in Fig. 3, and a text sequence si of the first node vi may be [Charlie, and, the, chocolate, factory] .
[0046] Different from conventional graph self-supervised learning, the design of self-supervised objective for TAGs are more challenging, especially when the model architecture contains two different modules with different scales of model parameters. In the pre-training stage, in order to make a harder self-supervised objective avoiding model overfitting, the masked language modeling (MLM) is utilized. In an embodiment, a portion of the text sequence may be randomly masked, by replacing the masked token with a special token named [MASK] . Then can be used to denote the text sequence after masking. As an example, the text sequence si′of the first node vi may be [Charlie, [MASK] , the, [MASK] , factory] . In an embodiment, each token T′t may be a random variable with following distribution: Pr (T′t= [MASK] ) =p and Pr (T′t=Tt) =1-p (1)
[0047] Here, p∈ (0, 1) is a hyper-parameter representing the mask rate. A smaller mask rate represents an easier self-supervised task and might make the model overfitting in some cases. Thus, in an embodiment, a larger mask rate could be chosen to let the model learn better. The value of mask rate can be adjusted based on implementation, which is not limiting.
[0048] Then, through LM 301, each node is represented as a sequence of hidden vectors:
[0049] Where is the hidden representations of t-th token of s′i. In an embodiment, when working with BERT-like LMs, a starting token (e.g., [CLS] ) and an ending token (e.g., [SEP] ) may be added to the sequence. The starting token may be referred to as a summary identification in some examples. As an example, after adding the starting token and the ending token, the text sequence corresponding to the first node vi may be [ [CLS] , Charlie, [MASK] , the, [MASK] , factory, [SEP] ] . And accordingly, the node can be represented as:
[0050] In this case, notice that the first hidden vector o0 corresponds to the special token [CLS] and can be treated as the “summary” representation of the entire text sequence si. For example, o0 may be representative of the entire text sequence to some extent.
[0051] To capture the correlations among nodes, a GNN encoder 302 is then used to propagate the hidden representations of nodes where the input of node vi, denoted as xi, is the hidden representation of si . In one embodiment, for example when using Bert-like LMs, xi may be the hidden representation o0 of si. After passing a GNN encoder, the node representations are denoted as H=fGNN (G, X) .
[0052] In one embodiment, the node representation H may be subsampled by pooling layers 304 to generate a new node representation H′with a reduced size. For example, a size of the new node representations H′ may be less than the size of the node representations H. The reduced size provides similar information to a subsequent layer while reducing memory consumption.
[0053] The propagated node presentations are exploited to construct the self-supervised training objective. For each node vi, the hidden representation hi can be combined with the output vector ot of each token, such as by concatenating, etc., and then fed to the prediction head 303 as:
[0054] In another embodiment, the hidden representation hi can be combined with the output vector ot of each token by averaging, aggregating or other suitable manners. In one embodiment, instead of using node representations H, the node representations H′as mentioned above may be used for combination with the output vector ot of each token. In an embodiment, the prediction head could be an MLP to predict the masked tokens (e.g., a mask decoder) .
[0055] The objective of the masked language modeling (MLM) is to predict the masked tokens in the original text sequence si. As an example, for the first node vi, based on the mask decoder of MLM may predict that the masked tokens are “and” and “chocolate” . The objective of MLM can be expressed as:
[0056] The indicator ensures that the loss is only applied on masked tokens.
[0057] The proposed framework is able to effectively integrate the LM and GNN with joint pre-training in a self-supervised way. By incorporating the encoder of GNNs as a supplement to LMs and keep the original self-supervised loss of the LM model (e.g., the masked language modeling as the training objective) , overfitting issues can be alleviated.
[0058] In a further aspect, due to the heavy language models, a mini-batch pre-training strategy can be adopted instead of using a whole TAG for each pre-training step. At every pre-training step, a mini-batch can be constructed by sampling a subgraph from the original graph and generates node representations according to the sampled subgraph. Any suitable sub-graph extraction method can be adopted, which is not limiting.
[0059] In an embodiment, the subgraph-based method called GraphSAINT can be used to obtain the sub-graph to preserve the connectivity of the whole graph. The sampling process starts by randomly selecting r root nodes from the whole node set V. Starting from each root node, a random walk of length l is sampled from the original graph structure. The random walk of length l may be a hyper parameter and may take values of 5, 10, 20 and 50, for example. Then a sampled node set Vs may be obtained by adding all the nodes that occurred in the random walks, and the subgraph Gs induced by Vs is used in the GNN encoder to generate node representations in the mini-batch.
[0060] Additionally, to reduce the sampling bias introduced by the sampler, a normalization technique can be adopted to get an unbiased estimator of the aggregated representation at layer l+1 of GNN encoder as: where v is node at layer l+1 , and u is node at layer l, is a scalar, taking an element of normalized adjacency matrix αu, v is the constant referred as aggregator normalization and is the weight matrix.
[0061] In a further aspect, since at each pre-training step, a batch of sampled graph may be fed to both LM and GNN encoder, the batch size may be increased to better leverage the ability of GNNs. However, the batch size is limited due to the large memory cost of the LM.Therefore, a smaller truncated length in practical can be used to account for a larger batch size, considering both training efficiency and information loss.
[0062] Table 1 shows the pseudocode of an example pre-training loop of the framework combining several embodiments as described above.
[0063] Table 1
[0064] The pre-trained model (e.g., comprising the pre-trained LM and the pre-trained GNN encoder) may be used for various downstream tasks. In one embodiment, one of the downstream tasks may be a few-shot node classification task. Few-shot node classification are tasks that involve training a machine learning model with a limited number of labeled nodes, and subsequently predicting the classes of other nodes based on these initial labels.
[0065] As an example, the N-way K-shot node classification tasks on a graph is described as follows with the node label set C, wherein N is an integer greater than 1 and K is an integer greater or equal to 1. As an example, N = 3, 5 or 10, and K = 3 or 5. Each task selects N labels from C, forming a subset The consists of two parts as follows:
[0066] wherein St means the support set and Qt means the query set. The machine learning model may be (pre) trained on St and subsequently evaluated on Qt.
[0067] Both the support set and the query set consist of nodes and their corresponding labels, which shown as follows: Qt= { (v′1, c′1) , (v′2, c′2) , …, (v′N×Q, c′N×Q) } ,
[0068] where v and v′ represent nodes, their corresponding labels are denoted as c and c′. In the support and query sets, each label Ci∈ Ct associated with K nodes and Q nodes, respectively. For the support set, there exists c (i-1) *K+j∈Ci , where i∈ {1, 2, …, N} and j∈ {1, 2, …, K} . Similarly, there exists c ′(i-1) *Q+j∈Ci , where i∈ {1, 2, …, N} and j∈ {1, 2, …, Q} for the query set.
[0069] Due to the inconsistency between the pre-training objectives and the downstream tasks, the pre-trained model might perform sub-optimally when directly used for downstream tasks. For example, as disclosed herein, a model comprising an LM and a GNN on TAG may be pre-trained. During the pre-training phase, token prediction tasks are undertaken and the model is equipped to align input with the pre-trained label space. However, the label space for the pre-trained model might not be the same (e.g., partially overlapping or non-overlapping) with the label space for a downstream classification task. In one example, the downstream classification task may be a few-shot node classification task.
[0070] Prompts may be designed to bridge the gap between the pre-train objective and the downstream tasks. For example, prompts may be applied to modify the input distribution to approximate the downstream label space more closely. Fig. 4 illustrates an exemplary framework of applying a prompt to an input to align to the downstream label space, in accordance with various aspects of the present disclosure.
[0071] An input data 401 may be input to a pre-trained model 403. As an example, the input data 401 may be a text sequence, a graph, or a TAG, and accordingly, the pre-trained model 403 may be a pre-trained LM model, a pre-trained GNN model or both, with their parameters fixed, as described elsewhere herein.
[0072] As mentioned above, the pre-trained label space might not be the same with the downstream label space. For example, as illustrated in Fig. 4, in the case that the model 403 is pre-trained with a masked token prediction task, the pre-trained label space 404 might comprise masked token prediction labels and might include about 5M labels. As another example, the downstream task might be a products classification task and accordingly, the downstream label space 405 might include less than 10 labels. For example, the pre-trained label space 404 might be partially overlapping with the downstream label space 405.
[0073] Based on input data 401, the pre-trained model 403 may predict a label 406 falling within the pre-trained label space 404 through model encoding. In some instances, due to the inconsistency between the pre-training objectives and the downstream tasks, the pre-trained model might perform sub-optimally when directly used for downstream tasks. For example, the predicted label 406 for input data 401 through the model encoding of the pre-trained model 403 might fall in the pre-trained label space 404, but not within the desired downstream label space 405.
[0074] Prompts 402 may be designed to be applied on the input data 401 to make the output more aligned with the downstream label space 405. As an example, based on input data 401 and a prompt 402, an adjusted input data 401’ may be generated as input to the pre-trained model 403. With the model encoding by the pre-trained model 403, an output label 407 may be obtained, which may fall into the desired downstream label space.
[0075] As described above, the prompt design for TAG might be challenging since there are both text (e.g., at the LM side) and structure information (e.g., at the GNN side) on TAG graphs. This disclosure relates to a joint prompting method, wherein a prompt TAG and a text prompt are learnt and combined together, e.g., by averaging, aggregating or other suitable manners, to mimic the pre-training paradigm and thus better adapt to the pre-trained network when used for inference. Fig. 5 illustrates an exemplary framework of joint prompt learning in a pre-trained language models (LMs) and graph neural networks (GNNs) on a TAG, in accordance with various aspects of the present disclosure.
[0076] In some examples, a downstream task to the pre-trained model may be a few-shot node classification task. To be specific, for an N-way K-shot few-shot node classification task, some of the nodes of a first TAG G may be classified with a respective label from N labels of the classification task, as disclosed above. Accordingly, some of the labeled nodes, referred as target nodes for a prompt learning phase, may be used for the joint prompt learning of the disclosure. Referring to Fig. 5, one of the labeled target nodes may be illustrated as solid circles in TAGs G and Gego, as detailed below.
[0077] To learn the prompt TAG as a part of the mixed prompt of the disclosure, an ego TAG Gego for each target node of a TAG G may be obtained from the TAG G. The ego TAG Gego may be a subgraph of the TAG G taking the target node as an ego and may be obtained by various subgraph extraction methods. For example, a random walk of length l may be performed starting from the ego (e.g., the target node) to sample a subgraph Gego based on the original TAG G , similar the above-mentioned random walking procedure. As another example, the ego TAG Gego may be obtained by, in addition to the ego (e.g., the target node) , including all the nodes of the original TAG G that are within a certain path length (e.g., a number of hops) to the ego, and the corresponding edges between those nodes based on the original TAG G.
[0078] In an embodiment, each node of the ego TAG Gego may be represented with a hidden representation of the text sequence of the corresponding node in the original TAG G. The hidden representation may be output by the pre-trained LM based on the text sequence of the corresponding node in TAG G. For example, a node viin the original TAG G may be associated with a text sequence The text sequence si may be fed into the pre-trained LM 301 to get the hidden representation associated with node vi , similar with described in respect to Fig. 3. A node v′i in the ego TAG Gego corresponding to the node viin the TAG G may be represented by the hidden representation oi.
[0079] In one embodiment, when working with BERT-like LMs, a starting token (e.g., [CLS] ) and an ending token (e.g., [SEP] ) may be added to the text sequence si of the node vito get similar with described in respect to Fig. 3. And after inputting s′ito the pre-trained LM 301 to obtain the hidden representation o′i of s′i the corresponding node v′i in the ego TAG Gego may be represented by the summary representation o0 of the hidden representation o′i, similar with described in Fig. 3. As an example, the text sequence si of the node vi may be [Charlie, and, the, chocolate, factory] , and s′i in this example may be [ [CLS] , Charlie, and, the, chocolate, factory, [SEP] ] . Accordingly, the corresponding node v′i in the ego TAG Gego may be represented by o0 of the hidden representation
[0080] A prompt TAG Gp may be constructed as an ancillary component connected to the target node's ego graph Gego . The prompt TAG Gp may comprise a number of M nodes, and M is an integer greater than 1. The number of M may be designated by a hyper parameter. For example, M may take a value of 2, 5, 6, 10 or 20. A greater value of M might create a richer internal structure of the prompt TAG, offering enhanced information. However, this might also complicate convergence in few-shot scenarios. As an example, as shown in Fig. 5, M = 6 nodes may be included in the prompt TAG Gp, denoted as n0, n1, …, n5.
[0081] Each node of the prompt TAG Gp may be initialized randomly or based on a representation of a label text sequence through the LM, wherein the label text sequence is associated with a label of a downstream classification task of the pre-trained model. As an example, at least one node of Gp may be initialized with a random representation. As illustrated in Fig. 5, 3 of the 6 nodes are initialized randomly, that is, n3, n4 and n5 may each be initialized with a respective random representation p3, p4 and p5 . In one example, all nodes of Gp may be initialized with random representations.
[0082] As described herein, for a downstream N-way K-shot few-shot node classification task (N is an integer greater than 1 and K is an integer greater or equal to 1) , at least some of the N labels of the downstream task may be known to the prompt learning phase. For example, the downstream task may be a 3-shot or 5-shot, 3-way, 5-way or 10-way node classification task. Under homophily hypothesis, employing label text embeddings for prompt TAG initialization is more direct and efficient in helping predict labels closer to the desired downstream label space. In this case, as an example, at least one node of Gp may be initialized based on a representation of one downstream label text sequence through the pre-trained LM 301. In an example, N nodes of the prompt TAG Gp are initialized based on representations of label text sequences of the N labels through the LM on a one-to-one basis. As shown in Fig. 5, the downstream label space 502 may comprises N = 3 labels, L0, L1 and L2. Each of the 3 labels is associated with a respective label text sequence As an example, l0= [Animals] , l1= [Sience, Fiction, and, Fantasy] and l2= [Activities, Crafts, and, Games] . Each of the three label text sequences li may be input to the pre-trained LM 301 to obtain a respective hidden representation pi of the label text sequences (e.g., ) . The hidden representation pi may be used to initialize a respective one node ni of the prompt TAG Gp.
[0083] In one embodiment, when working with BERT-like LMs, a starting token (e.g., [CLS] ) and an ending token (e.g., [SEP] ) may be added to the label text sequence li get similar with described in respect to Fig. 3. And after inputting l′ito the pre-trained LM 301 to obtain the hidden representation p′i of l′i the corresponding node ni in the prompt TAG Gp may be represented by the summary representation of the [CLS] token of a correspondingl′ithrough the LM, similar with described in Fig. 3.
[0084] In some embodiments, if a number of nodes in the prompt TAG Gp, M, is equal or greater than the number of labels, N, then N nodes of Gp are initialized based on representations of label text sequences of the N labels through the LM on a one-to-one basis, and the other (M-N) nodes of Gp are initialized randomly. As an example, the initialization of Gp may be as follows:
[0085] wherein the denotes the initial embedding of i-th prompt node ni in Gp, and the li denotes the label text sequence associated with the i-th label Li. In some examples, instead of li, l′i as described above may be used in Equation (5) for the initialization of Gp.
[0086] Inner edges between any two nodes within Gp may be formed based on how similar the representations of the two nodes are. A first similarity function (e.g., based on a dot product) may be used to calculate a first similarity metric between the representations of the two nodes. As an example, if the similarity metric between two nodes within Gp is large enough (e.g., equal or greater than an inner similarity threshold σinner ) , an inner edge between the two nodes within Gp may be formed; otherwise the inner edge is not formed. The inner similarity threshold σinner may be a hyper parameter indicating a pruning value (e.g., the entries on the matrix higher than σinner are formed as edge respectively) . The inner edges between nodes of prompt TAG Gp may be defined as:
[0087] where the Sim denotes the similarity function, and the pi denotes the representation of i-th node ni of prompt TAG Gp.
[0088] Then, a second TAG is obtained by combining the ego TAG Gego and the prompt TAG Gp. In an example, outer edges between any one node of the ego TAG Gego and any one node of the prompt TAG Gp may be formed based on how similar the representations of the two nodes are. A second similarity function (e.g., based on a dot product) may be used to calculate a second similarity metric between the representations of the two nodes. As an example, if the second similarity metric is large enough (e.g., equal or greater than an outer similarity threshold σouter) , an outer edge between one node v′iof the ego TAG Gego and one node nj of the prompt TAG Gp may be formed; otherwise the outer edge is not formed. The outer similarity threshold σouter may be a hyper parameter indicating a pruning value (e.g., the entries on the matrix higher than σouter are formed as edge respectively) . The inter-connectivity between nodes of Gego and Gp may be given by:
[0089] where the Sim denotes the second similarity function, xk denotes on the k-th node representation of the Gego , and the pj denotes the representation of j-th node nj of prompt TAG Gp.
[0090] After combining the ego TAG Gego and the prompt TAG Gp, the combined TAG (e.g., the second TAG) may be input to the pretrained GNN encoder 302 to obtain a representation H=fGNN (Gego ; Gp) . In some optional examples, the node representations H may be subsampled by pooling layers 304 to generate a subsampled node representation H′with a reduced size. In these examples, H′may be used in place of H for subsequent processing, as described below.
[0091] As another part of the mixed prompt of the disclosure, a text prompt wt may also be used. In an example, the text prompt wt may be initialized based on the representation of the text sequence of the target node v of the ego TAG Gego through the pre-trained LM 301. The initialization process of the text prompt wt can be defined similarly as:
[0092] wherein the sv denotes the text sequence of the target node v. In some examples, similarly as described above, when working with BERT-like LMs, the text prompt wt may be initialized with the summary representation of the [CLS] token of the target node v through the LM 301.
[0093] Similar with the pre-training paradigm, both of a representation of the second TAG H=fGNN (Gego ; Gp) (or H′, if pooling layers 304 are applied, as described above) and the text prompt wt may be used for label prediction by an MLP network 501. In some examples, a graph embedding of H (or H′, if pooling layers 304 are applied, as described above) may be obtained to combine with the text prompt wt, such as by concatenating, etc., and then fed to the task head of MLP 501, to predict a label for the target node v. As an example, the predicted label may correspond to one of the labels L0, L1 and L2. For example, the prompt learning forward function may be defined as:
[0094] During the prompt learning phase of the disclosure, the parameters of the pre-trained LM and GNN encoder are fixed, and both of the prompt TAG Gp and the text prompt wt are treated as trainable parameters and updated based on a loss function. In an example, the task head (e.g., the MLP layers) may be trainable based on the loss function as well. In an example, the loss function may be based on the predicted label for the target node and the label of the target node (e.g., the true label of the target node) .
[0095] After LM and GNN are both pre-trained and a mixed prompt comprising the prompt TAG and the text prompt are learnt as described in the disclosure, a TAG including nodes for label prediction may be used as input to the pre-trained LM and GNN during inference. A sub TAG may be obtained comprising the node for label prediction based on the input TAG. Similar with the generation of ego TAG, the sub TAG may be obtained with any of the subgraph-based methods, as described in the disclosure, and each node of the sub TAG may be represented with a hidden representation of the text sequence of the corresponding node in the input TAG through the pre-trained LM. In some embodiments, similar with described in respect to Figs 3 and 5, when working with BERT-like LMs, each node of the sub TAG may be represented as the summary representation of the [CLS] token of the corresponding node in the input TAG through the LM. In an embodiment, the representations of the text sequences through the LM can be computed in a mini-batch manner.
[0096] The sub TAG may be combined with the learnt prompt TAG to pass through the pre-trained GNN encoder. In some examples, similar as described with respect to Fig. 5, the sub TAG may be combined with the prompt TAG based on the formed outer edges between these two TAGs. For example, if a similarity metric between representations of one node of the sub TAG and one node of the prompt TAG is large enough (e.g., equal or greater than an outer similarity threshold σouter ) , an outer edge between these two nodes may be formed; otherwise the outer edge is not formed. A representation may be obtained by passing the combined sub TAG and the prompt TAG to the pre-trained GNN encoder.
[0097] The MLP (e.g., the MLP trained during the prompt learning phase) may be used to predict a label for the node based on the obtained representation and the learnt text prompt. For example, similar as described with respect to Figs. 3 and 5, the obtained representation and the text prompt may be combined (e.g., concatenated, averaged, etc.. ) and input to the MLP to predict a label for the node. For example, the obtained representation may be subsampled by pooling layers, and the subsampled representation may be combined (e.g., concatenated, averaged, etc.. ) with the text prompt and input to the MLP to predict a label for the node, similar as described with respect to Figs. 3 and 5.
[0098] Fig. 6 illustrates an exemplary flow chart for joint prompt learning in a pre-trained model comprising a language model (LM) and a graph neural network (GNN) encoder on a first TAG, in accordance with various aspects of the present disclosure. As described below, some or all illustrated features may be omitted in an implementation within the scope of the present disclosure, and some illustrated features may not be required for implementation of all embodiments. Further, some of the blocks may be performed parallel or in a different order. In some examples, the method may be carried out by any suitable apparatus or means for carrying out the functions or algorithm described below.
[0099] As mentioned herein, the first TAG comprises multiple nodes and multiple edges, each node in the first TAG representing a text sequence and each edge representing a relation between two nodes. A wide variety of real-world application can be depicted by TAG. In an embodiment, the nodes of the TAG stand for products in an E-commerce platform, the text sequence for the nodes comprise one or more of product descriptions, purchase records and / or click-through logs, and edges between two nodes may indicate that the two products tend to be purchased together. In another embodiment, the nodes of the TAG stand for works in a citation network, the text sequence for the nodes comprise one or more of titles, authors, affiliations, abstracts, references, and / or citations, and edges between two nodes may indicate that the two papers or articles share at least one common attributes, such as authors, affiliations, references, or citations. In yet another embodiment, the nodes of the TAG stand for accounts in a social network, the text sequence for the nodes comprise one or more of user profiles, follow / fans lists, and / or user behavior logs, and edges between two nodes may indicate that the two nodes are friends. In another embodiment, the nodes of the TAG stand for production processes in a manufacturing system, the text sequence for the nodes comprise one or more of production objects, production procedures, production logs, production materials, production lines / plants, and / or design documents, and edges between two nodes may indicate that the two nodes are interacted during production. The examples are not limiting, and any other suitable scenarios can be adopted.
[0100] The method begins at block 601, with at every pre-training step, obtaining an ego TAG for a target node of the multiple nodes of the first TAG.
[0101] In an embodiment, the target node may be a labeled node of the first TAG.
[0102] In an embodiment, the ego TAG may be obtained by a random walk sampler as described herein. In an embodiment, the ego TAG may be obtained by including the target node and all the nodes of the first TAG within a certain path length to the target node, and the corresponding edges between those nodes based on the first TAG, as described herein. In other embodiments, the ego TAG can be obtained by any suitable subgraph extraction method in the art.
[0103] In an embodiment, obtaining the ego TAG further comprises, for each node of the ego TAG: obtaining a representation of a text sequence of a corresponding node in the first TAG through the LM; and representing the node of the ego TAG with the obtained representation.
[0104] In an embodiment, obtaining the ego TAG further comprises, for each node of the ego TAG: adding a first summary identification to a text sequence of the node; obtaining a first summary representation of the first summary identification through the LM; and representing the node of the ego TAG with the first summary representation.
[0105] The method then proceeds to block 602, with obtaining a second TAG by combining the ego TAG and a prompt TAG, wherein each node of the prompt TAG is initialized randomly or based on a representation of a label text sequence through the pre-trained LM, wherein the label text sequence is associated with a label of a downstream classification task of the pre-trained model.
[0106] In an embodiment, the prompt TAG comprises a number of M nodes, M is an integer greater than 1. The number of M may be designated by a hyper parameter. For example, M may take a value of 2, 5, 6, 10 or 20.
[0107] In an embodiment, at least one node of the prompt TAG is initialized randomly (e.g., initialized with a random representation) . In an embodiment, at least one node of the prompt TAG is initialized based on a representation of a label text sequence through the LM.
[0108] In an embodiment, the downstream classification task comprises N labels, N is an integer greater than 1. For example, N may take a value of 3, 5 or 10. When M is equal or greater than N, N nodes of the prompt TAG are initialized based on representations of label text sequences of the N labels through the LM on a one-to-one basis; and the other (M-N) nodes of the prompt TAG are initialized randomly, as detailed in equation (5) .
[0109] In an embodiment, the node of the prompt TAG initialized based on the representation of the label text sequence is initialized by: adding a second summary identification to a label text sequence of a label of the downstream classification task; obtaining a second summary representation of the second summary identification through the LM; and initialize the node of the prompt TAG with the second summary representation.
[0110] In an embodiment, an edge between two nodes of the prompt TAG is formed in accordance with a comparison between a first similarity threshold and a similarity metric based on representations of text sequences of the two nodes through the LM, wherein the first similarity threshold is a hyper parameter, as detailed in equation (6) .
[0111] In an embodiment, combining the ego TAG and the prompt TAG further comprising: connecting the ego TAG and the prompt TAG by forming an edge between a first node of the prompt TAG and a second node of the ego TAG, in accordance with a comparison between a second similarity threshold and a similarity metric based on representations of text sequences of the first node and second node through the LM, wherein the second similarity threshold is a hyper parameter, as detailed in equation (7) .
[0112] The method then proceeds to block 603, with obtaining a first representation of the second TAG through the GNN encoder.
[0113] In an embodiment, the first representation is further subsampled by pooling layers.
[0114] The method then proceeds to block 604, with predicting a label for the target node based on the first representation and a text prompt through a multilayer perceptron (MLP) network, as detailed in equation (9) , the text prompt initialized based on a second representation of a text sequence of the target node through the LM, as detailed in equation (8) .
[0115] In an embodiment, the text prompt is initialized with the first summary representation of the target node.
[0116] In an embodiment, the label for the target node is predicted based on the subsampled first representation and the text prompt through the MLP network.
[0117] In an embodiment, predicting the label for the target node based on the first representation and the text prompt further comprising: concatenating the text prompt and the (subsampled) first representation; and predicting the label for the target node based on the concatenated text prompt and the (subsampled) first representation through the MLP network.
[0118] The method then proceeds to block 605, with updating the prompt TAG and the text prompt in accordance with a loss function based on the predicted label and a label of the target node.
[0119] In an embodiment, the method further comprises updating a parameter for the MLP network in accordance with the loss function based on the predicted label and the label of the target node.
[0120] In an embodiment, wherein the LM and the GNN encoder of the pre-trained model are jointly pre-trained by: selecting at least a part of the first TAG with nodes and edges therebetween; for each node of the selected TAG: masking a portion of a text sequence of the node randomly; obtaining a third representation of the masked text sequence through the LM; obtaining a fourth representation using the GNN encoder based on the nodes and edges of the selected TAG and at least a part of the third representation; predicting the masked portion of the text sequence of the node based on the third representation and the fourth representation; and updating parameters of both the LM and the GNN encoder in accordance with a loss function based on the predicted portion and corresponding original portion of the text sequence.
[0121] In an embodiment, the GNN encoder comprises multiple layers, and wherein an unbiased estimator of aggregated representation of the masked text sequence is used in each layer of the GNN encoder for normalization.
[0122] In an embodiment, for each node of the selected TAG, masking the portion of the text sequence randomly further comprises: masking the portion of the text sequence randomly by a pre-defined rate. In an embodiment, the portion of the text sequence are masked by a pre-defined rate as equation (1) . The mask rate can be set to 0.3, 0.5 or 0.75, etc. The mask rate value is not limiting and can be configured depending on implementation.
[0123] In an embodiment, obtaining the fourth representation further comprises: adding a third summary identification to the masked text sequence; obtaining a third summary representation of the third summary identification through the LM as a part of the third representation; and obtaining the fourth representation using the GNN encoder based on the nodes and edges of the selected TAG and the third summary representation, as detailed in equation (2) ’.
[0124] In an embodiment, predicting the masked portion of the text sequence of the node further comprises: concatenating the third representation and the fourth representation; and predicting the masked portion of the text sequence based on the concatenated third representation and the fourth representation, as detailed in equation (3) .
[0125] In an embodiment, the text sequence for each node of the TAG is truncated by a certain length. For example, the text sequence for each node can be truncated by a length of 32, 64, 128, 256 or 512, etc. The length value is not limiting and can be configured depending on implementation.
[0126] In an embodiment, the updating the parameters of both the LM and the GNN encoder is performed based on equation (4) described above.
[0127] The operations of blocks 601-605 may be performed iteratively. The number of iterations could be configured depending on implementation, which is not limiting.
[0128] Fig. 7 illustrates an exemplary flow chart for using the pre-trained LM and GNN encoder and the learnt prompt for a classification task on a third TAG, in accordance with various aspects of the present disclosure. As described below, some or all illustrated features may be omitted in an implementation within the scope of the present disclosure, and some illustrated features may not be required for implementation of all embodiments. Further, some of the blocks may be performed parallel or in a different order. In some examples, the method may be carried out by any suitable apparatus or means for carrying out the functions or algorithm described below.
[0129] The third TAG may be a similar one as described with Fig. 6. The LM and GNN encoder are pre-trained in accordance with methods described in Fig. 6. The learnt prompt comprises the prompt TAG and the text prompt learnt in accordance with methods described in Fig. 6. The method begins at block 701, with obtaining a sub TAG comprising a node for label prediction based on the third TAG.
[0130] In an embodiment, the sub TAG may be obtained by a random walk sampler as described herein. In an embodiment, the sub TAG may be obtained by including the node for label prediction and all the nodes of the third TAG within a certain path length to the node for label prediction, and the corresponding edges between those nodes based on the third TAG, as described herein. In other embodiments, the sub TAG can be obtained by any suitable subgraph extraction method in the art.
[0131] In an embodiment, obtaining the sub TAG further comprises, for each node of the sub TAG: adding a fourth summary identification to a text sequence of the node; obtaining a fourth summary representation of the fourth summary identification through the LM; and representing the node of the sub TAG with the fourth summary representation.
[0132] The method proceeds to block 702, with obtaining a fourth TAG by combining the sub TAG and the prompt TAG.
[0133] In an embodiment, combining the sub TAG and the prompt TAG further comprises: connecting the sub TAG and the prompt TAG by forming an edge between a third node of the prompt TAG and a fourth node of the sub TAG, in accordance with a comparison between the second similarity threshold and a similarity metric based on representations of text sequences of the third node and the fourth node through the LM.
[0134] The method proceeds to block 703, with obtaining a fifth representation of the fourth TAG through the GNN encoder.
[0135] In an embodiment, the fifth representation is further subsampled by pooling layers.
[0136] The method proceeds to block 704, with predicting a label for the node based on the (subsampled) fifth representation and the text prompt through the multilayer perceptron (MLP) network. The MLP is trained in accordance with methods described in Fig. 6.
[0137] In an embodiment, predicting the label for the node based on the (subsampled) fifth representation and the text prompt further comprises: concatenating the text prompt and the (subsampled) fifth representation; and predicting the label for the node based on the concatenated text prompt and the (subsampled) fifth representation through the MLP network.
[0138] In an embodiment, the text sequences for each node in the third TAG may be segmented into several batches by a certain batch size, and a representation for each of the several batches is generated through the pre-trained LM. Then the representations for each of the several batches are combined into the representation for the text sequence of the node.
[0139] In an embodiment, the GNN encoder comprises multiple layers and the fifth representation is generated layer by layer, and wherein a representation for one node of the fourth TAG at one layer of the GNN encoder is generated by aggregating representations of all its neighbors in the fourth TAG at a previous layer.
[0140] Fig. 8 illustrates an exemplary computer system, in accordance with various aspects of the present disclosure. The computer system may comprise at least one processor 810. The computer system may further comprise at least one storage device 820. It should be appreciated that the storage device 820 may store computer-executable instructions that, when executed, cause the processor 810 to perform any operations according to the embodiments of the present disclosure as described in connection with Figs 1-7.
[0141] The embodiments of the present disclosure may be embodied in one or more computer-readable medium such as non-transitory computer-readable medium. The non-transitory computer-readable medium may store computer-executable instructions that, when executed, cause one or more processors to perform any operations according to the embodiments of the present disclosure as described in connection with Figs 1-7.
[0142] The embodiments of the present disclosure may be embodied in a computer program product comprising computer-executable instructions that, when executed, cause one or more processors to perform any operations according to the embodiments of the present disclosure as described in connection with Figs 1-7.
[0143] It should be appreciated that all the operations in the methods described above are merely exemplary, and the present disclosure is not limited to any operations in the methods or sequence orders of these operations, and should cover all other equivalents under the same or similar concepts.
[0144] It should also be appreciated that all the modules in the apparatuses described above may be implemented in various approaches. These modules may be implemented as hardware, software, or a combination thereof. Moreover, any of these modules may be further functionally divided into sub-modules or combined together.
[0145] The previous description is provided to enable any person skilled in the art to practice the various aspects described herein. Various modifications to these aspects will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other aspects. Thus, the claims are not intended to be limited to the aspects shown herein. All structural and functional equivalents to the elements of the various aspects described throughout the present disclosure that are known or later come to be known to those of ordinary skill in the art are expressly incorporated herein by reference and are intended to be encompassed by the claims.
Claims
1.A method of prompt learning for a pre-trained model on a first Text-Attributed Graph (TAG) , wherein the pre-trained model comprises a pre-trained language model (LM) and a pre-trained graph neural network (GNN) encoder, and wherein the first TAG comprises multiple nodes and multiple edges, each node of the first TAG representing a text sequence and each edge of the first TAG representing a relation between two nodes, the method comprising:obtaining an ego TAG for a target node of the multiple nodes of the first TAG;obtaining a second TAG by combining the ego TAG and a prompt TAG, wherein each node of the prompt TAG is initialized randomly or based on a representation of a label text sequence through the pre-trained LM, wherein the label text sequence is associated with a label of a downstream classification task of the pre-trained model;obtaining a first representation of the second TAG through the GNN encoder;predicting a label for the target node based on the first representation and a text prompt through a multilayer perceptron (MLP) network, the text prompt initialized based on a second representation of a text sequence of the target node through the LM; andupdating the prompt TAG and the text prompt in accordance with a loss function based on the predicted label and a label of the target node.2.The method of claim 1, wherein obtaining the ego TAG further comprises, for each node of the ego TAG:adding a first summary identification to a text sequence of the node;obtaining a first summary representation of the first summary identification through the LM; andrepresenting the node of the ego TAG with the first summary representation.3.The method of claim 2, wherein the text prompt is initialized with the first summary representation of the target node.4.The method of claim 1, wherein the node of the prompt TAG initialized based on the representation of the label text sequence is initialized by:adding a second summary identification to a label text sequence of a label of the downstream classification task;obtaining a second summary representation of the second summary identification through the LM; andinitialize the node of the prompt TAG with the second summary representation.5.The method of claim 1, wherein an edge between two nodes of the prompt TAG is formed in accordance with a comparison between a first similarity threshold and a similarity metric based on representations of text sequences of the two nodes through the LM, wherein the first similarity threshold is a hyper parameter.6.The method of claim 1, wherein the downstream classification task comprises N labels and the prompt TAG comprises M nodes, M and N being integers greater than 1, and M being equal or greater than N;wherein N nodes of the prompt TAG are initialized based on representations of label text sequences of the N labels through the LM on a one-to-one basis; andwherein the other (M-N) nodes of the prompt TAG are initialized randomly.7.The method of claim 1, wherein combining the ego TAG and the prompt TAG comprises:connecting the ego TAG and the prompt TAG by forming an edge between a first node of the prompt TAG and a second node of the ego TAG, in accordance with a comparison between a second similarity threshold and a similarity metric based on representations of text sequences of the first node and second node through the LM, wherein the second similarity threshold is a hyper parameter.8.The method of claim 1, wherein predicting the label for the target node based on the first representation and the text prompt further comprises:concatenating the text prompt and the first representation; andpredicting the label for the target node based on the concatenated text prompt and the first representation through the MLP network.9.The method of claim 1, further comprising updating a parameter for the MLP network in accordance with the loss function based on the predicted label and the label of the target node.10.The method of claim 1, wherein the LM and the GNN encoder of the pre-trained model are jointly pre-trained by:selecting at least a part of the first TAG with nodes and edges therebetween;for each node of the selected TAG:masking a portion of a text sequence of the node randomly;obtaining a third representation of the masked text sequence through the LM;obtaining a fourth representation using the GNN encoder based on the nodes and edges of the selected TAG and at least a part of the third representation;predicting the masked portion of the text sequence of the node based on the third representation and the fourth representation; andupdating parameters of both the LM and the GNN encoder in accordance with a loss function based on the predicted portion and corresponding original portion of the text sequence.11.A method for label prediction by using the pre-trained model comprising the language model (LM) and the graph neural network (GNN) encoder, the prompt TAG, and the text prompt learnt with one of claims 1-10 on a third Text-Attributed Graph (TAG) , comprising:obtaining a sub TAG comprising a node for label prediction based on the third TAG;obtaining a fourth TAG by combining the sub TAG and the prompt TAG;obtaining a fifth representation of the fourth TAG through the GNN encoder; andpredicting a label for the node based on the fifth representation and the text prompt through the multilayer perceptron (MLP) network.12.The label prediction method of claim 11, wherein obtaining the sub TAG further comprises, for each node of the sub TAG:adding a fourth summary identification to a text sequence of the node;obtaining a fourth summary representation of the fourth summary identification through the LM; andrepresenting the node of the sub TAG with the fourth summary representation.13.The label prediction method of claim 11, wherein combining the sub TAG and the prompt TAG further comprises:connecting the sub TAG and the prompt TAG by forming an edge between a third node of the prompt TAG and a fourth node of the sub TAG, in accordance with a comparison between the second similarity threshold and a similarity metric based on representations of text sequences of the third node and the fourth node through the LM.14.The label prediction method of claim 11, wherein predicting the label for the node based on the fifth representation and the text prompt further comprises:concatenating the text prompt and the fifth representation; andpredicting the label for the node based on the concatenated text prompt and the fifth representation through the MLP network.15.A computer system, comprising:one or more processors; andone or more storage devices storing computer-executable instructions that, when executed, cause the one or more processors to perform the operations of the method of one of claims 1-14.16.A computer readable storage medium storing computer-executable instructions that, when executed, cause one or more processors to perform the operations of the method of one of claims 1-14.17.A computer program product comprising computer-executable instructions that, when executed, cause one or more processors to perform the operations of the method of one of claims 1-14.
Citation Information
Patent Citations
Systems and methods for language model-based text insertion
US11886826B1
Unsupervised ontology-based graph extraction from texts
US20170337268A1
Text processing method, model training method, and apparatus
US20220147715A1
Method of evaluating text similarity for diagnosis or monitoring of a health condition
US20230034401A1