An interactive attention-based graph similarity measurement method and system

By employing an interactive attention-based depth graph similarity measurement method, which utilizes a hybrid encoder and a similarity structure learning module, the matching problem of large-scale graph data is solved, achieving robust identification of structural variations and noise, and improving matching accuracy and efficiency.

CN122115904APending Publication Date: 2026-05-29牟瑾
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
牟瑾
Filing Date
2026-02-28
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies struggle to efficiently process large-scale graph data and lack robustness in the face of structural variations and noise, making it impossible to achieve fine-grained semantic matching.

Method used

We employ an interactive attention-based depth graph similarity measurement method. This method uses a hybrid encoder for node representation learning, combines a residual graph convolutional network and a structure-aware self-attention mechanism, and utilizes a cross-graph interactive attention module and a similarity structure learning module for multi-view similarity matrix fusion and topology matching pattern mining.

Benefits of technology

It achieves efficient and robust matching of large-scale graph data, can identify structural variations and noise, and improves matching accuracy and computational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122115904A_ABST
    Figure CN122115904A_ABST
Patent Text Reader

Abstract

The application discloses a graph similarity measurement method and system based on interactive attention, and belongs to the technical field of graph data processing and graph neural networks. The method comprises the following steps: obtaining a pair of images to be matched; performing node representation learning through a hybrid encoder of fused residual graph convolution and structure-aware self-attention to generate node embedding fusing local causal features and global semantic context; inputting the node embedding of the two graphs into a cross-graph interactive attention module to calculate a multi-view fine-grained node-level similarity matrix; adaptively fusing each view similarity matrix through similarity self-attention, and mining local topological matching patterns from the fused matrix through a convolutional neural network to finally map a scalar score representing the semantic similarity of the two graphs. The application converts the subgraph isomorphism problem into a learnable similarity measurement problem, can robustly identify the graph structure with structural variants and noise interference, and significantly improves the accuracy and efficiency of graph matching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of graph data processing and graph neural network technology. Specifically, it relates to a method and system for measuring the similarity of deep graphs based on interactive attention, which is applicable to scenarios such as network topology analysis, social network analysis, and bioinformatics that require accurate matching and similarity judgment of graph structure data. Background Technology

[0002] Graph matching, as a key technology in graph data processing, aims to measure the similarity between two graph structures or find the correspondence between nodes. It has been widely used in many fields such as computer vision, social network analysis, molecular structure comparison, and network security.

[0003] Traditional graph matching methods are mainly divided into two categories: The first is exact matching algorithms based on subgraph isomorphism, such as the Ullmann algorithm and the VF2 algorithm. However, the subgraph isomorphism problem has been proven to be NP-complete, and its computational complexity increases exponentially with the graph size, making it difficult to handle large-scale real-world scenarios. Furthermore, exact matching algorithms require completely identical graph structures, lacking tolerance for common structural variations in network topology, which can easily lead to missed detections. The second category is approximate matching algorithms based on graph edit distance, such as the A* algorithm and the Hungarian algorithm. While these methods relax the matching conditions to some extent, their computational complexity remains high, and they struggle to capture the global topological structure of the graph and the deep semantics of node attributes.

[0004] In recent years, with the development of deep learning, graph similarity learning methods based on graph neural networks have become a research hotspot. These methods typically encode the entire graph into fixed-dimensional vectors using graph neural networks, and then measure graph similarity by calculating the Euclidean distance or cosine similarity between vectors. However, this global pooling operation indiscriminately mixes information from all nodes in the graph, causing crucial but sparse structural information to be diluted and submerged by a large amount of irrelevant noise, severely weakening the model's discriminative ability in fine-grained semantic matching tasks. Furthermore, existing graph neural network-based methods have limitations in handling long-range dependencies, and deep networks are prone to oversmoothing of node representations, further degrading model performance.

[0005] In summary, there is currently a lack of a graph similarity measurement method that can efficiently process large-scale graph data, be robust to structural variations and noise, and achieve fine-grained semantic matching. Summary of the Invention

