Explainable Molecular Property Prediction: Aligning Chemical Concepts with Predictions via Language Models

## Abstract

Abstract Providing explainable molecular property predictions is critical for many scientific domains, such as drug discovery and material science. Though transformer-based language models have shown great potential in accurate molecular property prediction, they neither provide chemically meaningful explanations nor faithfully reveal the molecular structure-property relationships.
In this work, we develop a framework for e xplainable mol ecular property prediction based on la nguage models, dubbed as Lamole , which can provide chemical concepts-aligned explanations 1 1 1 Lamole is from the name of a historical winery in Italy called Lamole di Lamole. . We take a string-based molecular representation — Group SELFIES — as input tokens to pre-train and fine-tune our Lamole , as it provides chemically meaningful semantics.
By disentangling the information flows of Lamole , we propose considering both self-attention weights and gradients for better quantification of each chemically meaningful substructure’s impact on the model’s output.
To make the explanations more faithfully respect the structure-property relationship, we then carefully craft a marginal loss to explicitly optimize the explanations to be able to align with the chemists’ annotations.
We bridge the manifold hypothesis with the elaborated marginal loss to prove that the loss can align the explanations with the tangent space of the data manifold, leading to concept-aligned explanations.
Experimental results over six mutagenicity datasets and one hepatotoxicity dataset demonstrate Lamole can achieve comparable classification accuracy and boost the explanation accuracy by up to 14.3 % percent 14.3 14.3\% 14.3 % , being the state-of-the-art in explainable molecular property prediction.

## 1 Introduction

Molecular property prediction aims to reveal the molecular structures-property relationships, assisting scientists in screening molecules for various applications such as drug discovery and material design (Fang et al., ; Deng et al., ; Tripp et al., ; Wang et al., ; Ekström Kelvinius et al., ; Hong et al., ).
Several learning-based models are devised based on the underlying molecular representations, such as graph-based and string-based molecular representations. Among them, string-based molecular representations, e.g., simplified molecular input line entry systems (SMILES (Weininger, )), stand out for their simplicity and adaptability (Deng et al., ; Wigh et al., ; Cheng et al., ). By viewing the string-based molecular representation as a form of "chemical" language, the Transformer-based language models (LMs) like Bert (Kenton & Toutanova, ) offer higher throughput and accuracy for molecular property prediction (Deng et al., ; Chithrananda et al., ).

Figure: Figure 1: (a) The molecule visualization of prediction/explanation. The interaction between the benzene ring and the nitro group (highlighted in red) induces the mutagenic property of the molecule. (b)-(e) are the explanation results obtained with various methods: (b) OrphicX (Lin et al., ); (c) GNNExplainer (Ying et al., ), (d) GNN with gradient-based explainability technique (GradCAM (Selvaraju et al., )); (e) Bert with GradCAM (molecular string SMILES as input); (f) Bert with GradCAM (molecular string Group SELFIES (Cheng et al., ) as the input representation); (g) Our method *Lamole* assigns an importance score to each functional group/fragment to indicate their contribution to the property.
Refer to caption: x1.png

Figure: Figure 2: The SMILES and Group SELFIES strings of p-nitrobenzoic acid molecule ($\mathrm{C_{7}H_{5}NO_{4}}$): The tokens in the Group SELFIES string highlighted by color are the corresponding functional groups.
Refer to caption: x2.png

Despite the superior performance of learning-based prediction methods, what key factors induce the model’s predictions remain largely unexplored, impeding further advancements in the scientific domains. Typically, it is crucial to obtain explanations of predictions while achieving accurate predictions. These obtained explanations could be used for scientific hypotheses validation or/and providing actionable insights for refining investigations, such as optimization for molecular structural design (Wu et al., ; Wellawatte et al., ; Das et al., ). With different types of molecular representations, explainability techniques for graph neural networks (GNNs) or LMs might be adopted to alleviate the general lack of explainability in molecular prediction (Proietti et al., ; Ying et al., ; Ye et al., ; Lin et al., ).

However, we argue that existing explainability techniques often struggle to generate plausible explanations that can highlight chemically meaningful substructures and faithfully uncover the structure-property relationships simultaneously. Specifically, 1) from the molecular representation perspective, the commonly used representations do not explicitly encode the chemically meaningful substructures; current explainability methods can only highlight individual atoms and bonds as explanations (see Fig. 1 (b)$\sim$(e)). 2) From the perspective of explainability techniques, current methods suffer from two main limitations. First, they cannot effectively capture the interactions between functional groups within the molecular structure. Second, they could not generate explanations that align with chemists’ intuition. As a result, they fail to produce explanations that faithfully reflect the structure-property relationships.
(see Fig. 1 (f)). Therefore, an effective framework is imperative for explainable molecule property predictions.

The recently proposed string-based molecular representation — Group SELFIES (Cheng et al., ) — encodes molecules at the functional group/fragment level, showcasing the possibility of obtaining chemically meaningful explanations. As shown in Fig. 2, Group SELFIES converts a p-nitrobenzoic acid molecule to a string, which explicitly encodes chemically meaningful substructures as tokens, including a benzene, a nitro group, and a carboxyl group. Compared with 2D molecular graphs, Group SELFIES provides inherent semantic information, making it easier for the model to capture and understand chemically meaningful semantics. Moreover, using Group SELFIES eliminates the need to identify or segment chemically meaningful substructures in 2D molecular graphs.
With Group SELFIES’s simplicity and adaptability, this work develops an explainable molecular property prediction framework based on language models to provide chemical concepts-aligned explanations, called Lamole (see Fig. 1 (g)). The contributions can be summarized as follows.

