A molecule graph-oriented primitive level representation learning method and system
By comparing the loss function of graph diffusion model and Barlow twin dual view, the problem of the disconnect between atomic-level local neighborhood and global functional semantics in existing molecular graph representation learning methods is solved, and the semantic completeness and cross-task generalization ability of primitive-level representation are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TSINGHUA UNIVERSITY
- Filing Date
- 2025-08-26
- Publication Date
- 2026-06-26
AI Technical Summary
Existing molecular graph representation learning methods only focus on atomic-level local neighborhoods and cannot model higher-order functional substructures, resulting in a disconnect between local atomic information and global functional semantics. Furthermore, existing methods lack explicit mappings between atoms and primitives, leading to scattered training objectives and weak cross-task generalization ability.
The original molecular graph is noise-added and reconstructed using a graph diffusion model, dividing it into primitive subgraphs. Atomic views and primitive views are constructed and encoded using a graph neural network encoder. The atomic embedding matrix and primitive embedding matrix are optimized using a Barlow twin dual-view contrastive loss function to achieve cross-granularity representation alignment.
It improves the semantic completeness and task generalization ability of molecular representation, and significantly improves the model's understanding and prediction performance of molecular properties.
Smart Images

Figure CN121122502B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and computer science, and in particular to a method and system for learning primitive-level representations of molecular graphs. Background Technology
[0002] In fields such as AI-assisted drug design, material screening, and molecular property prediction, molecular graph representation learning has become one of the hot research and industrial applications. This technology is typically based on a graph representation of molecular structure, using atoms as nodes and chemical bonds as edges. It utilizes a graph neural network (GNN) to encode the graph structure, thereby providing structural feature representations for downstream tasks such as toxicity prediction and blood-brain barrier penetration prediction.
[0003] Current mainstream molecular graph representation learning methods mainly rely on atomic-level graph convolutional models, such as GCN (Graph Convolutional Network), GIN (Graph Isomorphism Network), and MPNN (Message Passing Neural Network). These methods achieve information propagation through recursive aggregation of atomic adjacency structures and have achieved good results on multiple datasets.
[0004] However, traditional molecular graph representation learning methods (such as GCN / GIN) only focus on atomic-level local neighborhoods and cannot model higher-order functional substructures (such as benzene rings, carboxyl groups, etc.), resulting in a disconnect between local atomic information and global functional semantics. The model struggles to understand the chemical groups that determine molecular properties. Furthermore, mainstream graph contrastive learning methods (such as GraphCL) rely on random graph perturbations (such as random edge / node deletion), leading to generated contrastive views that disrupt the rationality of chemical structures. The learned features lack practical biological activity significance, resulting in weak cross-task generalization ability. Existing methods (such as DiffPool) do not establish an explicit mapping between atoms and primitives, leading to isolated atomic and primitive-level representations, fragmented training objectives (such as independently optimizing losses of different granularities), and unstable performance on downstream tasks. Summary of the Invention
[0005] This invention provides a primitive-level representation learning method and system for molecular graphs to address the shortcomings of existing technologies that focus only on atomic-level local neighborhoods, which cannot model higher-order functional substructures, resulting in a disconnect between local atomic information and global functional semantics, and the difficulty in understanding the chemical groups that determine molecular properties. This invention improves the semantic completeness and task generalization ability of molecular representations.
[0006] This invention provides a primitive-level representation learning method for molecular graphs, comprising the following steps:
[0007] The original molecular graph is subjected to noise addition and reconstruction based on the graph diffusion model. The edge reconstruction error is calculated, and the original molecular graph is divided into multiple primitive subgraphs according to the edge reconstruction error, forming a set of primitive subgraphs.
[0008] Based on the original molecular graph and the set of primitive subgraphs, atomic views and primitive views are constructed respectively, and graph neural network encoders are used to encode the atomic views and primitive views respectively to obtain atomic embedding matrices and primitive embedding matrices.
[0009] Positive and negative sample pairs are constructed based on the atomic view and the primitive view. The Barlow twin dual-view contrast loss function is used to optimize the atomic embedding matrix and the primitive embedding matrix to achieve cross-granularity representation alignment.
[0010] According to the primitive-level representation learning method for molecular graphs provided by this invention, the original molecular graph is subjected to noise addition and reconstruction based on a graph diffusion model, the edge reconstruction error is calculated, and the original molecular graph is divided into multiple primitive subgraphs according to the edge reconstruction error, specifically including:
[0011] The original molecular graph is subjected to forward noise addition and reverse reconstruction using a pre-trained graph diffusion model, and the results for each edge are calculated. Reconstruction error Construct the edge reconstruction error matrix ,in, ;
[0012] Reconstruct the error matrix of the edges E Convert to edge weight matrix The conversion formula is:
[0013] ,
[0014] in, This refers to temperature hyperparameters.
[0015] Based on the edge weight matrix The original molecular graph is divided into multiple connected subgraphs using a spectral clustering algorithm.
[0016] For each cluster, check whether its induced subgraph is connected. If there are multiple connected components, treat each connected component as an independent primitive.
[0017] The final result is a set of primitives, in which each atomic node uniquely belongs to one primitive.
[0018] According to the primitive-level representation learning method for molecular graphs provided by this invention, the graph diffusion model is obtained by training by minimizing the diffusion reconstruction loss function, and the construction process of the diffusion reconstruction loss function specifically includes:
[0019] For the original molecular diagram Add forward noise and iteratively perturb the adjacency matrix according to the noise scheduling coefficient. , No. adjacency matrix of steps Represented as:
[0020] ;
[0021] in, , Indicates a time step. This is the adjacency matrix in the original graph. This is the adjacency matrix after adding noise; This is the node feature matrix, used to characterize the atomic attribute encoding. It is Gaussian noise. The noise dispatch coefficient is calculated using the following formula:
[0022] ,
[0023] in, , These represent the early time steps. Minimum noise introduced and final time step The maximum amount of noise introduced;
[0024] Through graph neural network encoder With multilayer perceptron encoder Predicting the first Step noise item And reconstruct the adjacency matrix:
[0025] ,
[0026] in, The reconstructed adjacency matrix, , The calculation formula is:
[0027] ;
[0028] ;
[0029] The diffusion reconstruction loss function is defined as:
[0030] .
[0031] According to the molecular graph-oriented primitive-level representation learning method provided by the present invention, the step of encoding the atomic view and the primitive view using a graph neural network encoder respectively includes:
[0032] Using a graph neural network encoder For information propagation in the atomic view, the node update formula is:
[0033] ;
[0034] in, For nodes In the The output feature vector of the layer, Indicates the index of the current layer. , It is the total number of network layers. Represents a node The neighboring nodes, Representing neighboring nodes In the The feature vector of the layer, Represents a non-linear activation function. Indicates the first The trainable weight matrix of the layer, Indicates the first The trainable bias vectors of the layer Represents a node The set of neighboring nodes;
[0035] In the weight matrix The graph neural network encoder Perform random weight pruning to generate the pruned weight matrix. :
[0036] ,
[0037] in, The retention probability is The mask matrix;
[0038] Using a pruned graph neural network encoder Encode the primitive view to obtain the feature representation of the nodes in the primitive view. The node update formula is:
[0039] ,
[0040] in, This represents the weight matrix calculated using the pruned weight matrix. Layer nodes Features This represents the weight matrix calculated using the pruned weight matrix. Layer neighbor nodes The characteristic of this is the approximate representation under sparsification constraints;
[0041] Graph-level pooling is performed on the updated atomic views and primitive views to obtain the atomic embedding matrix. and primitive embedding matrix :
[0042] ;
[0043] ,
[0044] in, This is the set of all atomic nodes in the original molecular graph after node updates. For set One of the atomic nodes, atomic nodes The final layer outputs a feature vector. This represents the set of all primitive nodes in the updated primitive view. Represents a set One of the primitive nodes, Represents a node The final layer outputs a feature vector.
[0045] According to the primitive-level representation learning method for molecular graphs provided by this invention, the graph neural network encoder is a graph isomorphic network, and the node update formula is:
[0046] ,
[0047] in, This represents a multilayer perceptron. Indicates learnable parameters, For nodes In the The output feature vector of the layer, Indicates the index of the current layer. , It is the total number of network layers. Represents a node The neighboring nodes, Representing neighboring nodes In the The feature vector of the layer, Represents a node The set of neighboring nodes.
[0048] According to the molecular graph-oriented primitive-level representation learning method provided by the present invention, the construction of positive and negative sample pairs based on atomic views and primitive views specifically includes:
[0049] For each atomic node Select the atomic node Belonging to the primitive Constitute positive samples ;
[0050] Randomly select nodes from other atomic nodes. , Constructing negative sample pairs ;
[0051] Randomly select primitive nodes from other primitives. , constitute negative sample pairs .
[0052] According to the molecular graph-oriented primitive-level representation learning method provided by the present invention, the Barlow twin dual-view contrast loss function is specifically as follows:
[0053] ,
[0054] in, This represents the total two-scale contrast loss. For the contrast loss of atomic views, For the contrast loss of the primitive view, As a weighting factor, , The calculation formula is:
[0055] ;
[0056] ,
[0057] in, This represents the dimension of the embedding vector. Cross-batch correlation matrix for atomic views The elements on the diagonal are used to represent the atomic view, the first... Each dimension of feature and its correlation with different samples Cross-batch correlation matrix for atomic views Off-diagonal elements are used to represent the atomic view, the first... The first dimension feature and the first Redundancy between features in each dimension Cross-batch correlation matrix for primitive view The elements on the diagonal are used to represent the primitive view, specifically the first element. Each dimension of feature and its correlation with different samples Cross-batch correlation matrix for primitive view Off-diagonal elements are used to represent the primitive view, specifically the element that is the first element. The first dimension feature and the first Redundancy between features in each dimension.
[0058] The present invention provides a primitive-level representation learning method for molecular graphs. , , , It is obtained through the following formula:
[0059] ;
[0060] ;
[0061] ;
[0062] ;
[0063] ;
[0064] ;
[0065] in, , These represent the cross-batch correlation matrices of the atomic views and the primitive views, respectively. Represents the atomic embedding matrix No. 3D feature vectors express The mean, express standard deviation Indicates the number of molecular maps in the batch. Represents the primitive embedding matrix No. 3D feature vectors express The mean, express standard deviation Indicates the number of primitive sets in the batch. , These represent the normalized atom embedding matrix and primitive embedding matrix, respectively. It is a small constant used to prevent the denominator from being zero.
[0066] This invention also provides a primitive-level representation learning system for molecular graphs, comprising the following modules:
[0067] Diffusion initiation module: used to add noise and reconstruct the original molecular graph based on the graph diffusion model, calculate the edge reconstruction error, and divide the original molecular graph into multiple primitive subgraphs according to the edge reconstruction error to form a primitive subgraph set;
[0068] Dual-scale encoding module: used to construct atomic views and primitive views based on the original molecular graph and the set of primitive subgraphs, respectively, and use a graph neural network encoder to encode the atomic views and the primitive views respectively to obtain the atomic embedding matrix and the primitive embedding matrix;
[0069] Dual-view comparison module: used to construct positive and negative sample pairs based on the atomic view and the primitive view, and to optimize the atomic embedding matrix and the primitive embedding matrix using the Barlow twin dual-view comparison loss function to achieve cross-granularity representation alignment.
[0070] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the primitive-level representation learning method for molecular graphs as described above.
[0071] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the primitive-level representation learning method for molecular graphs as described above.
[0072] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the primitive-level representation learning method for molecular graphs as described above.
[0073] This invention provides a primitive-level representation learning method and system for molecular graphs. It adds noise and reconstructs the original molecular graph based on a graph diffusion model, calculates the edge reconstruction error, and divides the original molecular graph into multiple primitive subgraphs based on the edge reconstruction error, forming a primitive subgraph set. Based on the original molecular graph and the primitive subgraph set, atomic views and primitive views are constructed respectively, and a graph neural network encoder is used to encode the atomic views and primitive views respectively, obtaining atomic embedding matrices and primitive embedding matrices. Positive and negative sample pairs are constructed based on the atomic views and primitive views, and the Barlow twin dual-view contrastive loss function is used to optimize the atomic embedding matrices and primitive embedding matrices, achieving cross-granularity representation alignment. This invention uses a diffusion model for self-supervised extraction of molecular primitives and atomic-primitive dual-view alignment to solve the systemic defects of traditional methods in cross-granularity structure modeling, semantically guided contrastive learning, and multi-level representation fusion, significantly improving the semantic completeness and task generalization ability of molecular representations. Attached Figure Description
[0074] To more clearly illustrate the technical solutions in this 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 some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0075] Figure 1 This is a flowchart illustrating the primitive-level representation learning method for molecular graphs provided by this invention.
[0076] Figure 2 This is the overall framework of the MotiLa model provided by this invention.
[0077] Figure 3 This is an overall flowchart of the primitive-level representation learning method for molecular graphs provided by the present invention.
[0078] Figure 4 This is a schematic diagram of the structure of the molecular graph-oriented primitive-level representation learning system provided by the present invention.
[0079] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0080] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0081] Current mainstream molecular graph representation learning methods primarily rely on atomic-level graph convolutional models, such as GCN (Graph Convolutional Network), GIN (Graph Isomorphism Network), and MPNN (Message Passing Neural Network). These methods achieve information propagation through recursive aggregation of atomic adjacency structures and have achieved good results on multiple datasets. However, they generally suffer from the following limitations:
[0082] 1) Lack of structural abstraction ability: Atomic-level graph neural networks focus on local neighborhoods and have difficulty capturing larger-scale semantic structures, such as "functional substructures" or "structural motifs" such as benzene rings and ester groups.
[0083] 2) Limited generalization of contrastive learning: In recent years, graph contrastive learning (GCL) has been widely used for unsupervised graph representation learning. Methods such as GraphCL, JOAO, SimGRACE, and InfoGraph construct different graph views for comparison, but they are mostly based on random perturbations or graph transformations and lack modeling of the actual semantic substructure in molecules.
[0084] 3) Lack of hierarchical structure representation: Most existing methods are "single-level embeddings", which cannot simultaneously take into account the local chemical properties of molecular structures and macroscopic functional block features, resulting in limited performance of the model when generalizing across datasets and transferring across tasks.
[0085] In addition, the above methods take into account local structures to some extent, but either lack the materialized concept of "primitives" or fail to explicitly align the structural relationships between multi-granularity representation layers, making it difficult to comprehensively model the multi-level semantic features of molecules.
[0086] Therefore, there is still room for improvement in existing technologies for efficient and generalizable learning of molecular multi-granularity structure expression.
[0087] To address the problems of existing molecular graph representation learning methods, such as single structural granularity, poor generalization ability of contrastive learning, and lack of multi-level structural alignment mechanisms, this invention provides a primitive-level representation learning method and system for molecular graphs. This method enables the automatic extraction and encoding of significant primitives in molecules and constructs explicit structural alignment between atomic and primitive levels, thereby improving the model's performance stability and cross-structure generalization ability under multiple tasks.
[0088] The present invention will now be described in detail with reference to the accompanying drawings. The specific operation methods in the method embodiments can also be applied to the device embodiments or system embodiments. In the description of the present invention, unless otherwise stated, "at least one" includes one or more. "Multiple" refers to two or more. For example, at least one of A, B, and C includes: A existing alone, B existing alone, A and B existing simultaneously, A and C existing simultaneously, B and C existing simultaneously, and A, B, and C existing simultaneously. In the present invention, " / " means "or". For example, A / B can mean A or B. "And / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone.
[0089] In some specific embodiments of the present invention, such as Figure 1 As shown, this scheme provides a primitive-level representation learning method for molecular graphs, including:
[0090] Step 100: Based on the graph diffusion model, noise is added to and reconstructed on the original molecular graph, the edge reconstruction error is calculated, and the original molecular graph is divided into multiple primitive subgraphs according to the edge reconstruction error to form a set of primitive subgraphs.
[0091] Step 200: Based on the original molecular graph and the set of primitive subgraphs, construct atomic views and primitive views respectively, and use a graph neural network encoder to encode the atomic views and primitive views respectively to obtain atomic embedding matrices and primitive embedding matrices; Step 300: Based on the atomic views and primitive views, construct positive and negative sample pairs, and use the Barlow twin dual-view contrast loss function to optimize the atomic embedding matrices and primitive embedding matrices to achieve cross-granularity representation alignment.
[0092] It should be noted that existing molecular graph neural networks and contrastive learning techniques struggle to effectively utilize semantic primitives within molecules, lack granularity coordination mechanisms, and suffer from scattered training targets, resulting in limited performance when handling complex structures and achieving high-precision generalization prediction tasks. Therefore, there is an urgent need for a molecular graph representation method that simultaneously possesses primitive extraction capabilities and multi-granularity alignment mechanisms to address these core issues.
[0093] Therefore, this invention employs a graph diffusion model noise-reconstruction mechanism to automatically partition the original molecular graph into a set of primitive subgraphs, obtaining diffusion-generated primitives. A graph neural network is used to encode the atom view (original graph) and the primitive view (subgraph set), outputting an embedding matrix to achieve dual-view encoding. A mapping between atoms and their respective primitives is established. Sample pairs are constructed based on the atom / primitive views, and the embedding is optimized using Barlow twin loss to achieve dual-view comparative learning. Through a primitive-aware method for molecular graph representation learning, an atomic-level and primitive-level dual-granularity information fusion mechanism is adopted. Primitive self-supervised extraction is achieved through graph diffusion operations, and combined with the primitive-atom dual-view comparative learning objective, cross-granularity structural consistency modeling is realized.
[0094] This invention automatically extracts primitives through a diffusion model, overcoming the semantic limitations of atomic-level graph neural networks and solving the structural discontinuity problem; it unifies the representation space of atoms and primitives through dual-view encoding and alignment mechanisms, achieving multi-granularity collaboration; and structure-guided contrastive learning avoids semantic distortion caused by random perturbations, thereby improving generalization ability.
[0095] In some possible embodiments of the present invention, the step of adding noise and reconstructing the original molecular graph based on the graph diffusion model, calculating the edge reconstruction error, and dividing the original molecular graph into multiple primitive subgraphs according to the edge reconstruction error specifically includes:
[0096] The original molecular graph is subjected to forward noise addition and reverse reconstruction using a pre-trained graph diffusion model, and the results for each edge are calculated. Reconstruction error Construct the edge reconstruction error matrix ,in, ;
[0097] Reconstruct the error matrix of the edges Convert to edge weight matrix The conversion formula is: ,in, This refers to temperature hyperparameters.
[0098] Based on the edge weight matrix The original molecular graph is divided into multiple connected subgraphs using a spectral clustering algorithm.
[0099] For each cluster, check whether its induced subgraph is connected. If there are multiple connected components, treat each connected component as an independent primitive.
[0100] The final result is a set of primitive subgraphs, where each atomic node uniquely belongs to a primitive. Specifically, this embodiment provides an implementation method for determining primitive subgraphs. This involves calculating the edge weight matrix after diffusion, where edge weights with smaller reconstruction errors are higher. The edge weight matrix is then subjected to Laplace eigendecomposition, and the first... Each feature vector is clustered, with connected nodes grouped into the same primitive. Clustering automatically identifies highly cohesive subgraphs (such as benzene rings) without requiring a predefined primitive library, enabling data-driven primitive generation. Hard partitioning using a spectral clustering algorithm avoids overlapping primitives, simplifying alignment logic (which can be extended to soft attribution) and ensuring unique atom attribution. In some possible embodiments of this invention, the graph diffusion model is trained by minimizing a diffusion reconstruction loss function. The construction process of the diffusion reconstruction loss function specifically includes: processing the original molecular graph... Add forward noise and iteratively perturb the adjacency matrix according to the noise scheduling coefficient. , No. adjacency matrix of steps Represented as:
[0101] (1);
[0102] (2),
[0103] in, Indicates a time step. This is the adjacency matrix in the original molecular graph. This is the adjacency matrix after adding noise; This is the node feature matrix, used to characterize the atomic attribute encoding. It is Gaussian noise. The noise dispatch coefficient is calculated using the following formula:
[0104] (3),
[0105] in, , These represent the early time steps. Minimum noise introduced and final time step Maximum noise level introduced; via graph neural network encoder With multilayer perceptron encoder Predicting the first T Step noise item And reconstruct the adjacency matrix:
[0106] (4);
[0107] in, The reconstructed adjacency matrix, , The calculation formula is:
[0108] (5);
[0109] (6);
[0110] The diffusion reconstruction loss function is defined as:
[0111] (7).
[0112] Specifically, this embodiment provides an implementation of a graph diffusion model. Through forward noise addition, backward reconstruction, and loss function construction, the noise reconstruction process forces the model to learn local dense structures of molecules (such as benzene rings). Subgraphs with small errors are the primitives, realizing the self-supervised generation of primitives. The diffusion loss serves as a self-supervised signal, replacing traditional expert rules and eliminating the need for manual annotation.
[0113] In some possible embodiments of the present invention, the step of encoding the atomic view and the primitive view using a graph neural network encoder specifically includes:
[0114] Using a graph neural network encoder For information propagation in the atomic view, the node update formula is:
[0115] (8);
[0116] in, For nodes In the The output feature vector of the layer, Indicates the index of the current layer. , It is the total number of network layers. Represents a node The neighboring nodes, Representing neighboring nodes In the The feature vector of the layer, Represents a non-linear activation function. Indicates the first The trainable weight matrix of the layer, Indicates the first The trainable bias vectors of the layer Represents a node The set of neighboring nodes;
[0117] In the weight matrix The graph neural network encoder Perform pruning to generate the pruned weight matrix. :
[0118] (9),
[0119] in, The retention probability is The mask matrix;
[0120] Using a pruned graph neural network encoder Encode the primitive view to obtain the feature representation of the nodes in the primitive view. The node update formula is:
[0121] (10)
[0122] in, This represents the weight matrix calculated using the pruned weight matrix. Layer nodes Features This represents the weight matrix calculated using the pruned weight matrix. Layer neighbor nodes The characteristic of this is the approximate representation under sparsification constraints;
[0123] Graph-level pooling is performed on the updated atomic views and primitive views to obtain the atomic embedding matrix. and primitive embedding matrix :
[0124] (11);
[0125] (12),
[0126] in, This is the set of all atomic nodes in the original molecular graph after node updates. For set One of the atomic nodes, atomic nodes The final layer outputs a feature vector. This represents the set of all primitive nodes in the updated primitive view. Represents a set One of the primitive nodes, Represents a node The final layer outputs a feature vector.
[0127] Specifically, this embodiment provides an implementation method for encoding the atomic view and the primitive view. Atom embedding is generated by aggregating neighbor information through a standard graph neural network, and a mask is applied to the weights (preserving probabilities). ), generate pruning weights, update nodes using a pruned graph neural network, and after pruning, the th Floor Neighbors Features (approximate representation under sparsity constraints). Atomic embeddings are generated by averaging across all graph nodes, and primitive embeddings are obtained by averaging across primitive nodes, thereby realizing the construction of the embedding matrix.
[0128] The above-described settings in this embodiment, by introducing structural inductive bias and pruning, force the graph neural network to focus on key connections (such as chemical bonds), thereby improving the robustness of primitive recognition; and by using dual-scale feature decoupling: atomic embedding matrix Preserving atomic details, primitive embedding matrix Abstract functional primitives provide the foundation for alignment.
[0129] In some possible embodiments of the present invention, the graph neural network encoder is a graph isomorphic network (GIN), and the node update formula is:
[0130] (13)
[0131] in, This represents a multilayer perceptron. Indicates learnable parameters, For nodes In the The output feature vector of the layer, Indicates the index of the current layer. , It is the total number of network layers. Represents a node The neighboring nodes, Representing neighboring nodes In the The feature vector of the layer, Represents a node The set of neighboring nodes.
[0132] Specifically, this embodiment provides another implementation of a graph neural network encoder, employing a graph isomorphic network (GIN) node update formula. GIN utilizes a multilayer perceptron and... Parametric aggregation functions are better suited to the isomorphic properties of molecular graphs than GCN / GAT, enhancing structural discrimination; and directly applicable graph neural networks improve the accuracy of primitive partitioning.
[0133] In possible embodiments, the graph neural network encoder may include one or more combinations of GCN, GIN, and GAT.
[0134] In some possible embodiments of the present invention, the construction of positive and negative sample pairs based on atomic views and primitive views specifically includes:
[0135] For each atomic node Select the atomic node Belonging to the primitive Constitute positive samples ;
[0136] Randomly select nodes from other atomic nodes. , Constructing negative sample pairs ;
[0137] Randomly select primitive nodes from other primitives. , constitute negative sample pairs .
[0138] Specifically, this embodiment provides an implementation method for constructing positive and negative sample pairs, where the positive sample is an atom. and its constituent elements Positive samples Negative samples are atomic-level negative sample pairs. and primitive-level negative sample pairs By constructing a structure-aware contrast, positive samples anchor primitive affiliation relationships, while negative samples enhance cross-primitive discriminability. Compared to the random perturbations of GraphCL, this method preserves chemical rationality and avoids semantic corruption.
[0139] In some possible embodiments of the present invention, the Barlow twin dual-view contrast loss function is specifically as follows:
[0140] (14)
[0141] in, This represents the total two-scale contrast loss. For the contrast loss of atomic views, For the contrast loss of the primitive view, As a weighting factor, , The calculation formula is:
[0142] (15);
[0143] (16)
[0144] in, This represents the dimension of the embedding vector. Cross-batch correlation matrix for atomic views The elements on the diagonal are used to represent the atomic view, the first... Each dimension of feature and its correlation with different samples Cross-batch correlation matrix for atomic views Off-diagonal elements are used to represent the atomic view, the first... The first dimension feature and the first Redundancy between features in each dimension Cross-batch correlation matrix for primitive view The elements on the diagonal are used to represent the primitive view, specifically the first element. Each dimension of feature and its correlation with different samples Cross-batch correlation matrix for primitive view Off-diagonal elements are used to represent the primitive view, specifically the element that is the first element. The first dimension feature and the first Redundancy between features in each dimension.
[0145] Specifically, this embodiment provides an implementation of the Barlow twin dual-view contrastive loss function, including atomic embedding autocorrelation and redundancy in different dimensions, to maximize information compression: It forces feature dimensions to be independent and highly discriminative; by jointly optimizing the atomic / primitive views, it solves the problem of scattered training targets and achieves unified comparison at multiple granularities.
[0146] In some possible embodiments of the present invention , , , It is obtained through the following formula:
[0147] (17);
[0148] (18);
[0149] (19);
[0150] (20);
[0151] (twenty one);
[0152] (twenty two);
[0153] in, 、 These represent the cross-batch correlation matrices of the atomic views and the primitive views, respectively. Represents the atomic embedding matrix No. 3D feature vectors express The mean, express standard deviation Indicates the number of molecular maps in the batch. The primitive embedding matrix represents the first... 3D eigenvectors express The mean, express standard deviation Indicates the number of primitive sets in the batch. , These represent the normalized atom embedding matrix and primitive embedding matrix, respectively. It is a small constant used to prevent the denominator from being zero.
[0154] Specifically, this embodiment provides an implementation method that eliminates the influence of dimensions through standardization. 、 To make different molecular representations comparable, a correlation matrix is constructed. 、 and , Measure the internal consistency of atomic embedding and primitive embedding.
[0155] This invention proposes a primitive-aware method for molecular graph representation learning. It adopts a dual-granularity information fusion mechanism of atomic-level and motif-level, realizes self-supervised primitive extraction through graph diffusion operation, and combines primitive-atomic dual-view comparison learning target to achieve cross-granularity structural consistency modeling.
[0156] In some specific embodiments of the present invention, such as Figure 2 As shown, Figure 2This paper presents the overall framework of the MotiLa model proposed in this invention, which consists of three main stages: diffusion initiation, dual-scale training, and task-specific fine-tuning. Specifically, the diffusion module generates and reconstructs the molecular graph, the dual-scale module extracts and aligns global and local features, and the fine-tuning stage applies the pre-trained representation to a specific molecular property prediction task.
[0157] During the diffusion initiation phase, noise is added to the molecular graph through a series of forward processes, transforming it from the original graph. Evolved into a high-noise graph Then, through a parameterized backpropagation process... Achieving noise reduction and reconstruction. This process involves... The model learns the denoising path step by step, thereby reconstructing the original molecular structure.
[0158] During the dual-scale training phase, after pruning The model also considers the global structural representation of molecules. ) and local functional groups ( ), and respectively through two graph neural network encoders and after pruning Extraction. Graph structural information is further integrated through a multilayer perceptron, and Barlow twin-style contrastive loss is used to optimize global and local representations, ensuring that the model can effectively capture both structural and functional semantics.
[0159] Finally, in the task-specific fine-tuning stage, the pre-trained representations are used for downstream tasks, such as hepatotoxicity prediction and solubility assessment. This stage introduces real labels and fine-tunes parameters using classification or regression heads to achieve highly targeted molecular property predictions.
[0160] This framework supports parameter sharing and feature alignment between different molecular graphs, enhancing the model's generalization ability. The overall structural design emphasizes a modeling philosophy that integrates structure awareness and function orientation, providing a systematic solution for efficiently learning the properties of complex molecules.
[0161] The following is in conjunction with the appendix Figure 2 The overall operation process of the MotiLa model that implements the above method provided by the present invention will be described in detail.
[0162] First, in the diffusion initiation phase:
[0163] This stage involves constructing a diffusion generation model, introducing controllable Gaussian noise into the graph structure, and achieving reverse reconstruction of the original graph. Specifically, this includes:
[0164] Step 1: Noise Addition Process
[0165] Given an initial graph The model at each time step The structure of the inner iterative perturbation graph. Step diagram representation The adjacency matrix is updated as follows:
[0166] , ,
[0167] in, For noise dispatch coefficient, It is Gaussian noise. The calculation formula is as follows:
[0168] .
[0169] Step 2, Noise Removal Process:
[0170] Building a graph neural network encoder With multilayer perceptron encoder Used to predict the T noise term of step :
[0171] .
[0172] One-time adjacency matrix reconstruction is performed using reparameterization techniques to obtain... :
[0173] ,
[0174] in, .
[0175] Step 3, Training Objective: The ultimate goal is to recover the original graph structure. The loss function is as follows:
[0176] .
[0177] Furthermore, in the dual-scale training phase:
[0178] This stage comprises two parts: network encoding and representation optimization, further enhancing the model's ability to learn structural features and motifs, specifically:
[0179] Step 1: Dual-scale network coding:
[0180] Using graph neural network models To propagate graph structure information, the node update method is as follows:
[0181] ;
[0182] .
[0183] To implement model pruning, in the weight matrix The graph neural network encoder Perform a random mask operation to generate :
[0184] .
[0185] in, The retention probability is p The mask matrix. The formula for updating the pruned nodes is:
[0186] .
[0187] Step 2: Dual-scale representation optimization:
[0188] After obtaining the node representations, the overall graph representation is constructed using the graph and subgraph structures respectively. and motif :
[0189] ;
[0190] .
[0191] The process of constructing positive and negative sample pairs based on atomic views and primitive views includes:
[0192] For each atomic node Select the atomic node Belonging primitive node Constitute positive samples ;
[0193] For each atomic node Randomly select the embedding vectors of other atomic nodes As negative sample pairs ;
[0194] For each primitive node Randomly select the embedding vectors of other primitive nodes. As negative sample pairs .
[0195] The Barlow twin dual-view contrast loss function is used for training, and the loss is defined as follows:
[0196] ,
[0197] in, This represents the total two-scale contrast loss. For the contrast loss of atomic views, For the contrast loss of the primitive view, This is the weighting factor.
[0198] The graph-level loss and the primitive-level loss are designed using Barlow twin loss respectively, i.e. , The calculation formula is:
[0199] ;
[0200] ,
[0201] in, This represents the dimension of the embedding vector. Cross-batch correlation matrix for atomic views The elements on the diagonal are used to represent the atomic view, the first... Each dimension of feature and its correlation with different samples Cross-batch correlation matrix for atomic views Off-diagonal elements are used to represent the atomic view, the first... The first dimension feature and the first Redundancy between features in each dimension Cross-batch correlation matrix for primitive view The elements on the diagonal are used to represent the primitive view, specifically the first element. Each dimension of feature and its correlation with different samples Cross-batch correlation matrix for primitive view Off-diagonal elements are used to represent the primitive view, specifically the element that is the first element. The first dimension feature and the first Redundancy between features in each dimension.
[0202] Among them, the cross-batch correlation matrix of atomic views cross-batch correlation matrix of primitive views The calculation is as follows:
[0203] ;
[0204] ;
[0205] in, Indicates the number of molecular maps in the batch. Indicates the number of primitive sets in the batch. , These represent the normalized atom embedding matrix and primitive embedding matrix, respectively.
[0206] ,
[0207] ;
[0208] ;
[0209] ,
[0210] in, Represents the atomic embedding matrix No. 3D feature vectors express The mean, express standard deviation Represents the primitive embedding matrix No. 3D feature vectors express The mean, express standard deviation It is a small constant used to prevent the denominator from being zero.
[0211] During the task fine-tuning phase:
[0212] The pre-trained model is then applied to specific molecular property prediction tasks, including:
[0213] The first category is classified tasks:
[0214] For the new map The model outputs a predicted vector:
[0215] (twenty three);
[0216] And cross-entropy is used as the classification loss:
[0217] (twenty four).
[0218] The second type is regression tasks:
[0219] The predicted value is:
[0220] (25);
[0221] The loss is the mean squared error:
[0222] (26).
[0223] In another specific embodiment of the present invention, to more clearly and intuitively illustrate the technical solution and overall structure of the present invention, by... Figure 3 The method steps and module relationships of the present invention are summarized below. Figure 3The document sequentially demonstrates the core modules, including original molecular graph input, primitive graph generation, dual-graph neural network encoder learning, cross-layer consistency alignment, and dual-view comparison target training, as well as the data flow and logical relationships between these modules. Specifically, it includes the following steps:
[0224] Step 310: Input molecular diagram structure: Construct a standard molecular diagram with atoms as nodes and chemical bonds as edges. G=(V,E) ;
[0225] Step 320, Graph Diffusion Processing Module: Calculate edge diffusion weights to form a weighted graph structure for primitive partitioning;
[0226] Step 330, Molecular Generator: Divide the molecular graph into multiple local subgraphs to form a molecular structure;
[0227] Step 340, Atomic Graph and Primitive Graph Encoder: Embed the two granularity structures using independent graph neural networks respectively;
[0228] Step 350, Dual-view Comparison Learning Module: Use graph augmentation to construct multiple sets of graph-view pairs for comparative learning training;
[0229] Step 360, Structural Representation Output: Output a structure-aware and semantically aligned graph embedding vector, which can be used for molecular property prediction tasks.
[0230] It is important to note that although graph neural networks (GNNs) have been widely used in the field of molecular graph representation learning, existing techniques still have significant shortcomings in areas such as structural granularity modeling, multi-level representation alignment, and contrastive learning generalization ability. These shortcomings are mainly manifested in the following aspects:
[0231] Defect 1: The structural modeling granularity is too limited, making it impossible to explicitly express semantic substructures.
[0232] Current mainstream graph neural network methods (such as GCN, GIN, MPNN, etc.) mainly perform feature aggregation and graph encoding at the atomic level. While this approach can learn information from local neighborhoods, it struggles to accurately identify and represent functional motifs with biological significance, such as benzene rings, carboxyl groups, and ester bonds. Since these higher-order structures often determine the physicochemical properties and reactivity of molecules, atomic-level encoding lacks the necessary abstraction capabilities, limiting the model's expressive depth and task performance.
[0233] Defect 2: Lack of structural semantic guidance in graph contrast learning, resulting in insufficient generalization ability.
[0234] In recent years, widely adopted graph contrastive learning methods (such as GraphCL, JOAO, and SimGRACE) largely rely on random graph view transformations (such as node deletion, edge permutation, and feature perturbation) to construct positive and negative sample pairs. These enhancement methods lack specificity for structural semantics, may compromise chemical rationality, and cause the model to learn contrastive features that lack actual semantic meaning, thus reducing its generalization and transfer capabilities for complex molecular structures.
[0235] Defect 3: Multi-granularity information fusion lacks an explicit mechanism, making it difficult to establish alignment between local and global aspects.
[0236] A few methods have attempted to implement multi-level structural representations using subgraphs or graph pooling (such as DiffPool and InfoGraph), but most have failed to establish a clear semantic correspondence mechanism between the atomic and primitive levels, resulting in information duplication or expression gaps in the fused representation. The inability to form clear alignment paths between structural embeddings affects the stability and interpretability of downstream tasks.
[0237] Defect 4: Lack of a unified training objective for representations of different granularities, resulting in scattered learning objectives.
[0238] In existing methods, multi-granularity structures (such as the whole graph, subgraphs, and nodes) are often optimized using independent objective functions during the training phase, lacking a unified information transfer and collaboration mechanism. This approach results in weak correlation between the embedding representations at different levels, making it difficult to form a unified discrimination space.
[0239] To address the aforementioned shortcomings of existing technologies, the present invention provides a primitive-level representation learning method for molecular graphs, aiming to solve the following key technical problems:
[0240] How to automatically extract semantically meaningful primitives from molecular diagrams and encode them without relying on expert annotation;
[0241] How to construct a contrastive learning objective with structural consistency so that the model can enhance the discriminativeness and generalization ability among multi-granular representations in an unsupervised manner;
[0242] How can the above mechanisms be made compatible with existing graph neural network architectures while maintaining efficient, transferable, and scalable training and inference capabilities?
[0243] By solving the above-mentioned technical problems, the present invention can significantly improve the semantic expression ability of molecular representation and provide more structure-aware feature inputs for tasks such as molecular property prediction, structure analysis, and drug screening.
[0244] In view of this, the present invention provides a self-supervised primitive extraction method based on graph diffusion mechanism. It utilizes an edge diffusion weight modeling strategy to automatically extract high-density local subgraphs from molecular graphs under unlabeled conditions and define them as primitives (motifs). This method requires no manual annotation and has a high degree of automation and structure awareness.
[0245] A dual-view construction and explicit alignment mechanism of atomic graphs and structural primitive graphs is proposed. Based on the atomic graph, a structural primitive graph is generated by graph partitioning, so that each atom establishes a corresponding mapping with its corresponding primitive, thereby realizing collaborative learning of structural consistency.
[0246] By designing a dual-view graph neural network encoder and a cross-layer consistency loss function, independent graph neural network encoders are used for atomic graphs and primitive graphs respectively. At the same time, the cross-layer consistency regularization term forces the alignment of their embedded representations, thereby improving the model's multi-granularity feature fusion capability.
[0247] By designing a cross-comparison learning objective function between atomic graphs and primitive graphs, this invention constructs a cross-comparison loss function based on multi-granularity structural views, guiding the model to automatically learn a structurally discriminative embedding space during unsupervised training.
[0248] A multi-loss joint optimization mechanism for the overall training objective is proposed, which introduces graph diffusion modeling loss, intra-view contrast loss and inter-view contrast loss to form a joint optimization objective, thereby synergistically improving the robustness and generalization ability of structural representation.
[0249] Through the flexible and scalable design of the graph partitioning module, the primitive extraction process in this method can be replaced by various methods such as graph clustering, spectral clustering, and attention aggregation, and has configurability and task adaptability.
[0250] Furthermore, the proposed method achieves compatibility with existing graph neural network architectures. The proposed solution is compatible with existing graph neural network module structures such as GCN, GIN, and GAT, and can be accessed without modifying the main network framework, making the invention applicable to various industrial task scenarios.
[0251] Through the above-described configuration of this invention, the following beneficial effects are achieved: Compared with existing molecular graph representation learning techniques based on graph neural networks, the molecular primitive representation learning method based on molecular graph diffusion and dual-scale alignment proposed in this invention achieves significant improvements in multiple aspects, including structural expressive power, contrastive generalization performance, cross-task adaptability, and interpretability. Specifically, this includes:
[0252] Effect 1: Enhances the hierarchy and semantic integrity of structural expression.
[0253] This invention automatically extracts high-density structural regions through a graph diffusion mechanism to form a data-driven motif graph representation, effectively compensating for the lack of expression in functional motif recognition in traditional atomic-level graph neural networks;
[0254] By aligning atomic diagrams with primitive diagrams, the model can simultaneously capture microscopic atomic information and macroscopic functional primitive information, thereby enhancing the hierarchical perception capability of structural embedding.
[0255] On real molecular graph data (such as Tox21, HIV, ZINC, etc.), the model can accurately capture important structural modules such as benzene rings, carboxyl groups, and ester chains, significantly improving the performance of downstream tasks.
[0256] Effect 2: Improves the discriminative ability and generalization performance under unsupervised contrastive learning.
[0257] This invention introduces a dual-view comparison mechanism and designs a cross-granularity structural consistency loss function to encourage the model to learn highly discriminative and semantically clear structural representations even on unlabeled data.
[0258] Experimental results show that, without using any annotations, the proposed method still outperforms models trained using methods such as GraphCL and JOAO in multiple downstream tasks, achieving improvements of 2% to 4% in ROC-AUC and RMSE metrics, respectively.
[0259] The multi-granularity comparison method significantly enhances the model's robustness to distribution changes such as graph perturbations, local missing data, and structural transformations.
[0260] Effect 3: Enhances the model's transferability and task adaptability.
[0261] Thanks to cross-layer embedding alignment and dual-scale feature fusion, the graph representation constructed in this invention can be flexibly applied to different tasks such as classification, regression, and retrieval.
[0262] Experiments show that when transferring from pre-training tasks (such as structural comparison) to downstream toxicity prediction or efficacy evaluation, the fine-tuned model can achieve excellent performance in just a few training cycles, demonstrating good transfer efficiency and convergence speed.
[0263] Effect 4: Improves structural interpretability and model transparency
[0264] Unlike black-box graph neural networks, this invention explicitly divides primitives so that each prediction result can be mapped to a specific combination of primitives, making it easier for researchers or medicinal chemistry experts to understand the reasons for the prediction.
[0265] For example, in HIV activity prediction tasks, the model shows high activation of certain nitrogen-containing heterocyclic motifs, which is consistent with the known pharmacological structure-activity relationship and has strong structural interpretability.
[0266] Effect 5: Efficient computational structure and controllable training process.
[0267] The proposed dual-graph modeling scheme has the ability to perform graph partitioning and embedding in parallel, and its overall computational cost is similar to that of traditional graph neural networks. It can run on mainstream GPU devices.
[0268] It does not rely on large-scale graph traversal or complex generative networks, resulting in more stable training and suitability for industrial deployment and large-scale structure screening.
[0269] In summary, this invention has significant innovation in structural modeling mechanism, and is superior to existing technologies in terms of expressive power, generalization performance, transferability and interpretability, and has outstanding technical application value and industrial transformation potential.
[0270] In some specific embodiments of the present invention, such as Figure 4 As shown, this scheme provides a primitive-level representation learning system for molecular graphs, including:
[0271] Diffusion initiation module 41: used to add noise and reconstruct the original molecular graph based on the graph diffusion model, calculate the edge reconstruction error, and divide the original molecular graph into multiple primitive subgraphs according to the edge reconstruction error to form a primitive subgraph set;
[0272] Dual-scale encoding module 42: is used to construct an atomic view and a primitive view based on the original molecular graph and the set of primitive subgraphs, respectively, and to encode the atomic view and the primitive view using a graph neural network encoder to obtain an atomic embedding matrix and a primitive embedding matrix.
[0273] Dual-view comparison module 43: used to construct positive and negative sample pairs based on the atomic view and the primitive view, and to optimize the atomic embedding matrix and the primitive embedding matrix using the Barlow twin dual-view comparison loss function to achieve cross-granularity representation alignment.
[0274] The molecular graph-oriented primitive-level representation learning system provided in this embodiment of the invention has a similar implementation principle and beneficial effects to the molecular graph-oriented primitive-level representation learning method shown in the above embodiments. Please refer to the implementation principle and beneficial effects of the molecular graph-oriented primitive-level representation learning method shown in the above embodiments, which will not be repeated here.
[0275] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5As shown, the electronic device may include a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a primitive-level representation learning method for molecular graphs. This method includes: adding noise and reconstructing the original molecular graph based on a graph diffusion model, calculating the edge reconstruction error, and dividing the original molecular graph into multiple primitive subgraphs according to the edge reconstruction error to form a primitive subgraph set; constructing an atomic view and a primitive view based on the original molecular graph and the primitive subgraph set, and encoding the atomic view and the primitive view using a graph neural network encoder to obtain an atomic embedding matrix and a primitive embedding matrix; constructing positive and negative sample pairs based on the atomic view and the primitive view, and optimizing the atomic embedding matrix and the primitive embedding matrix using a Barlow twin dual-view contrast loss function to achieve cross-granularity representation alignment.
[0276] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a 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 several 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 described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0277] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the primitive-level representation learning method for molecular graphs provided by the above methods. The method includes: adding noise and reconstructing the original molecular graph based on a graph diffusion model, calculating the edge reconstruction error, and dividing the original molecular graph into multiple primitive subgraphs according to the edge reconstruction error to form a primitive subgraph set; constructing an atomic view and a primitive view based on the original molecular graph and the primitive subgraph set, and encoding the atomic view and the primitive view respectively using a graph neural network encoder to obtain an atomic embedding matrix and a primitive embedding matrix; constructing positive and negative sample pairs based on the atomic view and the primitive view, and optimizing the atomic embedding matrix and the primitive embedding matrix using a Barlow twin dual-view contrast loss function to achieve cross-granularity representation alignment.
[0278] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements a primitive-level representation learning method for molecular graphs provided by the methods described above. This method includes: adding noise and reconstructing the original molecular graph based on a graph diffusion model, calculating the edge reconstruction error, and dividing the original molecular graph into multiple primitive subgraphs according to the edge reconstruction error to form a primitive subgraph set; constructing an atomic view and a primitive view based on the original molecular graph and the primitive subgraph set, and encoding the atomic view and the primitive view respectively using a graph neural network encoder to obtain an atomic embedding matrix and a primitive embedding matrix; constructing positive and negative sample pairs based on the atomic view and the primitive view, and optimizing the atomic embedding matrix and the primitive embedding matrix using a Barlow twin dual-view contrast loss function to achieve cross-granularity representation alignment.
[0279] The device embodiments described above are merely illustrative. The units described 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 modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0280] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0281] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A primitive-level representation learning method for molecular graphs, characterized in that, include: The original molecular graph is subjected to noise addition and reconstruction based on the graph diffusion model. The edge reconstruction error is calculated, and the original molecular graph is divided into multiple primitive subgraphs according to the edge reconstruction error, forming a set of primitive subgraphs. Based on the original molecular graph and the set of primitive subgraphs, atomic views and primitive views are constructed respectively, and graph neural network encoders are used to encode the atomic views and primitive views respectively to obtain atomic embedding matrices and primitive embedding matrices. Positive and negative sample pairs are constructed based on the atomic view and the primitive view. The Barlow twin dual-view contrast loss function is used to optimize the atomic embedding matrix and the primitive embedding matrix to achieve cross-granularity representation alignment.
2. The primitive-level representation learning method for molecular graphs according to claim 1, characterized in that, The method involves adding noise and reconstructing the original molecular graph based on a graph diffusion model, calculating the edge reconstruction error, and dividing the original molecular graph into multiple primitive subgraphs based on the edge reconstruction error. Specifically, this includes: The original molecular graph is subjected to forward noise addition and reverse reconstruction using a pre-trained graph diffusion model, and the results for each edge are calculated. Reconstruction error Construct the edge reconstruction error matrix ,in, ; Reconstruct the error matrix of the edges Convert to edge weight matrix The conversion formula is: , in, This refers to temperature hyperparameters. Based on the edge weight matrix The original molecular graph is divided into multiple connected subgraphs using a spectral clustering algorithm. For each cluster, check whether its induced subgraph is connected. If there are multiple connected components, treat each connected component as an independent structural primitive. The final result is a set of structural primitive subgraphs, in which each atomic node uniquely belongs to a structural primitive.
3. The primitive-level representation learning method for molecular graphs according to claim 2, characterized in that, The graph diffusion model is trained by minimizing the diffusion reconstruction loss function, and the construction process of the diffusion reconstruction loss function specifically includes: For the original molecular diagram Add forward noise and iteratively perturb the adjacency matrix according to the noise scheduling coefficient. , No. adjacency matrix of steps Represented as: ; in, , Indicates a time step. This is the adjacency matrix in the original molecular graph. This is the adjacency matrix after adding noise; This is the node feature matrix, used to characterize the atomic attribute encoding. It is Gaussian noise. The noise dispatch coefficient is calculated using the following formula: , in, , These represent the early time steps. Minimum noise introduced and final time step The maximum amount of noise introduced; Through graph neural network encoder With multilayer perceptron encoder Predicting the first Step noise item And reconstruct the adjacency matrix: , in, The reconstructed adjacency matrix, , The calculation formula is: ; ; The diffusion reconstruction loss function is defined as: 。 4. The primitive-level representation learning method for molecular graphs according to claim 3, characterized in that, The process of encoding the atomic view and the primitive view using a graph neural network encoder specifically includes: Using a graph neural network encoder For information propagation in the atomic view, the node update formula is: ; in, For nodes In the The output feature vector of the layer, Indicates the index of the current layer. , It is the total number of network layers. Represents a node The neighboring nodes, Representing neighboring nodes In the The feature vector of the layer, Represents a non-linear activation function. Indicates the first The trainable weight matrix of the layer, Indicates the first The trainable bias vectors of the layer. Represents a node The set of neighboring nodes; In the weight matrix The graph neural network encoder Perform random weight pruning to generate the pruned weight matrix. : , in, The retention probability is The mask matrix; Using a pruned encoder Encode the primitive view to obtain the feature representation of the nodes in the primitive view. The node update formula is: , in, This represents the weight matrix calculated using the pruned weight matrix. Layer nodes Features This represents the weight matrix calculated using the pruned weight matrix. Layer neighbor nodes The characteristic of this is the approximate representation under sparsification constraints; Graph-level pooling is performed on the updated atomic views and primitive views to obtain the atomic embedding matrix. and primitive embedding matrix : ; , in, This is the set of all atomic nodes in the original molecular graph after node updates. For set One of the atomic nodes, atomic nodes The final layer outputs a feature vector. This represents the set of all primitive nodes in the updated primitive view. Represents a set One of the primitive nodes, Represents primitive nodes The final layer outputs a feature vector.
5. The primitive-level representation learning method for molecular graphs according to claim 4, characterized in that, The graph neural network encoder is a graph isomorphic network, and the node update formula is: , in, This represents a multilayer perceptron. Indicates learnable parameters, For nodes In the The output feature vector of the layer, Indicates the index of the current layer. , It is the total number of network layers. Represents a node The neighboring nodes, Representing neighboring nodes In the The feature vector of the layer, Represents a node The set of neighboring nodes.
6. The primitive-level representation learning method for molecular graphs according to claim 4 or 5, characterized in that, The construction of positive and negative sample pairs based on atomic views and primitive views specifically includes: For each atomic node Select the atomic node Belonging primitive node Constitute positive samples ; Randomly select atomic nodes from other atomic nodes. , Constructing negative sample pairs ; Randomly select a primitive node from the other primitive nodes. , constitute negative sample pairs .
7. The primitive-level representation learning method for molecular graphs according to claim 6, characterized in that, The Barlow twin dual-view contrast loss function is specifically as follows: , in, This represents the total two-scale contrast loss. For the contrast loss of atomic views, For the contrast loss of the primitive view, As a weighting factor, , The calculation formula is: ; , in, This represents the dimension of the embedding vector. Cross-batch correlation matrix for atomic views The elements on the diagonal are used to represent the atomic view, the first... Each dimension of feature and its correlation with different samples Cross-batch correlation matrix for atomic views Off-diagonal elements are used to represent the atomic view, the first... The first dimension feature and the first Redundancy between features in each dimension Cross-batch correlation matrix for primitive view The elements on the diagonal are used to represent the primitive view, specifically the first element. Each dimension of feature and its correlation with different samples Cross-batch correlation matrix for primitive view Off-diagonal elements are used to represent the primitive view, specifically the element that is the first element. The first dimension feature and the first Redundancy between features in each dimension.
8. The primitive-level representation learning method for molecular graphs according to claim 7, characterized in that, , , , It is obtained through the following formula: ; ; ; ; ; ; in, , These represent the cross-batch correlation matrices of the atomic views and the primitive views, respectively. Represents the atomic embedding matrix No. 3D feature vectors express The mean, express standard deviation Indicates the number of molecular maps in the batch. Represents the primitive embedding matrix No. 3D feature vectors express The mean, express standard deviation Indicates the number of primitive sets in the batch. , These represent the normalized atom embedding matrix and primitive embedding matrix, respectively. It is a small constant used to prevent the denominator from being zero.
9. A primitive-level representation learning system for molecular graphs, characterized in that, include: Diffusion initiation module: used to add noise and reconstruct the original molecular graph based on the graph diffusion model, calculate the edge reconstruction error, and divide the original molecular graph into multiple primitive subgraphs according to the edge reconstruction error to form a primitive subgraph set; Dual-scale encoding module: used to construct atomic views and primitive views based on the original molecular graph and the set of primitive subgraphs, respectively, and use a graph neural network encoder to encode the atomic views and the primitive views respectively to obtain the atomic embedding matrix and the primitive embedding matrix; Dual-view comparison module: used to construct positive and negative sample pairs based on the atomic view and the primitive view, and to optimize the atomic embedding matrix and the primitive embedding matrix using the Barlow twin dual-view comparison loss function to achieve cross-granularity representation alignment.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the primitive-level representation learning method for molecular graphs as described in any one of claims 1 to 8.