arXiv:2411.12078v1cs.LG

Molecule Generation with Fragment Retrieval Augmentation

Seul Lee1∗, Karsten Kreis2, Srimukh Prasad Veccham2, Meng Liu2, Danny Reidenbach2, Saee Paliwal2, Arash Vahdat2†, Weili Nie2†

1KAIST · 2NVIDIA

seul.lee@kaist.ac.kr

{kkreis,sveccham,menliu,dreidenbach,saeep,avahdat,wnie}@nvidia.com

∗Work done during an internship at NVIDIA.
†Equal advising.

Abstract

Fragment-based drug discovery, in which molecular fragments are assembled into new molecules with desirable biochemical properties, has achieved great success. However, many fragment-based molecule generation methods show limited exploration beyond the existing fragments in the database as they only reassemble or slightly modify the given ones. To tackle this problem, we propose a new fragment-based molecule generation framework with retrieval augmentation, namely Fragment Retrieval-Augmented Generation (ff-RAG). ff-RAG is based on a pre-trained molecular generative model that proposes additional fragments from input fragments to complete and generate a new molecule. Given a fragment vocabulary, ff-RAG retrieves two types of fragments: (1) hard fragments, which serve as building blocks that will be explicitly included in the newly generated molecule, and (2) soft fragments, which serve as reference to guide the generation of new fragments through a trainable fragment injection module. To extrapolate beyond the existing fragments, ff-RAG updates the fragment vocabulary with generated fragments via an iterative refinement process which is further enhanced with post-hoc genetic fragment modification. ff-RAG can achieve an improved exploration-exploitation trade-off by maintaining a pool of fragments and expanding it with novel and high-quality fragments through a strong generative prior.

1 Introduction

The goal of small molecule drug discovery is to discover molecules with specific biochemical target properties, such as synthesizability [9], non-toxicity [40], solubility [31] and binding affinity, in the vast chemical space. Fragment-based drug discovery (FBDD) has been considered as an effective approach to explore the chemical space and has resulted in many successful marketed drugs [27]. Contrary to high-throughput screening (HTS) [41] that searches from a library of drug-like molecules, FBDD constructs a library of molecular fragments to synthesize new molecules beyond the existing molecule library, leading to a better chemical coverage [5].

Recently, generative models have been adopted in the field of FBDD to accelerate the process of searching for drug candidates [18, 45, 46, 30, 20, 11, 25]. These methods reassemble or slightly modify the fragments to generate new molecules with the knowledge of the generative model. As the methods are allowed to exploit chemical knowledge in the form of fragments to narrow the search space, they have shown meaningful success in generating optimized molecules. However, their performance is largely limited by the existing library of molecular fragments, where discovering new fragments is either impossible or highly limited. Some of the methods [14, 38, 25] suggested making modifications to existing fragments, but the modifications are only applied to small and local substructures and still heavily dependent on the existing fragments. The limited exploration beyond known fragments greatly hinders the possibility of generating diverse and novel drug candidates that may exhibit better target properties. Therefore, it is a challenge to improve the ability of discovering novel high-quality fragments, while exploiting existing chemical space effectively.

Radar plot with four axes, optimization performance at the top, synthesizability on the right, novelty at the bottom and diversity on the left, and a shape for each of four methods: f-RAG (ours) in blue, Genetic GFN in green, Mol GA in yellow and REINVENT in red.

Figure 1: A radar plot of target properties. ff-RAG strikes better balance among optimization performance, diversity, novelty, and synthesizability than the state-of-the-art techniques on the PMO benchmark [10].

Diagram of the framework. A fragment vocabulary on the left gives hard fragments and soft fragments, drawn as molecules. They go into a pink box, SAFE-GPT with retrieval augmentation: early layers of SAFE-GPT give an input embedding and soft fragment embeddings, a fragment injection block joins them into an augmented embedding, and later layers of SAFE-GPT give a new molecule. The new molecule goes to a molecule population, which feeds a green box below, genetic fragment modification: parent molecules go through crossover and mutation to a new molecule, which is decomposed into fragments. Dashed arrows labelled fragment update return to the fragment vocabulary, and arrows labelled molecule update go to the molecule population.

Figure 2: The overall framework of ff-RAG. After an initial fragment vocabulary is constructed from an existing molecule library, two types of fragments are retrieved during generation. Hard fragments are explicitly included in the newly generated molecules, while soft fragments implicitly guide the generation of new fragments. SAFE-GPT generates a molecule using hard fragments as input, while the fragment injection module in the middle of the SAFE-GPT layers injects the embeddings of soft fragments into the input embedding. After the generation, the molecule population and fragment vocabulary are updated with the newly generated molecule and its fragments, respectively. The exploration is further enhanced with genetic fragment modification, which also updates the fragment vocabulary and molecule population.

To this end, we propose a fragment-based molecule generation framework leveraging retrieval-augmented generation (RAG) [26], namely Fragment Retrieval-Augmented Generation (ff-RAG). As shown in Figure 2, ff-RAG augments the pre-trained molecular language model SAFE-GPT [34] with two types of retrieved fragments: hard fragments and soft fragments for a better exploration-exploitation trade-off. Specifically, we first construct a fragment vocabulary by decomposing known molecules from the existing library into fragments and scoring the fragments by measuring their contribution to target properties. From the fragment vocabulary, ff-RAG first retrieves fragments that will be explicitly included in the new molecule (i.e., hard fragments). Hard fragments serve as the input context to the molecular language model that predicts the remaining fragments. In addition to retrieval of hard fragments, ff-RAG retrieves fragments that will not be part of the generated molecule but provide informative guidance on predicting novel, diverse molecules (i.e., soft fragments). Concretely, the embeddings of soft fragments are fused with the embeddings of hard fragments (or input embeddings) through a lightweight fragment injection module in the middle of SAFE-GPT. The fragment injection module allows SAFE-GPT to generate new fragments by referring to the information conveyed by soft fragments.

During training, we only update the fragment injection module while keeping SAFE-GPT frozen. Inspired by Wang et al. [42], we train ff-RAG to learn how to leverage the retrieved fragments for molecule generation, using a self-supervised loss that predicts the most similar one in the set of soft fragments. At inference, ff-RAG dynamically updates the fragment vocabulary with newly generated fragments via an iterative refinement process. To further enhance exploration, we propose to modify the generated fragments from SAFE-GPT with a post-hoc genetic fragment modification process. The proposed ff-RAG takes the advantages of both hard and soft fragment retrieval to achieve an improved exploration-exploitation trade-off. We verify ff-RAG on various molecular optimization tasks, by examining the optimization performance, along with diversity, novelty, and synthesizability. As shown in Figure 1, ff-RAG exhibits the best balance across these essential considerations, demonstrating its applicability as a promising tool for drug discovery.

We summarize our contributions as follows:

• We introduce ff-RAG, a novel molecular generative framework that combines FBDD and RAG.

• We propose a retrieval augmentation strategy that operates at the fragment level with two types of fragments, allowing fine-grained guidance to achieve an improved exploration-exploitation trade-off and generate high-quality drug candidates.

• Through extensive experiments, we demonstrate the effectiveness of ff-RAG in various drug discovery tasks that simulate real-world scenarios.

2 Related Work

Fragment-based molecule generation. Fragment-based molecular generative models refer to a class of methods that reassemble existing molecular substructures (i.e., fragments) to generate new molecules. Jin et al. [18] proposed to find big molecular substructures that satisfy the given chemical properties, and learn to complete the substructures into final molecules by adding small branches. Xie et al. [45] proposed to progressively add or delete fragments using Markov chain Monte Carlo (MCMC) sampling. Yang et al. [46] proposed to use reinforcement learning (RL) to assemble fragments, while Maziarz et al. [30], Kong et al. [20], and Geng et al. [11] used VAE-based techniques. Lee et al. [25] proposed to take the target chemical properties into account in the fragment vocabulary construction and used a combination of RL and a genetic algorithm (GA) to assemble and modify the fragments. On the other hand, graph-based GAs [14, 38] decompose parent molecules into fragments that are combined to generate an offspring molecule, and are also mutated with a small probability. Since fragment-based strategies are limited by generating molecules outside of the possible combinations of existing fragments, they suffer from limited exploration in the chemical space. Some of the methods [14, 38, 25] suggest making modifications to existing fragments to overcome this problem, but this is not a fundamental solution because the modifications are only local, still being based on the existing fragments.

Retrieval-augmented molecule generation. Retrieval-augmented generation (RAG) [26] refers to a technique that retrieves context from external data databases to guide the generation of a generative model. Recently, RAG has gained attention as a means to enhance accuracy and reliability of large language models (LLMs) [6, 36, 3]. In the field of molecule optimization, Liu et al. [28] developed a text-based drug editing framework that repurposes a conversational language model for solving molecular tasks, where the domain knowledge is injected by a retrieval and feedback module. More related to us, Wang et al. [42] proposed to use a pre-trained molecular language model to generate molecules, while augmenting the generation with retrieved molecules that have high target properties. Contrary to this method that retrieves molecules, our proposed ff-RAG employs a fine-grained retrieval augmentation scheme that operates at the fragment level to achieve an improved exploration-exploitation trade-off.

3 Method