- 1.
We found that existing explainability techniques fail to provide chemically meaningful explanations, perceive functional group interactions, and reveal molecular structure-property relationships faithfully. To address the issues, we use Group SELFIES to pre-train and fine-tune LMs to make LMs easily understand the chemically meaningful semantics. Moreover, the process of generating explanations should reflect the reasoning process behind the model architecture. Therefore, by disentangling the information flows of Transformer-based LMs, we integrate the self-attention weights and gradients to capture the substructure interactions to better quantify each chemically meaningful substructure’s contribution to the predicted molecular properties.
- 2.
To make the explanations more faithfully respect the structure-property relationships, we elaborate on one marginal loss to calibrate the explanations by aligning them with the chemists’ annotations.
We show that using only a few molecules with ground truth annotations can significantly improve the explanation accuracy by up to 5%.
- 3.
We first bridge the manifold hypothesis with explainable molecular property prediction. We theoretically demonstrate that the elaborated marginal loss aligns explanations with the data manifold, respecting the structure-property relationship.

Experimental results over six mutagenicity datasets and one hepatotoxicity dataset demonstrate that Lamole can achieve comparable classification accuracy and improve the explanation accuracy by up to $14.3\%$. We also quantitatively evaluate explanations based on the first proposed plausibility metric. Compared to alternative baselines, the explanation plausibility of Lamole is improved by up to $9\%$. Extensive experimental studies demonstrate Lamole achieves state-of-the-art performance in explainable molecular property prediction.

## 2 Related Work

Several explainable GNNs are proposed to explain the relationship between the input graph and the prediction (Sun et al., ; Xiong et al., ; Lin et al., ; Ying et al., ; Luo et al., ; Lin et al., ). Among these works, structure similarity or attention weights are proposed to capture structural interaction (Sun et al., ; Xiong et al., ). However, two similar substructures do not necessarily lead to interaction between them, and attention weights are often inconsistent with the feature importance (Jain & Wallace, ; Serrano & Smith, ; Abnar & Zuidema, ). In addition, as shown in Fig. 1 (b)$\sim$(d), some trivial structures received relatively high importance scores, indicating the explanations might not align well with the chemical concepts.

On the other hand, with string-based molecular representations, LMs show great potential in molecular property prediction (Chithrananda et al., ; Wang et al., ; Ahmad et al., ; Ross et al., ). However, the "black-box" characteristics of LMs hamper trust use of these potent computational tools in scientific domains. Some explainability techniques could be applied to LMs. One way is to use the attention weights over the input tokens. However, recent studies suggest that "attention is not explanation" because attention weights could not reflect the true feature importance (Jain & Wallace, ; Serrano & Smith, ; Abnar & Zuidema, ). Perturbation-based methods perturb the inputs and evaluate the output changes to reveal the input importance. However, the generated explanations may change drastically with very small perturbations (Agarwal et al., ).
Gradient-based methods determine the feature importance by the partial derivatives of the output to each feature (Selvaraju et al., ). However, several works show that the gradient-based methods may not be reliable, as they disregard the influence of model architectures on the output and fail to incorporate the information of the model architectures into the explanations (Adebayo et al., ; Agarwal et al., ; Rudin, ). Therefore, the explanation generation process should reflect the model reasoning process behind the model architectures.
To this end, we disentangle the model architectures’ information flows to generate explanations that faithfully reveal the structure-property relationship.

## 3 Methodology

Problem Setup. Given a dataset $\mathcal{G}=\{(g^{(i)},y^{(i)})\}$ consisting of molecular graphs $\{g^{(i)}\}$ with their property labels $\{y^{(i)}\}$, explainable molecular property prediction aims to train a model $f$ to map a molecule $g$ to its property $y$, denoted as denoted as $f:g\mapsto y$, while providing an importance score vector $\mathbf{v}^{(i)}=\{\mathbf{v}_{1}^{(i)},\ldots,\mathbf{v}_{j}^{(i)}\}$ to indicate the contribution of $j$-th functional group/fragment to its property $y$.
Particularly, this work proposes to convert the molecular graph $g^{(i)}$ into the Group SELFIES string represented as $s^{(i)}=\{t_{1}^{(i)},\ldots,t_{j}^{(i)}\}$, where $t_{j}^{(i)}$ is the $j$-th functional group/fragment’s token, i.e., [$\cdot$] in Fig. 2. In addition, this work calibrates the explanations in a supervised manner. For this purpose, a few molecules with annotation masks are provided. The annotation masks $\mathbf{m}(g^{(i)})\in\{0,1\}^{j}$ indicate whether $t_{j}^{(i)}$ is the token of a ground truth substructure, where $\mathbf{m}_{j}(g^{(i)})=1$ denotes the substructure corresponding to the token $t_{j}^{(i)}$ inducing the molecular property of $g^{(i)}$.
This work uses $\mathcal{D}=\{(s^{(i)},y^{(i)})\}$ with a few annotation masks to learn a model $f$ for explainable molecular property prediction. We omit the superscript ^(i) for simplicity in the following parts.