[0006] The technical problem to be solved by the present invention is to overcome the shortcomings of the prior art and provide a method and system for measuring the similarity of deep graphs based on interactive attention. By introducing a cross-graph interactive attention mechanism and a similarity structure learning module, the problem of subgraph isomorphism is transformed into a similarity measurement problem that can be learned end-to-end, so as to achieve robust and accurate matching of graph structures with structural variations and noise interference.

[0007] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:

[0008] A depth map similarity measurement method based on interactive attention includes the following steps:

[0009] Step 1: Obtain the query graph Candidate graphs to be matched ;

[0010] Step 2: Process the query graph using a hybrid encoder. With candidate graph Perform node representation learning to generate query graph node embedding matrices respectively. and candidate graph node embedding matrix The hybrid encoder integrates a residual graph convolutional network with a structure-aware self-attention mechanism.

[0011] Step 3: Embed the query graph nodes into the matrix and candidate graph node embedding matrix Input a graph association analyzer to compute a set of fine-grained similarity matrices from multiple perspectives. Where M is the number of attention heads, and each similarity matrix It represents the degree of matching between query graph nodes and candidate graph nodes from a specific semantic perspective. and These represent the number of nodes in the two graphs, respectively.

[0012] Step 4: Set the multi-view similarity matrix The input similarity decision module adaptively fuses similarity matrices from different perspectives and mines local topological matching patterns from the fused matrix, ultimately mapping a scalar graph similarity score.

[0013] As a further improvement of the present invention, the method for learning node representations through a hybrid encoder in step 2 includes:

[0014] Step 2.1: Perform initial feature fusion on the heterogeneous attributes of the nodes in the graph to obtain the initial node feature matrix. ;

[0015] Step 2.2: The initial node feature matrix The input is an L-layer residual graph convolutional network, which aggregates the local neighborhood information of nodes layer by layer to generate node representations with enhanced local structure. The propagation rules for each layer are as follows: , To add self-connected adjacency matrices, Its degree matrix, Let L be the trainable weight matrix of the l-th layer. For activation functions;

[0016] Step 2.3: Characterize the nodes with enhanced local structure The input structure-aware self-attention module introduces the topological distance between nodes as a structural bias, calculates global attention coefficients, aggregates contextual information across the entire graph, and generates a node embedding matrix that integrates global semantic context. .

[0017] As a further improvement of the present invention, the calculation method for structure-aware self-attention in step 2.3 includes:

[0018] For the m-th attention head, the query matrix is ​​first obtained through a linear transformation. Key matrix Sum matrix :

[0019]

[0020] Attention coefficient of node i to node j The calculation formula is:

[0021]

[0022] in, Let be the shortest path distance between node i and node j in the undirected graph. For about The monotonically decreasing decay function, These are learnable parameters used to balance content information and structural information.

[0023] The global context-aware embedding of the final node i is obtained by concatenating the outputs of all M attention heads:

[0024]

[0025] As a further improvement of the present invention, the method for calculating the multi-view fine-grained similarity matrix by the cross-graph interactive attention module in step 3 includes:

[0026] Step 3.1: For the m-th attention head, embed the query graph node into the matrix. and candidate graph node embedding matrix Projecting these onto the query space, key space, and value space respectively, we obtain:

[0027]

[0028]

[0029] Step 3.2: Calculate the bidirectional attention matrix from the query graph to the candidate graph and obtain the context representation:

[0030]

[0031]

[0032] Step 3.3: Calculate the fine-grained similarity matrix of the m-th attention head:

[0033]

[0034] in, is the cosine similarity calculation function, and ⨂ represents element-wise multiplication.

[0035] As a further improvement of the present invention, the similarity structure learning module in step 4 includes a similarity self-attention unit and a topology matching pattern mining unit based on a convolutional neural network.

[0036] The similarity self-attention unit is configured to calculate similarity matrices from different perspectives. and Correlation weights between The similarity matrices of each perspective are weighted and fused according to the aforementioned relevance weights to generate a fused similarity matrix. ;