In this section, we introduce our Fragment Retrieval-Augmented Generation (ff-RAG) framework. ff-RAG aims to generate optimized molecules by leveraging existing chemical knowledge through RAG, while exploring beyond the known chemical space under the fragment-based drug discovery (FBDD) paradigm. We first introduce the hard fragment retrieval in Sec. 3.1. Then, we present the soft fragment retrieval in Sec. 3.2. Lastly, we describe the genetic fragment modification in Sec. 3.3.

3.1 Hard Fragment Retrieval

Given a set of NN molecules xix_i and their corresponding properties yi∈[0,1]y_i \in [0, 1], denoted as D={(xi,yi)}i=1N\mathcal{D} = \{(x_i, y_i)\}_{i=1}^N, we first construct a fragment vocabulary. We adopt an arm-linker-arm slicing algorithm provided by Noutahi et al. [34] which decomposes a molecule xx into three fragments: two arms FarmF_{\rm arm} (i.e., fragments that have one attachment point) and one linker FlinkerF_{\mathrm{linker}} (i.e., a fragment that has two attachment points). Decomposing molecules into arms and linkers (or scaffolds) is a popular approach utilized in various drug discovery strategies, such as scaffold decoration or scaffold hopping [37]. We ignored the molecules in the training set that cannot be decomposed, and a set of arms Farm={Farm,j}j=12N\mathcal{F}_{\text{arm}} = \{F_{\text{arm},j}\}_{j=1}^{2N} and a set of linkers Flinker={Flinker,j}j=1N\mathcal{F}_{\text{linker}} = \{F_{\text{linker},j}\}_{j=1}^{N} are obtained after the algorithm is applied to the molecules {xi}i=1N\{x_i\}_{i=1}^N. Subsequently, we calculate the score of each fragment Fj∈Farm∪FlinkerF_j \in \mathcal{F}_{\text{arm}} \cup \mathcal{F}_{\text{linker}} using the average property of all molecules containing FjF_j as their substructure as follows:

Diagram in two rows. Top: two arms, each from an arm vocab, written as one SAFE string, go into SAFE-GPT under the label linker design, which returns a whole molecule with a new linker between them. Bottom: an arm from an arm vocab and a linker from a linker vocab, joined into one fragment, go into SAFE-GPT under the label motif extension, which returns a whole molecule with a new ring added. Each molecule is drawn as a structure with its SAFE string under it, and asterisks mark the attachment points.

Figure 3: Hard fragment retrieval of ff-RAG. With a probability of 50%, ff-RAG either retrieves two arms as hard fragments for linker design (top) or one arm and one linker as hard fragments for motif extension (bottom).

score(Fj)=1∣S(Fj)∣∑(x,y)∈S(Fj)y,(1)\mathrm{score}(F_j) = \frac{1}{|S(F_j)|} \sum_{(x,y) \in S(F_j)} y, \tag{1}

where score(Fj)∈[0,1]\text{score}(F_j) \in [0,1], and S(Fj)={(x,y)∈D:Fj is a fragment of x}S(F_j) = \{(x,y) \in \mathcal{D} : F_j \text{ is a fragment of } x\}. Intuitively, the fragment score evaluates the contribution of a given fragment to the target property of the whole molecule of which it is a part. From Farm\mathcal{F}_{\text{arm}} and Flinker\mathcal{F}_{\text{linker}}, we choose the top-NfragN_{\rm frag} fragments based on the score to construct the arm fragment vocabulary Varm⊂Farm\mathcal{V}_{\text{arm}} \subset \mathcal{F}_{\text{arm}} and the linker fragment vocabulary Vlinker⊂Flinker\mathcal{V}_{\text{linker}} \subset \mathcal{F}_{\text{linker}}, respectively.

Given the fragment vocabularies Varm\mathcal{V}_{\mathrm{arm}} and Vlinker\mathcal{V}_{\text{linker}} consisting of high-property fragments, two hard fragments are randomly retrieved from the vocabularies. The hard fragments together form a partial molecular sequence that serves as input to a pre-trained molecular language model. In this work, we employ Sequential Attachment-based Fragment Embedding (SAFE) [34] as the molecular representation and SAFE-GPT [34] as the backbone generative model of ff-RAG. SAFE is a noncanonical version of simplified molecular-input line-entry system (SMILES) [43] that represents molecules as a sequence of dot-connected fragments. Importantly, the order of fragments in a SAFE string does not affect the molecular identity. Using the SAFE representation, ff-RAG forces the hard fragments to be included in a newly generated molecule by providing them as an input sequence to the language model to complete the rest of the sequence.

During generation, with a probability of 50%, ff-RAG either (1) retrieves two hard fragments from Varm\mathcal{V}_{\text{arm}} or (2) retrieves one from Varm\mathcal{V}_{\text{arm}} and one from Vlinker\mathcal{V}_{\text{linker}}. In the former case, ff-RAG performs linker design, which generates a new fragment that links the input fragments. In the latter case, ff-RAG first randomly selects an attachment point in the retrieved linker and combines it with the retrieved arm to form a single fragment, and then performs motif extension, which generates a new fragment that completes the molecule (Figure 3).

3.2 Soft Fragment Retrieval

Given two hard fragments as input, the molecular language model generates one new fragment to complete a molecule. Instead of relying solely on the model to generate the new fragment, we propose to augment the generation with the information of KK retrieved fragments, which we refer to as soft fragments, to guide the generation. Specifically, if the two hard fragments are all arms, ff-RAG randomly retrieves soft fragments from Vlinker\mathcal{V}_{\text{linker}}. If one of the hard fragments is an arm and another is a linker, ff-RAG randomly retrieves soft fragments from Varm\mathcal{V}_{\text{arm}}. Using up to the LL-th layer of the lauguage model LM0:L\text{LM}^{0:L}, the embeddings of the input sequence xinputx_{\text{input}} and the soft fragments {Fsoft,k}k=1K\{F_{\text{soft},k}\}_{k=1}^K are obtained as follows:

hinput=LM0:L(xinput)  and  Hsoft=concatenate([hsoft1,hsoft2,…,hsoftK]),where  hsoftk=LM0:L(Fsoft,k) for k=1,2,…,K.(2)\begin{split} \boldsymbol{h}_{\text{input}} = \text{LM}^{0:L}(x_{\text{input}}) \ \ \text{and} \ \ \boldsymbol{H}_{\text{soft}} = \text{concatenate}([\boldsymbol{h}_{\text{soft}}^1, \boldsymbol{h}_{\text{soft}}^2, \dots, \boldsymbol{h}_{\text{soft}}^K]), \\ \text{where} \ \ \boldsymbol{h}_{\text{soft}}^k = \text{LM}^{0:L}(F_{\text{soft},k}) \ \text{for} \ k{=}1,2,\dots,K. \end{split} \tag{2}
Diagram of the training. A training molecule x = F1.F2.F3 is split: the input sequence F1.F2, and the soft fragments F3, F3 2NN, F3 3NN and on to F3 KNN, go into SAFE-GPT with retrieval augmentation, where early layers of SAFE-GPT give an input embedding and soft fragment embeddings, fragment injection joins them into an augmented embedding, and later layers of SAFE-GPT give the output. The output, F3 1NN with a hat, is compared with the target sequence, F3 1NN, by cross entropy.

Figure 4: The self-supervised training process of the fragment injection module of ff-RAG. FkNNF^{k{\rm NN}} denotes the kk-th most similar fragment to FF. Using F1F_1 and F2F_2 as hard fragments, while using F3F_3 and its neighbors {F3kNN}k=2K\{F_3^{kNN}\}_{k=2}^K as soft fragments, the training objective is to predict F31NNF_3^{1NN}.

Subsequently, ff-RAG injects the embeddings of soft fragments through a trainable fragment injection module. Following Wang et al. [42], the fragment injection module uses cross-attention to fuse the embeddings of the input sequence and soft fragments as follows:

h=FI(hinput,Hsoft)=softmax(Query(hinput)⋅Key(Hsoft)⊤dKey)⋅Value(Hsoft),(3)\boldsymbol{h} = \text{FI}(\boldsymbol{h}_{\text{input}}, \boldsymbol{H}_{\text{soft}}) = \text{softmax}\left(\frac{\text{Query}(\boldsymbol{h}_{\text{input}}) \cdot \text{Key}(\boldsymbol{H}_{\text{soft}})^{\top}}{\sqrt{d_{\text{Key}}}}\right) \cdot \text{Value}(\boldsymbol{H}_{\text{soft}}), \tag{3}

where FI is the fragment injection module, Query, Key, and Value are multi-layer perceptrons (MLPs), and dKeyd_{\mathrm{Key}} is the output dimension of Key. Next, a molecule is generated by decoding the augmented embedding h\boldsymbol{h} using the later layers of the language model as xnew=LML+1:LT(h)x_{\text{new}} = \text{LM}^{L+1:L_T}(\boldsymbol{h}), where LTL_T is the total number of layers of the model. With the fragment injection module, ff-RAG can utilize information of soft fragments to generate novel fragments which are also likely to contribute to the high target properties. During generation, the fragment vocabulary is dynamically updated through an iterative process that scores newly generated fragments based on Eq. (1) and replaces fragments in the fragment vocabulary to the top-NfragN_{\mathrm{frag}} fragments.