Figure: Figure 3: An illustration of *Lamole*. Left panel: Group SELFIES strings are tokenized for fine-tuning the pre-trained language model, and an MLP classifier is equipped with a cross-entropy loss $\mathcal{L}_{CE}$ for molecular property prediction. Right panel: We disentangle the information flows of the Transformer to assert that both attention weights and gradient determine the output. Therefore, we incorporate the attention weights and gradients together to generate importance scores $\mathbf{v}$ as explanations. In addition, a marginal loss $\mathcal{L}_{M}$ is designed to align explanations with the chemists’ annotations $\mathbf{m}$.
Refer to caption: x3.png

### 3.1 Our Design: Lamole

In this work, we pre-train Transformer-based LMs, e.g., Bert family models, using the Group SELFIES corpus to make the models understand the chemical semantics behind Group SELFIES strings.
Then, we fine-tune the LMs with Group SELFIES strings and the molecular property labels for explainable molecular property prediction. An illustration of proposed *Lamole* is in Fig. 3. In what follows, we will introduce the detailed design of *Lamole*.

Fine-Tuning Stage. Fig. 3 shows the fine-tuning stage of the proposed *Lamole*. We assume that the Transformer encoder in *Lamole* stacks $L$ identical Transformer layers to encode the molecular string $s$ as token embedding $\mathbf{h}^{(l)}=\{\mathbf{h}_{1}^{(l)},\ldots,\mathbf{h}_{j}^{(l)}\}$, where $\mathbf{h}^{(l)}$ is the token embedding at the $l$-th layer.
We use the self-attention weighted average embedding $\mathbf{h}_{o}=(\sum_{j=1}\alpha_{j}\cdot\mathbf{h}_{j}^{(L)})/(\sum_{j=1}
\alpha_{j})$ for molecular property prediction, where $\alpha_{j}$ is the attention weight of the $j$-th token.
A multilayer perceptron (MLP) classifier is added to predict the molecular property $\hat{y}=\mathrm{MLP}(\mathbf{h}_{o})$ by minimizing the classification cross-entropy loss $\mathcal{L}_{CE}(y,\hat{y})$.

Information Flow-Based Explanations. To derive the explanations from Transformer-based LMs, a common practice is to use gradient-based methods to determine each feature’s importance by analyzing the output’s partial derivatives to each input feature (Selvaraju et al., ). However, we argue that using gradients alone cannot effectively capture substructure interactions. As depicted in Fig. 1 (f), the gradient-based method CradCAM incorrectly attributes the property to the nitro group and a benzene ring that is not connected to the nitro group.

We illustrate the possible reason by disentangling the information flows of the Transformer. As shown in Fig. 3 right panel, due to the skip connection and attention mechanism, both attention weights, gradients, and the input contribute to the outputs. Therefore, using gradients alone as explanations could fall short of capturing interactions. To address the issue, we leverage both attention and gradients, as well as the input, to derive explanations. Below, we will elaborate on integrating attention weights into gradient-based explanations.

Firstly, we show the process of deriving the gradient-based explanations. Similar to GradCAM (Selvaraju et al., ), the gradient with respect to the $j$-th token’s embedding $\mathbf{h}_{j}^{(l)}$ at the $l$-th layer is derived by $\nabla\mathbf{h}_{j}^{(l)}=\partial\hat{y}/{\partial\mathbf{h}_{j}^{(l)}}$,
where $\nabla\mathbf{h}_{j}$ signifies the importance of the $j$-th token in relation to the predicted property $\hat{y}$. Due to the skip connection in Fig. 3 right panel, the input, and its corresponding gradient should be leveraged together, and the weighted importance $\mathbf{w}$ of the $j$-th token at the $l$-th layer can be determined by

$$ $\mathbf{w}_{j}^{(l)}=\nabla\mathbf{h}_{j}^{(l)}\odot\mathbf{h}_{j}^{(l)},$ (1) $$

where $\odot$ is the Hadamard product. The weighted importance is regarded as the gradient-based explanation.

The interaction among tokens can be revealed by the self-attention mechanism in Fig. 3 right panel. The attention mechanism calculates pairwise similarity scores between all pairs of tokens to determine attention weights, and these attention weights inherently encode the functional group interactions.
Therefore, we combine the attention weights with the gradient-based explanation to capture functional group interactions. Assuming the attention weights of the $j$-th token at the $l$-th layer is $\alpha_{j}^{(l)}$, we integrate the attention weights with weighted importance $\mathbf{w}$ to consider the interactions. The importance score of the molecule $g$ can be obtained by

$$ $\mathbf{v}_{j}^{(l)}(g)=\left(\tanh(\overline{\alpha_{j}^{(l)}})\cdot\tanh( \mathbf{w}_{j}^{(l)})\right)^{\frac{1}{2}},$ (2) $$

where $\overline{\alpha_{j}^{(l)}}$ is the averaging of attention weights of multiple attention heads.
Finally, we sum $\mathbf{v}_{i}^{(l)}$ over all layers as the final importance score of the $j$-th token,

$$ $\mathbf{v}(g)=\mathrm{softmax}(\sum_{l=1}^{L}\mathbf{v}^{(l)}(g)).$ (3) $$

The higher the importance scores, the greater the contribution of the corresponding functional groups/fragments to the molecular property.

Towards Plausible Explanations. One plausible explanation should faithfully uncover the structure-property relationships. In other words, the explanation should match the ground-truth substructures with high confidence. Nevertheless, the importance scores of ground-truth substructures might not be significantly higher than those of other parts. To address this issue, we propose a marginal loss to explicitly align explanations with the chemists’ annotations to improve the explanations’ plausibility.