[0037] The topology matching pattern mining unit based on a convolutional neural network consists of alternating stacked two-dimensional convolutional layers and pooling layers, configured to process the fused similarity matrix. The image is processed as a structural image to mine local topological matching patterns. The mined patterns are then aggregated into a global feature vector using a multilayer perceptron and finally mapped to the inter-graph similarity score using a sigmoid activation function.

[0038] As a further improvement of the present invention, the similarity self-attention unit calculates the fusion similarity matrix. The methods include:

[0039] Given M similarity matrices Stacked as a three-dimensional tensor along the channel dimension ;

[0040] Calculate the correlation weight between channel i and channel j ,in For learnable attention vectors, For matrix flattening operation;

[0041] Normalize the relevance weights to obtain ;

[0042] Based on the normalized weights The enhanced channel representation is obtained by weighted summation of the original similarity matrix. Then, through convolution operations, all enhanced channel representations are fused into a final fused similarity matrix. .

[0043] As a further improvement of the present invention, the method further includes a model training step:

[0044] Construct a training dataset D, which contains multiple sets of sample pairs of query graphs and candidate graphs. and binary labels used to indicate whether the graph pair matches. ;

[0045] The sample pairs are calculated using the aforementioned depth map similarity measurement method. The predicted similarity score;

[0046] Based on binary cross-entropy loss function Calculate the loss between the predicted score and the true label y, and optimize the model parameters using the backpropagation algorithm. The loss function is defined as:

[0047]

[0048] Based on the same inventive concept, this invention also provides a depth map similarity measurement system based on interactive attention, comprising:

[0049] The graph acquisition module is configured to acquire query graphs. Candidate graphs to be matched ;

[0050] A hybrid encoder, configured to process the query graph via a hybrid encoder. With candidate graph Perform node representation learning to generate query graph node embedding matrices respectively. and candidate graph node embedding matrix The hybrid encoder integrates a residual graph convolutional network with a structure-aware self-attention mechanism.

[0051] A graph association analyzer, configured to analyze the query graph node embedding matrix and candidate graph node embedding matrix The set of fine-grained similarity matrices from multiple perspectives was calculated. ;

[0052] The similarity decision module is configured to adaptively fuse the set of similarity matrices from multiple perspectives, mine local topological matching patterns from the fused matrices, and finally map a scalar graph similarity score.

[0053] Compared with the prior art, the advantages of the present invention are as follows:

[0054] 1. This invention, by fusing residual graph convolution and structure-aware self-attention into a hybrid encoder, can stably capture the local causal structure of nodes and be aware of the global attack context, effectively solving the problems of long-range dependency modeling and oversmoothing.

[0055] 2. The cross-graph association analyzer proposed in this invention establishes a bidirectional semantic dialogue between two graphs at the node level, fully preserving the local matching structure. It transforms graph similarity comparison from a global scoring process into an interpretable node-level correspondence detection process, significantly improving the ability to perceive key but sparse attack signals.

[0056] 3. This invention adaptively fuses multi-view matching information through similarity self-attention in the similarity decision module and mines local topological matching patterns using convolutional neural networks, achieving robust recognition against structural variations and background noise. It transforms the NP-hard subgraph isomorphism problem into a similarity measurement problem that can be learned end-to-end, significantly improving computational efficiency while ensuring matching accuracy. Attached Figure Description

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

[0058] Figure 1 This is an overall flowchart of the depth map similarity measurement method based on interactive attention in this embodiment of the invention.

[0059] Figure 2 This is a schematic diagram of the core architecture of the depth graph similarity measurement model in this embodiment of the invention, showing the node representation learning module, the cross-graph interactive attention module, and the similarity structure learning module, as well as their data flow. Detailed Implementation

[0060] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that these embodiments are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0061] Example 1

[0062] like Figure 1 As shown, this embodiment provides a depth map similarity measurement method based on interactive attention, including the following steps:

[0063] Step S101: Obtain the query graph Candidate graphs to be matched .