Next, we need to train ff-RAG to learn how to augment the retrieved soft fragments into the molecule generation. To retain the high generation quality of SAFE-GPT and make the training process efficient, we keep the backbone language model frozen and only train the lightweight fragment injection module. Inspired by Wang et al. [42], we propose a new self-supervised objective that predicts the most similar fragment to the input fragments. Specifically, each molecular sequence xx in the training set is first decomposed into fragment sequences (F1,F2,F3)(F_1, F_2, F_3) with a random permutation between the fragments, using the same slicing algorithm used in the vocabulary construction. Importantly, using the SAFE representation, xx can be simply represented by connecting its fragments with dots as F1.F2.F3F_1.F_2.F_3. We consider the first two fragments as hard fragments. Given the remaining fragment F3F_3, we retrieve its KK most similar fragments {F3kNN}k=1K\{F_3^{kNN}\}_{k=1}^K from the training fragment pool. Here, we use the pairwise Tanimoto similarity using Morgan fingerprints of radius 2 and 1024 bits. Using the hard fragments as the input sequence as F1.F2F_1.F_2, the objective is to predict the most similar fragment F31NNF_3^{1NN} utilizing the original fragment and the next K−1K-1 most similar fragments {F3kNN}k=2K\{F_3^{kNN}\}_{k=2}^K as the soft fragments. The training process is illustrated in Figure 4, and the details are provided in Section D.1.

Note that the training of the fragment injection module is target property-agnostic, as the fragments used for training are independent of the target property. In contrast, the fragment vocabularies used for generation are target property-specific, as it is constructed using the scoring function in Eq. (1). This allows ff-RAG to effectively generate optimized molecules across different target properties without any retraining.

3.3 Genetic Fragment Modification

To further enhance exploration in the chemical space, we propose to modify the generated fragments with a post-hoc genetic algorithm (GA). Specifically, we adopt the operations of Graph GA [14]. We first initialize the population P\mathcal{P} with the top-NmolN_{\rm mol} molecules generated by our fragment retrieval-augmented SAFE-GPT based on the target property yy. Parent molecules are then randomly selected from the population and offspring molecules are generated by the crossover and mutation operations (see Jensen [14] for more details). The offspring molecules can have new fragments not contained in the initial fragment vocabulary, and the fragment vocabularies Varm\mathcal{V}_{\text{arm}} and Vlinker\mathcal{V}_{\text{linker}} are again updated by the top-NfragN_{\mathrm{frag}} fragments based on the scores of Eq. (1). In the subsequent generation, the population P\mathcal{P} is updated with the generated molecules so far by both SAFE-GPT and GA.

As shown in Figure 2, ff-RAG generates desirible molecules through multiple cycles of (1) the SAFE-GPT generation augmented with the hard fragment retrieval (Section 3.1) and the soft fragment retrieval (Section 3.2), and (2) the GA generation (Section 3.3). Through this interplay of hard fragment retrieval, soft fragment retrieval, and the genetic fragment modification, ff-RAG can exploit existing chemical knowledge through the form of fragments both explicitly and implicitly, while exploring beyond initial fragments by the dynamic vocabulary update. We summarize the generation process of ff-RAG in Algorithm 1 in Section C.

4 Experiments

We validate ff-RAG on molecule generation tasks that simulate various real-world drug discovery problems. We first conduct experiments on the practical molecular optimization (PMO) benchmark [10] in Section 4.1. We then conduct experiments to generate novel molecules that have high binding affinity, drug-likeness, and synthesizability in Section 4.2. We further perform analyses in Section 4.3.

4.1 Experiments on PMO Benchmark

Setup. We demonstrate the efficacy of ff-RAG on the 23 tasks from the PMO benchmark. Following the standard setting of the benchmark, we set the maximum number of oracle calls to 10,000 and evaluate optimization performance with the area under the curve (AUC) of the average property scores of the top-10 molecules versus oracle calls. In addition, we evaluate diversity, novelty, and synthesizability of generated molecules, other essential considerations in drug discovery. We use the Therapeutics Data Commons (TDC) library [12] to calculate diversity. Following previous works [18, 45, 24, 25], novelty is defined as the fraction of molecules that have the maximum Tanimoto similarity less than 0.4 with the training molecules. We use the synthetic accessibility (SA) [8] score of the TDC library to measure synthesizability. These values are measured using the top-100 generated molecules, following the setting of the benchmark. Further explanation on the evaluation metrics and experimental setup are provided in Section D.3.

Baselines. We employ the top-7 methods reported by the PMO benchmark and two recent state-of-the-art methods as our baselines. Graph GA [14] is a GA with a fragment-level crossover operation, and Mol GA [38] is a more hyperparameter-tuned version of Graph GA. Genetic GFN [19] is a method that uses Graph GA to guide generation of a GFlowNet. REINVENT [35] is a SMILES-based RL model and SELFIES-REINVENT is a modified REINVENT that uses the self-referencing embedded strings (SELFIES) [21] representation. GP BO [39] is a method that optimizes the Gaussian process acquisition function with Graph GA. STONED [33] is a GA-based model that operates on SELFIES strings. LSTM HC [7] is a SMILES-based LSTM model. SMILES GA [47] is a GA whose genetic operations are based on the SMILES context-free grammar.

Results. The results of optimization performance are shown in Table 1. ff-RAG outperforms the previous methods in terms of the sum of the AUC top-10 values and achieves the highest AUC top-10 values in 12 out of 23 tasks, demonstrating that the proposed combination of hard fragment retrieval, soft fragment retrieval, and genetic fragment modification is highly effective in discovering optimized drug candidates that have high target properties. On the other hand, the average scores of diversity, novelty, and synthesizability of the generated molecules are summarized in Table 2, and the full results are presented in Tables 4, 5, and 6. As shown in these tables, ff-RAG achieves the best diversity and synthesizability, and the second best novelty. Notably, ff-RAG shows the highest diversity in 12 out of 23 tasks, and the highest synthesizability in 19 out of 23 tasks. Note that the high novelty value of Mol GA comes at the cost of other important factors, i.e., optimization performance, diversity, and synthesizability. The essential considerations in drug discovery often conflict with each other, making the drug discovery problem challenging. These trade-offs are also visualized in Figure 1 and Figure 7, and ff-RAG effectively improves the trade-offs by utilizing existing fragments while dynamically updating the fragment vocabulary with newly proposed fragments.

4.2 Optimization of Docking Score under QED, SA, and Novelty Constraints

Setup. Following Lee et al. [24] and Lee et al. [25], we validate ff-RAG in a set of tasks that aim to optimize the binding affinity against a target protein while also maintaining high drug-likeness, synthesizability, and novelty. Following the previous works, we use docking score calculated by QuickVina 2 [2] with five protein targets, parp1, fa7, 5ht1b, braf, and jak2, to measure binding affinity. We use quantitative estimates of drug-likeness (QED) [4] and SA [8] to measure drug-likeness and synthesizability, respectively. Following the previous works, we set the target property yy as follows:

Table 1: PMO AUC top-10 results. The results are the mean and standard deviation of 3 independent runs. The results for Genetic GFN [19] and Mol GA [38] are taken from the respective original papers and the results for other baselines are taken from Gao et al. [10]. The best results are highlighted in bold.

