Hard hint-based global graph data unified graph modeling method
By adopting a unified graph modeling method for global graph data based on hard prompts, and utilizing large language models and Prompt nodes, the problems of cross-domain adaptability and high training cost of graph models are solved, and multi-task unified modeling and cross-domain performance improvement are achieved.
Patent Information
- Application Number
- CN202511118964.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-11
- Publication Date
- 2025-11-21
AI Technical Summary
Existing graph models face challenges in terms of training data scarcity and cross-domain adaptability, especially the inconsistency between pre-training tasks and downstream task objectives and the high cost of fine-tuning. Furthermore, existing research exhibits low reusability in graph structure data modeling.
We adopt a unified graph modeling method for global graph data based on hard prompts. By introducing a text attribute graph construction mechanism, we can align cross-domain features using a large language model to achieve unified modeling for multiple tasks. We use Prompt nodes and category nodes, combined with contrastive learning and dynamically expanding the graph structure to reduce computational costs.
It significantly improves the multi-task modeling effect, has obvious cross-domain performance advantages, reduces training costs, realizes unified modeling of multi-domain graph data with a single model, and has stronger generalization ability and stability.
Smart Images

Figure CN120996088A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a unified graph modeling method for global graph data based on hard cues, belonging to the field of machine learning technology in computer intelligence science. Background Technology
[0002] With the rapid development of modern information technology, graph-structured data has demonstrated unique advantages as a powerful tool in modeling complex relationships and structural information. However, due to the irregularity and complexity of graph-structured data, extracting important information and classifying it is a challenging task. Furthermore, existing graph models still face numerous challenges. Traditional supervised learning methods in the field of graph learning largely rely on the number of labeled graphs available for training, which is often insufficient in reality. This is because labeling graph-structured data often requires manual intervention, relying on substantial expert knowledge and significant human and time costs, making the process extremely complex.
[0003] To address the scarcity of training data, the "pre-training and fine-tuning" strategy has become one of the mainstream solutions. This approach involves pre-training on a large amount of unlabeled graph data to learn general graph representations, and then fine-tuning the model on a small amount of labeled data for the target task, thereby improving the model's generalization ability. The core of the pre-training phase is to design tasks using self-supervised learning, enabling the model to mine potential information from unlabeled data. By learning the local structure and global characteristics of the graph, a transferable graph representation is generated. As an effective technique, "pre-training and fine-tuning" provides an important approach to addressing data scarcity, and its potential is being demonstrated in an increasing number of practical applications.
[0004] While the "pre-training, fine-tuning" strategy can alleviate the data scarcity problem of downstream task-specific datasets, two challenges remain. First, the optimization objectives of the pre-training task and the downstream task are inconsistent. For example, pre-training tasks in the graph domain are typically link prediction or hidden feature reconstruction tasks, while downstream tasks are usually node classification or graph classification tasks. It's clear that there's an inherent gap between the pre-training and downstream tasks. Therefore, a model trained well on the pre-training task cannot effectively understand the semantic information of downstream data, severely impacting the transfer performance of the pre-trained model in downstream tasks. Second, the fine-tuning stage requires full parameter tuning of the entire model. In the "pre-training, fine-tuning" paradigm, the fine-tuning stage requires optimizing all parameters of the model. Although this stage optimizes on a small amount of labeled data for the target task, the computational cost in terms of time and memory is still high, especially for currently popular large language models, where the computational cost of fine-tuning is unbearable for ordinary computers.
[0005] To address the problems of the "pre-training, fine-tuning" strategy, some studies have shifted cue learning from the natural language processing domain to the graph domain. This aims to solve the initial problem of label scarcity and obtain general graph models with good transferability, allowing for rapid adaptation to various graph tasks. However, graph-structured data differs from natural language text and images. Graph-structured data exhibits non-Euclidean characteristics and is more complex in terms of data attributes and features. Therefore, research on modeling graph-structured data is currently limited and has very low reusability. Existing research faces many common unresolved issues, such as how to implement a unified model to address tasks in different graph domains and how to design more reasonable hard cue templates.
[0006] Therefore, there is an urgent need for a method that can solve common problems existing in the current modeling field. This invention proposes a unified graph modeling method for global graph data based on hard prompts, innovatively introducing a text attribute graph construction mechanism to unify the heterogeneous features of graph data from different domains. By introducing Prompt nodes and category nodes, it achieves unified handling of multi-task situations and source task guidance without requiring the design of multiple models, providing a practical and scalable solution for modeling. Summary of the Invention
[0007] To address the aforementioned issues, this invention proposes a unified graph modeling method for global graph data based on hard prompts. This method aims to leverage structured natural language templates and large language models to align cross-domain features, alleviating the problem that existing graph neural network methods require separate training for different datasets and are difficult to reuse. This approach utilizes powerful large language models to learn text attribute graphs constructed from graph data and achieves multi-task unification through Prompt nodes.
[0008] To achieve the above objectives, the present invention provides the following technical solution:
[0009] A unified graph modeling method for global graph data based on hard cues, the method comprising the following steps:
[0010] Step 1: Given graph data, use predefined text attribute templates to uniformly transform different graph domain datasets, enabling multi-domain graph data with different semantic backgrounds to be modeled within the same text framework, and generating a text attribute graph dataset. This specifically includes the following sub-steps:
[0011] Step 1-1: Given graph data, define a standardized text description template for node features. For node v i Its text features This can be described in natural language as follows:
[0012]
[0013] Among them, KNode Indicates the number of text features of a node. <feature description k >and <featurecontent k > These represent the feature type and specific content of the k-th feature, respectively.
[0014] Steps 1-2: Given graph data, define a standardized text description template for edge features. For edge e... ij Its text features This can be described in natural language as follows:
[0015]
[0016] Among them, K Edge Indicates the number of edge text features. <feature description k >and <featurecontent k > These represent the feature type and specific content of the k-th feature, respectively.
[0017] Steps 1-3: Given graph data, define standardized text description templates for node labels. For label y... i Its text features This can be described in natural language as follows:
[0018]
[0019] Steps 1-4, using graph-specific terminology, map heterogeneous features from graph data across different domains to a unified semantic space. This mechanism allows cross-domain benchmark datasets to be transformed into text attribute graph datasets with a unified pattern, enabling semantic alignment of features from different domains and allowing a single model to understand and process data from diverse domains.
[0020] In step 2, based on step 1, a large language model is used to semantically encode the generated text features. Then, based on a contrastive learning mechanism, the large language model is fine-tuned, specifically including:
[0021] Step 2-1, for each node v i Input its text features and the text features of their corresponding tags The node text and tag text are encoded separately using a large language model to generate corresponding embedding vectors:
[0022] Step 2-2: Based on the contrastive learning method, the InfoNCE loss function is used to force the node to maximize the embedding similarity with its true label and minimize the embedding similarity with other labels.
[0023]
[0024] in, Let τ be the cosine similarity, τ be the temperature hyperparameter, and N be the number of samples in the batch.
[0025] Step 3: Leveraging the text understanding capabilities of the large language model, semantic encoding and vectorization are performed on the text attribute graph, projecting heterogeneous text features into a shared latent space. The semantic encoding and vectorization process can be defined as: utilizing the text understanding capabilities of the large language model, encoding the processed text attribute graph data using the large language model trained in Step 2. Where x i ,x ij They represent nodes v respectively i and edge e ij Vectorized semantic features. Through the semantic understanding capabilities of large language models, heterogeneous text features can be projected onto a shared latent space, enabling subsequent models to process data from different domains simultaneously in the natural language domain, thus giving the model the ability to process global graph data.
[0026] Step 4: By dynamically expanding the graph structure, the task objective is encoded as the interaction relationship between the Prompt node and specific nodes in the graph, unifying various graph tasks into a logistic regression prediction problem of category nodes.
[0027] Step 4-1: For the graph classification task, input the graph data. Introducing the Prompt node p and the category node set C = {c i |i∈N}, connect the Prompt node p with all nodes v i and category node c i Connect and build an extended graph Generate category node embeddings using a graph neural network encoder. For the embedding of N category nodes, the probability of the graph belonging to category i is calculated using a linear layer MLP, and the final result is...
[0028] Step 4-2: For the node classification task, input graph data. Introducing the Prompt node p and the category node set C = {c i |i∈N}, only the Prompt node p and the target node v for which node classification needs to be performed are considered. i and category node c i Connect and build an extended graph Similarly, a graph neural network encoder is used to generate category node embeddings. The probability that a target node belongs to category i is calculated by using a linear layer MLP to embed N category nodes.
[0029] Step 4-3: For the connection prediction task, input graph data. Introducing the Prompt node p and the category node set C = {c i For |i∈N}, only the Prompt node p is connected to the two target nodes v that need to be predicted. i ,v j and category node c i Connect and build an extended graph Similarly, a graph neural network encoder is used to generate category node embeddings. The probability of two nodes being connected is calculated using a linear layer MLP for embedding N categories of nodes.
[0030] By dynamically expanding the graph structure and introducing Prompt nodes and category nodes, this step encodes the task objective as the interaction relationship between the Prompt node and specific nodes in the graph. This solves the problem in traditional graph learning tasks where it is difficult to uniformly model different task objectives and input formats, thus unifying multiple graph tasks into a logistic regression prediction problem based on category nodes.
[0031] Step 5: Introduce the guidance information of the source task into the Prompt node, and perform semantic encoding on the description text using a large language model to generate a high-dimensional semantic embedding. The source task guidance process is as follows:
[0032] Step 5-1: For each source task, define a description text s, which contains information such as task type, dataset name, and task objective.
[0033] Step 5-2: Encode the source task description text s using a fine-tuned large language model, representing it as a high-dimensional semantic embedding h. s =LLM(s), the initialization characteristic of the Prompt node p is...
[0034] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0035] (1) Significantly improves the performance of multi-task modeling and multi-domain unified graph modeling. In comparative experiments with benchmark models of various general graph representations, the single model of this method can achieve unified modeling of multi-domain graph data, and its performance is comparable to or even better than that of the single-domain benchmark method. At the same time, the performance gain brought by multi-domain joint training was also found. (2) Has cross-domain performance advantages. As can be seen from Table 1, in the PubMed-link prediction task, the AUC of the Ours-Qwen-1.5BGAT model trained in the whole domain reached 98.89±0.06, which is nearly 8 percentage points higher than that of the single-domain GAT (91.11±0.21); in the WN18RR connection prediction task, the ACC of Ours-Qwen-1.5B-GCN (98.68±0.62) is more than 28 percentage points higher than that of the single-domain GCN (70.28±2.56). The results show that the large language model achieves cross-domain feature alignment through semantic encoding of text attribute graphs, enabling the model to capture semantic information of different graph data, thereby overcoming the dependence of traditional single-domain models on domain-specific features. (3) The joint training mode is more stable. As shown in Table 1, overall, the global joint training model outperforms the standalone training model in 4 out of 7 validation experiments, and the difference in the remaining 3 is small. Therefore, it can be concluded that the joint training model has better overall performance and is more stable, and shows stronger generalization ability in cross-domain tasks. Moreover, the core value of global joint training is that it realizes the unified modeling of multi-domain graph data by a single model, without having to train the model from scratch for each domain, which significantly reduces the training cost in practical applications and provides an important direction for the generalization of models in the field of graph learning. (4) Through the large model fine-tuning strategy based on the comparison method, the computational cost is greatly reduced and the inference time is shortened. Attached Figure Description
[0036] Figure 1 This is a flowchart of the method of the present invention.
[0037] Figure 2 This is a schematic diagram of the global graph data unified graph modeling method based on hard hints provided by the present invention.
[0038] Figure 3 This invention provides a visualization diagram for enhancing clustering within the domain of a large language model. Detailed Implementation
[0039] The technical solutions provided by the present invention will be described in detail below with reference to specific implementations. It should be understood that the following specific implementations are only used to illustrate the present invention and are not intended to limit the scope of the present invention.
[0040] Example:
[0041] See Figures 1-3A unified graph modeling method for global graph data based on hard cues, the method comprising the following steps:
[0042] Step 1: Given graph data, use predefined text attribute templates to uniformly transform different graph domain datasets, enabling multi-domain graph data with different semantic backgrounds to be modeled within the same text framework, and generating a text attribute graph dataset. This specifically includes the following sub-steps:
[0043] Step 1-1: Given graph data, define a standardized text description template for node features. For node v i Its text features This can be described in natural language as follows:
[0044]
[0045] Among them, K Node Indicates the number of text features of a node. <feature description k >and <featurecontent k > These represent the feature type and specific content of the k-th feature, respectively.
[0046] Steps 1-2: Given graph data, define a standardized text description template for edge features. For edge e... ij Its text features This can be described in natural language as follows:
[0047]
[0048] Among them, K Edge Indicates the number of edge text features. <feature description k >and <featurecontent k > These represent the feature type and specific content of the k-th feature, respectively.
[0049] Steps 1-3: Given graph data, define standardized text description templates for node labels. For label y... i Its text features This can be described in natural language as follows:
[0050]
[0051] Steps 1-4, using graph-specific terminology, map heterogeneous features from graph data across different domains to a unified semantic space. This mechanism allows cross-domain benchmark datasets to be transformed into text attribute graph datasets with a unified pattern, enabling semantic alignment of features from different domains and allowing a single model to understand and process data from diverse domains.
[0052] In step 2, based on step 1, a large language model is used to semantically encode the generated text features, and the large language model is fine-tuned based on a contrastive learning mechanism. Specifically, this includes:
[0053] Step 2-1, for each node v i Input its text features and the text features of their corresponding tags The node text and tag text are encoded separately using a large language model to generate corresponding embedding vectors:
[0054] Step 2-2: Based on the contrastive learning method, the InfoNCE loss function is used to force the node to maximize the embedding similarity with its true label and minimize the embedding similarity with other labels.
[0055]
[0056] in, Let τ be the cosine similarity, τ be the temperature hyperparameter, and N be the number of samples in the batch.
[0057] Step 3: Leveraging the text understanding capabilities of the large language model, semantic encoding and vectorization are performed on the text attribute graph, projecting heterogeneous text features into a shared latent space. The semantic encoding and vectorization process can be defined as: utilizing the text understanding capabilities of the large language model, encoding the processed text attribute graph data using the large language model trained in Step 2. Where x i ,x ij They represent nodes v respectively i and edge e ij Vectorized semantic features. Through the semantic understanding capabilities of large language models, heterogeneous text features can be projected onto a shared latent space, enabling subsequent models to process data from different domains simultaneously in the natural language domain, thus giving the model the ability to process global graph data.
[0058] Step 4: By dynamically expanding the graph structure, the task objective is encoded as the interaction relationship between the Prompt node and specific nodes in the graph, unifying various graph tasks into a logistic regression prediction problem of category nodes.
[0059] Step 4-1: For the graph classification task, input the graph data. Introducing the Prompt node p and the category node set C = {c i |i∈N}, connect the Prompt node p with all nodes v i and category node c i Connect and build an extended graph Generate category node embeddings using a graph neural network encoder. For the embedding of N category nodes, the probability of the graph belonging to category i is calculated using a linear layer MLP, and the final result is...
[0060] Step 4-2: For the node classification task, input graph data. Introducing the Prompt node p and the category node set C = {c i |i∈N}, only the Prompt node p and the target node v for which node classification needs to be performed are considered. i and category node c i Connect and build an extended graph Similarly, a graph neural network encoder is used to generate category node embeddings. The probability that a target node belongs to category i is calculated by using a linear layer MLP to embed N category nodes.
[0061] Step 4-3: For the connection prediction task, input graph data. Introducing the Prompt node p and the category node set C = {c i For |i∈N}, only the Prompt node p is connected to the two target nodes v that need to be predicted. i ,v j and category node c i Connect and build an extended graph Similarly, a graph neural network encoder is used to generate category node embeddings. The probability of two nodes being connected is calculated using a linear layer MLP for embedding N categories of nodes.
[0062] By dynamically expanding the graph structure and introducing Prompt nodes and category nodes, this step encodes the task objective as the interaction relationship between the Prompt node and specific nodes in the graph. This solves the problem in traditional graph learning tasks where it is difficult to uniformly model different task objectives and input formats, thus unifying multiple graph tasks into a logistic regression prediction problem based on category nodes.
[0063] Step 5: Introduce the guidance information of the source task into the Prompt node, and perform semantic encoding on the description text using a large language model to generate a high-dimensional semantic embedding. The source task guidance process is as follows:
[0064] Step 5-1: For each source task, define a description text s, which contains information such as task type, dataset name, and task objective.
[0065] Step 5-2: Encode the source task description text s using a fine-tuned large language model, representing it as a high-dimensional semantic embedding h. s =LLM(s), the initialization characteristic of the Prompt node p is...
[0066] Experimental conditions: All experiments were implemented using PyTorch on an NVIDIA RTX A6000 48G GPU.
[0067] This paper presents experiments on five datasets: (1) The Cora dataset is a classic citation network dataset, where nodes represent academic papers and edges represent citation relationships between papers. Cora contains 2,708 nodes and 5,429 edges, with node features being bag-of-words representations based on paper content. The tasks are node classification (7 classes) or connection prediction. This dataset is widely used to validate the model's ability to capture semantic and structural information from academic papers. (2) The PubMed dataset is a citation network dataset in the biomedical field, where nodes represent academic papers and edges represent citation relationships. PubMed contains 19,717 nodes and 88,648 edges, with tasks being node classification (3 classes) or connection prediction. This dataset is used to validate the model's ability to perform citation network analysis in the biomedical field. Overall evaluation metrics were measured using accuracy (Acc) and area under the ROC curve (AUC).
[0068] As shown in Table 1, the model in this paper almost always outperforms other graph representation learning models on these two datasets.
[0069] Table 1 Comparison of Model Generation Performance
[0070]
[0071]
[0072] like Figure 3As shown, this experiment uses the Cora and PubMed node classification datasets for visualization analysis. After fine-tuning the large language model, the clustering performance of node features is significantly improved. Specifically, before fine-tuning the Cora dataset, nodes were scattered, with nodes from different categories intermingling; after fine-tuning, nodes of the same category clustered into compact clusters, such as class 0 nodes forming a more concentrated red area, significantly enhancing the distinguishability between categories. For the PubMed dataset, before fine-tuning, nodes were loosely distributed with blurred category boundaries; after fine-tuning, nodes within each cluster were tightly aggregated, significantly improving the clustering of similar features and greatly reducing dispersion. In summary, fine-tuning the large language model effectively strengthens the clustering effect of node features within the domain, making similar nodes more tightly clustered in low-dimensional space, and improving the distinguishability between categories, fully demonstrating the positive role of large language model fine-tuning in optimizing the distribution of node features.
[0073] It should be noted that the above embodiments are not intended to limit the scope of protection of the present invention. Equivalent transformations or substitutions made based on the above technical solutions all fall within the scope of protection of the claims of the present invention.
Claims
1. A unified graph modeling method for global graph data based on hard cues, characterized in that, The method includes the following steps: Step 1: Given graph data, use predefined text attribute templates to uniformly transform different graph domain datasets, enabling multi-domain graph data with different semantic backgrounds to be modeled within the same text framework, and generating a text attribute graph dataset. Step 2: Building upon Step 1, a large language model is used to semantically encode the generated text features. Based on a contrastive learning mechanism, the large language model is then fine-tuned. Step 3: Combining the text understanding capabilities of the large language model, semantic encoding and vectorization are performed on the text attribute graph, projecting heterogeneous text features into a shared latent space. Step 4: By dynamically expanding the graph structure, the task objective is encoded as the interaction relationship between the Prompt node and specific nodes in the graph, unifying various graph tasks into a logistic regression prediction problem of category nodes. Step 5: Introduce the guidance information of the source task into the Prompt node, and use a large language model to semantically encode the description text to generate a high-dimensional semantic embedding.
2. The method for unified graph modeling of global graph data based on hard hints according to claim 1, characterized in that, In step 1, the text attribute graph construction process is as follows: Step 1-1: Given graph data, define a standardized text description template for node features. For node v i Its text features In natural language, this can be described as follows: Among them, K Node Indicates the number of text features of a node. <feature description k >and <featire content k > These represent the feature type and specific content of the k-th feature, respectively. Steps 1-2: Given graph data, define a standardized text description template for edge features. For edge e... ij Its text features In natural language, this can be described as follows: Among them, K Edge Indicates the number of edge text features. <featire description k >and <feature content k > These represent the feature type and specific content of the k-th feature, respectively. Steps 1-3: Given graph data, define a standardized text description template for node labels. For label y... i Its text features In natural language, this can be described as follows: Steps 1-4 combine graph domain-specific terminology to map heterogeneous features of graph data from different domains to a unified semantic space. This mechanism allows cross-domain benchmark datasets to be converted into text attribute graph datasets with a unified pattern, enabling features from different domains to be semantically aligned and allowing a single model to understand and process data from different domains.
3. The method for unified graph modeling of global graph data based on hard hints according to claim 1, characterized in that, In step 2, the fine-tuning process of the large language model is as follows: Step 2-1, for each node v i Input its text features and the text features of their corresponding tags The node text and tag text are encoded separately using a large language model to generate corresponding embedding vectors: Step 2-2: Based on the contrastive learning method, the InfoNCE loss function is used to force the node to maximize the embedding similarity with its true label and minimize the embedding similarity with other labels. in, Let τ be the cosine similarity, τ be the temperature hyperparameter, and N be the number of samples in the batch.
4. The method for unified graph modeling of global graph data based on hard hints according to claim 1, characterized in that, In step 3, the semantic encoding and vectorization process is defined as follows: combining the text understanding capabilities of the large language model, the processed text attribute graph data is encoded using the large language model trained in step 2. Where x i ,x ij Representing node v respectively i and edge e ij Vectorized semantic features.
5. The method for unified graph modeling of global graph data based on hard hints according to claim 1, characterized in that, In step 4, the process of unifying the task situation is as follows: Step 4-1: For the graph classification task, input the graph data. Introducing the Prompt node p and the category node set C = {c i |i∈N}, connect the Prompt node p with all nodes v i and category node c i Connect and build an extended graph Generate category node embeddings using a graph neural network encoder. For the embedding of N category nodes, the probability of the graph belonging to category i is calculated using a linear layer MLP, and the final result is... Step 4-2: For the node classification task, input graph data. Introducing the Prompt node p and the category node set C = {c i |i∈N}, only the Prompt node p and the target node v for which node classification needs to be performed are considered. i and category node c i Connect and build an extended graph Similarly, a graph neural network encoder is used to generate category node embeddings. For N category node embeddings, the probability that the target node belongs to category i is calculated using a linear layer MLP. Step 4-3: For the connection prediction task, input graph data. Introducing the Prompt node p and the category node set C = {c i For |i∈N}, only the Prompt node p is connected to the two target nodes v that need to be predicted. i ,v j and category node c i Connect and build an extended graph Similarly, a graph neural network encoder is used to generate category node embeddings. The probability of two nodes being connected is calculated using a linear layer MLP for embedding N categories of nodes.
6. The method for unified graph modeling of global graph data based on hard hints according to claim 1, characterized in that, In step 5, the source task guidance process is as follows: Step 5-1: For each source task, define a description text s, which includes the task type, dataset name, and task objective information. Step 5-2: Encode the source task description text s using a fine-tuned large language model, representing it as a high-dimensional semantic embedding h. s =LLM(s), the initialization characteristic of the Prompt node p is...
7. A computer-readable storage medium storing computer instructions thereon, characterized in that: When executed by a processor, the computer instructions implement the steps of the unified graph modeling method for global graph data based on hard hints as described in any one of claims 1-6.
8. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the unified graph modeling method for global graph data based on hard hints as described in any one of claims 1 to 6.
