1. Introduction
Molecular property prediction is a critical task in drug discovery, pharmacology, and chemical biology, and accurate computational models can substantially reduce the cost and time associated with experimental screening [
1,
2,
3]. Graph neural networks (GNNs) are widely used for this purpose because molecules can be naturally represented as graphs, with atoms as nodes and chemical bonds as edges [
4,
5]. Graph convolutional networks (GCNs) [
4], message passing neural networks (MPNNs) [
6], graph isomorphism networks (GINs) [
5], AttentiveFP [
7], GPS [
8], and DeeperGCN [
9] have progressively improved molecular representation learning through expressive message passing, attention, and global-context modeling.
Despite these advances, conventional atom-level GNNs primarily model local atom–bond connectivity and may not explicitly capture the hierarchical organization of molecules. Chemically relevant information can arise at multiple structural levels, including functional groups, recurring substructures, motifs, and molecular scaffolds. Accordingly, recent studies have incorporated semantic information [
10], molecular tokenization [
11], domain-informed chemical signals [
12], geometric descriptors [
13], conformational information [
14], and three-dimensional molecular pretraining [
15]. Haghighatlari et al. [
16] further emphasized that successful chemical machine learning depends on the interplay among feature representation, data, and learning algorithms. These observations motivate molecular representations that capture chemically relevant structure beyond conventional atom-level connectivity.
Motif-based modeling provides one such strategy by organizing atoms into submolecular units and explicitly representing their relationships. This use of motifs should be distinguished from fragment-based drug discovery (FBDD), where small fragments primarily serve as starting points for compound identification and optimization through growing, merging, or linking strategies [
17]. In MSGRL, BRICS-derived substructures are instead treated as hierarchical representation units. Each substructure retains its internal atom–bond topology, while relationships among substructures are represented through a higher-level graph. Thus, the proposed approach does not assume that motifs are intrinsically superior to fragments; its distinction lies in how the resulting substructures are represented and learned.
Existing motif- and fragment-aware methods have explored related hierarchical representations from different perspectives. HimGNN [
18] jointly models atom- and motif-level representations, whereas FraGAT [
19] integrates atom-, fragment-, and molecular-level information through multi-scale graph attention. Among self-supervised approaches, MGSSL [
20] combines atom-level objectives with motif-generation tasks, HiMol [
21] learns node–motif–graph representations through multi-level self-supervision, and MICRO-Graph [
22] uses learned motifs to guide graph-to-subgraph contrastive learning. More recently, Long et al. [
23] represented BRICS-derived motifs using pretrained MoLFormer embeddings and modeled their interactions with a GATv2-based graph network for drug-induced QT prolongation. Together, these studies demonstrate the value of substructure-aware molecular modeling, but they focus primarily on supervised hierarchical integration, motif-aware pretraining, contrastive learning, or task-specific interactions among pre-encoded motifs.
A remaining question is how to learn the internal structure of individual motifs independently of downstream property labels while retaining the flexibility to learn task-specific relationships among motifs. In pretraining-based methods such as MGSSL [
20] and HiMol [
21], pretrained molecular encoders are subsequently adapted during downstream fine-tuning. By contrast, explicitly separating label-agnostic intra-motif structural learning from label-dependent inter-motif property learning remains less explored. Such a separation keeps the pretrained intra-motif encoder independent of downstream gradient updates while allowing the inter-motif network to adapt to individual tasks.
To address this problem, we propose MSGRL, a Motif-driven Self-supervised Graph Representation Learning framework for interpretable molecular property prediction. The central contribution of MSGRL is a decoupled hierarchical learning strategy that separates intra-motif structural representation learning from downstream inter-motif property learning. Each BRICS-derived motif is retained as an atom-based graph, and an MPNN-GRU encoder is pretrained using a variational motif graph autoencoder (VMGAE) that reconstructs its internal bond topology. The pretrained intra-motif encoder is then frozen, while the downstream module learns task-specific relationships over the motif graph and aggregates motif representations through attention-based pooling. This design preserves self-supervised intra-motif representations while allowing the inter-motif network and prediction head to adapt to individual molecular property tasks.
We evaluate MSGRL on eight MoleculeNet benchmark datasets [
24] covering classification and regression tasks. MSGRL achieves the highest ROC-AUC scores on all five evaluated classification datasets and the lowest RMSE on Lipophilicity, while its performance on ESOL and FreeSolv is more mixed. Ablation studies further examine the effects of encoder freezing, motif-based graph construction, and attention-based pooling. Motif-level attribution analyses provide additional qualitative and dataset-level evidence regarding the substructures emphasized by the model.
2. Results
2.1. Overall Framework
As illustrated in
Figure 1, MSGRL consists of three main components: an MPNN-GRU encoder, a VMGAE self-supervised pretraining module, and a downstream prediction module. Specifically, each molecule is first represented as a motif-based graph in which motif nodes are connected according to their shared atoms. Each motif is further represented as an atom-based graph that describes its internal atomic structure. The MPNN-GRU encoder operates on the atom-based graphs of individual motifs to learn atom-level representations, which form a motif-level feature matrix for each motif. The VMGAE module further optimizes these atom-level and motif-level representations through a variational graph autoencoding objective in a self-supervised manner. Finally, the downstream prediction module uses the frozen pretrained encoder to obtain motif-level feature matrices. Each matrix is first pooled into a motif vector. The resulting motif vectors are then propagated over the motif-based graph and aggregated through attention-based pooling to obtain a molecular-level representation.
2.2. Performance Comparison with Baseline Models
We compare MSGRL with representative molecular graph learning models, including general graph architectures (GCN-MPNN [
4], GIN-MPNN [
5], AttentiveFP [
7], GPS [
8], DeeperGCN [
9], VGAE [
25], and MetaGIN [
26]), motif- and fragment-aware methods (MICRO-Graph [
22], MGSSL [
20], HiMol [
21], HimGNN [
18], and FraGAT [
19]), and geometry- or semantic-aware models (GemNet [
27] and SCI [
10]).
As shown in
Table 1, MSGRL achieves the highest mean ROC-AUC on all five classification datasets and the lowest RMSE on Lipophilicity under the evaluated protocol. Two-sided Welch’s
t-tests with Holm correction show that MSGRL significantly outperforms the strongest competing baseline on BACE, BBBP, SIDER, Tox21, and Lipophilicity (
;
Supplementary Table S2). The difference on ClinTox is not statistically significant, whereas the strongest competing baseline significantly outperforms MSGRL on ESOL and FreeSolv.
Among the general-purpose GNN baselines, DeeperGCN and GPS show competitive performance on several datasets. However, these methods mainly operate on conventional molecular graph representations and do not explicitly incorporate motif-level inductive biases. For molecular property prediction, motif-level information can provide complementary structural priors beyond conventional atom-level connectivity.
Several motif- and subgraph-aware methods also show strong performance across the evaluated datasets. For example, FraGAT performs particularly well on BACE, BBBP, ClinTox, and Tox21, while HimGNN and HiMol show competitive results on several classification and regression benchmarks. MSGRL differs from these approaches by applying self-supervised pretraining to motif-specific atom-based graphs and keeping the pretrained intra-motif encoder fixed during downstream training. The motif-level predictor remains trainable and adapts to individual tasks.
MSGRL shows particularly strong performance on the classification benchmarks. For example, it achieves ROC-AUC values of 0.943 on SIDER and 0.947 on Tox21, outperforming the strongest competing baselines under the evaluated protocol. These results support the effectiveness of MSGRL for the evaluated multi-task classification settings. However, the present experiments do not isolate which specific dataset characteristics account for these improvements.
For regression tasks, MSGRL achieves the lowest RMSE of 0.438 on Lipophilicity, while its performance on ESOL and FreeSolv is more mixed. To complement the average RMSE values, we further report the maximum absolute prediction error for each regression dataset in
Supplementary Table S1 and present predicted-versus-ground-truth scatter plots and distribution comparisons in
Supplementary Figure S1. These analyses provide additional information on the largest observed prediction deviations and the agreement between predicted and experimental property distributions across the evaluated ranges. We note that this analysis does not constitute a formal activity-cliff evaluation, which would require explicitly identifying structurally similar molecular pairs with large property differences.
2.3. Ablation Study
To evaluate the contribution of the major design choices in MSGRL, we conduct ablation experiments across all eight datasets.
Figure 2 compares the full MSGRL model with four variants:
MSGRL with partial fine-tuning (PFT) keeps the atom embedding and the first four message-passing blocks of the VMGAE-pretrained MPNN-GRU encoder frozen, while fine-tuning only the final message-passing block and its associated normalization layer.
MSGRL without frozen encoder (w/o FE) fine-tunes the entire pretrained MPNN-GRU encoder together with the downstream prediction module.
MSGRL without motif-based graph construction (w/o M) bypasses motif extraction and motif-based graph construction and performs prediction directly on the conventional atom-level molecular graph.
MSGRL without all key components (w/o All) jointly removes the frozen-encoder strategy, motif-based graph construction, GRU-based message updating, and attention pooling, resulting in a simplified atom-level graph predictor.
Effect of freezing the pretrained encoder. To further examine the role of encoder freezing, we compare three downstream adaptation strategies: complete freezing in the full MSGRL model, partial fine-tuning (PFT), and full fine-tuning (w/o FE). In the PFT variant, the atom embedding and the first four message-passing blocks of the pretrained MPNN-GRU encoder remain frozen, while only the final message-passing block and its associated normalization layer are updated during downstream training. In the w/o FE variant, the entire pretrained encoder is fine-tuned together with the downstream prediction module.
As shown in
Figure 2, complete freezing consistently provides the strongest performance among the three strategies. For example, the ROC-AUC on SIDER decreases from 0.943 with complete freezing to 0.568 with partial fine-tuning and 0.544 with full fine-tuning. On Tox21, the corresponding values are 0.947, 0.752, and 0.754. Similar degradation is also observed on BACE, BBBP, and the regression benchmarks. These results indicate that, under the evaluated settings, updating the pretrained intra-motif encoder does not improve downstream performance. A possible explanation is that downstream optimization shifts the representations learned from the self-supervised intra-motif reconstruction objective toward task-specific patterns. Accordingly, keeping the pretrained encoder fixed provides a stable structural basis for subsequent inter-motif learning.
Effect of motif-based graph construction. To assess the contribution of the hierarchical motif representation, we compare MSGRL with the w/o M variant, which bypasses motif extraction and performs prediction directly on the conventional atom-level molecular graph. As shown in
Figure 2, removing motif-based graph construction consistently reduces performance. For example, the ROC-AUC decreases from 0.955 to 0.796 on BACE and from 0.972 to 0.925 on ClinTox. These results indicate that explicitly organizing molecular representations at the motif level provides complementary structural information beyond conventional atom-level connectivity.
Overall contribution of the key components. The w/o All variant jointly removes the frozen-encoder strategy, motif-based graph construction, GRU-based message updating, and attention pooling. This variant yields the weakest overall performance. Together with the individual ablations, these results show that the performance of MSGRL arises from the combined contributions of pretrained intra-motif representations and hierarchical motif-level downstream modeling rather than from a single component.
2.4. Effect of Graph-Level Pooling Modules
To examine how different graph-level readout strategies affect downstream prediction, we compare four pooling operations: attention, mean, max, and sum pooling. These pooling operations are applied to aggregate the motif-node representation matrix into a molecular-level representation
. The results are shown in
Figure 3.
Overall, attention-based pooling achieves the most stable performance across the eight datasets. For classification tasks, it obtains the best ROC-AUC scores on BACE and BBBP, reaching 0.955 and 0.962, respectively. For regression tasks, attention-based pooling achieves RMSE values of 0.438 on Lipophilicity and 1.939 on FreeSolv. These results indicate that adaptively weighting motif nodes is beneficial for molecular property prediction, especially when different motifs contribute unequally to the target property.
The advantage of attention-based pooling lies in its ability to assign task-dependent weights to motif-node representations. Unlike mean, max, and sum pooling, which aggregate all motif nodes using fixed rules, attention pooling can emphasize motifs that are more relevant to the prediction task. This property is particularly important for molecular graphs, where only a subset of functional groups or substructures may dominate a specific biological or physicochemical property. For example, sum pooling may overemphasize molecules with more motif nodes, while max pooling may retain only the most dominant local signal and ignore complementary motif-level information.
Nevertheless, simpler pooling operations also provide competitive results on some regression datasets, indicating that the advantage of attention pooling is not uniform across all tasks. Overall, attention-based pooling provides a flexible readout mechanism and shows the most stable performance across the evaluated datasets; it is therefore adopted as the default graph-level pooling strategy in MSGRL.
2.5. Motif-Level Visualization Case Study
To further examine the chemical interpretability of MSGRL, we select two structurally related compounds from the BACE dataset, BACE_598 and BACE_803. Here, these names correspond to the compound identifiers used in the dataset; the underscore and following number are integral parts of each identifier rather than subscripts. As shown in
Figure 4, each molecule is visualized from two complementary perspectives: its docked 3D binding pose in the BACE1 active site and its corresponding motif-level contribution map generated by MSGRL. This visualization strategy follows the drug–target interaction visualization scheme used in DeepDTAGen [
28]. By jointly examining the binding conformation and motif-level attribution, we aim to assess whether the motif importance estimated by MSGRL is consistent with the local chemical environment of the ligand in the catalytic pocket.
The 3D binding poses are visualized using PyMOL (version 3.0.0) [
29], and docking scores are obtained using AutoDock Vina (version 1.2.5) [
30]. A more negative docking score indicates a more favorable predicted binding conformation. In parallel, MSGRL produces a signed motif-level contribution score
for each motif, where
denotes the weight vector of the prediction head. Motifs with
are selected for visualization. In the 2D molecular contribution maps, selected motifs are highlighted using semi-transparent ellipses: blue denotes a positive contribution to the predicted active class, whereas orange denotes a negative contribution. The opacity of each ellipse is proportional to
. The reported logit denotes the raw output of the prediction head before sigmoid transformation, and
P denotes the sigmoid-transformed predicted probability of the molecule belonging to the positive class.
As shown in
Figure 4a,c, the contribution map of BACE_598 identifies two central heteroaromatic motifs, M2 and M3, as the dominant positive contributors. Although the 3D binding pose itself does not determine the sign of the model attribution, it shows that these motifs are deeply positioned within the BACE1 binding pocket. This spatial placement is consistent with their large positive contribution scores and with the favorable docking score of −8.47, suggesting a comparatively favorable predicted binding configuration. In contrast, the sulfur-containing five-membered ring M1 shows a negative contribution. Its orientation toward a more solvent-exposed region in the binding pose is qualitatively consistent with its negative motif-level attribution.
For BACE_803, the contribution map shows that the two central motifs, M2 and M3, remain the major positive contributors, as shown in
Figure 4b,d. Their spatial arrangement in the hydrophobic groove is similar to that observed for BACE_598, indicating that MSGRL assigns consistent importance to conserved central substructures across structurally related molecules. However, an important difference is observed at the terminal ring. Compared with BACE_598, the M4 motif of BACE_803 lacks the fluorine substituent and receives a more negative contribution score, changing from a weak positive contribution in BACE_598 to a negative contribution in BACE_803. In the corresponding 3D binding pose, this terminal ring is oriented toward the exterior of the binding pocket and appears to form fewer stabilizing contacts with the surrounding residues. Consistently, BACE_803 has a weaker docking score of −5.83, suggesting a less favorable predicted binding conformation than BACE_598.
Overall, this case study indicates that MSGRL can capture chemically meaningful motif-level differences between structurally related molecules. To complement the qualitative observations from these individual cases, we further evaluate motif-level attribution by analyzing the top-10 positive and negative contributing motifs across all benchmark datasets (
Supplementary Figures S2–S17). Across these datasets, the resulting motif rankings highlight chemically plausible functional groups, such as polar groups in the solubility benchmarks and lipophilic aromatic rings in the Lipophilicity dataset. The motif-level contribution maps are not intended to replace structure-based docking analysis, but they provide complementary interpretability by linking model predictions to specific substructures. The observed consistency between the model-derived motif attributions and the docking-based binding poses provides complementary support for motif-level interpretation.
3. Discussion
MSGRL addresses the scarcity of motif-level supervision by learning motif representations through self-supervised reconstruction of motif-specific atom-based graphs. By combining motif-based graph construction, an MPNN-GRU encoder, VMGAE pretraining, and attention-based pooling, MSGRL provides a hierarchical representation framework that captures both intra-motif atomic structure and inter-motif organization. The experimental results show that MSGRL performs strongly on molecular classification tasks, achieving the highest ROC-AUC on all five classification datasets. The strong results on SIDER and Tox21 are consistent with the effectiveness of the frozen-encoder strategy observed in the ablation study. The ablation studies further show that updating the pretrained encoder during downstream training reduces performance under the evaluated settings, while removing motif-based graph construction also leads to performance degradation.
The motif-based graph construction strategy is central to the effectiveness of MSGRL. Compared with conventional atom-level graph modeling, it introduces chemically meaningful structural priors by organizing atoms into motifs and modeling their connectivity through shared atoms. This design is well aligned with the role of functional groups and recurring substructures in molecular property prediction. In addition, attention-based pooling enables the model to emphasize task-relevant motifs and provides motif-level importance cues for interpretation.
The visualization case study on the BACE dataset further suggests that the motif-level attributions produced by MSGRL are chemically meaningful. The contribution maps highlight conserved central motifs and capture substituent-level differences between structurally related molecules, showing consistency with the corresponding docking poses and docking scores. These results support the interpretability of MSGRL, although such visual evidence should be regarded as complementary to experimental validation. In particular, model-derived motif attribution scores reflect feature importance within the learned network rather than definitive physical binding mechanisms, and should be viewed as hypothesis-generating indicators alongside dataset-wide motif rankings. Several limitations remain. First, the current motif construction strategy is based on chemically motivated decomposition rules rather than experimentally annotated functional motifs. Second, MSGRL mainly uses 2D graph-based structural information and does not explicitly model 3D geometry or conformational flexibility. Third, although MSGRL performs strongly on classification tasks and achieves the lowest RMSE on Lipophilicity, continuous physicochemical property prediction may require additional descriptors or spatial information. These limitations point to possible extensions involving curated motif knowledge, 3D molecular geometry, and more specialized regression-oriented modeling.
4. Materials and Methods
4.1. Datasets
We select eight benchmark datasets for molecular property prediction from MoleculeNet [
24] to evaluate the performance of MSGRL on both classification and regression tasks. These datasets cover diverse molecular properties related to biophysics, physical chemistry, physiology, toxicity, and side effects, enabling evaluation across different molecular property tasks. Specifically, five datasets are used for classification tasks, including BACE [
31], BBBP [
32], ClinTox [
33,
34], SIDER [
35], and Tox21 [
36]. The remaining three datasets are used for regression tasks, including ESOL [
37], FreeSolv [
38], and Lipophilicity, which is curated from the ChEMBL database [
39]. Additional details on the datasets are provided in
Supplementary Table S5. Together, these datasets enable a systematic evaluation of MSGRL on both discrete label prediction and continuous property prediction tasks.
4.2. Preliminaries
Given a molecular dataset , where denotes the r-th molecule and denotes its corresponding property label, the goal of molecular property prediction is to learn a mapping function that predicts molecular properties from graph-based structural representations of molecules. For classification tasks, denotes the binary labels over T prediction tasks, and the model outputs . For regression tasks, denotes continuous molecular properties, and the model outputs .
In MSGRL, each molecule is first decomposed using BRICS into an initial set of molecular fragments, which are subsequently organized into a motif-based graph. In this study, we use the term “motif” operationally to denote a BRICS-derived substructure that serves as a node in the higher-level molecular representation. This terminology does not imply that every extracted substructure corresponds to a universally defined or experimentally annotated chemical motif. Rather, each such substructure retains its internal atom-level topology and is modeled together with its relationships to other substructures in the parent molecule. The motif-based graph is defined as
, where
denotes the set of motif nodes and
is the number of motifs in the molecule. Each motif node
corresponds to a BRICS-derived substructure composed of one or more atoms. Let
denote the set of atoms contained in motif
. When a BRICS-derived fragment
F contains multiple sub-motifs, we first identify a shared-atom set
. For each sub-motif
derived from the same fragment, its atom set is constructed as
Therefore, the shared atoms are retained in each sub-motif derived from
F, and the resulting motif-specific atom graphs may overlap at these atoms. The edge set
describes the connectivity between motif nodes based on shared atoms. For a pair of motif nodes
and
, their shared atom set is defined as
. If
, the corresponding inter-motif edge set is denoted as
, where each
is associated with a shared atom between the two motifs, and
denotes the number of shared atoms between
and
. Because the same shared atom is retained in multiple motif-specific graphs, this construction introduces limited representational redundancy. These occurrences refer to the same atom in the parent molecule and retain the same initial atom attributes. However, they are encoded within different motif contexts and may therefore acquire context-dependent representations. This overlap is intentionally introduced to retain shared structural context between related motifs. Nevertheless, this construction may increase the representational exposure of shared atoms. In addition, BRICS decomposition imposes a structural prior. We therefore acknowledge both effects as potential sources of methodological bias. Since the construction depends only on molecular structure and not on downstream labels, it does not introduce label leakage. The process of constructing motif-based graphs from molecules is illustrated in
Figure 5, and the detailed construction procedure is summarized in Algorithm 1.
Each motif is further represented by an atom-based graph that characterizes its internal atomic structure. Specifically, the atom-based graph associated with motif
is denoted as
, where
denotes the set of atom nodes in the
p-th motif and
is the number of atoms in this motif. Each atom node
represents an individual atom, and
denotes the set of chemical bonds within the motif. For a molecule with
motifs, we denote the collection of its atom-based graphs as
. For notational simplicity,
is used to denote a generic atom-based graph when the motif index is clear from the context.
| Algorithm 1 Motif-based graph construction |
- 1:
, , - 2:
- 3:
▹ Generate initial fragments using the BRICS algorithm [ 40] - 4:
for each fragment do - 5:
if F contains sub-motifs then - 6:
- 7:
- 8:
for each sub-motif do - 9:
- 10:
▹ Retain the shared-atom set in each sub-motif derived from the same fragment - 11:
- 12:
- 13:
- 14:
- 15:
end for - 16:
else - 17:
- 18:
- 19:
- 20:
- 21:
- 22:
- 23:
end if - 24:
end for - 25:
for each pair of motif nodes , do - 26:
- 27:
if then - 28:
- 29:
- 30:
- 31:
end if - 32:
end for - 33:
return
|
4.3. The MPNN-GRU Encoder
The MPNN-GRU encoder operates on the atom-based graph of each motif to learn atom-level representations. Since the atom-based graph
of each motif has been defined in
Section 4.2, we formulate the encoder on a generic atom-based graph
for simplicity. Let
and
denote the initial feature vectors of atom node
and bond
, respectively. The detailed descriptions of these atom and bond features are provided in
Supplementary Tables S3 and S4. The initial hidden state of atom
is obtained by mapping its input feature into the hidden space
where
and
are trainable parameters, and
denotes a nonlinear activation function.
At the
l-th layer, the encoder first computes messages from neighboring atoms. For atom
, the message aggregated from its neighbors is defined as
where
denotes the set of neighboring atoms of
, and
is an atom-level message function that integrates the representation of the central atom, the representation of a neighboring atom, and the corresponding bond feature. In our implementation,
is parameterized by a learnable neural transformation
where
denotes vector concatenation,
and
are trainable parameters, and
is a nonlinear activation function.
The aggregated message is then used to update the atom representation through a GRU
The GRU-based update allows the encoder to recurrently refine atom representations across multiple message-passing layers while retaining useful information from previous hidden states.
After
MPNN-GRU layers, the encoder outputs an atom-level representation matrix
For the
p-th motif, the corresponding output is denoted as
, which serves as the motif-level feature matrix composed of atom representations within motif
. The encoder producing this matrix is optimized by the VMGAE module during self-supervised pretraining and then kept frozen for downstream prediction.
4.4. The VMGAE Self-Supervised Pretraining Module
The VMGAE self-supervised pretraining module is designed to pretrain the MPNN-GRU encoder on motif-specific atom-based graphs without requiring explicit motif-level labels. Since supervised annotations for motif representation learning are generally unavailable, VMGAE learns atom-level latent representations by reconstructing the internal graph structure of each motif. This self-supervised objective encourages the encoder to capture chemical-bond connectivity within motifs, thereby providing structurally informative motif-level feature matrices for the downstream prediction module.
For the atom-based graph
associated with motif
, the MPNN-GRU encoder generates an atom-level feature matrix
. For notational simplicity, we omit the motif index
p and denote the feature matrix and adjacency matrix of a generic atom-based graph as
and
, respectively. Following the variational graph autoencoder framework [
25], VMGAE approximates the posterior distribution of latent atom representations as
where
denotes the latent representation matrix of atom nodes.
The posterior distribution is parameterized by two graph-aware projection heads, which estimate the mean and log-variance matrices from
and
where
and
are learnable graph-aware transformations. The latent atom representation matrix is then sampled using the reparameterization trick
where ⊙ denotes element-wise multiplication.
To reconstruct the internal chemical bond topology of the atom-based graph, VMGAE adopts an inner-product decoder
where
is the sigmoid activation function and
denotes the reconstructed adjacency matrix.
The VMGAE objective consists of two terms: an adjacency reconstruction loss and a KL divergence regularization term. The reconstruction term encourages
to preserve the local bond connectivity within each motif, while the KL term regularizes the posterior distribution toward a standard Gaussian prior
where
and
with
denoting the standard Gaussian prior. Equivalently, this objective corresponds to minimizing the negative evidence lower bound. After VMGAE pretraining, the MPNN-GRU encoder is kept frozen and used to produce structurally informed atom-level feature matrices, which are subsequently pooled into motif-level representations for downstream molecular property prediction.
4.5. The Downstream Prediction Module
The downstream prediction module transforms VMGAE-pretrained motif-level feature matrices into molecular-level representations for property prediction. In this stage, the pretrained MPNN-GRU encoder is kept frozen, and only the motif-level message-passing network, attention pooling module, and task-specific prediction head are trained using downstream labels. Unlike the MPNN-GRU encoder and VMGAE module, which operate on motif-specific atom-based graphs, the downstream module performs message passing on the motif-based graph
. For each motif node
, we use the frozen pretrained MPNN-GRU encoder to obtain a motif-level feature matrix
, where each row corresponds to the representation of an atom within the motif. This matrix is first pooled into a motif vector
where
denotes an atom-level pooling function over the atoms within motif
. The resulting vector
is used as the initial representation of motif node
.
For two connected motif nodes
and
, their inter-motif edge set is denoted as
. The corresponding edge representation is obtained by aggregating the features associated with these inter-motif edges
where
denotes an edge-level pooling function and
is the feature vector associated with edge
.
The motif vectors are then updated through motif-level message passing. At the
l-th layer, the message received by motif node
is computed as
where
denotes the set of neighboring motif nodes of
, and
is the motif-level message function. The motif-node representation is then updated by a GRU-based recurrent update
Here,
serves as the input to the GRU at the
l-th message-passing layer, while
is the previous hidden state of motif node
.
After
layers of motif-level message passing, an attention-based pooling mechanism is applied to obtain a molecular-level representation. As illustrated in
Figure 6, the attention pooling module transforms the motif-node representation matrix into a molecular-level vector by assigning adaptive importance weights to different motif nodes. Specifically, it first computes a gating score for each motif representation and then uses the normalized attention weights to aggregate the transformed motif features into the final molecular representation
.
For motif node
, the attention score is computed as
where
and
are trainable parameters, and
denotes a nonlinear activation function. The normalized attention weight is then calculated by
The molecular-level representation is obtained by aggregating motif-node representations according to their attention weights
The attention weights
provide motif-level importance cues, reflecting the relative contribution of different motifs to the final molecular representation.
Finally, the molecular-level representation
is fed into a task-specific prediction head
where
denotes the raw output of the prediction head.
For classification tasks, the predicted probability is obtained by
, and the model is optimized using the binary cross-entropy loss
where
denotes the set of molecule–task pairs with available labels, and
and
denote the ground-truth label and predicted probability for the
t-th task of the
r-th molecule, respectively.
For regression tasks, the raw output is directly used as the prediction, i.e.,
. The model is optimized using the mean squared error loss
where
and
denote the ground-truth value and predicted value for the
t-th regression task of the
r-th molecule, respectively. The final supervised objective is selected according to the task type of each dataset.
4.6. Experimental Settings
Each dataset is partitioned into training, validation, and test sets using scaffold-based splitting with an 8:1:1 ratio [
18,
20]. Molecules assigned to the same scaffold group are kept within the same partition to reduce scaffold overlap between training and evaluation data. Molecular structures are processed using RDKit, and the atom and bond features used by MSGRL follow the Open Graph Benchmark (OGB) feature definitions. ROC-AUC is used as the evaluation metric for classification datasets, whereas RMSE is used for regression datasets.
For each downstream dataset, VMGAE pretraining is performed exclusively on molecules in the corresponding training split. Neither validation nor test molecules are used for self-supervised pretraining or supervised parameter optimization. The validation set is used for model selection and, where applicable, hyperparameter selection, whereas the test set is used only for final evaluation.
Both the intra-motif MPNN-GRU encoder and the downstream motif-graph propagation network contain five message-passing layers, with a hidden dimension of 300 and a dropout rate of 0.5. VMGAE pretraining is performed for 400 epochs using Adam with a learning rate of and a batch size of 32. During downstream training, the pretrained MPNN-GRU encoder is frozen (requires_grad=False), while the motif-graph network, attention-pooling module, and prediction head are optimized for 400 epochs using the same learning rate and batch size.
For baseline comparison, all methods use the same dataset versions, scaffold-based partitions, evaluation metrics, and test-set isolation protocol. Architecture-specific preprocessing, input representations, and hyperparameters follow the corresponding official implementations or original publications whenever available; when multiple recommended configurations are available, selection is based only on validation performance. All methods are evaluated over ten runs with different random seeds, and results are reported as mean ± standard deviation. All experiments are implemented in PyTorch (version 2.7.1) [
41] and executed on an Ubuntu server equipped with an NVIDIA GeForce RTX 5090 GPU. Statistical comparisons between MSGRL and the strongest competing baseline on each dataset are performed using two-sided Welch’s
t-tests based on the ten-run summary statistics, with Holm correction applied for multiple comparisons. Adjusted
p-values below 0.05 are considered statistically significant.
5. Conclusions
In this study, we propose MSGRL, a motif-driven self-supervised graph representation learning framework for molecular property prediction. MSGRL decomposes molecules into molecular fragments, represents each motif as an atom-based graph, and constructs a motif-based graph to model inter-motif connectivity. The MPNN-GRU encoder is pretrained through a VMGAE objective and then kept frozen to provide stable motif-level feature matrices for downstream prediction.
The downstream prediction module further pools motif-level feature matrices into motif vectors, performs message passing on the motif-based graph, and applies attention-based pooling to obtain molecular-level representations. This design enables MSGRL to preserve the structural features learned during label-independent pretraining while learning task-specific predictors from downstream labels.
Experiments on eight MoleculeNet benchmark datasets demonstrate the effectiveness of MSGRL. The model achieves the highest ROC-AUC scores on all five classification datasets and the lowest RMSE on Lipophilicity, while its performance on ESOL and FreeSolv is more mixed. Ablation studies confirm the importance of the frozen pretrained encoder, motif-based graph construction, and attention-based pooling. Motif-level attribution analyses provide qualitative and dataset-level evidence regarding the substructures emphasized by the model and offer complementary support for model interpretation.
Future work will extend MSGRL by incorporating curated motif annotations, explicit 3D molecular geometry, and more complex biochemical reasoning scenarios, such as drug–drug interaction prediction, drug–target affinity estimation, and retrosynthesis analysis. These directions may further improve the generality, interpretability, and practical utility of motif-driven self-supervised molecular representation learning.