rxn4chemistry/rxnmapper

RXNMapper: Unsupervised attention-guided atom-mapping. Code complementing our Science Advances publication on "Extraction of organic chemistry grammar from unsupervised learning of chemical reactions" (https://advances.sciencemag.org/content/7/15/eabe4166).

What it solves

Chemists often need to know exactly which atoms in the starting materials end up where in the products of a chemical reaction. Doing this by hand is slow and error-prone. RXNMapper automates this "atom mapping" step using a machine-learning model that learned the underlying grammar of organic chemistry without any human-annotated examples.

How it works

RXNMapper uses an ALBERT transformer model that was trained in an unsupervised way on a large dataset of chemical reactions. When you give it a valid reaction SMILES (a standard text notation for molecules and reactions), it returns the same reaction with atom-mapping numbers inserted and a confidence score for that mapping. The library provides two ways to use it: a simple RXNMapper class for one-off calls, and a BatchedMapper class that automatically handles batching and error cases, so you can process many reactions at once without worrying about invalid inputs.

Who it's for

Researchers and developers working with chemical reaction data—for example, cheminformatics specialists, organic chemists, or anyone building tools that need to reason about how atoms move in a reaction. The project is open source and can be installed via pip, and the underlying research was published in Science Advances.

Highlights

  • Peer-reviewed in Science Advances (open access) and presented at an ICML workshop
  • Simple Python API: get_attention_guided_atom_maps() returns mapped reactions with confidence scores
  • BatchedMapper handles large inputs and invalid reactions gracefully
  • Works directly on SMILES strings, the standard representation in chemistry

Related

  • Project
  • Project
  • Project
  • Project