Oracleff-RAG (ours)Genetic GFNMol GAREINVENTGraph GA
albuterol_similarity0.977 ± 0.0020.949 ± 0.0100.896 ± 0.0350.882 ± 0.0060.838 ± 0.016
amlodipine_mpo0.749 ± 0.0190.761 ± 0.0190.688 ± 0.0390.635 ± 0.0350.661 ± 0.020
celecoxib_rediscovery0.778 ± 0.0070.802 ± 0.0290.567 ± 0.0830.713 ± 0.0670.630 ± 0.097
deco_hop0.936 ± 0.0110.733 ± 0.1090.649 ± 0.0250.666 ± 0.0440.619 ± 0.004
drd20.992 ± 0.0000.974 ± 0.0060.936 ± 0.0160.945 ± 0.0070.964 ± 0.012
fexofenadine_mpo0.856 ± 0.0160.856 ± 0.0390.825 ± 0.0190.784 ± 0.0060.760 ± 0.011
gsk3b0.969 ± 0.0030.881 ± 0.0420.843 ± 0.0390.865 ± 0.0430.788 ± 0.070
isomers_c7h8n2o20.955 ± 0.0080.969 ± 0.0030.878 ± 0.0260.852 ± 0.0360.862 ± 0.065
isomers_c9h10n2o2pf2cl0.850 ± 0.0050.897 ± 0.0070.865 ± 0.0120.642 ± 0.0540.719 ± 0.047
jnk30.904 ± 0.0040.764 ± 0.0690.702 ± 0.1230.783 ± 0.0230.553 ± 0.136
median10.340 ± 0.0070.379 ± 0.0100.257 ± 0.0090.356 ± 0.0090.294 ± 0.021
median20.323 ± 0.0050.294 ± 0.0070.301 ± 0.0210.276 ± 0.0080.273 ± 0.009
mestranol_similarity0.671 ± 0.0210.708 ± 0.0570.591 ± 0.0530.618 ± 0.0480.579 ± 0.022
osimertinib_mpo0.866 ± 0.0090.860 ± 0.0080.844 ± 0.0150.837 ± 0.0090.831 ± 0.005
perindopril_mpo0.681 ± 0.0170.595 ± 0.0140.547 ± 0.0220.537 ± 0.0160.538 ± 0.009
qed0.939 ± 0.0010.942 ± 0.0000.941 ± 0.0010.941 ± 0.0000.940 ± 0.000
ranolazine_mpo0.820 ± 0.0160.819 ± 0.0180.804 ± 0.0110.760 ± 0.0090.728 ± 0.012
scaffold_hop0.576 ± 0.0140.615 ± 0.1000.527 ± 0.0250.560 ± 0.0190.517 ± 0.007
sitagliptin_mpo0.601 ± 0.0110.634 ± 0.0390.582 ± 0.0400.021 ± 0.0030.433 ± 0.075
thiothixene_rediscovery0.584 ± 0.0090.583 ± 0.0340.519 ± 0.0410.534 ± 0.0130.479 ± 0.025
troglitazone_rediscovery0.448 ± 0.0170.511 ± 0.0540.427 ± 0.0310.441 ± 0.0320.390 ± 0.016
valsartan_smarts0.627 ± 0.0580.135 ± 0.2710.000 ± 0.0000.178 ± 0.3580.000 ± 0.000
zaleplon_mpo0.486 ± 0.0040.552 ± 0.0330.519 ± 0.0290.358 ± 0.0620.346 ± 0.032
Sum16.92816.21314.70814.19613.751
OracleSELFIES-REINVENTGP BOSTONEDLSTM HCSMILES GA
albuterol_similarity0.826 ± 0.0300.898 ± 0.0140.745 ± 0.0760.719 ± 0.0180.661 ± 0.066
amlodipine_mpo0.607 ± 0.0140.583 ± 0.0440.608 ± 0.0460.593 ± 0.0160.549 ± 0.009
celecoxib_rediscovery0.573 ± 0.0430.723 ± 0.0530.382 ± 0.0410.539 ± 0.0180.344 ± 0.027
deco_hop0.631 ± 0.0120.629 ± 0.0180.611 ± 0.0080.826 ± 0.0170.611 ± 0.006
drd20.943 ± 0.0050.923 ± 0.0170.913 ± 0.0200.919 ± 0.0150.908 ± 0.019
fexofenadine_mpo0.741 ± 0.0020.722 ± 0.0050.797 ± 0.0160.725 ± 0.0030.721 ± 0.015
gsk3b0.780 ± 0.0370.851 ± 0.0410.668 ± 0.0490.839 ± 0.0150.629 ± 0.044
isomers_c7h8n2o20.849 ± 0.0340.680 ± 0.1170.899 ± 0.0110.485 ± 0.0450.913 ± 0.021
isomers_c9h10n2o2pf2cl0.733 ± 0.0290.469 ± 0.1800.805 ± 0.0310.342 ± 0.0270.860 ± 0.065
jnk30.631 ± 0.0640.564 ± 0.1550.523 ± 0.0920.661 ± 0.0390.316 ± 0.022
median10.355 ± 0.0110.301 ± 0.0140.266 ± 0.0160.255 ± 0.0100.192 ± 0.012
median20.255 ± 0.0050.297 ± 0.0090.245 ± 0.0320.248 ± 0.0080.198 ± 0.005
mestranol_similarity0.620 ± 0.0290.627 ± 0.0890.609 ± 0.1010.526 ± 0.0320.469 ± 0.029
osimertinib_mpo0.820 ± 0.0030.787 ± 0.0060.822 ± 0.0120.796 ± 0.0020.817 ± 0.011
perindopril_mpo0.517 ± 0.0210.493 ± 0.0110.488 ± 0.0110.489 ± 0.0070.447 ± 0.013
qed0.940 ± 0.0000.937 ± 0.0000.941 ± 0.0000.939 ± 0.0000.940 ± 0.000
ranolazine_mpo0.748 ± 0.0180.735 ± 0.0130.765 ± 0.0290.714 ± 0.0080.699 ± 0.026
scaffold_hop0.525 ± 0.0130.548 ± 0.0190.521 ± 0.0340.533 ± 0.0120.494 ± 0.011
sitagliptin_mpo0.194 ± 0.1210.186 ± 0.0550.393 ± 0.0830.066 ± 0.0190.363 ± 0.057
thiothixene_rediscovery0.495 ± 0.0400.559 ± 0.0270.367 ± 0.0270.438 ± 0.0080.315 ± 0.017
troglitazone_rediscovery0.348 ± 0.0120.410 ± 0.0150.320 ± 0.0180.354 ± 0.0160.263 ± 0.024
valsartan_smarts0.000 ± 0.0000.000 ± 0.0000.000 ± 0.0000.000 ± 0.0000.000 ± 0.000
zaleplon_mpo0.333 ± 0.0260.221 ± 0.0720.325 ± 0.0270.206 ± 0.0060.334 ± 0.041
Sum13.47113.15613.02412.22312.054

Table 2: Top-100 diversity, top-100 novelty, and top-100 SA score results. The results are the average values of all 23 tasks. The best results are highlighted in bold.

Metricff-RAG (ours)Genetic GFNMol GAREINVENT
Average diversity ↑0.5320.4430.4910.468
Average novelty ↑0.8000.7240.8450.540
Average SA score ↓2.0263.7704.6053.207

Table 3: Novel top 5% docking score (kcal/mol) results. The results are the means and standard deviations of 3 independent runs. The results for RationaleRL, PS-VAE, RetMol, and GEAM are taken from Lee et al. [25]. Other baseline results except for Genetic GFN are taken from Lee et al. [24]. Lower is better, and the best results are highlighted in bold.

Methodparp1fa75ht1bbrafjak2
JT-VAE [16]-9.482 ± 0.132-7.683 ± 0.048-9.382 ± 0.332-9.079 ± 0.069-8.885 ± 0.026
REINVENT [35]-8.702 ± 0.523-7.205 ± 0.264-8.770 ± 0.316-8.392 ± 0.400-8.165 ± 0.277
Graph GA [14]-10.949 ± 0.532-7.365 ± 0.326-10.422 ± 0.670-10.789 ± 0.341-10.167 ± 0.576
MORLD [15]-7.532 ± 0.260-6.263 ± 0.165-7.869 ± 0.650-8.040 ± 0.337-7.816 ± 0.133
HierVAE [17]-9.487 ± 0.278-6.812 ± 0.274-8.081 ± 0.252-8.978 ± 0.525-8.285 ± 0.370
GA+D [32]-8.365 ± 0.201-6.539 ± 0.297-8.567 ± 0.177-9.371 ± 0.728-8.610 ± 0.104
MARS [45]-9.716 ± 0.082-7.839 ± 0.018-9.804 ± 0.073-9.569 ± 0.078-9.150 ± 0.114
GEGL [1]-9.329 ± 0.170-7.470 ± 0.013-9.086 ± 0.067-9.073 ± 0.047-8.601 ± 0.038
RationaleRL [18]-10.663 ± 0.086-8.129 ± 0.048-9.005 ± 0.155No hit found-9.398 ± 0.076
FREED [46]-10.579 ± 0.104-8.378 ± 0.044-10.714 ± 0.183-10.561 ± 0.080-9.735 ± 0.022
PS-VAE [20]-9.978 ± 0.091-8.028 ± 0.050-9.887 ± 0.115-9.637 ± 0.049-9.464 ± 0.129
MOOD [24]-10.865 ± 0.113-8.160 ± 0.071-11.145 ± 0.042-11.063 ± 0.034-10.147 ± 0.060
RetMol [42]-8.590 ± 0.475-5.448 ± 0.688-6.980 ± 0.740-8.811 ± 0.574-7.133 ± 0.242
GEAM [25]-12.891 ± 0.158-9.890 ± 0.116-12.374 ± 0.036-12.342 ± 0.095-11.816 ± 0.067
Genetic GFN [19]-9.227 ± 0.644-7.288 ± 0.433-8.973 ± 0.804-8.719 ± 0.190-8.539 ± 0.592
ff-RAG (ours)-12.945 ± 0.053-9.899 ± 0.205-12.670 ± 0.144-12.390 ± 0.046-11.842 ± 0.316
y=DS^×QED×SA^∈[0,1],(4)y = \widehat{\mathrm{DS}} \times \mathrm{QED} \times \widehat{\mathrm{SA}} \in [0,1], \tag{4}

where DS^\widehat{\mathrm{DS}} and SA^\widehat{\mathrm{SA}} are the normalized DS and SA according to Eq. (7) in Section D.4. We generate 3,000 molecules and evaluate them using novel top 5% DS (kcal/mol), which indicates the mean DS of the top 5% unique and novel hits. Here, novel hits are defined as the molecules that satisfy all the following criteria: (the maximum similarity with the training molecules) < 0.4, DS < (the median DS of known active molecules), QED > 0.5, and SA < 5. Further details are provided in Section D.4.

Baselines. JT-VAE [16], HierVAE [17], MARS [45], RationaleRL [18], FREED [46], PS-VAE [20], and GEAM [25] are the methods that first construct a fragment vocabulary using a molecular dataset, then learn to assemble those fragments to generate new molecules. On the other hand, Graph GA [14], GEGL [1], and Genetic GFN [19] are GA-based methods that utilize the information of fragments by adopting the fragment-based crossover operation. GA+D [32] is a discriminator-enhanced GA method that operates on the SELFIES representation. RetMol [42] is a retrieval-based method that uses retrieved example molecules to augment the generation of a pre-trained molecular language model. REINVENT [35] and MORLD [15] are RL models that operate on SMILES and graph molecular representations, respectively. MOOD [24] is a diffusion model that employs an out-of-distribution control to improve novelty.

