Graph classification model training method and device

By generating descriptive text for nodes and combining it with the encoding of graph neural networks and large language models, the problem of fusing graph modalities and language modalities is solved, improving the performance and interpretability of graph classification models.

CN121527490APending Publication Date: 2026-02-13ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511604538.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-04
Publication Date
2026-02-13

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively integrate graph modalities and linguistic modalities, resulting in limited performance in graph classification tasks.

Method used

By generating descriptive text for each node in the relational graph, processing the subgraphs of nodes and their neighboring nodes using graph neural networks, and combining this with a large language model for encoding, an effective fusion of graph modalities and language modalities is achieved.

Benefits of technology

It improves the performance of graph classification models, ensures semantic consistency between graph modalities and language modalities, and maintains the interpretability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121527490A_ABST
    Figure CN121527490A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a graph classification model training method and device, and the method comprises the steps: obtaining a description text corresponding to a target node in a target sub-graph, and the node information description in the description text comprises special lexical elements indicating the target node and neighbor nodes thereof; and performing graph embedding processing on the target sub-graph by using a graph neural network to obtain node representations corresponding to the target node and the neighbor nodes thereof. And inputting the description text and each node representation into a target large model, enabling the target large model to encode each lexical element in the description text, adding each node representation to a special lexical element position indicating a corresponding node to obtain a text representation, and performing first response prediction based on the text representation. A first loss is calculated based on a first probability for each first tag lexical element in the first tag lexical element sequence in the first response prediction. Parameters of the graph neural network and the target large model are updated according to the comprehensive loss, and the comprehensive loss comprises the first loss.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to one or more embodiments in the field of machine learning, and more particularly to a training method and apparatus for a graph classification model. Background Technology

[0002] Large Language Models (LLMs) have demonstrated exceptional performance in various natural language processing tasks, including dialogue generation, machine translation, question answering systems, and text summarization. However, LLMs have inherent limitations in effectively modeling structured knowledge (such as graph structures)—knowledge crucial for capturing complex relationships and dependencies in diverse real-world domains like social networks, biological systems, and knowledge graphs. To address this issue, recent research has explored combining Graph Neural Networks (GNNs) with LLMs. By integrating the advantages of GNNs in modeling structured information with the powerful language capabilities of LLMs, this approach offers new opportunities to improve the performance of graph classification tasks. However, current solutions fail to effectively integrate graph modalities with language models, significantly impacting the performance of graph classification tasks. Summary of the Invention

[0003] This specification describes one or more embodiments of a training method and apparatus for a graph classification model, which trains the graph classification model based on the effective fusion of graph modalities and language modalities, thereby greatly improving the performance of the trained model in performing classification tasks.

[0004] Firstly, a training method for a graph classification model is provided, wherein the graph classification model includes a graph neural network and a target large model; the method includes:

[0005] Obtain the descriptive text corresponding to the target node in the target subgraph. The descriptive text includes node information description and task text. The node information description includes special words that indicate the target node and its neighboring nodes. The task text indicates a classification task.

[0006] The target subgraph is embedded using the graph neural network to obtain node representations corresponding to the target node and its neighboring nodes.

[0007] The descriptive text and the node representations are input into the target large model, which encodes each word in the descriptive text and adds the node representations to the special word positions that indicate the corresponding nodes to obtain the text representation. The first response prediction is then performed based on the text representation.

[0008] The first loss is calculated based on the first probability of each first tag word in the first tag word sequence in the first response prediction.

[0009] The parameters of the graph neural network and the target large model are updated based on the comprehensive loss; the comprehensive loss includes the first loss.

[0010] Secondly, a training device for a graph classification model is provided, the graph classification model comprising a graph neural network and a target large model; the device comprises:

[0011] The acquisition unit is used to acquire the descriptive text corresponding to the target node in the target subgraph. The descriptive text includes node information description and task text. The node information description includes special words that indicate the target node and its neighboring nodes. The task text indicates a classification task.

[0012] The processing unit is used to perform graph embedding processing on the target subgraph using the graph neural network to obtain node representations corresponding to the target node and its neighboring nodes respectively;

[0013] The input unit is used to input the description text and the node representations into the target large model, so that the model encodes each word in the description text and adds the node representations to the special word positions that indicate the corresponding nodes to obtain the text representations, and performs the first response prediction based on the text representations.

[0014] The calculation unit is configured to calculate a first loss based on the first probability of each first tag word in the first tag word sequence in the first response prediction;

[0015] An update unit is used to update the parameters of the graph neural network and the target large model based on the comprehensive loss; the comprehensive loss includes the first loss.

[0016] Thirdly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of the first aspect.

[0017] Fourthly, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement the method of the first aspect.

[0018] The training method for a graph classification model provided in one or more embodiments of this specification obtains text representations by instructing a large model to add node representations of the target node and its neighboring nodes determined by a graph neural network when encoding the descriptive text of the target node. Response prediction is then performed based on these text representations. This effectively bridges the semantic gap between graph structure data and the output of the large model, achieving an effective fusion of graph modalities and linguistic modalities. This helps improve the performance of the trained graph classification model in performing graph classification tasks. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments in this specification, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A schematic diagram illustrating descriptive text in one example of this specification is shown;

