[Paper Review] Recent advances in the Self-Referencing Embedding Strings (SELFIES) library
This paper presents selfies 2.1.1, an enhanced open-source Python library for Self-Referencing Embedding Strings (SELFIES), a 100% syntactically and semantically robust molecular string representation. The library enables error-free generation of valid molecules via a context-free grammar with self-referencing functions, achieving fast roundtrip translation (252 seconds for 300k molecules) and supporting customizable, efficient, and extensible molecular generation without post-hoc filtering.
String-based molecular representations play a crucial role in cheminformatics applications, and with the growing success of deep learning in chemistry, have been readily adopted into machine learning pipelines. However, traditional string-based representations such as SMILES are often prone to syntactic and semantic errors when produced by generative models. To address these problems, a novel representation, SELF-referencing embedded strings (SELFIES), was proposed that is inherently 100% robust, alongside an accompanying open-source implementation called selfies. Since then, we have generalized SELFIES to support a wider range of molecules and semantic constraints, and streamlined its underlying grammar. We have implemented this updated representation in subsequent versions of selfies, where we have also made major advances with respect to design, efficiency, and supported features. Hence, we present the current status of selfies (version 2.1.1) in this manuscript. Our library, selfies, is available at GitHub (https://github.com/aspuru-guzik-group/selfies).
Motivation & Objective
- To address syntactic and semantic errors in string-based molecular representations like SMILES, which commonly arise in generative machine learning models.
- To extend the SELFIES representation to support all major SMILES features, including complex functional groups, rings, and branches, while maintaining 100% validity.
- To improve the performance, usability, and extensibility of the open-source selfies library for integration into diverse machine learning and cheminformatics workflows.
- To enable the creation of large, valid, and diverse molecular structures through customizable alphabets and grammar constraints without post-processing filters.
- To lay the foundation for future extensions of SELFIES to polymers, crystals, non-covalent systems, and reaction representations.
Proposed method
- The SELFIES representation uses a Chomsky type-2, context-free grammar augmented with self-referencing functions to encode molecular branching and ring formation, ensuring all generated strings are chemically valid.
- The library implements a deterministic derivation process that translates SELFIES strings into molecular graphs by recursively resolving self-references and applying valence constraints.
- The core encoder() function maps any valid SELFIES string to a canonical SMILES string, while decoder() reverses the process, enabling roundtrip translation.
- The alphabet is customizable: users can filter out low-valence atoms or multiple bonds to control molecular size distribution during random generation.
- The implementation is self-contained, requiring no external dependencies, and includes utility functions for translation, validation, and grammar customization.
- Performance benchmarks were conducted on the DTP open compound collection (300k molecules), measuring roundtrip translation time as a function of molecular size.

Experimental results
Research questions
- RQ1How can a string-based molecular representation be made inherently robust to both syntactic and semantic errors in generative machine learning models?
- RQ2To what extent can the SELFIES grammar support all major features of the SMILES representation, including complex branching, rings, and functional groups?
- RQ3How does the performance of SELFIES translation scale with molecular size, and what is the computational cost of roundtrip translation for large datasets?
- RQ4Can customizable alphabets in SELFIES be used to control the size and diversity of generated molecules without requiring post-hoc filtering?
- RQ5What are the key design principles and implementation strategies that enable high performance and extensibility in a self-contained molecular string library?
Key findings
- The roundtrip translation of 300,000 molecules from SMILES to SELFIES and back to SMILES took 252 seconds (136 s encode, 116 s decode), demonstrating high efficiency.
- Randomly generated SELFIES strings using a basic alphabet produced mostly small molecules due to early termination from high-valence or multi-bond symbols.
- Filtering the alphabet to exclude multi-bonds and low-valence atoms significantly increased the average molecular size, enabling the generation of larger, valid molecules.
- The decoder function successfully translated all 1,000 randomly sampled SELFIES strings into valid SMILES strings without any failures, confirming 100% robustness.
- The library’s performance scales linearly with molecular size, with translation time increasing proportionally to the number of atoms in the molecule.
- The implementation is fully self-contained and dependency-free, enabling seamless integration into diverse ML and cheminformatics pipelines.
Better researchstarts right now
From reading papers to final review, dramatically reduce your research time.
No credit card · Free plan available
This review was created by AI and reviewed by human editors.