Abstract
Large Language Models (LLMs) have demonstrated significant potential in chemical research, yet they are often constrained by the limitations of textual molecular representations like SMILES, which can obscure fine-grained local chemical environments. We introduce AtomDisc, a novel atom-level tokenizer designed to bridge the gap between molecular graphs and serialized language models. AtomDisc translates local atomic environments into discrete tokens using a vector-quantized Graph Isomorphism Network (GIN). This "chemical alphabet" allows LLMs to process structural nuances—such as electron density and steric hindrance—alongside natural language instructions. Our approach achieves state-of-the-art performance across MoleculeNet benchmarks and chemical reaction tasks, while providing unprecedented interpretability by grounding model attention on specific atomic sites.
Introduction
The integration of LLMs into chemistry primarily relies on SMILES strings, which are convenient but inherently "lossy." A single SMILES token often represents a cluster of atoms, failing to capture the local environments that dictate molecular behavior. Conversely, graph-based models capture connectivity but lack the reasoning capabilities of transformer architectures. AtomDisc addresses this "language barrier" by creating a discrete, learnable alphabet of 512 structural tokens. Each token represents a quantized local atomic environment, allowing the LLM to "see" the molecule with the precision of a microscope.
Methodology
The AtomDisc framework employs a four-stage pipeline to integrate structural intuition into a LLaMA-2-7B model:
- Atom-Level Encoding: A Graph Isomorphism Network (GIN) generates continuous embeddings for every atom based on its local neighborhood.
- Vector Quantization (VQ): These embeddings are mapped to the nearest codeword in a 512-entry codebook, converting complex environments into discrete IDs (e.g.,
<atom_433>). - Embedding Alignment: A runtime projection strategy maps these structural tokens into the LLM’s native embedding space.
- Multi-task Fine-tuning: The model is trained using Low-Rank Adaptation (LoRA) on a combination of molecular descriptions and reaction tasks.
The codebook was trained on approximately 7.8 million atoms from 220,000 PubChem molecules. Instruction tuning utilized an augmented ChEBI-20 dataset (100k pairs) and the Mol-Instructions dataset (370k pairs), covering forward reactions, retrosynthesis, and reagent prediction.
Results and Discussion
AtomDisc achieved state-of-the-art (SOTA) performance on MoleculeNet classification tasks with an average ROC-AUC of 84.7%, surpassing models like MoLFormer-XL. In generative tasks, the improvement was even more pronounced; for Forward Reaction Prediction, AtomDisc reached an Exact Match score of 0.846, a significant jump from the previous best of 0.611.
Beyond performance, AtomDisc reveals deep structure-property associations. The model autonomously identifies "mixture tokens"—fuzzy chemical boundaries where atoms share characteristics of multiple functional groups (e.g., carbons with both aromatic and alkene character). This data-driven categorization provides a more nuanced understanding than rigid, human-defined rules.
Furthermore, the use of discrete atomic tokens enhances interpretability. Analysis of internal attention weights shows that the LLM naturally focuses on chemically relevant regions, such as reaction centers, when making predictions or proposing synthetic routes.
Conclusion
AtomDisc successfully bridges the gap between graph-based structural representation and the reasoning power of LLMs. While currently focused on 2D topology, future work will explore the integration of 3D spatial conformations to better capture stereochemistry and biological activity. Expanding the codebook size and exploring end-to-end training of the encoder could further unlock the potential of this "chemical alphabet" for specialized domains like materials science.
Summary updated