Results. The results are shown in Table 3. In all five tasks, ff-RAG outperforms all the baselines. Note that the evaluation metric, novel top 5% DS, is designed to reflect the nature of the drug discovery problem, which optimizes multiple target properties by finding a good balance between exploration and exploitation. The results demonstrate the superiority of ff-RAG in generating drug-like, synthesizable, and novel drug candidates that have high binding affinity to the target protein with the improved exploration-exploitation trade-off. We additionally visualize the generated molecules in Figure 8.

Additional comparison with GEAM. To further justify the advantage of ff-RAG over GEAM, we additionally include the results of seven multi-property optimization (MPO) tasks in the PMO benchmark (Section 4.1) in Table 7. As we can see, ff-RAG significantly outperforms GEAM in all the tasks, validating its applicability to a wide range of drug discovery problems.

Three panels. (a) Line plot of Avg. Top-10 against number of oracle calls, from 0 to 10,000, with a line for each of four versions of f-RAG: hard+soft+GA in blue, soft+GA in green, hard+GA in yellow and hard+soft in red. (b) Radar plot with axes optimization performance, synthesizability, novelty and diversity, with a shape for the same four and for f-RAG (GA) in grey. (c) The same radar plot for f-RAG in blue and f-RAG with delta = 0.8 in green, 0.6 in yellow and 0.4 in red.

Figure 5: (a) The optimization curves in the deco_hop task of the PMO benchmark of the ablated ff-RAGs. Solid lines denote the mean and shaded areas denote the standard deviation of 3 independent runs. (b) Overall results of the ablated ff-RAGs. (c) Results with different values of δ\delta of the similarity-based fragment filter.

4.3 Analysis

Ablation study. To verify the effect of each component of ff-RAG, we conduct experiments with various combinations of the components, i.e., hard fragment retrieval (hard), soft fragment retrieval (soft), and genetic fragment modification (GA), in Figure 5(a) and Figure 5(b). The detailed results are shown in Table 8 and Table 9. For ff-RAG (soft+GA) that does not utilize the hard fragment retrieval, we randomly initialized the fragment vocabularies instead of selecting the top-NfragN_{\rm frag} fragments based on Eq. (1) and let the model use random hard fragments. Note that even though ff-RAG (hard+soft), ff-RAG that does not utilize the genetic fragment modification, shows very high diversity, the value is not meaningful as the generated molecules are not highly optimized, not novel, and not synthesizable. The same applies to the high novelty of ff-RAG (soft+GA) and ff-RAG (GA). On the contrary, the full ff-RAG achieves the best optimization performance and synthesizability while showing reasonably high diversity and novelty. Importantly, ff-RAG outperforms ff-RAG (hard+GA) in all the metrics, especially for diversity and novelty, indicating the soft fragment retrieval aids the model in generating more diverse and novel drug candidates while maintaining their high target properties.

Controlling optimization performance-diversity trade-off. It is well-known that molecular diversity is important in drug discovery, especially when the oracle has noise. However, optimization performance against the target property and molecular diversity are conflicting factors [10, 19]. To control this trade-off between optimization performance and diversity, we additionally introduce a similarity-based fragment filtering strategy, which excludes similar fragments from the fragment vocabulary. Specifically, when updating the vocabulary, new fragments that have a higher Tanimoto similarity than δ\delta to fragments in the vocabulary are filtered out. Morgan fingerprints of radius 2 and 1024 bits are used to calculate the Tanimoto similarity. The results of the similarity-based fragment filter with different values of δ\delta are shown in Figure 5(c), verifying ff-RAG can increase diversity at the expense of optimization performance by controlling δ\delta.

Effect of the fragment vocabulary update. To analyze the effect of the dynamic update of the fragment vocabulary during generation, we visualize the distribution of the docking scores of molecules generated by ff-RAG with or with the fragment vocabulary update in Figure 6. The dynamic update allows ff-RAG to generate more optimized molecules in terms of the target property. Notably, with the dynamic update, ff-RAG can discover molecules that have higher binding affinity to the target protein than the top molecule in the training set, and we visualize an example of such molecules in the figure. Note that the molecule also has low similarity (0.321) with the training molecules. This result demonstrates the explorability of ff-RAG to discover drug candidates that lie beyond the training distribution.

Density plot of docking score in kcal/mol, from -16 to -6, with a blue curve for with fragment update and a red one for without. A dashed line near -15 is labelled best in ZINC250k, and beside it sits a small drawing of one molecule, with an arrow.

Figure 6: DS distribution of molecules generated by ff-RAG with or without the fragment vocabulary update in the jak2 task.

5 Conclusion

We proposed ff-RAG, a new fragment-based molecular generative framework that utilizes hard fragment retrieval, soft fragment retrieval, and genetic fragment modification. With hard fragment retrieval, ff-RAG can explicitly exploit the information contained in existing fragments that contribute to the target properties. With soft fragment retrieval, ff-RAG can balance between exploitation of existing chemical knowledge and exploration beyond the existing fragment vocabulary. Soft fragment retrieval with SAFE-GPT allows ff-RAG to propose new fragments that are likely to contribute to the target chemical properties. The proposed novel fragments are then dynamically incorporated in the fragment vocabulary throughout generation. This exploration is further enhanced with genetic fragment modification, which modifies fragments with genetic operations and updates the vocabulary. Through extensive experiments, we demonstrated the efficacy of ff-RAG to improve the exploration-exploitation trade-off. ff-RAG outperforms previous methods, achieving state-of-the-art performance to synthesize diverse, novel, and synthesizable drug candidates with high target properties.

Acknowledgements

We would like to thank the NVIDIA GenAIR team for their comments during the development of the framework.

References

References (47)

[1] Sungsoo Ahn, Junsu Kim, Hankook Lee, and Jinwoo Shin. Guiding deep molecular optimization with genetic exploration. Advances in neural information processing systems, 33:12008–12021, 2020.

[2] Amr Alhossary, Stephanus Daniel Handoko, Yuguang Mu, and Chee-Keong Kwoh. Fast, accurate, and reliable molecular docking with quickvina 2. Bioinformatics, 31(13):2214–2216, 2015.

[3] Akari Asai, Sewon Min, Zexuan Zhong, and Danqi Chen. Retrieval-based language models and applications. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 6: Tutorial Abstracts), pages 41–46, 2023.

[4] G Richard Bickerton, Gaia V Paolini, Jérémy Besnard, Sorel Muresan, and Andrew L Hopkins. Quantifying the chemical beauty of drugs. Nature chemistry, 4(2):90–98, 2012.

[5] Marta Bon, Alan Bilsland, Justin Bower, and Kirsten McAulay. Fragment-based drug discovery—the importance of high-quality molecule libraries. Molecular Oncology, 16(21): 3761–3777, 2022.

[6] Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George Bm Van Den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, et al. Improving language models by retrieving from trillions of tokens. In International conference on machine learning, pages 2206–2240. PMLR, 2022.

[7] Nathan Brown, Marco Fiscato, Marwin HS Segler, and Alain C Vaucher. Guacamol: benchmarking models for de novo molecular design. Journal of chemical information and modeling, 59(3):1096–1108, 2019.

[8] Peter Ertl and Ansgar Schuffenhauer. Estimation of synthetic accessibility score of drug-like molecules based on molecular complexity and fragment contributions. Journal of cheminformatics, 1:1–11, 2009.

[9] Wenhao Gao and Connor W Coley. The synthesizability of molecules proposed by generative models. Journal of chemical information and modeling, 60(12):5714–5723, 2020.

[10] Wenhao Gao, Tianfan Fu, Jimeng Sun, and Connor Coley. Sample efficiency matters: a benchmark for practical molecular optimization. Advances in Neural Information Processing Systems, 35:21342–21357, 2022.

[11] Zijie Geng, Shufang Xie, Yingce Xia, Lijun Wu, Tao Qin, Jie Wang, Yongdong Zhang, Feng Wu, and Tie-Yan Liu. De novo molecular generation via connection-aware motif mining. In International Conference on Learning Representations, 2023.

[12] Kexin Huang, Tianfan Fu, Wenhao Gao, Yue Zhao, Yusuf H Roohani, Jure Leskovec, Connor W Coley, Cao Xiao, Jimeng Sun, and Marinka Zitnik. Therapeutics data commons: Machine learning datasets and tasks for drug discovery and development. In NeurIPS Track Datasets and Benchmarks, 2021.

[13] John J Irwin, Teague Sterling, Michael M Mysinger, Erin S Bolstad, and Ryan G Coleman. Zinc: a free tool to discover chemistry for biology. Journal of chemical information and modeling, 52 (7):1757–1768, 2012.

[14] Jan H Jensen. A graph-based genetic algorithm and generative model/monte carlo tree search for the exploration of chemical space. Chemical science, 10(12):3567–3572, 2019.

[15] Woosung Jeon and Dongsup Kim. Autonomous molecule generation using reinforcement learning and docking to develop potential novel inhibitors. Scientific Reports, 10, 12 2020.

[16] Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Junction tree variational autoencoder for molecular graph generation. In International Conference on Machine Learning, pages 2323–2332. PMLR, 2018.

[17] Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Hierarchical generation of molecular graphs using structural motifs. In International Conference on Machine Learning, pages 4839–4848. PMLR, 2020.