[0021] Figure 2 This is a schematic diagram illustrating an implementation scenario of one embodiment disclosed in this specification;

[0022] Figure 3 A flowchart illustrating a training method for a graph classification model according to an embodiment of this specification is shown.

[0023] Figure 4 The loss L is shown in one example in this specification. sft A schematic diagram of the calculation method;

[0024] Figure 5 This document illustrates a schematic diagram of an optimization method for a target large model in one example.

[0025] Figure 6 A schematic diagram of a training apparatus for a graph classification model according to an embodiment of this specification is shown. Detailed Implementation

[0026] The solution provided in this specification will now be described with reference to the accompanying drawings.

[0027] The following is a description of the definition of the graph classification task mentioned above:

[0028] Typically, a relational graph (or simply graph) can be formally defined as G = (V, E, X), where V = {v1, v2, ..., v...} n} represents a set of nodes. This represents a set of edges used to encode pairwise relationships between nodes. This represents the node feature matrix. Each... Corresponding node v i The feature vector is denoted by d, where d represents the dimension of the node feature.

[0029] The graph classification task described above essentially assigns one of k discrete class labels to each node in G = (V, E, X). Specifically, let Y = {1, 2, ..., k} represent the set of class labels, and the training samples can be represented as: (x i ,yi ),in Represents node v i eigenvectors ∈V, y i ∈Y is the corresponding category label, and the training objective is to learn a graph classification model. Make f(x) i It can accurately predict the category label y of each node. i .

[0030] Currently, the main approach to perform the above graph classification task is to integrate graph neural networks and large language models, which can be divided into the following two categories:

[0031] The first category involves textualizing the graph structure before inputting it into a large language model for processing. For example, some implementations use natural language templates to describe nodes and their relationships, generating a textual representation of the subgraph. Others use special lexical units to represent nodes and edges, effectively converting the graph structure into a sequence format suitable for large language models. However, these implementations have significant drawbacks: the textualization process may lead to the loss of graph structure information, and the serialized representation may not fully capture the complex relationships within the graph. Furthermore, due to the token length constraints of large language models, these implementations face challenges in scalability, making them unsuitable for processing large graph structures containing broad domain information.

[0032] The second category focuses on representation alignment between graph neural networks and the semantic space of large language models. For example, some implementations achieve semantic consistency by projecting the node embeddings generated by the graph neural network into the embedding space of the large language model. Other implementations employ attention mechanisms to directly integrate graph structure information into the representations of the large language model. While these implementations improve the fusion of graph and language modalities, they still face several challenges: the representation alignment process may not be optimal, leading to performance bottlenecks in tasks requiring precise understanding of graph structure and language semantics; furthermore, these implementations often lack interpretability, making it difficult to clearly explain how the model uses graph information to make decisions or generate outputs.

[0033] Based on this, this solution proposes to pre-generate descriptive text containing connection relationship information for each node in the relation graph, that is, to capture the network structure and feature information of the node in text form, and to use a graph neural network to process the subgraph of the node and obtain the node representation of the node and its neighboring nodes. Then, based on the descriptive text and the aforementioned node representations, reasoning is performed using a large language model. In other words, the above training objective is further refined to learning a graph classification model. T here refers to the descriptive text mentioned above. In other words, this solution integrates the representational capabilities of graph neural networks and large language models to construct a more semantically rich graph classification model.

[0034] The above is the inventive concept provided in the embodiments of this specification, and the solution can be implemented based on this inventive concept. Before describing the solution in detail, let's take any node v as an example and describe its text T. v The acquisition process will be explained as follows:

[0035] First, perform subgraph sampling on node v.

[0036] When dealing with large-scale graph data, subgraph sampling is crucial for reducing computational complexity and achieving scalable processing. This scheme employs a k-order sampling strategy to extract a local subgraph centered on node v. Specifically, for node v, its neighboring nodes within a k-order (e.g., 2-order) range are sampled and represented as: N (k) (v).

[0037] Secondly, based on node v and its neighboring nodes, determine the descriptive text for node v.

[0038] In this scheme, for each node v, multiple descriptive texts can be constructed. A single descriptive text can be represented as a tuple: (task text, <node information description>), where the task text indicates the classification task (usually without specifying a specific node), and the node information description can include special terms indicating node v and its neighboring nodes. Here, the neighboring nodes can be from: N (k) (v) is randomly selected. Additionally, it may include a brief overview of the object represented by the node. The object here can be, for example, text, and thus the brief overview could be, for example, the title or summary of that text.

[0039] Of course, in practice, the above descriptive text may also include instructions for performing the classification task (specific nodes need to be specified).

[0040] Figure 1 A schematic diagram of descriptive text is shown in one example of this specification. Figure 1 The description text comprises three parts: task text, node information description, and instructions. The node information description includes special terms indicating node v: <node v >A brief overview of the object represented by node v: description v And special terms indicating the i neighboring nodes of node v: A brief overview of the i objects represented by the i neighboring nodes:

[0041] The above describes the method for obtaining the descriptive text of nodes. The following describes the implementation process of this solution.

