skillfed

selfies

SELFIES (SELF-referencIng Embedded Strings) is a general-purpose, sequence-based, robust representation of semantically constrained graphs.

selfies v2.2.0 181.1K downloads/30d#10,134 on PyPI862
Permissive license AGING released

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 selfies

uv

uv add selfies

poetry

poetry add selfies

Installing 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

License :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

molecular string representationSELFIES SMILES conversionrobust molecular encodinggenerative chemistry modelsmolecular graph representationchemical string tokenizationvalid molecule generation
chemistrymolecular-mlgraph-representation

More Artificial Intelligence packages