First, we formally define the plausibility of explanations. "Plausibility" refers to how the interpretation convinces humans (Wiegreffe & Pinter, ; Herman, ; Jacovi & Goldberg, ). Similarly, in our context, "plausibility" refers to the degree of confidence in the explanations that would convince the chemists.

###### Definition 1

Eq. (4) defines the explanation plausibility based on the scores of two parts, i.e., the scores on ground truth and the scores on non-ground truth. The lower the scores on non-ground truth and the greater the scores on ground truth, the better explanation plausibility. Therefore, to maximize the plausibility, our objective can be transformed to minimize the importance score of non-ground truth and maximize the importance score of ground truth.

To this end, we design a max-margin loss to optimize the importance score. In our work, the ground truth substructures are annotated by a binary mask vector $\mathbf{m}(g)\in\{0,1\}^{j}$. It is worth noting that using only a few annotations can significantly improve the explanation accuracy. Specifically, the mask vector $\mathbf{m}$ enforces the explanations to align with the ground truth substructures. To achieve the goal, a max-margin loss is designed by maximizing the mean value of the importance scores of tokens that have mask values of 1 while minimizing the mean value of importance scores for tokens with mask values of 0.

$$ $\mathcal{L}_{M}(\mathbf{v},\mathbf{m})=\mathbb{E}_{g\in\mathcal{G}}\left[\max \left(0,\frac{\sum_{j=1}(1-\mathbf{m}_{j}(g))\cdot\mathbf{v}_{j}(g)}{N_{s}}- \frac{\sum_{j=1}\mathbf{m}_{j}(g)\cdot\mathbf{v}_{j}(g)}{N_{c}}\right)+ \triangle_{1}\right],$ (5) $$

where $\triangle_{1}$ is a margin term, $N_{s}$ is the number of tokens with mask values $\mathbf{m}(g)$ of 0, and $N_{c}$ is the number of tokens with mask values $\mathbf{m}(g)$ of 1.
The overall optimization objective of the fine-tuning stage is to minimize $\mathcal{L}_{CE}+\mathcal{L}_{M}$. The core of Eq. (5) is the discrepancy between the average importance score of ground truth and the average importance score of non-ground truth. By minimizing $\mathcal{L}_{M}$, the discrepancy between the two importance scores is maximized. In other words, the average importance score of non-ground truth is suppressed, and the average importance score of ground truth is increased. Finally, the explanation plausibility defined in Eq. (4) is improved. The next section will theoretically show that by using the designed marginal loss, the explanations can faithfully reflect the structure-property relationships.

###### Definition 1

### 3.2 Theoretical Analysis

We bridge the manifold hypothesis with the marginal loss to theoretically show that the explanations can respect the structure-property relationships.
Before giving the proof, the notation and definition regarding the manifold hypothesis are presented.

Manifold Hypothesis. It is widely believed that natural data, including molecules, distribute around a manifold (Bordt et al., ; Lin et al., ; Godwin et al., ; Singh et al., ).
According to the manifold hypothesis for gradient-based explanations (Bordt et al., ), if a feature lies in the tangent space of a manifold, then the feature respects the manifold and contributes to the class, and such a feature is desirable to be explained. We call these features "causal features" in our work. Conversely, if a feature is orthogonal to the manifold, then the feature does not contribute to the class. We call these features "spurious features".

With the annotation masks, the causal features $s^{*}$ and spurious features $\overline{s}^{*}$ can be distinguished by $s^{*}=s\odot\mathbf{m}(g)$ and $\overline{s}^{*}=s\odot(1-\mathbf{m}(g))$, respectively, where $\overline{s}^{*}\cup s^{*}=s$ and $s^{*}\cap\overline{s}=\varnothing$. By projecting the causal features and spurious features into the data manifold $\mathcal{M}$, the corresponding manifold regarding the causal features and spurious features can be defined as follows,

###### Definition 2

With this decomposition, we demonstrate how the gradient-based explanations $\nabla_{g}\log p(y|g)$ can uncover the structure-property relationships. Due to the page limitation, we provide the proof in Appendix.

###### Theorem 1

###### Definition 2

###### Theorem 1

## 4 Experiments

### 4.1 Experimental Setup

Datasets. We use six datasets on two types of tasks, i.e., hepatotoxicity and mutagenicity, to evaluate the algorithmic performance for the explainable molecular property prediction. Six mutagenicity datasets are Mutag (Debnath et al., ), Mutagen (Morris et al., ), PTC-FM (Toivonen et al., ), PTC-FR (Toivonen et al., ), PTC-MM (Toivonen et al., ), and PTC-MR (Toivonen et al., ). For hepatotoxicity (Toivonen et al., ), the Liver dataset (Liu et al., ) is used. We used these datasets as the ground truth substructures in these datasets are known. For detailed information on these datasets and the ground truth substructures, please refer to Appendix.

Evaluation Metrics. We use three metrics for evaluating the performance of the proposed *Lamole*.
1) Classification Accuracy: We evaluate the model’s predictions by $\sum_{i=1}^{I}\mathbb{I}(y^{(i)}=\hat{y}^{(i)})/I$.
2) Explanation Accuracy: We follow the experimental settings in GNNExplainer (Ying et al., ), which formulates the explanation problem as a binary classification of edges. We treat edges inside ground-truth substructure as positive edges and negative otherwise, and AUC is adopted as the metric for quantitative evaluation. We only consider the mutagenic/hepatotoxic molecules because no explicit substructures exist in nonmutagenic/nonhepatotoxic ones.
3) Explanations’ Plausibility: We use the defined explanations’ plausibility $\mathrm{EP}$ to measure how confident the explanation aligns with the ground truth.

