Augmenting Molecular Language Models with Local n-gram Memory

Xinni Zhang, Zijing Liu, He Cao, Yu Li, Irwin King
6/10/2026
cs.CLcs.AI

No confident code implementation found for this paper.

Abstract

Transformer-based language models for SMILES strings suffer from a locality gap: standard character-level tokenization fragments chemically meaningful motifs, forcing models to repeatedly learn local syntax at the expense of long-range dependencies. To address this without disrupting standard tokenizers, we propose MolGram, which integrates a conditional $n$-gram memory module into molecular language models. MolGram maps local string patterns to learned embeddings via scalable hash lookups and dynamically injects this regional context into hidden states. Evaluations across three tasks, including unconditional molecule generation, forward reaction prediction, and single-step retrosynthesis, show that MolGram consistently improves performance. Crucially, our analyses demonstrate that MolGram outperforms baselines with 3$\times$ more parameters, establishing explicit local pattern memory as a highly efficient inductive bias.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{zhang2026augmenting,
  title  = {Augmenting Molecular Language Models with Local n-gram Memory},
  author = {Xinni Zhang and Zijing Liu and He Cao and Yu Li and Irwin King},
  year   = {2026},
  eprint = {2606.12113},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2606.12113v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2606.12113.svg)](https://codeofpaper.com/paper/2606.12113)

Discussion