[18] Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Multi-objective molecule generation using interpretable substructures. In International conference on machine learning, pages 4849–4859. PMLR, 2020.

[19] Hyeonah Kim, Minsu Kim, Sanghyeok Choi, and Jinkyoo Park. Genetic-guided gflownets: Advancing in practical molecular optimization benchmark. arXiv preprint arXiv:2402.05961, 2024.

[20] Xiangzhe Kong, Wenbing Huang, Zhixing Tan, and Yang Liu. Molecule generation by principal subgraph mining and assembling. Advances in Neural Information Processing Systems, 35: 2550–2563, 2022.

[21] Mario Krenn, Florian Häse, AkshatKumar Nigam, Pascal Friederich, and Alan Aspuru-Guzik. Self-referencing embedded strings (selfies): A 100% robust molecular string representation. Machine Learning: Science and Technology, 1(4):045024, 2020.

[22] Matt J Kusner, Brooks Paige, and José Miguel Hernández-Lobato. Grammar variational autoencoder. In International Conference on Machine Learning, pages 1945–1954. PMLR, 2017.

[23] Greg Landrum et al. RDKit: Open-source cheminformatics software, 2016. URL http://www. rdkit. org/, https://github. com/rdkit/rdkit, 2016.

[24] Seul Lee, Jaehyeong Jo, and Sung Ju Hwang. Exploring chemical space with score-based out-of-distribution generation. In International Conference on Machine Learning, pages 18872–18892. PMLR, 2023.

[25] Seul Lee, Seanie Lee, Kenji Kawaguchi, and Sung Ju Hwang. Drug discovery with dynamic goal-aware fragments. International Conference on Machine Learning, 2024.

[26] Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, et al. Retrieval-augmented generation for knowledge-intensive nlp tasks. Advances in Neural Information Processing Systems, 33:9459–9474, 2020.

[27] Qingxin Li. Application of fragment-based drug discovery to versatile targets. Frontiers in molecular biosciences, 7:180, 2020.

[28] Shengchao Liu, Jiongxiao Wang, Yijin Yang, Chengpeng Wang, Ling Liu, Hongyu Guo, and Chaowei Xiao. Conversational drug editing using retrieval and domain feedback. In The Twelfth International Conference on Learning Representations, 2023.

[29] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. International Conference on Learning Representations, 2019.

[30] Krzysztof Maziarz, Henry Richard Jackson-Flux, Pashmina Cameron, Finton Sirockin, Nadine Schneider, Nikolaus Stiefl, Marwin Segler, and Marc Brockschmidt. Learning to extend molecular scaffolds with structural motifs. In International Conference on Learning Representations, 2021.

[31] Nicholas A Meanwell. Improving drug candidates by design: a focus on physicochemical properties as a means of improving compound disposition and safety. Chemical research in toxicology, 24(9):1420–1456, 2011.

[32] AkshatKumar Nigam, Pascal Friederich, Mario Krenn, and Alan Aspuru-Guzik. Augmenting genetic algorithms with deep neural networks for exploring the chemical space. In International Conference on Learning Representations, 2020.

[33] AkshatKumar Nigam, Robert Pollice, Mario Krenn, Gabriel dos Passos Gomes, and Alan Aspuru-Guzik. Beyond generative models: superfast traversal, optimization, novelty, exploration and discovery (stoned) algorithm for molecules using selfies. Chemical science, 12(20):7079– 7090, 2021.

[34] Emmanuel Noutahi, Cristian Gabellini, Michael Craig, Jonathan SC Lim, and Prudencio Tossou. Gotta be safe: a new framework for molecular design. Digital Discovery, 3(4):796–804, 2024.

[35] Marcus Olivecrona, Thomas Blaschke, Ola Engkvist, and Hongming Chen. Molecular de-novo design through deep reinforcement learning. Journal of cheminformatics, 9(1):1–14, 2017.

[36] Ori Ram, Yoav Levine, Itay Dalmedigos, Dor Muhlgay, Amnon Shashua, Kevin Leyton-Brown, and Yoav Shoham. In-context retrieval-augmented language models. Transactions of the Association for Computational Linguistics, 11:1316–1331, 2023.

[37] Gisbert Schneider, Werner Neidhart, Thomas Giller, and Gerard Schmid. “scaffold-hopping” by topological pharmacophore search: a contribution to virtual screening. Angewandte Chemie International Edition, 38(19):2894–2896, 1999.

[38] Austin Tripp and José Miguel Hernández-Lobato. Genetic algorithms are strong baselines for molecule generation. arXiv preprint arXiv:2310.09267, 2023.

[39] Austin Tripp, Gregor NC Simm, and José Miguel Hernández-Lobato. A fresh look at de novo molecular design benchmarks. In NeurIPS 2021 AI for Science Workshop, 2021.

[40] Fabio Urbina, Filippa Lentzos, Cédric Invernizzi, and Sean Ekins. Dual use of artificial-intelligence-powered drug discovery. Nature Machine Intelligence, 4(3):189–191, 2022.

[41] W Patrick Walters, Matthew T Stahl, and Mark A Murcko. Virtual screening—an overview. Drug discovery today, 3(4):160–178, 1998.

[42] Zichao Wang, Weili Nie, Zhuoran Qiao, Chaowei Xiao, Richard Baraniuk, and Anima Anandkumar. Retrieval-based controllable molecule generation. In International Conference on Learning Representations, 2023.

[43] David Weininger. Smiles, a chemical language and information system. 1. introduction to methodology and encoding rules. Journal of chemical information and computer sciences, 28 (1):31–36, 1988.

[44] Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, et al. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 conference on empirical methods in natural language processing: system demonstrations, pages 38–45, 2020.

[45] Yutong Xie, Chence Shi, Hao Zhou, Yuwei Yang, Weinan Zhang, Yong Yu, and Lei Li. Mars: Markov molecular sampling for multi-objective drug discovery. In International Conference on Learning Representations, 2020.

[46] Soojung Yang, Doyeong Hwang, Seul Lee, Seongok Ryu, and Sung Ju Hwang. Hit and lead discovery with explorative rl and fragment-based molecule generation. Advances in Neural Information Processing Systems, 34:7924–7936, 2021.

[47] Naruki Yoshikawa, Kei Terayama, Masato Sumita, Teruki Homma, Kenta Oono, and Koji Tsuda. Population-based de novo molecule generation, using grammatical evolution. Chemistry Letters, 47(11):1431–1434, 2018.

A Limitations

Since our proposed ff-RAG is built on a pre-trained backbone molecular language model, it relies heavily on the generation performance of the backbone model. However, this also means that our method delegates the difficult task of molecule generation to a large model and lets the lightweight fragment injection module take care of the relatively easy task of fragment retrieval augmentation. This strategy enables very efficient and fast training (Section D.5) and makes ff-RAG a simple but powerful method to solve various drug discovery tasks.

B Broader Impacts

Through our paper, we demonstrated that ff-RAG can achieve improved trade-offs between various considerations in drug discovery, showing its strong applicability to real-world drug discovery tasks. However, given its effectiveness, ff-RAG has the possibility to be used maliciously to generate harmful molecules. This can be prevented by setting the target properties to comprehensively consider toxicity and other side effects, or filtering out toxic fragments from the fragment vocabulary during generation.

C Generation Process of ff-RAG

Algorithm 1, Generation Process of f-RAG. Input: dataset D, fragment vocabulary size N_frag, molecule population size N_mol, number of soft fragments K, number of total generations G, number of SAFE-GPT generations per cycle G_SAFE-GPT and number of GA generations per cycle G_GA. Set V_arm to the top N_frag arms and V_linker to the top N_frag linkers obtained from D (Eq. 1), and set P and M to the empty set. While M holds fewer than G molecules: first, fragment retrieval-augmented SAFE-GPT generation, for i from 1 to N_SAFE-GPT: randomly retrieve two hard fragments, F_hard,1 and F_hard,2, from V_arm union V_linker; randomly retrieve K soft fragments from V_arm union V_linker; using F_hard,1.F_hard,2 as input and the soft fragments, run SAFE-GPT to generate a molecule x; then update: add x to M, decompose x into F_arm,1, F_linker and F_arm,2, set V_arm to the top N_frag arms from V_arm and F_arm,1 and F_arm,2, V_linker to the top N_frag linkers from V_linker and F_linker, and P to the top N_mol from P and x. Then GA generation, for i from 1 to N_GA: select parent molecules from P, perform crossover and mutation to generate a molecule x, and make the same updates. Output: generated molecules M.

D Experimental Details

D.1 Training of Fragment Injection Module

In this section, we describe the details for training the fragment injection module, the only part of the ff-RAG framework that is trained. ff-RAG has 2,362,368 trainable parameters, coming from the fragment injection module. These correspond to only 2.64% of the total parameters of 89,648,640, indicating that the fragment injection module is very lightweight compared to the backbone molecular language model.

Throughout the paper, we used the official codebase including the pre-trained SAFE-GPT3 of Noutahi et al. [34]. Following the codebase, we used the HuggingFace Transformer library [44] (Apache-2.0 license) to train the fragment injection module. We set the number of retrieved soft fragments to K=10K = 10. For the layer of the backbone language model that the fragment injection module will be inserted behind, we conducted experiments with the search space L∈{1,6}L \in \{1,6\}, and found the L=1L = 1-st layer works well. The results showing this comparison are provided in Table 11. The fragment injection module was trained to 8 epochs with a learning rate of 1×10−41 \times 10^{-4} using the AdamW optimizer [29]. We performed searches with the search spaces (epoch) ∈{5,8,10}\in \{5, 8, 10\} and (learning rate) ∈{1×10−4,5×10−3}\in \{1 \times 10^{-4}, 5 \times 10^{-3}\}, respectively.

