Manuscript Offprint

arXiv:2610.18438

STAMP as a topology-aware molecular language for fragment-level learning and editing

Yuxuan Ren, Jiatong Li, Ziqiao Meng, Yatao Bian

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Molecular fragments provide chemically meaningful units, but existing molecular languages rarely make their locations and connections explicit for editing. Here we introduce STAMP (Sequential Tree Attachment-based Motif-Preserving representation), a topology-aware molecular language that connects fragment-level representation learning with precise structural editing. STAMP separately encodes motif identity, attachment sites and tree topology, making fragments reusable across contexts and subtrees directly accessible. Learned representations capture motif similarity and recurring transformations, and lower activity-cliff prediction error on 23 of 30 targets versus a matched SMILES encoder. Compatible subtree operations support scaffold-preserving optimization, ranking first among six methods on 15 of 23 benchmark objectives. A deterministic compiler enables frozen language models to act on indexed fragments, improving molecular editing, optimization, transformation transfer and change identification by 9 to 56 percentage points over plain SMILES. Together, these results establish an executable molecular language in which learned chemical units remain directly operable during design.

1 Introduction

Language models trained on molecular strings can generate compounds [1, 2], predict molecular properties [3, 4] and assist synthesis planning [5, 6]. The molecular language determines which chemical units and relations are explicit during learning. Reliable reconstruction and validity are fundamental requirements [7]. Molecular design also requires locating and modifying chemical units while preserving the surrounding structure. SMILES faithfully serializes molecular graphs, but a functional-group replacement can require coordinated changes across non-contiguous parts of the string [8]. SELFIES addresses validity [9, 10]; fragment-level editing additionally requires explicit attachment sites and substructure boundaries.

Fragment representations expose larger chemical units for learning and construction [11–14]. SAFE, fragSMILES, Group-SELFIES and Molcano make fragments or their connections explicit [15–18]. Junction-tree models encode fragment topology [12, 13]; t-SMILES serializes SMILES-described fragments through a breadth-first traversal of a full binary tree [19]. Subsequent work has examined how traversal and fragment order affect generative learning [20]. The question is how to make these chemical units directly addressable for editing while retaining them as units for molecular learning.

An edit must identify the part to change, specify its replacement and preserve the surrounding structure. Fragment identity, attachment sites and assembly topology therefore have distinct roles. Many current serializations couple some of these variables or leave fragment positions implicit [18–22][18–22]. Replacement, linker insertion and scaffold modification often depend on external graph operations or regeneration of the molecular string. Representing these variables separately can make the target, boundary and attachment requirements of an edit explicit within the sequence.

Here we introduce STAMP, the Sequential Tree Attachment-based Motif-Preserving representation, as an ordered fragment-tree molecular state. Distinct motif, joint and branch tokens encode fragment identity, attachment atoms and tree topology. A benzene motif can therefore be reused across attachment positions and substitution contexts. A canonical depth-first traversal assigns fragment

Figure

indices and maps each subtree to a contiguous token span. Deterministic decoding assembles the encoded fragments into a molecular graph, while the indexed fragments and subtree spans define targets for structural editing (Fig. 1).

The same state supports both molecular learning and structural operations. Generative and predictive models learn from its motif identities and structural relations. Search algorithms replace an indexed subtree with an attachment-compatible donor and decode the resulting sequence. For instruction-guided editing, a frozen language model selects an indexed target and a growth, deletion or replacement action. A deterministic compiler checks compatibility, executes the action and validates the product. The chemical units exposed during learning thus remain accessible to search algorithms and language models during molecular modification.

We evaluate this shared state through generation, property prediction, optimization and instruction-guided editing. STAMP exactly reconstructs all 20,000 molecules sampled from the ZINC-250K training split and produces compact sequences. Under matched training and sampling, it gives the highest yield of unique valid molecules meeting drug-likeness and synthetic-accessibility thresholds among eight evaluated representations. Larger-scale, fragment-constrained and text-conditioned experiments extend these construction settings. STAMP encoders improve on ChemBERTa-2 10M baselines on most evaluated MoleculeNet tasks [4, 23] and lower activity-cliff prediction error on 23 of 30 MoleculeACE targets relative to the matched SMILES-BPE encoder [24]. Their embeddings capture motif similarity, distinguish attachment changes from motif substitutions and represent recurring transformations consistently across molecular contexts.

Fragment-tree search achieves aggregate PMO performance comparable to GenMol and gives the better outcome in 24 of 27 lead-optimization cells where either method succeeds. Compiled actions improve single-step editing with frozen language models and support transfer of demonstrated transformations to new molecules. Together, these results establish STAMP as a common representation through which molecular structure can be generated, learned and modified.

References (36)