[0042] Figure 2This is a schematic diagram illustrating an implementation scenario of one of the embodiments disclosed in this specification. Figure 2 In this context, graph classification models include graph neural networks and target large models. Furthermore, the training sample set D is used to train the graph classification models. align This includes each training sample corresponding to a node in the target relationship graph. Each training sample includes the descriptive text T corresponding to node v. v and its tag lexical sequence Y v =[c1,c2,…,c n ], v∈V, where V is the total number of nodes in the target relation graph. Wherein, the description text T v Special terms are used to represent node v and its neighboring nodes; see [link to details]. Figure 1 As shown.

[0043] For a node v corresponding to a single training sample, a graph neural network can be used to perform graph embedding on the subgraph of node v, thereby obtaining the node representation of node v and its neighboring nodes.

[0044] Next, the description text T of node v can be... v The node representations of node v and its neighboring nodes are input into the target large model, which encodes each word in the descriptive text. The node representations of node v and its neighboring nodes are then added to the special word positions that indicate the corresponding nodes to obtain the text representations. Response prediction is then performed based on the text representations.

[0045] Finally, based on the probability of each tag word in the tag word sequence in the response prediction... (1≤t≤n), calculate the loss L align And based on including the loss L align The combined loss, including the parameters of the graph neural network and the target large model, is used to update the parameters.

[0046] Figure 3 A flowchart illustrating a training method for a graph classification model according to an embodiment of this specification is shown. It should be noted that this method includes multiple iterations. Figure 3 The method steps involved in the t-th iteration (t is a positive integer) are shown. It can be understood that multiple iterations of updating the graph classification model can be achieved by repeatedly executing the steps shown.

[0047] like Figure 3 As shown, the method may include the following steps:

[0048] Step S302: Obtain the training sample set, which includes each training sample corresponding to each node in the target relationship graph. Each training sample includes the descriptive text T of the corresponding node v. v and its tag lexical sequence Y v =[c1,c2,…,cn ].

[0049] In one example, each node in the target relationship graph represents a text, and the connecting edges represent the reference relationships between the texts. Therefore, this target relationship graph can also be called a text relationship graph.

[0050] In another example, each node in the target relationship graph represents a user, and the connecting edges represent transaction relationships between users; thus, this target relationship graph can also be called a user relationship graph.

[0051] The description text T of the above single node v v As mentioned above, it can be represented as a tuple: (task text, <node information description>), where the task text indicates a classification task (usually without specifying a specific node), and the node information description may include special terms indicating node v and its neighboring nodes. Additionally, it may include a brief overview of the object represented by the node, such as the title or summary of the text.

[0052] Of course, in practice, the above description text T v It may also include instructions for performing classification tasks (which require specifying specific nodes), but this manual does not limit this.

[0053] It should be understood that in practice, multiple descriptive texts can be generated for a single node v, and the node information descriptions in different descriptive texts can be different. More specifically, the neighboring nodes included in the node information descriptions are different. For example, one descriptive text may include the second-order neighboring nodes of node v, while another descriptive text may include the third-order neighboring nodes of node v.

[0054] The above-mentioned tag lexical sequence Y v This refers to the category label of node v, which can be manually labeled or generated using a large language model based on the descriptive text T. v The prediction was obtained.

[0055] Step S304: For any training sample in the training sample set, use a graph neural network to perform graph embedding processing on the target subgraph of the corresponding node v to obtain the node representations corresponding to node v and its neighboring nodes respectively.

[0056] Here, the target subgraph can be extracted from the target relationship graph by using a k-order sampling strategy, and is a local subgraph centered on node v.

[0057] Taking the graph neural network implemented as the GraphSAGE model (hereinafter referred to as the model) as an example, assuming that the model includes m layers, the processing of each layer can include the following two steps:

[0058] First, message aggregation is performed for each node in the target subgraph. Taking node v as an example, the specific message aggregation formula can be as follows:

[0059]

[0060] in, This represents the node representation of node v in the (l-1)th layer of the model. Let v represent the node representation of node u, a neighbor of node v, at layer (l-1) of the model. This represents the aggregation result of node v.

[0061] Secondly, the aggregation result of each node is mapped to the node representation in the current layer. Taking node v as an example again, the specific mapping formula can be as follows:

[0062]

[0063] in, See the definition above. W represents the node v in the l-th layer of the model. (l) Let be the model parameters for the l-th layer, and σ be the ReLU activation function. That is, each node is updated through a nonlinear projection with learnable parameters.

[0064] It should be understood that after the above m layers of processing, the final node representations (hereinafter also referred to as graph semantic representations) of node v and its neighboring nodes can be obtained.

[0065] Step S306, the description text T of node v v The node representations of node v and its neighboring nodes are input to the target large model, which is then used to describe the text T. v After encoding each lexical unit, the node representation is added to the special lexical position that indicates the corresponding node to obtain the text representation, and response prediction is performed based on the text representation.

[0066] The target large model here can include an input layer, a hidden layer, and an output layer.

[0067] Furthermore, the input layer may include a word embedding layer and a positional encoding layer. The word embedding layer is used to convert each word in the input text into a corresponding embedding vector, that is, to encode each word in the input text. The positional encoding layer is used to add positional information to the embedding vectors of each word.