D.2 Genetic Operations for Fragment Modification

As described in Section 3.3, we adopt the operations of Graph GA [14] to modify the generated fragments to further enhance exploration of ff-RAG. Specifically, in the crossover operation, parents are cut at random positions at ring or non-ring positions with a probability of 50%, and random fragments from the cut are combined to generate offspring. In the mutation operation, bond insertion/deletion, atom insertion/deletion, bond order swapping, or atom changes are performed on the offspring molecule with a predefined probability.

D.3 Experiments on PMO Benchmark

In this section, we describe the experimental details used in the experiments of Section 4.1.

Implementation details. We used the official codebase4 of Gao et al. [10] for implementing the experiments. We used ZINC250k [13] with the same train/test split used by Kusner et al. [22] to train the fragment injection module and construct the initial fragment vocabulary. We set the size of the fragment vocabulary to Nfrag=50N_{\mathrm{frag}} = 50 and the size of the molecule population to Nmol=50N_{\rm mol} = 50. When constructing the fragment vocabulary, fragments were filtered according to the number of atoms. We searched the size range in the search space [(min. number of atoms), (max. number of atoms)] ∈\in {[5, 12], [10, 16], [10, 30]}. As a result, we used the range [5, 12] for the albuterol_similarity, isomers_c7h8n2o2m, isomers_c9h10n2o2pf2cl, median1, qed, sitagliptin_mpo, zaleplon_mpo tasks, [10, 30] for the gsk3b and jnk3 tasks, and [10, 16] for the rest of the tasks. We also confined the size of the generate molecules. We used the range [10, 30] for the albuterol_similarity, isomers_c7h8n2o2m, isomers_c9h10n2o2pf2cl, median1, qed, sitagliptin_mpo, zaleplon_mpo tasks, [30, 80] for the gsk3b and jnk3 tasks, and [20, 50] for the rest of the tasks. We set the mutation rate of the GA to 0.1. We set the number of SAFE-GPT generation and number of GA generation in one cycle to GSAFE-GPT=10G_{\text{SAFE-GPT}} = 10 and GGA=10G_{\mathrm{GA}} = 10, respectively.

Measuring novelty and synthesizability. Following previous works [18, 45, 24, 25], novelty of the generated molecules X\mathcal{X} is measured by the fraction of molecules that have a similarity less than 0.4 compared to its nearest neighbor xSNNx_{\text{SNN}} in the training set as follows:

Novelty=1N∑x∈X1{sim(x,xSNN)<0.4},(5)\text{Novelty} = \frac{1}{N} \sum_{x \in \mathcal{X}} \mathbb{1}\{ \text{sim}(x, x_{\text{SNN}}) < 0.4 \}, \tag{5}

