Relationship graph reconstruction method and apparatus, computer device, and readable storage medium
Patent Information
- Application Number
- PCT/CN2026/075695
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-02-26
- Filing Date
- 2026-01-29
- Publication Date
- 2026-09-03
Smart Images

Figure CN2026075695_03092026_PF_FP_ABST
Abstract
Description
Methods, apparatus, computer equipment, and readable storage media for reconstructing relation graphs Technical Field
[0001] This application relates to the field of graph data processing technology, and in particular to a method, apparatus, computer device and readable storage medium for reconstructing a relation graph. Background Technology
[0002] A relationship graph is a graphical data structure used to represent complex relationships between entities, describing entities and their connections through nodes and edges. It is widely used in social network analysis, gene regulatory networks, recommender systems, and other scenarios. However, due to incomplete data collection, noise interference, or storage limitations, relationship graphs often suffer from missing or corrupted data. Therefore, to significantly improve the completeness and usability of knowledge graphs, it is necessary to reconstruct relationship graphs.
[0003] In related technologies, the reconstruction of a relation graph typically involves extracting feature representations of nodes from the missing graph, calculating the similarity between nodes based on these features, predicting missing edges based on the similarity scores, and then adding these edges back to the graph. However, while this reconstruction method is simple and easy to implement, it is only suitable for cases with sparse data or simple graph structures. In cases with complex graph structures and implicit relationships between nodes, this method often ignores the global structural information of the graph, resulting in a lack of global consistency and accuracy in the repaired graph. Summary of the Invention
[0004] The main objective of this application is to propose a method, apparatus, computer device, and readable storage medium for reconstructing a relational graph, which can improve the global consistency and accuracy of the reconstructed relational graph.
[0005] To achieve the above objectives, a first aspect of this application proposes a method for reconstructing a relational graph, the method comprising:
[0006] Obtain a pre-constructed initial relationship graph, and generate node feature matrices corresponding to multiple target nodes and an initial adjacency matrix representing the connection relationship between the multiple target nodes based on the initial relationship graph;
[0007] Using the target model, feature transfer and feature aggregation are performed between the multiple target nodes based on the initial adjacency matrix and the node feature matrix to obtain the intermediate features of each target node;
[0008] For each target node, the intermediate features are mapped to the latent space to obtain the corresponding distribution parameters; wherein, the latent space is used to map the local dependencies between each target node and its neighboring nodes, as well as the global dependencies of each target node in the initial relation graph;
[0009] Randomly sample the Gaussian distribution corresponding to the distribution parameters of each target node to obtain the latent representation vector corresponding to each target node, and generate the latent representation matrix corresponding to the initial relation graph based on multiple latent representation vectors;
[0010] Based on the latent representation matrix, the connection probability between any two target nodes is predicted, and the target adjacency matrix is obtained based on multiple connection probabilities.
[0011] Using the target model, the initial relation graph is reconstructed based on the node feature matrix and the target adjacency matrix to obtain the target relation graph.
[0012] Accordingly, a second aspect of this application proposes a relational graph reconstruction apparatus, the apparatus comprising:
[0013] The acquisition module is used to acquire a pre-constructed initial relationship graph, and generate a node feature matrix corresponding to multiple target nodes and an initial adjacency matrix representing the connection relationship between the multiple target nodes based on the initial relationship graph.
[0014] An aggregation module is used to perform feature transfer and feature aggregation among the multiple target nodes based on the initial adjacency matrix and the node feature matrix using the target model, to obtain the intermediate features of each target node.
[0015] The mapping module is used to map the intermediate features to the latent space for each target node to obtain the corresponding distribution parameters; wherein, the latent space is used to map the local dependencies between each target node and its neighboring nodes, as well as the global dependencies of each target node in the initial relation graph;
[0016] The sampling module is used to randomly sample the Gaussian distribution corresponding to the distribution parameters of each target node to obtain the potential representation vector corresponding to each target node, and generate the potential representation matrix corresponding to the initial relation graph based on multiple potential representation vectors;
[0017] The prediction module is used to predict the connection probability between any two target nodes based on the latent representation matrix, and to obtain the target adjacency matrix based on multiple connection probabilities.
[0018] The reconstruction module is used to reconstruct the initial relation graph based on the node feature matrix and the target adjacency matrix using the target model, thereby obtaining the target relation graph.
[0019] In some embodiments, the relational graph reconstruction apparatus further includes a training module for:
[0020] Obtain a pre-constructed sample relationship graph, and generate a sample node feature matrix corresponding to multiple sample nodes and a first adjacency matrix representing the connection relationship between the multiple sample nodes based on the sample relationship graph.
[0021] By using a preset model, feature transfer and feature aggregation are performed between the multiple sample nodes based on the first adjacency matrix and the sample node feature matrix to obtain the intermediate features of each sample node.
[0022] For each sample node, the intermediate features of the sample are mapped to the latent space to obtain the corresponding sample distribution parameters; wherein, the latent space is used to map the local dependencies between each sample node and its neighboring sample nodes, as well as the global dependencies of each sample node in the sample relationship graph;
[0023] Randomly sample the Gaussian distribution corresponding to the sample distribution parameters of each sample node to obtain the sample latent representation vector corresponding to each sample node, and generate the sample latent representation matrix corresponding to the sample relationship graph based on multiple sample latent representation vectors;
[0024] Based on the latent representation matrix of the samples, the sample connection probability of any two sample nodes is predicted, and a second adjacency matrix is obtained based on multiple sample connection probabilities.
[0025] Based on the consistency between the first adjacency matrix and the second adjacency matrix, the reconstruction terms of the preset model are determined;
[0026] Obtain a preset prior distribution, and determine the regularization term of the preset model based on the difference between the sample Gaussian distribution and the prior distribution;
[0027] The parameters of the preset model are adjusted by maximizing the lower bound of evidence constructed by the reconstruction term and the regularization error to obtain the target model.
[0028] In some implementations, the training module is further configured to:
[0029] Based on the first adjacency matrix, determine the sample node relationship between any two sample nodes;
[0030] In the second adjacency matrix, the corresponding edge prediction probability is determined based on the relationship between any two sample nodes.
[0031] Based on the consistency between the sample node relationships and the edge prediction probabilities, the corresponding log-likelihood loss is determined;
[0032] Based on the multiple log-likelihood losses corresponding to the sample relationship graph, the reconstruction terms of the preset model are constructed.
[0033] In some implementations, the training module is further configured to:
[0034] For each sample node, calculate the divergence value between the sample Gaussian distribution and the prior distribution;
[0035] The regularization term of the preset model is constructed based on multiple divergence values corresponding to multiple sample nodes.
[0036] In some implementations, the reconstruction of the relationship graph further includes a setting module for:
[0037] Obtain multiple graph convolutional layers of the preset model;
[0038] Multiple preset attention mechanisms are obtained, and different graph attention mechanisms are set in each graph convolutional layer; wherein, message passing is performed between any adjacent graph convolutional layers through residual connections, and the different graph attention mechanisms include microscale mechanism, mesoscale mechanism, macroscale mechanism, dynamic scale mechanism and multi-relation scale mechanism.
[0039] In some implementations, the aggregation module is further configured to:
[0040] Through each graph convolutional layer of the target model, features are passed to the neighboring nodes of each target node according to the initial adjacency matrix and the node feature matrix to obtain the adjacent aggregated features;
[0041] The adjacent aggregated features and corresponding node features of each target node are aggregated to obtain the intermediate features of each target node.
[0042] In some implementations, the prediction module is further configured to:
[0043] Based on the latent representation matrix, determine the inner product value of the latent representation vectors of any two target nodes;
[0044] The connection probability of any two target nodes is obtained by processing the inner product value of the latent representation vectors of any two target nodes through an activation function.
[0045] The target adjacency matrix is obtained based on the connection probabilities between multiple target nodes.
[0046] Accordingly, a third aspect of the present application provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the relationship graph reconstruction method of any one of the embodiments of the first aspect of the present application.
[0047] Accordingly, a fourth aspect of the embodiments of this application proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method for reconstructing a relational graph according to any one of the embodiments of the first aspect of this application.
[0048] This application embodiment obtains a pre-constructed initial relationship graph and generates node feature matrices corresponding to multiple target nodes and an initial adjacency matrix representing the connection relationships between multiple target nodes based on the initial relationship graph. Through a target model, feature transfer and feature aggregation are performed between multiple target nodes based on the initial adjacency matrix and the node feature matrix to obtain intermediate features for each target node. For each target node, the intermediate features are mapped to a latent space to obtain corresponding distribution parameters. The latent space is used to map the local dependencies between each target node and its neighboring nodes, as well as the global dependencies of each target node in the initial relationship graph. Random sampling is performed on the Gaussian distribution corresponding to the distribution parameters of each target node to obtain a latent representation vector for each target node, and a latent representation matrix corresponding to the initial relationship graph is generated based on multiple latent representation vectors. Based on the latent representation matrix, the connection probability between any two target nodes is predicted, and a target adjacency matrix is obtained based on multiple connection probabilities. Through a target model, the initial relationship graph is reconstructed based on the node feature matrix and the target adjacency matrix to obtain the target relationship graph. This approach enhances the representational power of target nodes through feature propagation, enabling each target node to more accurately reflect its dependencies on other target nodes in subsequent steps. Simultaneously, mapping the intermediate features of target nodes to the latent space allows the representation of the relational graph to move beyond explicit connections (adjacency matrices) and capture deeper implicit relationships—local and global dependencies of target nodes. This ensures the repaired graph structure maintains global consistency and avoids unnatural connections. Furthermore, by sampling latent representations from the latent space, the model can infer implicit dependencies between nodes, generating a more natural, coherent, and accurate graph structure. In summary, this application improves the global consistency and accuracy of the reconstructed relational graph. Attached Figure Description
[0049] Figure 1 is a schematic diagram of the architecture of the relationship graph reconstruction system provided in an embodiment of this application;
[0050] Figure 2 is a flowchart of the relationship graph reconstruction method provided in the embodiments of this application;
[0051] Figure 3 is a general flowchart of the relationship graph reconstruction method provided in the embodiments of this application;
[0052] Figure 4 is a schematic diagram of the functional modules of the relational graph reconstruction device provided in an embodiment of this application;
[0053] Figure 5 is a schematic diagram of the hardware structure of the computer device provided in an embodiment of this application. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0055] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0057] A relationship graph is a graphical data structure used to represent complex relationships between entities, describing entities and their connections through nodes and edges. It is widely used in social network analysis, gene regulatory networks, recommender systems, and other scenarios. However, due to incomplete data collection, noise interference, or storage limitations, relationship graphs often suffer from missing or corrupted data. Therefore, to significantly improve the completeness and usability of knowledge graphs, it is necessary to reconstruct relationship graphs.
[0058] In related technologies, the reconstruction of a relation graph typically involves extracting feature representations of nodes from the missing graph, calculating the similarity between nodes based on these features, predicting missing edges based on the similarity scores, and then adding these edges back to the graph. However, while this reconstruction method is simple and easy to implement, it is only suitable for cases with sparse data or simple graph structures. In cases with complex graph structures and implicit relationships between nodes, this method often ignores the global structural information of the graph, resulting in a lack of global consistency and accuracy in the repaired graph.
[0059] Based on this, embodiments of this application provide a method, apparatus, computer device, and readable storage medium for reconstructing a relational graph, which can improve the global consistency and accuracy of the reconstructed relational graph.
[0060] The relationship graph reconstruction method, apparatus, computer equipment, and readable storage medium provided in this application are specifically described through the following embodiments. First, the relationship graph reconstruction system in this application is described.
[0061] Referring to Figure 1, in some embodiments, this application provides a relational graph reconstruction system, including a terminal 11 and a server 12.
[0062] For example, terminal 11 can be a personal computer, laptop, high-performance workstation, mobile device, etc. The terminal can be responsible for collecting raw data (such as social network data, genetic data, etc.), preprocessing it, and converting it into an initial relational graph. Terminal 11 can send the node feature matrix and adjacency matrix corresponding to the initial relational graph to server 12, and receive and display the reconstructed relational graph returned by server 12.
[0063] Furthermore, the server 12 can be a high-performance server, a distributed computing cluster, a storage device, etc. The server 12 can receive data uploaded by the terminal 11, load or train a model based on variational graph networks according to user needs, use the model to reconstruct the graph data, obtain the reconstructed relational graph, and send the relational graph to the terminal 11.
[0064] Furthermore, the terminal 11 and the server 12 can interact with each other via network communication to ensure the efficiency of the entire map reconstruction process and the user experience.
[0065] The reconstruction method of the relational graph in the embodiments of this application can be illustrated by the following examples.
[0066] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent will be obtained first. Furthermore, the collection, use, and processing of this data will comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user will be obtained through pop-ups or redirects to confirmation pages. Only after obtaining the user's separate permission or consent will the necessary user-related data for the normal operation of the embodiments of this application be obtained.
[0067] In this embodiment, the description will focus on the reconstruction device of the relationship graph, which can be integrated into a computer device. Referring to Figure 2, which is a flowchart of the steps of the relationship graph reconstruction method provided in this embodiment, this embodiment takes the integration of the relationship graph reconstruction device into a terminal or server as an example. When the processor on the terminal or server executes the program instructions corresponding to the relationship graph reconstruction method, the specific process is as follows:
[0068] Step 101: Obtain the pre-constructed initial relationship graph, and generate node feature matrices corresponding to multiple target nodes and an initial adjacency matrix representing the connection relationship between multiple target nodes based on the initial relationship graph.
[0069] In some implementations, in order to enable the model to learn useful patterns and information from graph data more accurately, mathematical representations of node feature matrices and adjacency matrices can be established based on the initial relational graph, providing normalized input to the model.
[0070] The initial relational graph can be a topological network consisting of entities (target nodes) and the edges (connections) between these entities. The initial relational graph can be represented by G = (V, E), where V represents an entity and E represents the edge between entities.
[0071] In this context, target nodes can be a subset of entity nodes in the initial relation graph that are to be used for relation inference or structural repair. For example, in the initial relation graph corresponding to a social network, target nodes can represent users; in the initial relation graph corresponding to a gene regulation network, target nodes can represent genes.
[0072] The node feature matrix can be a two-dimensional matrix, where each row represents the feature vector of an entity (i.e., a target node), and the columns represent different feature dimensions. For example, if there are N target nodes in the initial relation graph, and each target node has D-dimensional features, then the size of the node feature matrix X is N×D.
[0073] The initial adjacency matrix can be a matrix used to represent the connection relationships between target nodes in the initial relation graph. For an initial relation graph with n target nodes, its initial adjacency matrix A is an n×n matrix, where A ij This represents the connection relationship between target node i and target node j.
[0074] In some implementations, the node features corresponding to all target nodes can be normalized, and a node feature matrix can be generated based on the normalized data; or, after generating the node feature matrix, the node feature matrix can be normalized to obtain a processed node feature matrix, ensuring that the numerical ranges between different feature dimensions are relatively consistent. For example, the normalization method can be Min-Max normalization, Z-Score standardization, maximum value normalization, etc., and the specific normalization method can be determined according to the actual situation.
[0075] For example, adjacency matrices can be symmetric (suitable for undirected graphs) or asymmetric (suitable for directed graphs). Connections between target nodes can be determined in various ways. For instance, connections can be constructed by calculating the similarity between node features (such as cosine similarity, Euclidean distance, etc.). If the feature similarity between two nodes is higher than a similarity threshold, then there is a connection between the corresponding target nodes. Alternatively, connections can be determined by setting a distance threshold; for example, if the distance between two target nodes is less than a preset distance threshold, then there is a connection between them. Or, if prior knowledge or external data sources provide interaction or connection information between nodes, this information can be directly used to construct the adjacency matrix. For example, in social networks, friendships or partnerships can be directly used as connections between target nodes.
[0076] Furthermore, since most target nodes are not directly connected, the initial adjacency matrix is usually sparse. Therefore, we can retain only the important or strong connections between target nodes and sparsely represent the initial adjacency matrix to avoid storing zero-value elements and improve computational efficiency.
[0077] In some implementations, to improve the stability of feature propagation, maintain consistent feature scales, and avoid degree deviation, the initial adjacency matrix can be normalized to improve the performance of the target model. For example, symmetric normalization (also known as Laplacian normalization) or degree normalization can be used to process the initial adjacency matrix. Taking symmetric normalization as an example, the normalization formula is as follows:
[0078] Where A is the initial adjacency matrix before normalization. Let I be the initial adjacency matrix after normalization using the degree matrix D, and let I be the identity matrix with the same dimensions as the initial adjacency matrix.
[0079] In some implementations, target nodes typically possess additional prior information (such as category labels, external relationships, etc.) or supplementary information about the initial relationship graph (such as the community structure of the initial relationship graph, known functional modules, etc.). This additional information can be processed to improve the accuracy of subsequent relationship graph reconstruction.
[0080] For example, for the category label information of target nodes (e.g., user occupation categories in social networks, gene function categories in gene networks), a one-hot encoding or embedding vector of the category label can be added to the original feature vector for each target node. This expands the dimension of the node feature matrix to the original feature dimension plus the dimension of the category label. This allows the model to better capture the semantic information of the target nodes and thus more accurately infer the relationships between them. Furthermore, if external data sources exist (e.g., user interaction records in social networks, protein-protein interaction databases in gene networks), the external relationship strength between each target node and other nodes can be calculated, and these relationship strengths can be added as node features to the node feature matrix to help the model reconstruct the graph structure more accurately.
[0081] Furthermore, if the community structure in the initial relational graph is known (e.g., a circle of friends in a social network, a functional module in a gene network, etc.), additional connection weights can be added to each target node within a community to represent the probability that it belongs to the same community, in order to provide additional local connection clues and help the model reconstruct the graph structure more accurately.
[0082] Furthermore, if the functional modules in the initial relational graph are known (e.g., metabolic pathways in a gene network, interest groups in a social network), additional connection weights can be added to the target nodes within each functional module to represent the probability that they belong to the same functional module. In this way, the adjacency matrix contains not only the original connection information but also functional module information, helping the model to reconstruct the graph structure more accurately.
[0083] By obtaining the node feature matrix and initial adjacency matrix of the initial relation graph, we can clearly characterize each target node and the connection relationship between target nodes, which makes it easier for subsequent models to learn useful patterns and information from graph data more accurately.
[0084] Step 102: Using the target model, feature transfer and feature aggregation are performed between multiple target nodes based on the initial adjacency matrix and node feature matrix to obtain the intermediate features of each target node.
[0085] In some implementations, in order to provide high-quality node representations for subsequent graph data repair and resolution enhancement, multi-layer stacking of graph convolutional networks can be used to achieve cross-layer propagation and dynamic aggregation of node features, so as to capture local neighborhood structure and global topological dependencies, and provide information-complete node embeddings for potential spatial mapping.
[0086] The target model can be a pre-trained deep learning model, specifically a deep learning model that combines Graph Neural Networks (GNNs) and Variational Autoencoders (VAEs). The target model can be obtained by adjusting the parameters of the preset model after maximizing the lower bound of evidence constructed from the reconstruction error and regularization error.
[0087] Among them, intermediate features can be the updated feature representations obtained by each target node after feature transfer and feature aggregation in the target model. The intermediate features corresponding to each target node not only contain the original feature information of the target node itself, but also integrate the feature information of its neighboring nodes, reflecting the local and global context information of the target node in the initial relation graph.
[0088] For example, the target model can be a Variational Graph Autoencoder (VGAE), comprising an encoder and a decoder. Specifically, the VGAE encoder can consist of multiple graph convolutional layers for processing graph structure data and node features. Each graph convolutional layer captures the local connectivity patterns of the target nodes in the initial relation graph and integrates information from neighboring nodes through an information propagation mechanism. At the end of the encoder, the VGAE can use variational inference to learn the distribution parameters of the latent representations of the nodes to output the latent representations. Furthermore, the target adjacency matrix of the initial relation graph can be reconstructed using the decoder of the target model.
[0089] In some implementations, corresponding connection weights can be assigned to edges between any connected target nodes. If target node i and target node j are directly connected (i.e., A...), then... ij If the node features of node j are not equal to 0, then the node features of node j can be transmitted to the target node i. When there is a connection weight between the target node i and the target node j, the strength of feature transmission can be determined according to the connection weight. The larger the connection weight, the more significant the impact of feature transmission.
[0090] Furthermore, after feature propagation, each target node receives multiple feature vectors from its neighboring nodes. These multiple feature vectors are then integrated into a single vector through feature aggregation, yielding the intermediate feature representation of the target node. For example, the aggregation function used during feature aggregation can be summation, averaging, maximum maximization, etc.
[0091] The above methods can effectively integrate the target node and its neighbor information, enhance the target model's ability to understand and analyze graph data, and facilitate the full learning of the potential features of the relation graph.
[0092] In some implementations, to enhance the target model's ability to understand and model graph-structured data, feature transfer and aggregation can be performed on each target node to improve the accuracy and efficiency of graph data analysis. Step 102 may include:
[0093] (102.1) Through each graph convolutional layer of the target model, feature transfer is performed on the neighboring nodes of each target node according to the initial adjacency matrix and node feature matrix to obtain the neighbor aggregation feature;
[0094] (102.2) Aggregate the adjacent aggregated features and the corresponding node features of each target node to obtain the intermediate features of each target node.
[0095] Graph convolutional layers are a core component in the target model for processing graph data. Each graph convolutional layer processes the input node feature matrix and initial adjacency matrix, using adjacency relationships to pass information from neighboring nodes to each target node, and updating the node features of the corresponding target node accordingly. Multiple graph convolutional layers can be stacked to achieve deeper feature extraction and more complex dependency modeling.
[0096] The adjacent aggregation feature can be the node features obtained after the feature propagation process in each graph convolutional layer. Specifically, in a graph convolutional layer, each target node receives information from its direct neighboring nodes and aggregates it with its own node features to finally generate an intermediate feature containing information about neighboring nodes.
[0097] Among them, node features can be the original attributes or feature vectors of each target node, used to describe the intrinsic attributes or states of the corresponding target node.
[0098] For example, in each graph convolutional layer, feature propagation can be performed for each target node, and each target node i will receive node features from all its neighboring nodes j. Specifically, for each target node i, the neighbor aggregation features of its neighboring nodes can be calculated using the following formula.
[0099] Where N(i) represents the set of neighboring nodes of target node i, and d i d is the degree of the target node i (i.e., the number of its neighboring nodes). jIt is the degree of the target node j (this is for the case where the initial adjacency matrix was not normalized before; if it has been normalized, the normalized value can be used for calculation). W is the node feature of target node j at layer l. (l) σ is the weight matrix of the l-th layer, and σ is the activation function.
[0100] Furthermore, the adjacent aggregate features of each target node can be... and its own node characteristics Aggregation is performed to generate intermediate features for each target node. For example, the intermediate features for each target node can be calculated using the following formula.
[0101] Where N(i) represents the set of neighboring nodes of the target node i; It is the adjacent aggregated feature of target node j in the l-th graph convolutional layer. σ is the node feature of target node i in layer l, and σ is the activation function.
[0102] In some implementations, different aggregation labels can be assigned to different characteristics of different target nodes, and corresponding aggregation strategies can be determined based on the aggregation labels. For example, taking an initial relationship graph as a social network graph, each user corresponds to a target node. For highly active users, the aggregation label can use a weighted average aggregation method, where the weights are determined by the interaction frequency between the user (target node) and their friends (neighboring nodes), emphasizing the influence of their main friends. For newly registered users (target nodes), the aggregation label can use a max-pooling aggregation method for feature transfer, highlighting the influence of their most influential few friends (neighboring nodes). In this way, targeted feature transfer and aggregation strategies can reduce unnecessary computation and improve the computational efficiency of the model.
[0103] Through the above methods, the target model can effectively integrate the information of the target node and its neighboring nodes to generate new node feature representations, thereby better capturing the complex relationships in the graph structure, which is of great significance for accurately reconstructing the relationship graph.
[0104] Step 103: For each target node, map the intermediate features to the latent space to obtain the corresponding distribution parameters; wherein, the latent space is used to map the local dependencies between each target node and its neighboring nodes, as well as the global dependencies of each target node in the initial relation graph.
[0105] In some implementations, in order to efficiently and accurately process and analyze complex relationship graphs, intermediate features can be mapped to a latent space and their distribution parameters can be learned to capture local and global dependencies between target nodes, enabling the target model to handle different types of relationship graphs more flexibly.
[0106] The latent space can be a low-dimensional continuous vector space used to encode the latent semantic information of the initial relation graph (target nodes and edges), that is, to capture the dependencies between target nodes. The latent space is used by an encoder (graph convolutional network) to map the intermediate features of each target node to parameters (mean and log-variance) of a Gaussian distribution, thereby generating a latent representation of the target node.
[0107] The distribution parameters can be parameters that describe the probability distribution of latent representation vectors in the latent space. For example, the distribution parameters can include the mean (used to represent the central position of the latent representation vector of the target node, reflecting its typical semantics in the latent space) and the log-variance (describes the degree of dispersion of the latent representation vector, used to control the randomness of the generation process).
[0108] Local dependencies can be the interaction relationships between each target node and its direct neighbor nodes, which helps the target model learn the local context of the target node, thereby better capturing fine-grained patterns in the graph.
[0109] Among them, global dependencies can be the global structural features of each target node in the entire initial relation graph.
[0110] Specifically, the encoder of the target model maps intermediate features to a probability distribution (e.g., a Gaussian distribution), whose parameters (mean and log-variance) describe the points in the latent space. Taking a social network graph as an example, if the intermediate features corresponding to target node 1 are as follows:
[0111] For target node 1, the encoder learns the distribution parameters of its latent representation as: mean μ i = [0.5, 0.2], logarithmic variance It should be noted that the specific value of the logarithmic variance can be automatically learned through the model training process, thereby better capturing the uncertainty of the data.
[0112] By acquiring the distribution parameters of each target node, the target model can learn effective latent representations. This process not only captures the local and global dependencies between nodes, but also enables the target model to learn from graph data without labels. This is particularly important for processing large-scale, unlabeled graph data, and can significantly improve the effectiveness of graph data restoration and resolution enhancement.
[0113] Step 104: Randomly sample the Gaussian distribution corresponding to the distribution parameters of each target node to obtain the latent representation vector corresponding to each target node, and generate the latent representation matrix corresponding to the initial relational graph based on multiple latent representation vectors.
[0114] In some implementations, in order to achieve efficient repair and resolution enhancement of graph data, the potential representation vector corresponding to each target node can be obtained by randomly sampling from the Gaussian distribution corresponding to the distribution parameters of each target node, so as to provide strong support for subsequent graph analysis tasks.
[0115] Among them, the Gaussian distribution can be a continuous probability distribution model used to describe the probability distribution of the potential representation vector of each target node.
[0116] The latent representation vector can be a value randomly sampled from a Gaussian distribution, representing the specific location of each target node in the latent space, that is, representing the specific latent representation of each target node. By randomly sampling the Gaussian distribution to obtain the latent representation vector, a certain degree of randomness can be introduced, allowing the target model to explore a wider solution space and avoid getting trapped in local optima.
[0117] The latent representation matrix can be a set of latent representation vectors of all target nodes, with each row corresponding to the latent representation vector of a target node and each column representing a dimension of the latent space.
[0118] For example, the mean μ learned by the target model i Sum of logarithmic variance The standard deviation can be calculated. Then, the corresponding Gaussian distribution is determined based on the mean and standard deviation. And obtain the latent representation vector z by randomly sampling from the Gaussian distribution. i Furthermore, based on the multiple latent representation vectors corresponding to multiple target nodes, a latent representation matrix is generated to introduce necessary randomness, enabling the target model to capture the uncertainty in the data. For example, if the initial relational graph includes 3 target nodes (A, B, C), the target model learns the mean and log-variance for each target node: Node A: μ A =[0.1,0.2], Node B: Node C: Next, random sampling is performed on the Gaussian distribution of each target node to obtain the latent representation vector of each target node: the latent representation vector of node A: z A = [0.12, 0.18], the latent representation vector of node B: z B= [0.31, 0.42], the latent representation vector of node C: z C = [0.49, 0.61]. Therefore, the latent representation matrix H corresponding to this initial relational graph is:
[0119] In some implementations, importance sampling can be performed on the Gaussian distribution corresponding to the distribution parameters of each target node to obtain the latent representation vector corresponding to each target node. Specifically, based on the characteristics of the initial relationship graph, target sampling regions in the latent space that require denser sampling can be selected. For example, if there are target nodes with higher probability density in a specific region (i.e., probability density greater than a preset probability threshold), denser sampling is introduced in the high probability density region, and multiple sampling points obtained from the Gaussian distribution are weighted (the weight can be proportional to the probability density) to obtain the latent representation vector corresponding to each target node. The latent representation matrix corresponding to the initial relationship graph is then generated based on the multiple latent representation vectors corresponding to multiple target nodes.
[0120] In some implementations, hierarchical sampling can be performed on the Gaussian distribution corresponding to the distribution parameters of each target node to obtain the latent representation vector for each target node. For example, the sampling process of the latent representation vector can be divided into global and local levels, with different distribution parameters defined for the global and local levels of each target node. The global level is used to capture the global structure of each target node in the initial relation graph, and the local level is used to capture the local structure of each target node in the initial relation graph. For example, the global latent representation vector can be obtained by sampling from the global Gaussian distribution corresponding to the global level. In the local Gaussian distribution corresponding to the local level, the local latent representation vector is obtained by sampling. Furthermore, the global latent representation vector and the local latent representation vector can be weighted and combined (for example, the global latent representation vector has a weight of 0.6, and the local latent representation vector has a weight of 0.4, etc.) to obtain the latent representation vector of each target node, and the latent representation matrix corresponding to the initial relation graph can be generated based on the multiple latent representation vectors corresponding to multiple target nodes.
[0121] By generating the latent representation matrix corresponding to the initial relational graph, not only can randomness be introduced to help the target model explore a wider solution space and avoid local optima, but also the uncertainty in the data can be captured, improving the adaptability and generalization ability of the target model to complex graph structure data, enabling the model to more accurately infer and reconstruct the complex relationships between nodes in the graph.
[0122] Step 105: Based on the latent representation matrix, predict the connection probability between any two target nodes, and obtain the target adjacency matrix based on multiple connection probabilities.
[0123] In some implementations, to recover missing or damaged graph structures, the latent representation matrix can be decoded to predict the connection probability between any two target nodes and a new target adjacency matrix can be reconstructed, so that the target model can generate a more coherent and natural graph structure.
[0124] The connection probability can be the likelihood that there is an edge (i.e., a connection) between two target nodes in the initial relationship graph predicted by the target model. In other words, it is used to reflect the strength of the relationship between any two target nodes or the confidence that a connection exists.
[0125] The target adjacency matrix can be a matrix representing the connection relationship between any two target nodes in the initial relation graph, with a size of N×N, where N is the number of target nodes in the initial relation graph.
[0126] For example, taking the initial relationship graph as a social network graph, it contains 5 target nodes, each of which has a latent representation vector. The latent representation matrix Z is represented as follows: Z = [z1, z2, z3, z4, z5];
[0127] Among them, z i It is the latent representation vector of the target node i.
[0128] Furthermore, for each pair of target nodes (i, j), the target model can calculate the inner product between the latent representation vectors of any two target nodes based on the latent representation vector of each target node in the latent representation matrix, and convert it into specific connection probabilities using the Sigmoid activation function. Then, a target adjacency matrix can be generated based on the connection probabilities between multiple target nodes.
[0129] By generating a target adjacency matrix, the resolution and detail of the graph can be enhanced, the quality and usability of the graph data can be improved, and it is easier to repair missing or damaged graph structures in the future.
[0130] In some implementations, to infer the connectivity between target nodes from the latent space, a target adjacency matrix can be obtained based on the latent representation matrix to improve the accuracy of graph representation and the effectiveness of graph analysis tasks. For example, step 105 may include:
[0131] (105.1) Based on the latent representation matrix, determine the inner product value of the latent representation vectors of any two target nodes;
[0132] (105.2) The connection probability of any two target nodes is obtained by processing the inner product of the latent representation vectors of any two target nodes through the activation function;
[0133] (105.3) Based on the connection probabilities between multiple target nodes, the target adjacency matrix is obtained.
[0134] The inner product can be a dot product operation between two latent representation vectors, used to calculate the similarity or correlation between the latent representation vectors of any two target nodes.
[0135] For example, for any two target nodes i and j, the inner product of their latent representation vectors is calculated as Z. i ·Z j Z i Z is the latent representation vector of target node i. j Let be the latent representation vector of target node j. The strength of the association between nodes can be quantified by calculating the inner product between any two target nodes.
[0136] Understandably, since directly using the inner product value as the connection probability might cause the probability to exceed the range [0,1], it is necessary to use an activation function (such as the Sigmoid function) to map the inner product value to the [0,1] interval to obtain the connection probability pij between nodes. The formula for this process is as follows:
[0137] Where σ is the Sigmoid function.
[0138] Furthermore, once the connection probabilities between all node pairs in the initial relational graph are calculated, a target adjacency matrix can be constructed based on these probabilities. Each element of the target adjacency matrix represents the probability that an edge exists between the corresponding node pairs. Each connection probability can be compared with a probability threshold; connections greater than the threshold are assigned a value of 1, and those less than the threshold are assigned a value of 0, thus visually representing the connection relationships between the target nodes and obtaining the final reconstructed target adjacency matrix.
[0139] By constructing a target adjacency matrix, a reliable foundation can be provided for tasks such as relation graph reconstruction, node classification, and connection prediction, significantly improving the accuracy and efficiency of relation graph reconstruction.
[0140] Step 106: Using the target model, the initial relation graph is reconstructed based on the node feature matrix and the target adjacency matrix to obtain the target relation graph.
[0141] In some implementations, in order to provide higher quality graph data, the initial relation graph can be reconstructed based on the node feature matrix and the target adjacency matrix to predict the originally missing or damaged connections, or to remove spurious connections, thereby making the repaired relation graph clearer and more accurate.
[0142] Among them, the target relation graph can be obtained by reconstructing the graph structure from the initial relation graph through the target model.
[0143] For example, taking a social network graph, target nodes represent users, and edges represent friendship relationships (connections) between users. The initial relationship graph may contain some missing connections (e.g., user A and user B are actually friends, but this isn't recorded in the initial graph). After updating the target model to obtain the target adjacency matrix, the model can predict the friendship relationship between user A and user B based on the target adjacency matrix (the element representing the connection between user A and user B in the target adjacency matrix is 1), and add this edge to the reconstructed target relationship graph.
[0144] This application embodiment obtains a pre-constructed initial relationship graph and generates node feature matrices corresponding to multiple target nodes and an initial adjacency matrix representing the connection relationships between multiple target nodes based on the initial relationship graph. Through a target model, feature transfer and feature aggregation are performed between multiple target nodes based on the initial adjacency matrix and the node feature matrix to obtain intermediate features for each target node. For each target node, the intermediate features are mapped to a latent space to obtain corresponding distribution parameters. The latent space is used to map the local dependencies between each target node and its neighboring nodes, as well as the global dependencies of each target node in the initial relationship graph. Random sampling is performed on the Gaussian distribution corresponding to the distribution parameters of each target node to obtain a latent representation vector for each target node, and a latent representation matrix corresponding to the initial relationship graph is generated based on multiple latent representation vectors. Based on the latent representation matrix, the connection probability between any two target nodes is predicted, and a target adjacency matrix is obtained based on multiple connection probabilities. Through a target model, the initial relationship graph is reconstructed based on the node feature matrix and the target adjacency matrix to obtain the target relationship graph. This approach enhances the representational power of target nodes through feature propagation, enabling each target node to more accurately reflect its dependencies on other target nodes in subsequent steps. Simultaneously, mapping the intermediate features of target nodes to the latent space allows the representation of the relational graph to move beyond explicit connections (adjacency matrices) and capture deeper implicit relationships—local and global dependencies of target nodes. This ensures the repaired graph structure maintains global consistency and avoids unnatural connections. Furthermore, by sampling latent representations from the latent space, the model can infer implicit dependencies between nodes, generating a more natural, coherent, and accurate graph structure. In summary, this application improves the global consistency and accuracy of the reconstructed relational graph.
[0145] In some implementations, to enable the model to learn from data and improve its performance on reconstruction tasks facing various types of relationship graphs, a pre-defined model can be trained to capture complex relationships and dependencies between nodes. For example, the target model can be trained in the following ways:
[0146] (A.1) Obtain the pre-constructed sample relationship graph, and generate sample node feature matrices corresponding to multiple sample nodes and a first adjacency matrix representing the connection relationship between multiple sample nodes based on the sample relationship graph.
[0147] (A.2) Using a preset model, feature transfer and feature aggregation are performed between multiple sample nodes based on the first adjacency matrix and the sample node feature matrix to obtain the intermediate features of each sample node.
[0148] (A.3) For each sample node, the intermediate features of the sample are mapped to the latent space to obtain the corresponding sample distribution parameters; wherein, the latent space is used to map the local dependencies between each sample node and its neighboring sample nodes, as well as the global dependencies of each sample node in the sample relationship graph.
[0149] (A.4) Randomly sample the Gaussian distribution corresponding to the sample distribution parameters of each sample node to obtain the sample latent representation vector corresponding to each sample node, and generate the sample latent representation matrix corresponding to the sample relationship graph based on multiple sample latent representation vectors;
[0150] (A.5) Based on the latent representation matrix of the samples, predict the sample connection probability of any two sample nodes, and obtain the second adjacency matrix based on multiple sample connection probabilities;
[0151] (A.6) Based on the consistency between the first adjacency matrix and the second adjacency matrix, determine the reconstruction terms of the preset model;
[0152] (A.7) Obtain the preset prior distribution, and determine the regularization term of the preset model based on the difference between the sample Gaussian distribution and the prior distribution;
[0153] (A.8) The parameters of the preset model are adjusted by maximizing the lower bound of evidence constructed by the reconstruction term and the regularization error to obtain the target model.
[0154] Among them, the sample relationship graph can be a relationship graph extracted from actual data for training the model, containing multiple sample nodes and their connection relationships. The sample relationship graph is the object of the pre-set model reconstruction.
[0155] Among them, sample nodes can be a subset of entity nodes in the sample relationship graph that need to be inferred about relationships or repaired in structure.
[0156] The sample node feature matrix can be a two-dimensional matrix, where each row corresponds to the feature vector of a sample node, and the columns represent different feature dimensions, which describe the specific attributes or behaviors of each sample node.
[0157] The first adjacency matrix can be a matrix used to represent the connection relationships between sample nodes in the sample relationship graph.
[0158] The preset model can be a deep learning model to be trained, specifically a deep learning model that combines graph neural networks (GNN) and variational autoencoders (VAE). Training the preset model can continuously improve the accuracy of the second adjacency matrix generated by the model, and the model parameters can be adjusted in the process to obtain the target model.
[0159] Among them, the intermediate features of the samples can be the updated feature representation obtained by each sample node after feature transfer and feature aggregation in the preset model. The intermediate features of each sample node not only contain the original feature information of the sample node itself, but also integrate the feature information of its neighboring nodes, reflecting the local and global context information of the sample node in the sample relationship graph.
[0160] The latent space can be a low-dimensional hidden representation space used to map the local and global dependencies of sample nodes. In the latent space, the node features of sample nodes are compressed into latent representation vectors to better capture the complex patterns between sample nodes.
[0161] The sample distribution parameters can be the distribution parameters (mean and log-variance) of each sample node in the latent space, which define the Gaussian distribution of the sample corresponding to that sample node.
[0162] Local dependencies can refer to the interactions and dependencies between each sample node and its direct neighbors.
[0163] Global dependencies can refer to the overall dependencies between all sample nodes in the entire sample relationship graph. Global dependencies help to capture the overall structure and pattern of the sample relationship graph.
[0164] The latent representation vector of a sample can be a value randomly sampled from the Gaussian distribution of the sample distribution parameters, representing the specific location of each sample node in the latent space.
[0165] The latent representation matrix of a sample can be a matrix composed of the latent representation vectors of all sample nodes, used to represent the overall structure of the sample relationship graph in the latent space.
[0166] The sample connection probability can be the probability that there is an edge between any two sample nodes, which is calculated based on the sample latent representation matrix. The sample connection probability can be calculated using the inner product and the Sigmoid function.
[0167] The second adjacency matrix can be a predicted adjacency matrix generated based on the sample connection probability, representing the reconstructed graph structure.
[0168] The reconstruction term measures the consistency between the first and second adjacency matrices, reflecting the model's ability to reconstruct the graph structure. Furthermore, the reconstruction term can be obtained by minimizing the reconstruction error. It measures the probabilistic matching degree of reconstructing the second adjacency matrix using the sample latent representation matrix. In other words, the reconstruction term evaluates the similarity between the second adjacency matrix reconstructed by the pre-defined model and the actually observed first adjacency matrix, given the sample latent representation matrix, thereby reducing the gap between the reconstructed sample target relation graph and the sample relation graph.
[0169] The regularization term measures the difference between the sample Gaussian distribution and the prior distribution, ensuring that the distribution of the latent representation vector does not deviate too far from the prior distribution. The regularization term can be obtained by minimizing the divergence value.
[0170] The lower bound of evidence can be constructed using reconstruction and regularization terms. It is used to maximize the likelihood estimation of the edge relationships in the graph while minimizing the difference between the distribution of the sample latent representation vector and the prior distribution.
[0171] In some implementations, the process of generating a sample node feature matrix and a first adjacency matrix from the sample relationship graph and updating it to obtain a second adjacency matrix corresponding to the first adjacency matrix is the same as the process of generating a node feature matrix and an initial adjacency matrix from the initial relationship graph and updating it to obtain a target adjacency matrix corresponding to the initial adjacency matrix, except for the difference in the data objects processed. This application embodiment will not elaborate on the process of obtaining the second adjacency matrix; for details, please refer to the aforementioned process of obtaining the target adjacency matrix.
[0172] In some implementations, to improve the computational efficiency and training speed of graph data modeling, the parameters of a pre-defined model can be adjusted by constructing a lower bound of evidence to obtain the target model. Specifically, the lower bound of evidence can be constructed based on a reconstruction term and a regularization term. Specifically, the reconstruction term can be determined based on the consistency between the first and second adjacency matrices, so that the latent representation vectors learned by the pre-defined model can reconstruct the structure of the original sample relation graph as accurately as possible. By maximizing the reconstruction term, the pre-defined model is encouraged to learn latent representations that better explain the original graph structure, helping the pre-defined model capture complex relationships and patterns in the sample relation graph, thereby achieving better performance in tasks such as graph reconstruction, node classification, and link prediction.
[0173] Furthermore, the regularization term can be determined by obtaining a predefined prior distribution and based on the difference between the sample Gaussian distribution and the prior distribution. In the predefined model, the prior distribution can be a standard Gaussian distribution. The regularization term ensures that the learned latent representation does not deviate too far from the prior distribution by minimizing the Kullback-Leibler divergence (KL divergence) between the latent distribution and the prior distribution. This effectively prevents overfitting in the predefined model and improves the model's generalization ability.
[0174] In some implementations, by maximizing the lower bound of evidence, the pre-defined model can achieve a balance between the learned latent representations and the reconstructed graph structure. For example, the formula for constructing the lower bound of evidence (ELBO) is as follows:
[0175] Where A is the first adjacency matrix, X is the sample node feature matrix, and H is the sample latent representation matrix.
[0176] In some implementations, by maximizing the lower bound of evidence, efficient adjustment of the parameters of a pre-defined model can be achieved in unsupervised learning. Training can be stopped when the pre-defined model has been trained a preset number of times (e.g., 500, 1000 times, the specific number can be set according to actual conditions), thus obtaining the target model. Alternatively, at the end of each training round, the current ELBO value is calculated. When the number of times the ELBO change is less than a preset threshold (e.g., 0.001) exceeds a preset number (e.g., 3 times), the model is considered to have converged, training is stopped, and the target model is obtained.
[0177] Training the pre-defined model using the above methods not only improves its ability to reconstruct the original relational graph but also ensures the quality of the latent representation, enabling the model to perform well in various graph data analysis tasks. Furthermore, by maximizing the lower bound of evidence, a self-supervised learning strategy can be utilized to train the model using the structural information of the graph (such as connectivity relationships) without the need for manually labeled graph data. This achieves the goal of learning latent representation vectors from unlabeled graph data, improving the model's training efficiency.
[0178] In some implementations, to make the predicted edge relationships as close as possible to the true adjacency matrix, a pre-defined model can be trained by constructing reconstruction terms and maximizing these terms. This allows the model to more accurately predict the connections between target nodes, enhancing its ability to predict graph structures. For example, (A.6) may include:
[0179] (A.6.1) Determine the sample node relationship between any two sample nodes based on the first adjacency matrix;
[0180] (A.6.2) In the second adjacency matrix, determine the corresponding edge prediction probability based on the sample node relationship between any two sample nodes;
[0181] (A.6.3) Based on the consistency between the sample node relationships and the edge prediction probabilities, determine the corresponding log-likelihood loss;
[0182] (A.6.4) Construct the reconstruction term of the preset model based on multiple log-likelihood losses corresponding to the sample relationship graph.
[0183] The sample node relationship can be any connection between two sample nodes. Specifically, the sample node relationship can be represented by the elements in the first adjacency matrix.
[0184] The edge prediction probability can be the probability that there is an edge between any two sample nodes in the second adjacency matrix. Specifically, the edge prediction probability can be calculated using the inner product and the Sigmoid function.
[0185] Log-likelihood loss can be considered a loss function that measures the consistency between the edge prediction probabilities of the model and the actual existence of edges. Specifically, log-likelihood loss calculates the log-likelihood estimate of the second adjacency matrix given the latent representation vector.
[0186] For example, A in the first adjacency matrix ij When the value is 1, it indicates that there is a connection between sample node i and sample node j; otherwise, it indicates that there is no connection.
[0187] In some implementations, for any two sample nodes i and j, the edge prediction probability P(A) of an edge between them can be calculated in the following way: ij =1|H i H j ):
[0188] Among them, A ij H represents the values in the first adjacency matrix, where σ is the activation function; i H represents the value of sample node i in the sample latent representation matrix. j This represents the value of sample node j in the sample latent representation matrix.
[0189] Furthermore, for any pair of sample nodes corresponding to two sample nodes, the value A in the first adjacency matrix can be used as a reference. ij The predicted probability P(A) of the edge ij =1|H i H j To determine the consistency of A and B, calculate the corresponding log-likelihood loss log p(A). ij |H i H j The specific process is as follows:
[0190] logp(A ij |H i H j ) = A ij log(P(A ij =1|H i H j ))+(1-A ij )log(1-P(A ij =1|H i H j ));
[0191] Furthermore, by summing the log-likelihood losses for all sample nodes, we can obtain the total log-likelihood loss (i.e., the reconstruction term of the pre-defined model) E. q [log p(A|H)]:
[0192] Here, A represents the first adjacency matrix, H represents the sample latent representation matrix, and p(A|H) represents the probability distribution of reconstructing A given H. By optimizing the reconstruction terms, the reconstructed second adjacency matrix can be made as close as possible to the first adjacency matrix, thereby achieving effective reconstruction of the graph structure.
[0193] By constructing reconstruction terms, the difference between the second adjacency matrix generated by the preset model and the original first adjacency matrix can be compared. By maximizing the reconstruction terms, the edge prediction probability predicted by the preset model can be made as close as possible to the connection situation in the actual sample relationship graph. This allows for the evaluation of the preset model's ability to reconstruct the graph structure corresponding to the current model parameters, so as to facilitate subsequent adjustments to the model parameters.
[0194] In some implementations, to ensure that the Gaussian distribution of the samples does not deviate too far from the prior distribution, a regularization term for the pre-defined model can be constructed. Minimizing this regularization term encourages the Gaussian distribution of the samples generated by the pre-defined model to be closer to the prior distribution, thereby improving the model's generalization ability and preventing overfitting. For example, "determining the regularization term of the pre-defined model based on the difference between the Gaussian distribution of the samples and the prior distribution" in (A.7) can include:
[0195] (A.7.1) For each sample node, calculate the divergence between the sample Gaussian distribution and the prior distribution;
[0196] (A.7.2) Construct the regularization term of the preset model based on multiple divergence values corresponding to multiple sample nodes.
[0197] The divergence value can be the Kullback-Leibler divergence (KL divergence for short), which is used to measure the difference between the Gaussian distribution of the sample and the prior distribution.
[0198] The Gaussian distribution of the samples can be a distribution in the latent space that maps the feature matrix of the sample nodes and the first adjacency matrix of the target model. This distribution can be assumed to be Gaussian, but the specific settings are determined according to the actual configuration.
[0199] The prior distribution can be a standard Gaussian distribution (mean 0, covariance is the identity matrix), which serves as the prior hypothesis for the latent representation vector of the sample.
[0200] For example, for sample node i, its corresponding sample Gaussian distribution q(H i |X,A) can be represented as:
[0201] Where A is the first adjacency matrix and X is the feature matrix of the sample nodes.
[0202] For example, the prior distribution p(H) can be a standard Gaussian distribution: p(H) = N(0, I);
[0203] Where I is the identity matrix.
[0204] Furthermore, for each sample node i, the formula for calculating the divergence between its sample Gaussian distribution and the prior distribution is as follows: D KL(q(H i |X,A)||p(H);
[0205] Where A is the first adjacency matrix, X is the sample node feature matrix, and H is the sample latent representation matrix.
[0206] Furthermore, for each sample node i in the sample relationship graph, the sum of its multiple divergence values can be used as the regularization term of the preset model, as specifically expressed below:
[0207] By constructing a regularization term, the Gaussian distribution of the samples is made close to the prior distribution, making the meaning and role of each sample's latent representation vector clearer and more independent, thus improving the accuracy and efficiency of the model in reconstructing the relational graph. At the same time, this also means that the latent representation variables have a certain degree of universality and can be transferred and applied in different tasks and scenarios.
[0208] In some implementations, to enhance the model's expressive power, multi-scale attention mechanisms and residual connections can be introduced into each graph convolutional layer of the model's graph convolutional network (GCN) to process the corresponding graph data, thereby improving the graph data restoration and resolution enhancement effects. For example, relational graph reconstruction methods may also include:
[0209] (B.1) Obtain multiple graph convolutional layers of the preset model;
[0210] (B.2) Obtain multiple preset attention mechanisms and set different graph attention mechanisms in each graph convolutional layer; among them, message passing is carried out between any adjacent graph convolutional layers through residual connections. The different graph attention mechanisms include microscale mechanism, mesoscale mechanism, macroscale mechanism, dynamic scale mechanism and multi-relation scale mechanism.
[0211] Graph convolutional layers can be a core component in the target model, used to process graph-structured data. Each graph convolutional layer can generate an updated node representation by aggregating the feature information of sample nodes and their neighboring nodes.
[0212] Graph attention mechanisms can be used to dynamically assign importance weights to neighboring nodes of different samples. By introducing attention mechanisms, the model can more flexibly capture complex dependencies between sample nodes.
[0213] Among them, the microscale mechanism can be a mechanism that focuses on local information in a pre-defined model. It mainly focuses on the interaction and dependency between sample nodes and their direct neighboring nodes, aiming to capture fine-grained local patterns.
[0214] The mesoscale mechanism can be a mechanism that focuses on mesoscopic structural information within a pre-defined model. It primarily focuses on community structures or subgraph structures in the sample relationship graph, aiming to capture dependencies in intermediate features to improve the quality of the overall graph representation. Specifically, the mesoscale mechanism can focus on the relationships between sample nodes and their second- or third-order sample neighbors, capturing graph structures of a moderate range.
[0215] Among them, the macro-scale mechanism can be a mechanism that focuses on global information in a pre-set model. It mainly focuses on the overall structure and dependencies of the entire relationship graph, aiming to capture a wide range of patterns and trends.
[0216] Among them, the dynamic scaling mechanism can be a graph convolution mechanism that can adapt to information at different scales. The dynamic scaling mechanism can automatically adjust the scale range of its focus according to the characteristics of the sample relationship graph, thereby capturing local, mesoscopic and global information at the same time. The dynamic scaling mechanism improves the flexibility and adaptability of the model.
[0217] Among them, the multi-relation scaling mechanism can be a mechanism capable of handling multiple types of relationships. It not only focuses on the connection relationships between sample nodes, but also considers different types of relationships (such as friendship relationships, cooperative relationships, etc.). The multi-relation scaling mechanism enhances the model's ability to understand complex relationship graphs by introducing relationship embedding or relationship awareness mechanisms.
[0218] In some implementations, the attention mechanism for different graph convolutional layers can be selected from at least one of the above types and configured accordingly. For example, a microscale mechanism can be used in graph convolutional layer 1, a mesoscale mechanism can be used in graph convolutional layer 2, and so on, depending on the specific circumstances.
[0219] In some implementations, when different graph convolutional layers of the preset model are configured with different graph attention mechanisms, it means that different graph convolutional layers of the target model are configured with different graph attention mechanisms.
[0220] In some implementations, as the number of graph convolutional layers increases, the model may face the problem of vanishing gradients or information loss, leading to a decrease in model performance. Therefore, when the number of graph convolutional layers exceeds a threshold, residual connections can be introduced between each graph convolutional layer to ensure that information is effectively transferred between different graph convolutional layers and effectively avoid information loss.
[0221] By setting up multi-scale attention mechanisms and residual connections in multiple graph convolutional layers, attention can be paid to the relation graph at different scales in different graph convolutional layers. This not only enhances the model's expressive power and understanding effect, but also improves the model's training stability and generalization ability.
[0222] Please refer to Figure 3, which illustrates an overall embodiment of the technical solution of this application. In some embodiments, after obtaining the initial relational graph, the corresponding node feature matrix and initial adjacency matrix can be obtained. After inputting the node feature matrix and initial adjacency matrix into the target model, the graph convolutional network of the target model learns the latent representation of the target nodes through multiple graph convolutional layer operations, captures the local and global dependencies between target nodes, and outputs the distribution parameters (mean μ and variance σ) of the latent representation of each node through the encoder of the target model. The distribution parameters define the Gaussian distribution of each target node in the latent space.
[0223] Furthermore, a latent representation vector corresponding to each target node can be sampled from the Gaussian distribution. This latent representation vector captures the local and global structural information of the target node. Then, a latent representation matrix can be generated based on the multiple latent representation vectors corresponding to multiple target nodes. The decoder of the target model then predicts the connection probability between any two target nodes based on this latent representation matrix, generating a reconstructed target adjacency matrix. Finally, a target relationship graph can be generated based on the node feature matrix and the initial adjacency matrix.
[0224] It should be noted that during the training of the preset model, after generating the reconstructed second adjacency matrix based on the latent representation matrix of the samples, the reconstruction term and regularization term can be calculated, and the lower bound of evidence can be generated based on the reconstruction term and regularization term. The preset model is trained by maximizing the lower bound of evidence to obtain the target model, so as to ensure that the preset model can effectively learn the complex relationships between target nodes from the relation graph and maintain good performance.
[0225] This application embodiment obtains a pre-constructed initial relationship graph and generates node feature matrices corresponding to multiple target nodes and an initial adjacency matrix representing the connection relationships between multiple target nodes based on the initial relationship graph. Through a target model, feature transfer and feature aggregation are performed between multiple target nodes based on the initial adjacency matrix and the node feature matrix to obtain intermediate features for each target node. For each target node, the intermediate features are mapped to a latent space to obtain corresponding distribution parameters. The latent space is used to map the local dependencies between each target node and its neighboring nodes, as well as the global dependencies of each target node in the initial relationship graph. Random sampling is performed on the Gaussian distribution corresponding to the distribution parameters of each target node to obtain a latent representation vector for each target node, and a latent representation matrix corresponding to the initial relationship graph is generated based on multiple latent representation vectors. Based on the latent representation matrix, the connection probability between any two target nodes is predicted, and a target adjacency matrix is obtained based on multiple connection probabilities. Through a target model, the initial relationship graph is reconstructed based on the node feature matrix and the target adjacency matrix to obtain the target relationship graph. This approach enhances the representational power of target nodes through feature propagation, enabling each target node to more accurately reflect its dependencies on other target nodes in subsequent steps. Simultaneously, mapping the intermediate features of target nodes to the latent space allows the representation of the relational graph to move beyond explicit connections (adjacency matrices) and capture deeper implicit relationships—local and global dependencies of target nodes. This ensures the repaired graph structure maintains global consistency and avoids unnatural connections. Furthermore, by sampling latent representations from the latent space, the model can infer implicit dependencies between nodes, generating a more natural, coherent, and accurate graph structure. In summary, this application improves the global consistency and accuracy of the reconstructed relational graph.
[0226] Referring to Figure 4, this application embodiment also provides a relation graph reconstruction apparatus, which can implement the above-described relation graph reconstruction method. The relation graph reconstruction apparatus includes:
[0227] The acquisition module 41 is used to acquire a pre-constructed initial relation graph and generate a node feature matrix corresponding to multiple target nodes and an initial adjacency matrix representing the connection relationship between multiple target nodes based on the initial relation graph.
[0228] The aggregation module 42 is used to perform feature transfer and feature aggregation between multiple target nodes based on the initial adjacency matrix and node feature matrix through the target model, so as to obtain the intermediate features of each target node.
[0229] The mapping module 43 is used to map the intermediate features to the latent space for each target node to obtain the corresponding distribution parameters; wherein, the latent space is used to map the local dependencies between each target node and its neighboring nodes, as well as the global dependencies of each target node in the initial relation graph;
[0230] The sampling module 44 is used to randomly sample the Gaussian distribution corresponding to the distribution parameters of each target node to obtain the potential representation vector corresponding to each target node, and generate the potential representation matrix corresponding to the initial relation graph based on multiple potential representation vectors;
[0231] The prediction module 45 is used to predict the connection probability between any two target nodes based on the latent representation matrix, and to obtain the target adjacency matrix based on multiple connection probabilities.
[0232] The reconstruction module 46 is used to reconstruct the initial relation graph based on the node feature matrix and the target adjacency matrix using the target model, so as to obtain the target relation graph.
[0233] The specific implementation of the relationship graph reconstruction device is basically the same as the specific embodiment of the relationship graph reconstruction method described above, and will not be repeated here. Subject to meeting the requirements of the embodiments of this application, the relationship graph reconstruction device may also be equipped with other functional modules to implement the relationship graph reconstruction method described above.
[0234] This application also provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described method for reconstructing the relational graph. This computer device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0235] Please refer to Figure 5, which illustrates the hardware structure of a computer device according to another embodiment. The computer device includes:
[0236] The processor 51 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0237] The memory 52 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 52 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 52 and called by the processor 51 to execute the relationship graph reconstruction method of the embodiments of this application.
[0238] Input / output interface 53 is used to implement information input and output;
[0239] The communication interface 54 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0240] Bus 55 transmits information between various components of the device (e.g., processor 51, memory 52, input / output interface 53, and communication interface 54);
[0241] The processor 51, memory 52, input / output interface 53, and communication interface 54 are connected to each other within the device via bus 55.
[0242] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for reconstructing the relational graph.
[0243] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0244] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0245] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0246] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0247] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0248] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0249] It should be understood that in this application, "at least one" and "several" refer to one or more, and "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0250] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0251] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0252] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0253] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0254] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A method for reconstructing a relational graph, characterized in that, The method includes: Obtain a pre-constructed initial relationship graph, and generate node feature matrices corresponding to multiple target nodes and an initial adjacency matrix representing the connection relationship between the multiple target nodes based on the initial relationship graph; Using the target model, feature transfer and feature aggregation are performed between the multiple target nodes based on the initial adjacency matrix and the node feature matrix to obtain the intermediate features of each target node; For each target node, the intermediate features are mapped to the latent space to obtain the corresponding distribution parameters; wherein, the latent space is used to map the local dependencies between each target node and its neighboring nodes, as well as the global dependencies of each target node in the initial relation graph; Randomly sample the Gaussian distribution corresponding to the distribution parameters of each target node to obtain the latent representation vector corresponding to each target node, and generate the latent representation matrix corresponding to the initial relation graph based on multiple latent representation vectors; Based on the latent representation matrix, the connection probability between any two target nodes is predicted, and the target adjacency matrix is obtained based on multiple connection probabilities. Using the target model, the initial relation graph is reconstructed based on the node feature matrix and the target adjacency matrix to obtain the target relation graph.
2. The method for reconstructing a relational graph according to claim 1, characterized in that, The target model is trained in the following way: Obtain a pre-constructed sample relationship graph, and generate a sample node feature matrix corresponding to multiple sample nodes and a first adjacency matrix representing the connection relationship between the multiple sample nodes based on the sample relationship graph. By using a preset model, feature transfer and feature aggregation are performed between the multiple sample nodes based on the first adjacency matrix and the sample node feature matrix to obtain the intermediate features of each sample node. For each sample node, the intermediate features of the sample are mapped to the latent space to obtain the corresponding sample distribution parameters; wherein, the latent space is used to map the local dependencies between each sample node and its neighboring sample nodes, as well as the global dependencies of each sample node in the sample relationship graph; Randomly sample the Gaussian distribution corresponding to the sample distribution parameters of each sample node to obtain the sample latent representation vector corresponding to each sample node, and generate the sample latent representation matrix corresponding to the sample relationship graph based on multiple sample latent representation vectors; Based on the latent representation matrix of the samples, the sample connection probability of any two sample nodes is predicted, and a second adjacency matrix is obtained based on multiple sample connection probabilities. Based on the consistency between the first adjacency matrix and the second adjacency matrix, the reconstruction terms of the preset model are determined; Obtain a preset prior distribution, and determine the regularization term of the preset model based on the difference between the sample Gaussian distribution and the prior distribution; The parameters of the preset model are adjusted by maximizing the lower bound of evidence constructed by the reconstruction term and the regularization error to obtain the target model.
3. The method for reconstructing a relational graph according to claim 2, characterized in that, The step of determining the reconstruction terms of the preset model based on the consistency between the first adjacency matrix and the second adjacency matrix includes: Based on the first adjacency matrix, determine the sample node relationship between any two sample nodes; In the second adjacency matrix, the corresponding edge prediction probability is determined based on the relationship between any two sample nodes. Based on the consistency between the sample node relationships and the edge prediction probabilities, the corresponding log-likelihood loss is determined; Based on the multiple log-likelihood losses corresponding to the sample relationship graph, the reconstruction terms of the preset model are constructed.
4. The method for reconstructing a relational graph according to claim 2, characterized in that, The step of determining the regularization term of the preset model based on the difference between the sample Gaussian distribution and the prior distribution includes: For each sample node, calculate the divergence value between the sample Gaussian distribution and the prior distribution; The regularization term of the preset model is constructed based on multiple divergence values corresponding to multiple sample nodes.
5. The method for reconstructing a relational graph according to claim 2, characterized in that, The method further includes: Obtain multiple graph convolutional layers of the preset model; Multiple preset attention mechanisms are obtained, and different graph attention mechanisms are set in each graph convolutional layer; wherein, message passing is performed between any adjacent graph convolutional layers through residual connections, and the different graph attention mechanisms include microscale mechanism, mesoscale mechanism, macroscale mechanism, dynamic scale mechanism and multi-relation scale mechanism.
6. The method for reconstructing a relational graph according to claim 1, characterized in that, The step involves using the target model to perform feature transfer and feature aggregation among the multiple target nodes based on the initial adjacency matrix and the node feature matrix, to obtain intermediate features for each target node, including: Through each graph convolutional layer of the target model, features are passed to the neighboring nodes of each target node according to the initial adjacency matrix and the node feature matrix to obtain the adjacent aggregated features; The adjacent aggregated features and corresponding node features of each target node are aggregated to obtain the intermediate features of each target node.
7. The method for reconstructing a relational graph according to claim 1, characterized in that, The step of predicting the connection probability between any two target nodes based on the latent representation matrix, and obtaining the target adjacency matrix based on multiple connection probabilities, includes: Based on the latent representation matrix, determine the inner product value of the latent representation vectors of any two target nodes; The connection probability of any two target nodes is obtained by processing the inner product value of the latent representation vectors of any two target nodes through an activation function. The target adjacency matrix is obtained based on the connection probabilities between multiple target nodes.
8. A device for reconstructing a relational graph, characterized in that, The device includes: The acquisition module is used to acquire a pre-constructed initial relationship graph, and generate a node feature matrix corresponding to multiple target nodes and an initial adjacency matrix representing the connection relationship between the multiple target nodes based on the initial relationship graph. An aggregation module is used to perform feature transfer and feature aggregation among the multiple target nodes based on the initial adjacency matrix and the node feature matrix using the target model, to obtain the intermediate features of each target node. The mapping module is used to map the intermediate features to the latent space for each target node to obtain the corresponding distribution parameters; wherein, the latent space is used to map the local dependencies between each target node and its neighboring nodes, as well as the global dependencies of each target node in the initial relation graph; The sampling module is used to randomly sample the Gaussian distribution corresponding to the distribution parameters of each target node to obtain the potential representation vector corresponding to each target node, and generate the potential representation matrix corresponding to the initial relation graph based on multiple potential representation vectors; The prediction module is used to predict the connection probability between any two target nodes based on the latent representation matrix, and to obtain the target adjacency matrix based on multiple connection probabilities. The reconstruction module is used to reconstruct the initial relation graph based on the node feature matrix and the target adjacency matrix using the target model, thereby obtaining the target relation graph.
9. A computer device, characterized in that, The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the relationship graph reconstruction method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the method for reconstructing the relational graph as described in any one of claims 1 to 7.