--- id: selfies version: "2.2.0" license: unclear license_treatment: permissive maintenance: aging --- # selfies — SELFIES (SELF-referencIng Embedded Strings) is a general-purpose, sequence-based, robust representation of semantically constrained graphs. License: permissive · Maintenance: aging · Downloads: 181.1K/mo ## 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 above — 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 pip install selfies uv add selfies 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_current - Install friction: low - Maintenance: aging - Downloads: 181.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags molecular string representation, SELFIES SMILES conversion, robust molecular encoding, generative chemistry models, molecular graph representation, chemical string tokenization, valid molecule generation, chemistry, molecular-ml, graph-representation [View on SkillFed](https://skillfed.io/packages/selfies) · [View on PyPI](https://pypi.org/project/selfies/)