[0068] The hidden layers can include encoder and / or decoder layers. Furthermore, the encoder layer can include a multi-head self-attention layer, a feedforward neural network layer, and a layer normalization layer. The multi-head self-attention layer calculates the correlation between each word in the input text and other words, thereby capturing long-distance dependencies in long texts. The feedforward neural network layer performs a non-linear transformation on the output of the multi-head self-attention layer to further extract features. The layer normalization layer normalizes the features of each input text element.

[0069] The decoder layer can include a masked multi-head self-attention layer, an encoder-decoder attention layer, a feedforward neural network layer, and a layer normalization layer. The masked multi-head self-attention layer is similar to the multi-head self-attention layer, but during text generation, to ensure the model's autoregressive properties, subsequent words need to be masked to prevent the model from seeing subsequent information. When the hidden layer includes both an encoder and a decoder layer, the encoder-decoder attention layer is used to fuse the encoder's output information into the decoder layer, enabling the decoder layer to utilize the contextual information extracted by the encoder layer for text generation. The feedforward neural network layer and the layer normalization layer have the same function and principle as their corresponding layers in the encoder layer, used to perform non-linear transformations and normalization on the intermediate outputs of the decoder layer.

[0070] The output layer described above maps the output of the hidden layer to a preset vocabulary space, thereby calculating a score for each word in the preset vocabulary space. It should be understood that the above-described tag word sequence Y... v =[c1,c2,…,c n The various tag terms in the table are also included in this preset vocabulary space.

[0071] Of course, in practice, the above output layer can also include a softmax layer, which is used to convert the scores of each word into a probability distribution so that the sum of the probabilities of all words is 1, making it easier for the model to select the word with the highest probability as the generated result.

[0072] Unlike conventional schemes that use word embedding layers, this scheme processes the descriptive text T... v After encoding each word in the text, that is, after obtaining the descriptive text T, v After obtaining the embedding vectors of each word element, further processing is required. Specifically, the graph semantic representations of node v and its neighboring nodes need to be added to the positions of the special words indicating node v and its neighboring nodes. That is, the embedding vectors of the special words indicating node v are replaced with the graph semantic representations of node v, and the embedding vectors of the special words indicating neighboring nodes are replaced with the graph semantic representations of the neighboring nodes, thus obtaining the output of the word embedding layer (hereinafter referred to as the text representation). Then, the text representation is processed by the positional encoding layer, hidden layer, and output layer, that is, response prediction is performed on the text representation.

[0073] It should be noted that this scheme can effectively integrate graph modalities and language modalities by encoding each word in the descriptive text and adding graph semantic representations of node v and its neighboring nodes. This can greatly improve the performance of the trained graph classification model in performing classification tasks.

[0074] It should be understood that when node v has multiple descriptive texts, these multiple descriptive texts can be input separately into the target large model for response prediction.

[0075] Step S308, based on the above response prediction for the tag word sequence Y v Calculate the loss L based on the probability of each tag term in the text. align And based on this, adjust the parameters of the graph neural network and the target large model.

[0076] It should be understood that the above response prediction is the word-by-word generation process. Specifically, this scheme reads Y from the preset vocabulary space when the target large model generates the first word. v The probability of the first tag word in Then, when the target large model generates the second lexical unit, it reads Y from the preset vocabulary space. v The probability of the second tag word in And so on, until Y is read. v The probability of the last tag word in

[0077] After reading the various probabilities Then, the loss L can be calculated using the following formula. align :

[0078]

[0079] Among them, c t For the tag word sequence Y v The t-th tag word in the string, where n is the number of tag words, and θ LLM For the parameters of the large language model, θ GNN These are the parameters of the graph neural network.

[0080] It should be understood that when multiple descriptive texts of node v are input into the target large model, then for the label term sequence Y... v Each tag word can obtain multiple probabilities. These multiple probabilities can be averaged to obtain the final probability of the tag word.

[0081] Thus, we obtain the loss L corresponding to any training sample. align Similarly, the loss L corresponding to each training sample can be calculated.align Then we can analyze each loss L align Perform synthesis (e.g., summation) and based on the final L align Then, update the parameters of the graph neural network and the target large model to obtain the trained graph classification model.

[0082] The above is based solely on loss L align The explanation of the training process for the image classification model should be understood as follows: based on this loss L... align When training a graph classification model, the gap between graph structure data and LLM output can be effectively bridged, ensuring robust semantic consistency between graph modalities and language modalities.

[0083] In practical applications, when interpretability is crucial, graph classification models not only need to accurately perform classification tasks but also need to provide clear explanations for these decisions. Therefore, the training objective is updated to train a graph classification model that can not only perform classification tasks but also generate analytical content to elucidate its decision-making process, expressed as: Here, Analysis refers to the explanatory information generated by the graph classification model.

[0084] To achieve the aforementioned updated training objective, this scheme proposes to combine loss L... align and loss L sft To train the graph classification model. The following example uses the same training sample to illustrate the loss L. sft The calculation process will be explained.

[0085] Figure 4 The loss L is shown in one example in this specification. sft A schematic diagram of the calculation method. Figure 4 First, obtain the description text T of node v. v Then, several predefined instructions are used to replace the description text T. v The original instructions in the code yield several corresponding target descriptions T′. v It should be understood that these predefined instructions convey the same intent, or in other words, they serve the same purpose, such as instructing the execution of classification tasks and the output of explanatory information.

[0086] Then, for any target description T′ v The corresponding tag word sequence is determined as follows:

[0087] A large-scale model of the base (such as the GPT-2, GPT-3 series, etc.) can be used to describe T′ for this target. v Perform multiple predictions to obtain multiple predicted responses Y′ v In particular, the generation parameters (e.g., temperature parameters) of the large model differ in different predictions.

[0088] Furthermore, it should be understood that each of the above predicted responses Y′ v It contains both the classification result of node v and explanatory information for that classification result.

[0089] Next, the multiple predicted responses Y′ can be obtained. v Select the target prediction response Y′ with the best quality from the pool. vbest .

[0090] In one embodiment, the target predicted response Y′ can be selected based on expert experience. vbest .

[0091] In another embodiment, advanced large models (e.g., GPT-4, PaLM 2, etc.) can be used to predict responses Y′ from multiple sources. v Select the target to predict the response Y′ vbest .

[0092] Specifically, multiple predicted responses Y′ can be used. v Describe the target T′ respectively v After combining the data, input it into a high-level large model, and then let it evaluate multiple predicted responses Y′ from several evaluation dimensions. v A quality assessment was performed to obtain the multiple predicted responses Y′. v Each corresponds to a quality score. Then, the multiple predicted responses Y′ are... v The predicted response corresponding to the maximum quality score is determined as the target predicted response Y′. vbest .

[0093] The aforementioned evaluation dimensions may include: the accuracy of the response, the degree of compliance with instructions, and the reasonableness of explanatory information.

[0094] After determining the above target predicted response Y′ vbest Then, the target description T′ can be determined based on it. v Tag term sequence: Y′ vbest =[c′1,c′2,…,c′ n ].

[0095] Then, the target description T′ can be made. v The node representations of node v and its neighboring nodes are input to the large target model, and their descriptions of the target T′ are given. v After encoding each lexical unit, the node representation is added to the specific lexical position indicating the corresponding node to obtain the text representation. Based on the text representation, response prediction is performed again, and based on this second response prediction, a response is made for the tag lexical sequence: Y′. vbest Calculate the loss L based on the probability of each tag term in the text. sft .

[0096] Specifically, in the description of the target T′ v After encoding each term in the target description T′, the target description T′ is obtained. v After obtaining the embedding vectors of each word element, further processing is required. Specifically, the graph semantic representations of node v and its neighboring nodes need to be added to the positions of the special words indicating node v and its neighboring nodes. That is, the embedding vectors of the special words indicating node v are replaced with the graph semantic representations of node v, and the embedding vectors of the special words indicating neighboring nodes are replaced with the graph semantic representations of the neighboring nodes, thus obtaining the output of the word embedding layer (hereinafter referred to as the text representation). Then, the text representation is processed by the positional encoding layer, hidden layer, and output layer, that is, a second response prediction is performed on the text representation.

[0097] It should be understood that this re-predicted response is also a word-by-word generation process. This scheme reads Y′ from the pre-defined vocabulary space when the target large model generates the first word. vbest The probability of the first tag word in Then, when the target large model generates the second lexical unit, Y′ is read from the preset vocabulary space. vbest The probability of the second tag word in And so on, until Y′ is read. vbest The probability of the last tag word in

[0098] After reading the various probabilities Then, the loss L can be calculated using the following formula. sft :

[0099]

[0100] Where, c′ t For the tag word sequence Y′ vbest The t-th tag word in the string, where n is the number of tag words, and θ LLM For the parameters of the large language model, θ GNN These are the parameters of the graph neural network.

[0101] Similarly, T′ can be described based on other objectives. v Calculate the loss L sft Then, the descriptions of each objective T′ are given. v The corresponding losses L sft By combining the results, we obtain the loss L for node v. sft That is, to obtain the loss L corresponding to any training sample. sft .

[0102] After obtaining the loss L corresponding to each training sample sftAfterwards, each loss L can be analyzed. sft By performing synthesis (e.g., summation), we obtain the final L. sft Finally, we can consider the final L mentioned above. align And the final L sft The parameters of the graph neural network and the target large model are then integrated and updated based on the integrated loss to obtain the trained graph classification model.

[0103] In one example, the final L can be calculated according to the following formula. align And the final L sft To synthesize:

[0104] L total =λ1·L align +λ2·L sft (Formula 5)

[0105] Among them, L total For the overall loss, λ1 and λ2 are both hyperparameters.

[0106] It should be understood that, based on this loss L sft This allows the target large model to evaluate and select a more interpretable response. In other words, combining the aforementioned loss L... sft After training a graph classification model, the trained graph classification model can not only output the classification results of nodes (i.e., category labels), but also output explanatory information about the classification results.

[0107] Furthermore, when training a graph classification model iteratively based on comprehensive loss, this approach enables the model to iteratively evaluate and improve its response, thereby enhancing interpretability and generation quality, and ultimately improving performance and transparency.

[0108] Finally, in order for the aforementioned target model to distinguish between high-quality and low-quality responses, this scheme will continue to refine the comprehensive loss L... total The trained target large model is then optimized.

[0109] Figure 5 This document illustrates a schematic diagram of an optimization method for a target large model in one example. Figure 5 In the above description, T′ is used to describe any of the above objectives. v , and their corresponding multiple predicted responses Y′ v Represented as: Y′ v ={Y′ vbest ,Y′ v1 ,…,Y′ vn-1}, where Y′ vbest The optimal predicted response is given by n, where n is the number of predicted responses.

[0110] Specifically, the target description T′ can be...v As a sample description, the predicted response Y′ vbest As a preference response Y′ vpos and any other predicted response Y′ vi (1≤i≤n-1) represents the unbiased response Y′ vneg This generates training samples, thus obtaining n-1 training samples. Furthermore, T′ can be described based on other objectives. v This is used to generate training samples, thus obtaining the target sample set.

[0111] It should be noted that this scheme first obtains several target descriptions T′ through instruction substitution. v Then, describe T′ for each target. v Multiple predicted responses Y′ are generated using a large base model. v And it is evaluated using a high-level large model, thereby selecting the target predicted response Y′. vbest Finally, constructing a target sample set based on the screening results can greatly improve the quality and diversity of the sample set.

[0112] Then, using the trained target model as the initial large model, and based on the target sample set, several rounds of update operations are performed iteratively to obtain the final large model. Each round of update operations includes:

[0113] Describe the target T′ v and preference response Y′ vpos The combined sequence s1 is input into the current large model π. θ and the initial large model π ref The probability of the sequence logarithm of the combined sequence s1 is obtained as: logπ θ (Y′ vpos |T′ v ) and logπ ref (Y′ vpos |T′ v Then, the ratio of the two log probabilities is calculated as the preference response Y′. vpos The corresponding preference value is r1.

[0114] Wherein, the logarithmic probability is: logπ θ (Y′ vpos |T′ v Specifically, this is achieved through the analysis of the current large model π. θ Regarding the preference response Y′ vpos The logarithmic probability is obtained by summing the predicted log probabilities of each word in the sequence. Similarly, the logarithmic probability is: logπ ref (Y′ vpos |T′ v Specifically, this is achieved through the initial large model π. refRegarding the preference response Y′ vpos The summation of the predicted log probabilities of each word in the sequence is obtained.

[0115] And, describe the target T′ v Non-preference response Y′ vneg The combined sequence s2 is input into the current large model π. θ and the initial large model π ref The probability of the sequence logarithm of the combined sequence s2 is obtained as: logπ θ (Y′ vneg |T′ v ) and logπ ref (Y′ vneg |T′ v Then, the ratio of the two log probabilities is calculated as the unbiased response Y′. vneg The corresponding preference value is r2.

[0116] Finally, the loss L is calculated based on the difference between preference value r1 and preference value r2. DPO Among them, the loss L DPO It is negatively correlated with this difference. And based on the loss L DPO Update the parameters of the current large model.

[0117] In one example, the loss L can be calculated using the following formula: DPO :

[0118]

[0119] Where β is a hyperparameter.

[0120] After obtaining the final large model, the trained graph neural network and the final large model can be combined to form the graph classification model trained by this scheme.

[0121] For example, for any relation graph G1, when classifying node v1, we can first use a trained graph neural network to perform graph embedding on the target subgraph of node v1, obtaining the semantic representations of each graph corresponding to node v1 and its neighboring nodes. Next, the descriptive text of node v1 and the semantic representations of each graph can be input into the final large model. The model encodes each word in the descriptive text and adds the semantic representations of each graph to the specific word positions indicating the corresponding node, obtaining the target text representation. Based on the target text representation, response prediction is performed to obtain the target response containing the classification result and explanatory information of node v1.

[0122] In summary, the training method for the graph classification model provided in this specification ensures robust semantic consistency between graph and language modalities while maintaining the model's interpretability. Furthermore, this approach has broad applicability and can be applied to various large language models and graph classification tasks without requiring extensive adjustments.

[0123] The large model described in this specification is the Large Language Model (LLM). A LLM is a natural language processing model based on deep learning techniques, typically with billions to hundreds of billions or even more parameters, possessing powerful language understanding and generation capabilities. LLMs can employ the Transformer architecture or its variants (such as GPT, BERT, etc.), which utilizes an attention mechanism to globally model sequential data, efficiently handling long-distance dependencies and thus performing exceptionally well in natural language tasks. LLMs learn the statistical features and semantic relationships of language through pre-training on large-scale corpora, giving them outstanding generalization capabilities. The core capabilities of LLMs include, but are not limited to: understanding contextual semantics, generating coherent and grammatically correct text, performing logical reasoning, and handling multi-task scenarios. Their usage typically includes two modes: direct inference and fine-tuning. In direct inference mode, the user guides the LLM to generate specific outputs by designing prompts. Cue words can be task descriptions or instructions in text form, used to stimulate the semantic understanding and generation capabilities of large language models. In fine-tuning mode, large language models are further trained on small-scale datasets in specific domains to optimize their performance on specific tasks. The powerful generalization ability and flexibility of large language models make them an important tool in the field of artificial intelligence, providing efficient and accurate solutions for automated text generation and understanding.

[0124] In some embodiments, large language models can also understand and generate data from other modalities (such as visual and audio data). In this case, large language models can also be called multimodal large language models (MLLMs). MLLMs provide a richer and more natural interactive experience by integrating multiple types of input and output, such as text, images, and sound. The core advantage of MLLMs lies in their ability to process and understand information from different modalities and fuse this information to complete complex tasks. For example, MLLMs can analyze an image and generate descriptive text, or generate a corresponding image based on a text description. This cross-modal understanding and generation capability makes MLLMs widely applicable across multiple fields.

[0125] It should be noted that the key technologies of large language models can be found in the detailed description in the paper "A Survey of Large Language Models" (paper number: arXiv:2303.18223v16, published on March 11, 2025, public link: https: / / doi.org / 10.48550 / arXiv.2303.18223), and will not be repeated here.

[0126] Corresponding to the training method of the graph classification model described above, one embodiment of this specification also provides a training apparatus for a graph classification model, such as... Figure 6 As shown, the device may include:

[0127] The acquisition unit 602 is used to acquire the description text corresponding to the target node in the target subgraph. The description text includes node information description and task text. The node information description includes special words that indicate the target node and its neighboring nodes. The task text indicates the classification task.

[0128] The processing unit 604 is used to perform graph embedding processing on the target subgraph using a graph neural network to obtain the node representations corresponding to the target node and its neighboring nodes respectively.

[0129] The input unit 606 is used to input the descriptive text and the node representations into the target large model, so that the model encodes each word in the descriptive text and adds the node representations to the special word positions that indicate the corresponding nodes to obtain the text representations, and performs the first response prediction based on the text representations.

[0130] The calculation unit 608 is used to calculate the first loss based on the first probability of each first tag word in the first tag word sequence in the first response prediction;

[0131] The update unit 610 is used to update the parameters of the graph neural network and the target large model based on the comprehensive loss, which includes the first loss.

[0132] In one embodiment, the descriptive text further includes raw instructions for performing the classification task, and the apparatus further includes:

[0133] Replacement unit 612 is used to replace the original instructions in the description text with predefined instructions to obtain the target description. The predefined instructions indicate that a classification task is performed and explanatory information is output.

[0134] The input unit 606 is also used to input the target description and the node representation into the target large model, so that it can perform the second response prediction;

[0135] The computing unit 608 is also used to calculate a second loss based on the second probability of each second label word in the second label word sequence in the second response prediction, the second label word sequence being determined based on the target prediction response among multiple predicted responses output by the first large model for the target description;

[0136] The determination unit 614 is used to determine the comprehensive loss based on the first loss and the second loss.

[0137] In one embodiment, the input unit 606 is further configured to input any first predicted response and target description into the second large model, so that the model can evaluate the quality of the first predicted response from several evaluation dimensions to obtain a quality score of the first predicted response.

[0138] The determining unit 614 is also used to determine the predicted response corresponding to the maximum quality score among multiple predicted responses as the target predicted response.

[0139] In one embodiment, the aforementioned evaluation dimensions include:

[0140] Accuracy of the response;

[0141] The degree to which instructions are followed;

[0142] The reasonableness of explanatory information.

[0143] In one embodiment, the target subgraph consists of nodes and their connecting edges that originate from the target node in the target relation graph and are reached via a preset number of connecting edges k.

[0144] In one embodiment, the device further includes:

[0145] Construction unit 616 is used to construct a target sample set, wherein a single sample includes a target description, a target prediction response, and any second prediction response other than the target prediction response among multiple prediction responses;

[0146] The update unit 610 is also used to take the trained target large model as the initial large model, and perform several rounds of update operations based on the target sample set to obtain the final large model.

[0147] In one embodiment, the update unit 610 is specifically used for:

[0148] The first combined sequence of the target description and the target prediction response is input into the current large model and the initial large model, respectively, to obtain the first and second sequence log probabilities of the first combined sequence, and the first preference value is determined based on them;

[0149] The second combined sequence of the target description and the second predicted response is input into the current large model and the initial large model, respectively, to obtain the log probabilities of the third and fourth sequences, and the second preference value is determined based on them;

[0150] The parameters of the current large model are updated with the goal of maximizing the difference between the first preference value and the second preference value.

[0151] In one embodiment, a single node in the target subgraph represents text, and the node information description further includes a brief overview of the text corresponding to the target node and its neighboring nodes.

[0152] The functions of each functional unit of the apparatus in the above embodiments of this specification can be implemented through the steps of the above method embodiments. Therefore, the specific working process of the apparatus provided in one embodiment of this specification will not be repeated here.

[0153] This specification provides a training apparatus for a graph classification model in one embodiment, which can improve the performance of the trained graph classification model when performing graph classification tasks.

[0154] According to another embodiment, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed in a computer, causes the computer to perform a combination Figure 3 The method described.

[0155] According to another embodiment, a computing device is also provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements a combination... Figure 3 The method described.

[0156] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the medium or device embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0157] The steps of the methods or algorithms described in conjunction with the disclosure in this specification can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in RAM, flash memory, ROM, EPROM, EEPROM, registers, hard disk, external hard disk, CD-ROM, or any other form of storage medium well known in the art. An exemplary storage medium is coupled to the processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an ASIC. Alternatively, the ASIC can reside in a server. Of course, the processor and storage medium can also exist as discrete components in the server.

[0158] Those skilled in the art will recognize that, in one or more of the examples above, the functions described in this invention can be implemented using hardware, software, firmware, or any combination thereof. When implemented in software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium accessible to a general-purpose or special-purpose computer.

[0159] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0160] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of this specification. It should be understood that the above description is only a specific embodiment of this specification and is not intended to limit the scope of protection of this specification. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of this specification should be included within the scope of protection of this specification.

Claims

1. A training method for a graph classification model, wherein the graph classification model comprises a graph neural network and a target large model; the method comprises: Obtain the descriptive text corresponding to the target node in the target subgraph. The descriptive text includes node information description and task text. The node information description includes special words that indicate the target node and its neighboring nodes. The task text indicates a classification task. The target subgraph is embedded using the graph neural network to obtain node representations corresponding to the target node and its neighboring nodes. The descriptive text and the node representations are input into the target large model, which encodes each word in the descriptive text and adds the node representations to the special word positions that indicate the corresponding nodes to obtain the text representation. The first response prediction is then performed based on the text representation. The first loss is calculated based on the first probability of each first tag word in the first tag word sequence in the first response prediction. The parameters of the graph neural network and the target large model are updated based on the comprehensive loss; the comprehensive loss includes the first loss.

2. The method according to claim 1, wherein, The descriptive text also includes raw instructions for performing the classification task; the method further includes: The target description is obtained by replacing the original instructions in the description text with predefined instructions; the predefined instructions instruct the execution of a classification task and the output of explanatory information. The target description and the node representations are input into the target large model to perform a second response prediction. The second loss is calculated based on the second probability of each second label word in the second label word sequence in the second response prediction; the second label word sequence is determined based on the target prediction response among the multiple predicted responses output by the first large model for the target description; The comprehensive loss is determined based on the first loss and the second loss.

3. The method according to claim 2, wherein, The target predicted response is obtained through the following steps: Input any first predicted response and the target description into the second large model, and let it evaluate the quality of the first predicted response from several evaluation dimensions to obtain the quality score of the first predicted response. The prediction response that corresponds to the maximum quality score among the plurality of prediction responses is determined as the target prediction response.

4. The method according to claim 3, wherein, The evaluation dimensions include: Accuracy of the response; The degree to which instructions are followed; The reasonableness of explanatory information.

5. The method according to claim 2, further comprising: Construct a target sample set, wherein a single sample includes the target description, the target prediction response, and any second prediction response other than the target prediction response among the plurality of prediction responses; The trained target model is used as the initial large model. Based on the target sample set, several rounds of update operations are performed iteratively to obtain the final large model.

6. The method according to claim 5, wherein, A single-round update operation includes: The first combined sequence of the target description and the target prediction response is input into the current large model and the initial large model, respectively, to obtain the first and second sequence log probabilities of the first combined sequence, and the first preference value is determined based on them; The second combined sequence of the target description and the second predicted response is input into the current large model and the initial large model, respectively, to obtain the log probabilities of the third and fourth sequences, and the second preference value is determined based on them; The parameters of the current large model are updated with the goal of maximizing the difference between the first preference value and the second preference value.

7. The method according to claim 1, wherein, The target subgraph is composed of nodes and their connecting edges that start from the target node in the target relationship graph and are reached via a preset number of connecting edges (k).

8. The method according to claim 1, wherein, Each node in the target subgraph represents text; the node information description also includes a brief overview of the text corresponding to the target node and its neighboring nodes.

9. A training apparatus for a graph classification model, the graph classification model comprising a graph neural network and a target large model; The device includes: The acquisition unit is used to acquire the descriptive text corresponding to the target node in the target subgraph. The descriptive text includes node information description and task text. The node information description includes special words that indicate the target node and its neighboring nodes. The task text indicates a classification task. The processing unit is used to perform graph embedding processing on the target subgraph using the graph neural network to obtain node representations corresponding to the target node and its neighboring nodes respectively; The input unit is used to input the description text and the node representations into the target large model, so that the model encodes each word in the description text and adds the node representations to the special word positions that indicate the corresponding nodes to obtain the text representations, and performs the first response prediction based on the text representations. The calculation unit is configured to calculate a first loss based on the first probability of each first tag word in the first tag word sequence in the first response prediction; An update unit is used to update the parameters of the graph neural network and the target large model based on the comprehensive loss; the comprehensive loss includes the first loss.

10. A computer-readable storage medium having a computer program stored thereon, wherein, When the computer program is executed in the computer, it causes the computer to perform the method of any one of claims 1-8.

11. A computing device comprising a memory and a processor, wherein, The memory stores executable code, and when the processor executes the executable code, it implements the method of any one of claims 1-8.