Baselines. We combine *Lamole* into three BERT family models, such as DistilBert (Sanh, ), DeBerta (He et al., ), and Bert to evaluate the performance of the proposed *Lamole*.
For evaluating classification accuracy, we compare our *Lamole* with one SMILES string-based LM, ChemBERTa (Chithrananda et al., ) and several GNNs including GCN (Kipf & Welling, ), DGCNN (Zhang et al., ), edGNN (Jaume et al., ), GIN (Xu et al., ), RW-GNN (Nikolentzos & Vazirgiannis, ), DropGNN (Papp et al., ), and IEGN (Maron et al., ).

For evaluating explanation accuracy, *Lamole* is compared with three types of alternative methods: 1) GCN with feature-based explainability techniques, including SmoothGrad (Smilkov et al., ), GradInput (Shrikumar et al., ), and GradCAM (Selvaraju et al., ), 2) Bert with the above feature-based explainability techniques, where Group SELFIES is used as input for a fair comparison, and 3) explainable GNNs including OrphicX (Lin et al., ), GNNExplainer (Ying et al., ), PGExplainer (Luo et al., ), and Gem (Lin et al., ). The details of experimental settings can be found in Appendix.

### 4.2 Results

Prediction Performance. Table 1 shows the classification accuracy of compared algorithms. As we can see, our proposed *Lamole*+DistilBert, *Lamole*+DeBerta, and *Lamole*+Bert not only can provide explainability but also can achieve comparable prediction accuracy as compared to existing predictive methods. In addition, *Lamole* models show superior performance over ChemBERTa. This suggests that using molecular representations with more chemical semantics, like Group SELFIES, can help LMs better learn the chemical semantics and structure-property relationships.

**Table 1: Mean Classification Accuracy on the Seven Datasets (%)**
| Methods | Mutag | Mutagen | PTC-FM | PTC-FR | PTC-MM | PTC-MR | Liver |
| --- | --- | --- | --- | --- | --- | --- | --- |
| GCN (Kipf & Welling, ) | 84.6 | 78.9 | 54.8 | 63.0 | 57.8 | 53.3 | 41.1 |
| DGCNN (Zhang et al., ) | 85.8 | 74.8 | 57.3 | 63.5 | 61.0 | 58.6 | 44.6 |
| edGNN (Jaume et al., ) | 86.9 | 75.2 | 59.8 | 65.7 | 64.4^† | 56.3 | 44.5 |
| GIN (Xu et al., ) | 87.5 | 82.3^‡ | 62.1^† | 66.2 | 65.1^‡ | 64.0 | 44.9 |
| RW-GNN (Nikolentzos & Vazirgiannis, ) | 87.2 | 80.3 | 61.9 | 64.0 | 62.4 | 57.0 | 43.2 |
| DropGNN (Papp et al., ) | 89.4^‡ | 80.7^† | 62.0 | 66.0 | 63.7 | 64.2 | 45.0 |
| IEGN (Maron et al., ) | 84.6 | 80.1 | 60.8 | 59.8 | 61.1 | 59.5 | 45.3 |
| ChemBERTa (Chithrananda et al., ) | 86.8 | 78.0 | 60.0 | 65.7 | 60.4 | 58.7 | 45.7 |
| *Lamole*+DistilBert | 84.2 | 76.8 | 57.5 | 69.0 | 60.2 | 64.5^† | 47.2^† |
| *Lamole*+DeBerta | 86.8 | 73.7 | 58.6 | 69.5^† | 59.7 | 63.8 | 45.8 |
| *Lamole*+Bert | 88.2^† | 74.5 | 62.4^‡ | 70.0^‡ | 61.2 | 66.0^‡ | 47.5^‡ |

Explanation Performance. Table 2 presents the explanation accuracy of the compared explainability techniques. It should be noted that the ground truth annotations used in our work provide additional supervisory signals. Therefore, we also align the generated explanations of these baselines with the annotations for fair comparison, and the ground truth annotation rate is 10%.
*Lamole* improves the explanation accuracy by $1.4\%\sim 14.3\%$ compared to the baseline methods. We also investigated the explanation accuracy of our *Lamole* under different ground truth annotation rates (10%, 20%, 50%, and 100%). The impact of annotation rates can be found in Appendix. In addition, we discuss the rationale of using labeled annotations (see Appendix).