where N = ∣X∣N\,=\,|\mathcal{X}| and sim(x,x′)\mathrm{sim}(x,x') is the pairwise Tanimoto similarity of molecules xx and x′x'. The similarity is calculated using Morgan fingerprints of radius 2 and 1024 bits obtained by the RDKit [23]

3 https://github.com/datamol-io/safe (Apache-2.0 license)

library. On the other hand, since synthetic accessibility (SA) [8] scores range from 1 to 10 with higher scores indicating more difficult synthesis, we measure synthesizability using the normalized SA score as follows:

Synthesizability=10−SA9.(6)\text{Synthesizability} = \frac{10 - \mathrm{SA}}{9}. \tag{6}

Visualizing the Radar Plots. To draw Figure 1 and Figure 5, sum AUC top-10, average top-100 diversity, average top-100 novelty, and normalized average top-100 SA score on the PMO benchmark in Table 1 and Table 2 were used to indicate optimization performance, diversity, novelty, and synthesizability, respectively. After the SA score is normalized according to Eq. (6), all the values are min-max normalized to [0, 1].

D.4 Optimization of Docking Score under QED, SA, and Novelty Constraints

In this section, we describe the experimental details used in the experiments of Section 4.2.

Implementation details. We used the official codebase5 of Lee et al. [24] for implementing the experiments. Following Lee et al. [24] and Lee et al. [25], we used ZINC250k [13] with the same train/test split used by Kusner et al. [22] to train the fragment injection module and construct the initial fragment vocabulary. As in Section D.3, when constructing the fragment vocabulary, fragments were filtered based on their number of atoms. We set the range to [5, 12]. To confinee the size of the generate molecules, we used the range [20, 40]. The mutation rate of the GA was set to 0.1. We set the number of SAFE-GPT generation and number of GA generation in one cycle to GSAFE-GPT=1G_{\text{SAFE-GPT}} = 1 and GGA=3G_{\mathrm{GA}}=3, respectively.

Measuring docking score, QED, SA, and novelty. We strictly followed the setting used in previous works [24, 25] to measure these properties. Specifically, we used QuickVina 2 [2] to calculate docking scores (DSs). We used the RDKit [23] library to calculate QED and SA. Following previous works, we compute the normalized DS (DS^\widehat{\mathrm{DS}}) and the normalized SA (SA^\widehat{\mathrm{SA}}) as follows:

DS^=−clip(DS)20∈[0,1],SA^=10−SA9∈[0,1],(7)\widehat{\mathrm{DS}} = -\frac{\mathrm{clip}(\mathrm{DS})}{20} \in [0,1], \quad \widehat{\mathrm{SA}} = \frac{10 - \mathrm{SA}}{9} \in [0,1], \tag{7}

where clip is the function that clips the value in the range [−20,0][-20,0]. As in Section D.3, novelty is determined as 1{sim(x,xSNN)<0.4}\mathbb{1}\{\text{sim}(x, x_{\text{SNN}}) < 0.4\}.

D.5 Computing resources

We trained the fragment injection module using one GeForce RTX 3090 GPU. The training took less than 4 hours. We generated molecules using one Titan XP (12GB), GeForce RTX 2080 Ti (11GB), or GeForce RTX 3090 GPU (24GB). The experiments on each task in Section 4.1 took less than 2 hours and the experiments on each task in Section 4.2 took approximately 2 hours.

E Additional Experimental Results

In this section, we provide additional experimental results.

Diversity, novelty, and synthesizability results on PMO benchmark. We provide the full results of Table 2 in Table 4, Table 5, and Table 6. As shown in the tables, ff-RAG achieves the best diversity and synthesizability, while showing the second best novelty. We also provide the pairwise trade-off plots in Figure 7.

Comparison with GEAM on PMO benchmark. To provide additional comparisons of ff-RAG to GEAM [25], we followed the setup of Lee et al. [25] to conduct experiments on the seven MPO tasks in the PMO benchmark. As shown in Table 7, ff-RAG largely outperforms the baselines including GEAM in all of the tasks.

Ablation study. We provide the full results of Figure 5(b) in Table 8 and Table 9. As shown in the tables, Figure 5(a), and Figure 5(b), the three components of ff-RAG, hard fragment retrieval, soft fragment retrieval, and genetic fragment modification, are essential to the superior performance of ff-RAG and improved balance between various drug discovery considerations.

Controlling optimization performance-diversity trade-off. We provide the full results of Figure 5(c) in Table 10. As shown in the table and Figure 5(c), ff-RAG can effectively control the performance-diversity trade-off with the similarity-based fragment filtering.

Effect of location of the fragment injection module. We provide the results of ff-RAG with L=1L = 1 and L=6L = 6 in Table 11. As shown in the table, ff-RAG with L=1L = 1 works better than ff-RAG with L=6L = 6, probably because injecting information from soft fragments in an earlier layer can carry more information into the final augmented embedding. As a result of this experiment, ff-RAG in the main experiments used L=1L = 1.

Visualization of generated molecules. We visualize examples of the generated molecules by ff-RAG in Figure 8. The examples are drawn randomly from the molecules used to calculate the novel top 5% DS values in Table 3.

Three scatter plots against optimization performance, from about 14 to 17: diversity, novelty and synthesizability. Each has a star for each of four methods, f-RAG in blue, Genetic GFN in green, Mol GA in yellow and REINVENT in red, and a grey arrow labelled Better pointing up and to the right.

Figure 7: Various trade-offs between the basic considerations in drug discovery. Sum AUC top-10, average top-100 diversity, average top-100 novelty, and normalized average top-100 SA score on the PMO benchmark are used to measure optimization performance, diversity, novelty, and synthesizability, respectively.

Table 4: Top-100 diversity results. The results are the mean of 3 independent runs. The best results are highlighted in bold.

Oracleff-RAG (ours)Genetic GFNMol GAREINVENT
albuterol_similarity0.5050.3750.5960.418
amlodipine_mpo0.3940.2800.3710.334
celecoxib_rediscovery0.3600.2830.3180.306
deco_hop0.4820.5360.4220.445
drd20.4910.5210.5480.496
fexofenadine_mpo0.5260.4240.5080.403
gsk3b0.3290.1590.0850.402
isomers_c7h8n2o20.8240.7860.8200.765
isomers_c9h10n2o2pf2cl0.7970.6210.7890.699
jnk30.3180.3540.0450.205
median10.6140.4300.5430.436
median20.4240.4700.4240.382
mestranol_similarity0.5720.2140.4430.322
osimertinib_mpo0.4800.4500.5050.444
perindopril_mpo0.3750.3940.4540.346
qed0.8160.6420.6010.699
ranolazine_mpo0.5700.3830.4200.318
scaffold_hop0.4790.4650.4510.456
sitagliptin_mpo0.6470.1650.6320.673
thiothixene_rediscovery0.4280.3880.4380.387
troglitazone_rediscovery0.4450.3910.4070.410
valsartan_smarts0.6000.8810.9020.882
zaleplon_mpo0.7510.5810.5630.530
Average0.5320.4430.4910.468

Table 5: Top-100 novelty results. The results are the mean of 3 independent runs. The best results are highlighted in bold.

Oracleff-RAG (ours)Genetic GFNMol GAREINVENT
albuterol_similarity0.5430.6670.9570.553
amlodipine_mpo0.0000.0370.1130.000
celecoxib_rediscovery0.9300.9800.8850.943
deco_hop0.6500.9231.0000.893
drd20.5700.7800.9870.357
fexofenadine_mpo1.0000.9401.0000.547
gsk3b1.0001.0001.0000.757
isomers_c7h8n2o20.9530.6470.9470.373
isomers_c9h10n2o2pf2cl0.9930.7471.0000.273
jnk31.0000.9331.0001.000
median10.4370.8100.9800.433
median20.8800.1270.9430.010
mestranol_similarity0.8500.8930.9700.923
osimertinib_mpo0.9170.7371.0000.617
perindopril_mpo0.9730.8501.0000.930
qed0.7570.4230.0530.063
ranolazine_mpo1.0000.4531.0000.290
scaffold_hop0.8100.9931.0000.930
sitagliptin_mpo0.9201.0001.0000.303
thiothixene_rediscovery0.9270.9800.9600.920
troglitazone_rediscovery0.6830.9170.6830.833
valsartan_smarts0.8200.2000.3230.123
zaleplon_mpo0.7930.6100.7500.343
Average0.8000.7240.8450.540

Table 6: Top-100 SA score results. The results are the mean of 3 independent runs. Lower is better and the best results are highlighted in bold.

Oracleff-RAG (ours)Genetic GFNMol GAREINVENT
albuterol_similarity1.4513.2413.8223.311
amlodipine_mpo2.2183.6753.8063.645
celecoxib_rediscovery1.5842.7352.3882.667
deco_hop2.6014.3335.0663.262
drd21.0792.6053.0512.514
fexofenadine_mpo1.8374.4374.7214.193
gsk3b1.2534.78510.0002.964
isomers_c7h8n2o21.9973.3544.7213.323
isomers_c9h10n2o2pf2cl1.1254.1085.3142.828
jnk31.7464.67910.0004.202
median12.0364.0984.5164.058
median23.4083.0223.8612.957
mestranol_similarity1.9874.2414.7804.131
osimertinib_mpo3.0533.7344.2933.257
perindopril_mpo2.1534.6744.6484.146
qed2.9683.3402.5012.232
ranolazine_mpo2.0553.4894.4223.096
scaffold_hop3.6913.5135.1463.030
sitagliptin_mpo1.6275.6525.4792.912
thiothixene_rediscovery2.8662.6212.8722.444
troglitazone_rediscovery1.6314.5413.6723.255
valsartan_smarts2.8673.1273.5303.100
zaleplon_mpo1.5742.7173.2962.236
Average2.0263.7704.6053.207

Table 7: PMO MPO AUC top-100 results. The results are the means of 3 runs. The results for REINVENT, Graph GA, and SELFIES-REINVENT are taken from Gao et al. [10], and the results for GEAM are taken from Lee et al. [25]. The best results are highlighted in bold.

MethodAmlodipineFexofenadineOsimertinibPerindoprilRanolazineSitagliptinZaleplon
REINVENT [35]0.6080.7520.8060.5110.7190.0060.325
Graph GA [14]0.6220.7310.7990.5030.6700.3300.305
SELFIES-REINVENT0.5740.7050.7910.4870.6950.1180.257
GEAM [25]0.6260.7990.8310.5140.7140.4170.402
ff-RAG (ours)0.704 ± 0.0180.827 ± 0.0100.850 ± 0.0070.640 ± 0.0170.779 ± 0.0160.458 ± 0.0240.423 ± 0.001

Table 8: PMO AUC top-10 results of the ablated versions of ff-RAG. The results are the mean of 3 independent runs. The best results are highlighted in bold.

ff-RAG
Hard retrieval✓✗✓✓✗
Soft retrieval✓✓✗✓✗
GA✓✓✓✗✓
albuterol_similarity0.9770.9070.9740.8750.929
amlodipine_mpo0.7490.6200.7470.6290.666
celecoxib_rediscovery0.7780.5240.7480.5050.695
deco_hop0.9360.6210.9080.8110.645
drd20.9920.9870.9930.9930.976
fexofenadine_mpo0.8560.8230.8380.7560.830
gsk3b0.9690.8250.9670.8760.822
isomers_c7h8n2o20.9550.9400.9310.8910.968
isomers_c9h10n2o2pf2cl0.8500.7950.8800.7270.896
jnk30.9040.8340.9030.8000.612
median10.3400.2930.3390.2900.285
median20.3230.2500.3150.2550.284
mestranol_similarity0.6710.6500.6830.5660.550
osimertinib_mpo0.8660.8350.8670.8210.838
perindopril_mpo0.6810.5300.6670.5850.564
qed0.9390.9370.9410.9370.942
ranolazine_mpo0.8200.8000.8090.7260.808
scaffold_hop0.5760.5560.5890.5090.522
sitagliptin_mpo0.6010.5020.6150.3040.576
thiothixene_rediscovery0.5840.4580.5790.4320.545
troglitazone_rediscovery0.4480.3970.4590.3130.396
valsartan_smarts0.6270.6850.6240.0000.540
zaleplon_mpo0.4860.4620.5100.4470.506
Sum16.92815.23116.89014.04815.395

Table 9: Top-100 diversity, top-100 novelty, and top-100 SA score results of the ablated versions of ff-RAG. The results are the average values of all 23 tasks. The best results are highlighted in bold.

ff-RAG
Hard retrieval✓✗✓✓✗
Soft retrieval✓✓✗✓✗
GA✓✓✓✗✓
Average diversity ↑0.5320.5440.4970.7440.489
Average novelty ↑0.8000.9240.7200.4380.860
Average SA score ↓2.0264.1132.2313.4434.235

Table 10: Top-100 diversity, top-100 novelty, and top-100 SA score results with different values of δ\delta of the similarity-based fragment filter. The results are the average values of all 23 tasks.

Metricff-RAGff-RAG δ=0.8\delta = 0.8ff-RAG δ=0.6\delta = 0.6ff-RAG δ=0.4\delta = 0.4
Sum AUC ↑\uparrow16.92816.64816.26215.765
Average diversity ↑\uparrow0.5320.6060.6810.724
Average novelty ↑\uparrow0.8000.7780.7510.796
Average SA score ↓\downarrow2.0263.8363.8253.852

Table 11: Effect of location of the fragment injection module LL. The results are the mean of 3 independent runs. ff-RAG in the main experiments used L=1L = 1. The best results are highlighted in bold.

Oracleff-RAG (L=1L = 1)ff-RAG (L=6L = 6)
albuterol_similarity0.9770.971
amlodipine_mpo0.7490.721
celecoxib_rediscovery0.7780.764
deco_hop0.9360.935
drd20.9920.991
fexofenadine_mpo0.8560.847
gsk3b0.9690.974
isomers_c7h8n2o20.9550.950
isomers_c9h10n2o2pf2cl0.8500.848
jnk30.9040.901
median10.3400.351
median20.3230.322
mestranol_similarity0.6710.685
osimertinib_mpo0.8660.865
perindopril_mpo0.6810.698
qed0.9390.939
ranolazine_mpo0.8200.798
scaffold_hop0.5760.586
sitagliptin_mpo0.6010.547
thiothixene_rediscovery0.5840.583
troglitazone_rediscovery0.4480.447
valsartan_smarts0.6270.685
zaleplon_mpo0.4860.486
Sum16.92816.894
Figure 8, parp1: ten generated molecules drawn as structures, in two rows of five, each with four numbers under it (docking score, QED, SA and similarity, as the caption says). The docking scores run from -12.5 to -14.1.
Figure 8, fa7: ten generated molecules drawn as structures, in two rows of five, each with its four numbers under it. The docking scores run from -9.4 to -10.7.
Figure 8, 5ht1b: ten generated molecules drawn as structures, in two rows of five, each with its four numbers under it. The docking scores run from -12.2 to -13.5.
Figure 8, braf: ten generated molecules drawn as structures, in two rows of five, each with its four numbers under it. The docking scores run from -11.9 to -13.1.
Figure 8, jak2: ten generated molecules drawn as structures, in two rows of five, each with its four numbers under it. The docking scores run from -11.3 to -13.3.

Figure 8: The generated molecules by ff-RAG. Random top 5% novel hits generated in the experiments of Section 4.2 are visualized. The docking score (kcal/mol), QED, SA, and the maximum similarity with the molecules in the training set are at the bottom of each molecule.