[0064] In this embodiment, query graph It can be an attack pattern diagram abstracted from cybersecurity threat intelligence, a candidate diagram. It can be a localized source graph extracted from system audit logs that may contain information about attack activities. Both graphs are graph-structured data that includes node attribute features and edge structure information.

[0065] Step S102: Node representation learning is performed using a hybrid encoder.

[0066] Query graph and candidate graph Two identical hybrid encoders with shared parameters are input separately to generate their respective node embedding matrices. and .like Figure 2 As shown, the hybrid encoder is a core component of the node representation learning module in the depth map similarity measurement model.

[0067] The hybrid encoder specifically includes the following sub-steps:

[0068] Step S1021: Initial feature fusion.

[0069] For each node in the input graph G, its heterogeneous attributes are characterized. For discrete attributes such as node type, one-hot encoding is used followed by linear transformation; for text attributes such as entity name and command line, a pre-trained language model is used to extract semantic vectors. All features are concatenated to obtain the initial node feature matrix. ,in For the number of nodes, This represents the initial feature dimension.

[0070] Step S1022: Local causal structure capture.

[0071] The initial feature matrix enter A layered residual graph convolutional network. Each graph convolutional layer updates node features according to the following rules:

[0072]

[0073] in, For adjacency matrices with added self-connections, Its degree matrix, Let L be the trainable weight matrix of the l-th layer. The ReLU activation function is used. Residual connections ensure the training stability of deep networks and prevent feature degradation. After two layers of propagation, node representations with enhanced local structure are obtained. .

[0074] Step S1023: Global attack context modeling.

[0075] Will Input structure-aware self-attention module. This embodiment employs a multi-head attention mechanism, with a certain number of heads... For the m-th header, first calculate the query... ,key Sum : The attention coefficient of node i to node j is:

[0076]

[0077] in, Let be the shortest path distance between the two nodes in the undirected graph. As a structural bias term, it gives greater attention weight to nodes that are topologically adjacent. These are learnable parameters. The embedding of the final node i is obtained by concatenating the outputs of all the heads:

[0078]

[0079] Step S103: Cross-graph interactive attention computation.

[0080] The result obtained in step S102 and Input cross-graph interactive attention module, such as Figure 2 As shown. This module also uses a multi-head mechanism (number of heads). ), parallel processing.

[0081] Taking the m-th header as an example, we first obtain two sets of query, key, and value through linear transformation:

[0082]

[0083]

[0084] Then, the attention matrices for both directions and their corresponding context representations are calculated:

[0085]

[0086]

[0087] Next, the fine-grained similarity matrix corresponding to this head is calculated. :

[0088]

[0089] in, `⨀` indicates that the cosine similarity is calculated row-wise, and `⨀` indicates element-wise multiplication. The elements in this matrix... It incorporates bidirectional interactive information, representing the degree of matching between query graph node i and candidate graph node j from viewpoint m.

[0090] The outputs of all M heads form a set .

[0091] Step S104: Similarity structure learning and similarity score output.

[0092] Input the set of multi-view similarity matrices into the similarity structure learning module, such as... Figure 2 As shown, this module contains two main units: a similarity self-attention unit and a topology matching pattern mining unit based on a convolutional neural network.

[0093] Step S1041: Similarity self-attention fusion.

[0094] First, stack the four similarity matrices into a tensor along the channel dimension. Then calculate the self-attention weights between channels:

[0095]

[0096]

[0097] in, For learnable vectors, Flatten the matrix. Perform a weighted summation on the original matrix according to the weights to obtain the enhanced channel representation. Finally, through a Convolution merges the four enhancement channels into a final fused similarity matrix. .

[0098] Step S1042: Topology matching pattern mining.

[0099] Will The input is considered as a single-channel matching heatmap, consisting of a convolutional neural network composed of three alternating stacked 2D convolutional layers and two max-pooling layers. The kernel size is set to... The stride is 1. Convolution operations can capture... Highlighting patterns for locally clustered nodes, for example, when querying node i in the graph and its neighbors. , respectively with node j in the candidate subgraph and its neighbors Highly matched, then in Location and High values ​​will be displayed simultaneously, and CNNs can effectively capture this topological alignment pattern.