**Table 2: Mean Explanation Accuracy on the Seven Datasets (%)**
| Methods | Mutag | Mutagen | PTC-FM | PTC-FR | PTC-MM | PTC-MR | Liver |
| --- | --- | --- | --- | --- | --- | --- | --- |
| GradInput+GCN (Shrikumar et al., ) | 70.3 | 67.9 | 69.7 | 66.4 | 64.6 | 65.0 | 73.0 |
| GradCAM+GCN (Selvaraju et al., ) | 69.8 | 67.0 | 71.0 | 67.9 | 66.2 | 67.3 | 69.4 |
| SmoothGrad+GCN (Smilkov et al., ) | 69.2 | 66.8 | 67.5 | 62.6 | 64.9 | 63.1 | 66.4 |
| GradInput+Bert (Shrikumar et al., ) | 75.1 | 72.6 | 73.0 | 68.9 | 65.6 | 69.6 | 75.6 |
| GradCAM+Bert (Selvaraju et al., ) | 75.3 | 72.4 | 77.5 | 70.0 | 70.2 | 73.0 | 76.0 |
| SmoothGrad+Bert (Smilkov et al., ) | 73.4 | 72.8 | 73.7 | 71.0 | 67.0 | 69.9 | 75.1 |
| GNNExplainer (Ying et al., ) | 70.6 | 64.2 | 68.9 | 67.9 | 66.8 | 67.1 | 72.1 |
| PGExplainer (Luo et al., ) | 66.5 | 58.7 | 70.3 | 68.0 | 65.9 | 67.0 | 71.5 |
| Gem (Lin et al., ) | 73.7 | 66.0 | 71.3 | 69.0 | 68.9 | 69.2 | 73.6 |
| OrphicX (Lin et al., ) | 78.0^‡ | 71.5 | 74.6 | 70.4 | 70.9^† | 71.4 | 74.0 |
| *Lamole*+DistilBert | 70.9 | 73.0 | 74.0 | 70.2 | 69.6 | 78.1^‡ | 76.1^‡ |
| *Lamole*+DeBerta | 76.1 | 75.0^† | 79.9^† | 72.1^† | 70.3 | 77.2^† | 75.0 |
| *Lamole*+Bert | 77.8^† | 75.2^‡ | 81.1^‡ | 72.2^‡ | 72.0^‡ | 73.1 | 77.3^† |

Figure: Figure 4: Explanation visualization of one molecule (ID: 155) from the Mutag dataset.
Refer to caption: x4.png

Figure: (a) Mutag
Refer to caption: x5.png

We selected some representative molecules for explanation visualization. These explanations are shown in Figs. 1 and 4, respectively. The right panel of those figures is the importance scores obtained by *Lamole*, where "other" in the figures is the average importance score of other unlisted functional groups/fragments. Compared to baseline methods, *Lamole* provides chemically meaningful explanations. Particularly, the interaction among the functional groups is successfully captured.
More visualization results can be found in Appendix.

In addition, we evaluated the performance of compared algorithms by using the proposed explanation plausibility metric $\mathrm{EP}$. The statistical results of $\mathrm{EP}$ are presented in Figs. 5 and LABEL:epfr.
From the figures, we can observe that the $\mathrm{EP}$ values of the comparison algorithm are slightly lower, which means that the algorithms cannot confidently reflect the relationships between structure and property.
Compared to the comparison algorithm, the $\mathrm{EP}$ values of *Lamole* have increased by $2\%\sim 9\%$.
More analysis regarding the explanation plausibility can be found in Appendix.

### 4.3 Ablation Studies

We conducted ablation studies for each component in our *Lamole*. Specifically, we removed the attention weights in the explanations, removed the marginal loss, and only used attention weights as explanations. The corresponding ablation algorithms are named *Lamole* ($-\alpha$), *Lamole* ($-\mathcal{L}_{M}$), and *Lamole* (Att), respectively. The results are shown in Fig. 6. The explanation accuracy decreases by 1.4%$\sim$2.3% when removing the attention weights. Removing the marginal loss can decrease the explanation accuracy by 1.0%$\sim$5.0%. Regarding the results of using only attention weights, The explanation accuracy decreases by 1.4%$\sim$6.3%. The above results confirm the effectiveness of using the marginal loss, attention weights, and gradients.

Figure: Figure 6: The explanation accuracy of Lamole+Bert, Lamole+Bert ($-\alpha$), Lamole+Bert ($-\mathcal{L}_{M}$), and Lamole (Att).
Refer to caption: x8.png

From the perspective of model training, the marginal loss enables the model to be trained under the causal signals. To verify, we compared the classification performance with and without the marginal loss, as shown in Table 3. Without the marginal loss, the classification accuracy degrades by 0.7%$\sim$3.7%. The above results indicate that marginal loss could help identify the causal features, thereby improving classification accuracy.

**Table 3: The classification performance with and without the marginal loss (%)**
| Methods | Mutag | Mutagen | PTC-FM | PTC-FR | PTC-MM | PTC-MR | Liver |
| --- | --- | --- | --- | --- | --- | --- | --- |
| *Lamole*-$\mathcal{L}_{M}$ | 84.9 | 73.8 | 58.6 | 69.3 | 59.7 | 62.3 | 44.6 |
| *Lamole* | 88.2 | 74.5 | 62.4 | 70.0 | 61.2 | 66.0 | 47.5 |

To investigate the attention weights, the attention weights of two molecules are depicted in Fig. 7. From Fig. 7 middle panel, it can be found the correlation among the ground truth substructures is higher than others, showcasing the rationality of using attention weights to capture the functional group interactions. When we aggregate the attention weights for each token, as shown in Fig. 7 right panel, the top two attention weights of the molecule (ID:155) match the two ground truth substructures. However, the top two attention weights of the molecule (ID:156) do not match the two ground truth substructures. The above results indicate that attention weights can capture the interactions and also confirm that "attention is not explanation" (Jain & Wallace, ; Serrano & Smith, ; Abnar & Zuidema, ). Due to the page limitation, the limitation of the proposed work is provided in Appendix.

Figure: Figure 7: Attention weights visualization. The ground truth substructures are highlighted in red.
Refer to caption: x9.png

## 5 Conclusions

