selfies
SELFIES (SELF-referencIng Embedded Strings) is a general-purpose, sequence-based, robust representation of semantically constrained graphs.
What it is and what it does
SELFIES is a molecular string representation designed to guarantee that every string encodes a valid, semantically meaningful molecule. Unlike SMILES, which can produce invalid molecules through random mutations, SELFIES enforces chemical constraints at the string level, making it particularly useful for generative machine learning models that need to explore molecular space without producing chemically impossible structures.
The package provides bidirectional translation between SELFIES and SMILES formats, tokenization, encoding/decoding for neural networks, and customizable semantic constraints (including hypervalent chemistry). It has no external runtime dependencies and supports Python 3.7 and later, making it straightforward to integrate into existing chemistry or ML pipelines.
Use it for:
- Training generative models (VAEs, GANs) on molecular data where every sampled string must decode to a valid molecule
- Converting existing SMILES datasets to SELFIES for more robust chemical exploration and mutation
- Encoding molecules as fixed-length vectors or integer sequences for neural network input
- Creating random valid molecules for high-throughput virtual screening or lead generation
- Analyzing molecular structure by tokenizing and attributing SELFIES symbols to SMILES output tokens
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts between SELFIES (Self-Referencing Embedded Strings) and SMILES molecular representations, ensuring syntactically and semantically valid molecular strings for machine learning applications.
Yes, if you work with generative chemistry models or need guaranteed-valid molecular representations. The package is well-established (first released 2019, now at 2.2.0) with no known vulnerabilities and permissive licensing. The aging maintenance status (576 days since last release) is not a blocker for stable use, but verify that it meets your specific ML framework and performance requirements before committing to a production pipeline.
Install
selfies on PyPI
pip
pip install selfiesuv
uv add selfiespoetry
poetry add selfiesInstalling selfies
Before you install
Low install friction with no runtime dependencies. Maintenance status is aging—last release was 576 days ago, though the repository remains active with recent commits and 862 stars.
License in practice
Licensed under Apache License (permissive), allowing commercial and private use with minimal restrictions.
Quickstart
import selfies as sf
benzene_smiles = "c1ccccc1"
benzene_selfies = sf.encoder(benzene_smiles)
print(benzene_selfies) # [C][=C][C][=C][C][=C][Ring1][=Branch1]
recovered_smiles = sf.decoder(benzene_selfies)
print(recovered_smiles) # C1=CC=CC=C1
Verify before relying
- Whether the package is actively maintained or in maintenance-only mode given the aging status
- Performance characteristics for large-scale molecular datasets or real-time encoding/decoding
- Compatibility with specific chemistry frameworks or ML pipelines beyond the examples shown
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 576 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 181,097/month — #10,134 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: selfies-2.2.0-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
aimsim-coreProvides core molecular featurization and…
permissive · top 15,000 on PyPI
mordredcommunityCalculates molecular descriptors from chemical…
permissive · top 15,000 on PyPI
py2opsinpy2opsin converts IUPAC chemical names to…
permissive · top 15,000 on PyPI
mhfpEncodes molecular structures as MinHash…
unclear · top 15,000 on PyPI
chempropChemprop trains and deploys message passing…
permissive · top 15,000 on PyPI
padelpyPaDELPy wraps the PaDEL-Descriptor Java engine…
permissive · top 15,000 on PyPI
mace-torchMACE trains and evaluates machine learning…
permissive · top 15,000 on PyPI
prolifProLIF generates interaction fingerprints from…
permissive · top 15,000 on PyPI
autogluon.multimodalAutoGluon Multimodal automates machine learning…
permissive · top 15,000 on PyPI
PubChemPyPubChemPy is a Python wrapper around the…
permissive · top 5,000 on PyPI