[0100] After convolution and pooling operations, the feature map is flattened into a one-dimensional vector and fed into a multilayer perceptron consisting of two fully connected layers. The final fully connected layer uses the sigmoid activation function and outputs a scalar value, which is the final inter-graph similarity score.

[0101]

[0102] This score intuitively reflects the candidate graph Includes query graph The higher the score, the greater the similarity to the described attack pattern.

[0103] Step S105: Model training.

[0104] In practical applications, the model needs to be trained. A training dataset D is constructed, where each sample contains a pair of graphs. and binary tags (1 indicates a match, 0 indicates a mismatch). A binary cross-entropy loss function is used:

[0105]

[0106] The parameters of all modules in the model are optimized using the backpropagation algorithm to minimize the loss function. This yields a well-trained graph similarity measurement model.

[0107] Example 2

[0108] This embodiment provides a depth map similarity measurement system based on interactive attention, used to implement the method described in Embodiment 1, and its structure is as follows: Figure 2 As shown, it includes:

[0109] The graph input interface is configured to retrieve the query graph. Candidate graphs to be matched This interface can be a database connector, a file reader, or a network data receiving module.

[0110] Hybrid encoder, configured to process the query graph With candidate subgraph Perform node feature learning to generate query graph node feature matrices respectively. and candidate graph node feature matrix The structure-aware encoder integrates a residual graph convolutional network and a topology-enhanced self-attention mechanism, and its specific implementation is as described in step S102 of Embodiment 1.

[0111] A graph association analyzer, configured to analyze the query graph node feature matrix and candidate graph node feature matrix The set of fine-grained correlation matrices from multiple perspectives was calculated. The specific implementation method is as described in step S103 of Embodiment 1.

[0112] The similarity decision module is configured to adaptively fuse the multi-view association matrix set, mine local structure matching patterns from the fused matrix, and finally map a scalar inter-graph similarity score. Its specific implementation is as described in step S104 of Embodiment 1.

[0113] In summary, this invention transforms the complex subgraph isomorphism problem into a similarity measurement problem that can be learned end-to-end by introducing an interactive attention mechanism and similarity structure learning. It can robustly identify graph structures with structural variations and noise interference, significantly improving the accuracy and efficiency of graph matching. It can be widely applied in multiple fields such as cybersecurity threat hunting, social network analysis, and bioinformatics.

[0114] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A depth map similarity measurement method based on interactive attention, characterized in that, Includes the following steps: Step 1: Obtain the graph pair to be matched, graph A and graph B; Step 2: Perform node representation learning on graphs A and B using a hybrid encoder to generate node embedding matrices for graph A. And the node embedding matrix of graph B The hybrid encoder integrates a residual graph convolutional network with a structure-aware self-attention mechanism. Step 3: Embed the nodes of Graph A into the matrix And the node embedding matrix of graph B Input a graph association analyzer to compute a set of fine-grained similarity matrices from multiple perspectives. Where M is the number of attention heads, and each similarity matrix This characterizes the degree of matching between nodes in graph A and nodes in graph B from a specific semantic perspective. and These represent the number of nodes in the two graphs, respectively. Step 4: Set the multi-view similarity matrix The input similarity decision module adaptively fuses similarity matrices from different perspectives and mines local topological matching patterns from the fused matrix, ultimately mapping a scalar graph similarity score.

2. The method according to claim 1, characterized in that, The method for node representation learning using a hybrid encoder in step 2 includes: Step 2.1: Perform initial feature fusion on the heterogeneous attributes of the nodes in the graph to obtain the initial node feature matrix. ; Step 2.2: The initial node feature matrix The input is an L-layer residual graph convolutional network, which aggregates the local neighborhood information of nodes layer by layer to generate node representations with enhanced local structure. The propagation rules for each layer are as follows: To add self-connected adjacency matrices, Its degree matrix, Let L be the trainable weight matrix of the l-th layer. For activation functions; Step 2.3: Characterize the nodes with enhanced local structure The input structure-aware self-attention module introduces the topological distance between nodes as a structural bias, calculates global attention coefficients, aggregates contextual information across the entire graph, and generates a node embedding matrix that integrates global semantic context. .