This work proposed Lamole for explainable molecular property prediction based on language models. Lamole uses Group SELFIES as input for chemically meaningful semantics. By disentangling the information flows of Transformer-based LMs, Lamole integrates attention weights into gradients to generate explanations to quantify each chemically meaningful substructure’s impact on the model’s output.
Furthermore, one marginal loss is designed to calibrate the explanations to be more faithful by aligning them with the chemists’ annotation.
Lamole ’s effectiveness has been demonstrated through theoretical analysis and extensive experimental validation.

## Peer Reviews

confidence: 5
contribution: 2
initial_rating: 5
presentation: 2
questions: 1. Can you provide a summary of the major differences needed to be implemented in the BERT model to transform it into Lamole? Specifically, it appears that the main changes involve using Group SELFIES as input, adding a marginal loss function during training, and computing importance scores using attention weights and gradients. Are there any other architectural or substantial modifications required?

2. Can you include large language model (LLM)-based models in the comparison with Lamole, e.g. Llama 3.1 or ChemLLM[1]? In particular, we can use prompting to generate explanations for the most important parts of the molecule for LLM-based models.

3. How does the model scale with larger datasets and more complex molecules? Are there any computational bottlenecks introduced by the marginal loss or the computation of importance scores?

[1] Zhang, Di, et al. "Chemllm: A chemical large language model." arXiv preprint arXiv:2402.06852 (2024).
soundness: 2
strengths: - The paper is well-organized and clearly written. It provides detailed explanations of the methodology, covering both theoretical foundations and practical implementations. 

- Methodology-wise, it introduces a marginal loss function that aligns the model's explanations with chemists' annotations. This approach aims to improve the faithfulness of the explanations by ensuring they are grounded in expert knowledge, which is valuable for applications requiring interpretability. 

- The paper conducts experiments on multiple datasets and compares the proposed method with several baselines, including both graph neural network (GNN)-based models and transformer-based models using SMILES representations. This comprehensive evaluation helps in assessing the performance of Lamole across different scenarios.
summary: The paper introduces Lamole, a framework designed for explainable molecular property prediction using transformer-based language models. Lamole utilizes Group SELFIES, a string-based molecular representation that encodes molecules at the functional group or fragment level, providing chemically meaningful tokens as input. The model integrates attention weights and gradients from the transformer architecture to compute importance scores for each substructure, aiming to generate explanations that align with chemical concepts. Additionally, a marginal loss function is introduced to align the model's explanations with chemists' annotations, enhancing the faithfulness of the explanations to the structure-property relationships. Experimental results on mutagenicity and hepatotoxicity datasets indicate that Lamole achieves comparable classification accuracy and improves explanation accuracy compared to baseline methods.
weaknesses: The technical novelty is limited, as Lamole is essentially a BERT model with Group SELFIES input and a new loss function. The use of attention weights combined with gradients for explanations lacks proper justification, especially given known issues with attention-based interpretability. The dependence on expert annotations severely limits practical applicability, while the marginal performance improvements don't justify the added complexity. The evaluation lacks comparisons with modern language models that could potentially generate explanations through prompting. The theoretical analysis of the marginal loss, while interesting, overshadows more practical concerns about model utility.

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 2
questions: 1) The presentation of ground truth explanations for the dataset is ambiguous. Line 826 states that “the ground truth for the mutagenic class is benzene with a chemical group, such as N=N, NO₂, and NH₂.” However, the limitations section mentions that “the proposed Lamole still requires human label annotations as additional supervisory signals.” This raises questions about how the ground truth is derived and the role of human annotations in this process.

2) If the ground truth annotations are human-derived, are they based on chemical principles or domain-specific knowledge? Additionally, are these ground truth explanations employed in the comparative methods, and if so, how are they implemented?

3) Providing a rationale for selecting baselines would strengthen the study. Given that the proposed method is an inherent explanation model, why are post-hoc methods chosen for comparison? Are there potentially more appropriate models available for this purpose?

4)  Regarding the chemical explanations, the claim in line 826 lacks persuasive evidence. Additional support from relevant chemical literature, such as [1], would enhance this assertion. Could the authors also provide further evidence from chemical sources to substantiate their claims?

5)  In Table 1, why does the GIN model outperform more complex models, such as ChemBERTa?

6) Are all datasets in this study composed of 2D graphs? What criteria are used for dataset selection, and could the six mutagenicity datasets be considered a single dataset due to their similarities? It would be beneficial to examine experimental results from other datasets.

7) Additional experimental results and conclusions from the ablation study would enhance the paper.

8) Given the limited number of functional groups in molecules, what advantages does an advanced architecture for explanations offer over simpler approaches like brute-force or heuristic search methods? It would be informative to see performance results on larger and more complex molecules.

9) In Section A.8 of the Appendix, the paper provides statistical data on training and inference times. What is the time complexity of the proposed method, and why are similar timing statistics not provided for all baseline methods?

10) How does the performance of the pre-trained models affect the final explanation results? Furthermore, why is the Zinc dataset selected for pre-training?

11) What advantages does explanation plausibility offer compared to explanation accuracy as an evaluation metric? Why is the title for Fig. 11 “Explanation Accuracy”?

12) Given that the performance of the baselines is similar, how are they trained or fine-tuned to ensure a fair comparison? Are techniques such as grid search employed? It would be helpful to provide further details.

[1]  Patlewicz, G., Rodford, R. and Walker, J.D., 2003. Quantitative structure‐activity relationships for predicting mutagenicity and carcinogenicity. Environmental Toxicology and Chemistry: An International Journal, 22(8), pp.1885-1893.
soundness: 2
strengths: 1) The paper incorporates language models (LMs) to facilitate scientifically meaningful explanations, potentially promoting advancements in related fields.

2) The paper proposes a novel method that combines attention weights with gradients to capture interactions between functional groups.

3) The paper presents a brief theoretical analysis that bridges the manifold hypothesis with explainable molecular property prediction.

4) The paper introduces a new model, Lamole, and demonstrates the effectiveness of the proposed methods through experiments on seven datasets. Ablation studies and visualizations further illustrate the performance of the proposed approach.
summary: This work primarily focuses on providing meaningful and faithful explanations for molecular property predictions through the use of language models. To ensure scientifically meaningful explanations, Group SELFIES is employed to decompose SMILES strings into functional groups, which serve as basic explanatory units to maintain chemical relevance. Transformer-based LMs which are pretrained and fine-tuned with Group SELFIES strings, are leveraged to combine attention weights with gradients, capturing interactions between functional groups. Additionally, a marginal loss function and a theoretical analysis are introduced to enhance the explanation results. The effectiveness of the proposed approach is demonstrated through experiments on seven datasets, accompanied by visualizations that illustrate the outcome of the proposed method.
weaknesses: 1) The novelty and contributions of this paper are limited. Although it aims to provide chemically meaningful explanations, understand functional group interactions, and faithfully reveal molecular structure-property relationships, it achieves little beyond addressing functional group interactions. Overall, the paper offers limited insights.

2) The proposed method employs gradients and attention mechanisms to capture functional group interactions; however, it lacks in-depth or theoretical analysis, despite the experimental results demonstrating the approach’s effectiveness.

3) The paper includes an excessive amount of information without clearly establishing connections to the primary research problem. For instance, on line 265, it states, “To address this issue, …” and subsequently introduces a max-margin loss function. However, it remains unclear which specific issue is being addressed and how this function directly relates to the problem. A similar lack of clarity appears on line 323, where the authors mention “projecting the causal features and spurious features into the data manifold.” It would be helpful to know if definitions of causal features and spurious features are provided in the paper. Furthermore, given that the paper focuses on identifying optimal subgraphs, it is unclear if these features are specifically discussed in the context of subgraphs.

4) The work relies heavily on functional groups obtained through Group SELFIES, which may limit its generalizability and broader applicability. While the primary objective of an explanation model is to offer user-friendly interpretations, the necessity of incorporating explanation methods diminishes if only a limited set of subgraphs is available.

5) Lastly, while the paper introduces LMs to address the problem, it provides little justification for their necessity or potential within this context.

---

confidence: 4
contribution: 2
initial_rating: 6
presentation: 4
questions: - How is the threshold for the importance score determined? For example, in Figure 1(g), nitro-0 and benzene-1 do not appear to show a significant difference, as only nitro-0 and benzene-0 are presented as results.
- Why is the variance of the EP score much larger than that of the baselines?
- Do the results based on the experimental settings of GNNExplainer align with domain experts’ perspectives? Specifically, does high explanation accuracy truly indicate that the model explains well? The binary edge classification seems somewhat unconventional and lacks validity for me.
- Does the information flow-based explanation improve explainability in other domains? The approach appears to be general enough for broader applications.
- How is the ground truth defined in Figure 4?
soundness: 3
strengths: - This work sheds light on the important but often overlooked topic of explainability in molecular property prediction.
- The comprehensive experiments, including effective visualizations such as attention scores and explanation visualizations, enhance the overall comprehensibility of the paper.
summary: This paper introduces Lamole, an explainable molecular property prediction model based on language models. It employs GroupSELFIES, self-attention weights, and gradients to extract the impact of chemically meaningful substructures on the output of molecular property predictions.
weaknesses: - The baselines presented in Table 1 are outdated, with the most recent one dating back to 2020. While I understand that the baselines for explanation accuracy may be limited, there is room for improvement in the property prediction baselines.
- Including a baseline with GROUPSELFIES (incorporating LSTM/Transformer) in Table 1 could strengthen the experimental results.

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 2
questions: Please refer to Weaknesses.
soundness: 1
strengths: 1. The explainable molecular property prediction is crucial to drug discovery.
2. The paper is well-written and easy to follow.
summary: The paper introduces Lamole, an explainable language-based model designed for predicting molecular properties. It uses Group SELFIES representation as input to a pre-trained language model and generates explanations using both gradients and attention weights. Additionally, it incorporates annotations from chemists to enhance the explanations provided.
weaknesses: 1. My primary concern centers on the experimental section of the paper. The seven datasets employed are all relatively small, which may not fully demonstrate the scalability or generalizability of the proposed method. To address this, it would be beneficial to extend the testing to include medium-sized and large-sized datasets.
2. The experimental section would benefit from having more advanced baseline comparisons. Given that the proposed method uses Group SELFIES representation, it is essential to conduct a comparison with other motif-based graph explanation methods. Additionally, since the proposed method is a language-based model, it would be highly beneficial to compare it with other language-based models for molecular property prediction.
3. Explanation accuracy is insufficient for thoroughly evaluating an explanation method. Additional metrics, such as Fidelity +/-, should also be employed to assess the method's effectiveness. 
4. The reliance on annotations that require domain knowledge presents a limitation, as most datasets do not include this information. This restricts the applicability of the proposed method across various datasets that lack domain-specific annotations.