3. The method according to claim 2, characterized in that, The calculation method for structure-aware self-attention in step 2.3 includes: For the m-th attention head, the query matrix is ​​first obtained through a linear transformation. Key matrix Sum matrix : Attention coefficient of node i to node j The calculation formula is: in, Let be the shortest path distance between node i and node j in the undirected graph. For about The monotonically decreasing decay function, These are learnable parameters used to balance content information and structural information. The global context-aware embedding of the final node i is obtained by concatenating the outputs of all M attention heads:

4. The method according to claim 1, characterized in that, The method for calculating the multi-view fine-grained similarity matrix in step 3 of the graph correlation analyzer includes: Step 3.1: For the m-th attention head, embed the node of graph A into the matrix. And the node embedding matrix of graph B Projecting these onto the query space, key space, and value space respectively, we obtain: Step 3.2: Calculate the bidirectional attention matrix from graph A to graph B and obtain the context representation: , , Step 3.3: Calculate the fine-grained similarity matrix of the m-th attention head: in, is the cosine similarity calculation function, and ⨂ represents element-wise multiplication.

5. The method according to claim 1, characterized in that, The similarity decision module in step 4 includes a similarity self-attention unit and a topology matching pattern mining unit based on a convolutional neural network. The similarity self-attention unit is configured to calculate similarity matrices from different perspectives. and Correlation weights between The similarity matrices of each perspective are weighted and fused according to the aforementioned relevance weights to generate a fused similarity matrix. ; The topology matching pattern mining unit based on a convolutional neural network consists of alternating stacked two-dimensional convolutional layers and pooling layers, configured to process the fused similarity matrix. The image is processed as a structural image to mine local topological matching patterns. The mined patterns are then aggregated into a global feature vector using a multilayer perceptron. Finally, the Sigmoid activation function is used to map the graph similarity score.

6. The method according to claim 5, characterized in that, The similarity self-attention unit calculates the fusion similarity matrix. The methods include: Given M similarity matrices Stacked as a three-dimensional tensor along the channel dimension ; Calculate the correlation weight between channel i and channel j ,in For learnable attention vectors, For matrix flattening operation; Normalize the relevance weights to obtain ; Based on the normalized weights The enhanced channel representation is obtained by weighted summation of the original similarity matrix. Then, through convolution operations, all enhanced channel representations are fused into a final fused similarity matrix. .

7. The method according to claim 1, characterized in that, The method also includes a model training step: Construct a training dataset D, which contains multiple pairs of sample samples to be matched, and binary labels to indicate whether the sample pairs match. ; The predicted similarity score of the sample pair is calculated using the depth map similarity measurement method as described in any one of claims 1 to 6. The loss between the predicted score and the true label y is calculated based on the binary cross-entropy loss function L, and the model parameters are optimized using the backpropagation algorithm. The loss function is defined as follows:

8. A depth map similarity measurement system based on interactive attention, characterized in that, include: The graph input interface is configured to obtain the graph pair to be matched, graph A and graph B. The hybrid encoder is configured to perform node representation learning on graphs A and B, respectively, and generate node embedding matrices for graph A. And the node embedding matrix of graph B The hybrid encoder integrates a residual graph convolutional network with a structure-aware self-attention mechanism. A graph association analyzer, configured to analyze the node embedding matrix of graph A. And the node embedding matrix of graph B The set of fine-grained similarity matrices from multiple perspectives was calculated. ; The similarity decision module is configured to adaptively fuse the set of similarity matrices from multiple perspectives, mine local topological matching patterns from the fused matrices, and finally map a scalar graph similarity score.