Skip to main content

Overview

ChemLactica models use a structured prompt format to condition molecule generation on desired properties and structural similarities. Prompts are constructed using special tags that the model learned during pretraining.
Example from the README: </s>[SAS]2.25[/SAS][SIMILAR]CC(=O)OC1=CC=CC=C1C(=O)O 0.62[/SIMILAR][START_SMILES] generates a molecule with SAS score ~2.25 and Tanimoto similarity ~0.62 to aspirin.

Prompt Structure

A complete prompt follows this pattern:

Components

  1. EOS Token (</s>): Marks the start of a new prompt
  2. Property Tags: Specify desired molecular properties
  3. Similarity Tags: Reference molecules with similarity scores
  4. Start Tag: [START_SMILES] signals the model to begin SMILES generation

Property Tags

Available Properties

ChemLactica models understand these molecular properties from pretraining:
Estimates how difficult a molecule is to synthesize.
  • Range: 1.0 (easy) to 10.0 (very difficult)
  • Typical values: 2.0-4.0 for drug-like molecules
Measures drug-likeness based on molecular properties.
  • Range: 0.0 to 1.0
  • Typical values: >0.7 for drug-like molecules
Surface area of polar atoms, important for membrane permeability.
  • Range: 0 to ~300 Ų
  • Typical values: 20-140 Ų for oral bioavailability
Lipophilicity measure for membrane permeability.
  • Range: Typically -2 to 6
  • Typical values: 0-5 for drug-like molecules
Total molecular weight in Daltons.
  • Range: Variable
  • Typical values: 150-500 Da for drug-like molecules

Multiple Properties

Combine multiple property tags in a single prompt:

Similarity Constraints

SIMILAR Tag Format

Reference molecules to guide structural similarity:
  • reference_smiles: SMILES string of the reference molecule
  • similarity_score: Tanimoto similarity (0.0 to 1.0) using Morgan fingerprints (ECFC4)

Example: Aspirin Analogs

This generates molecules with ~0.62 Tanimoto similarity to aspirin.

Multiple Similar Molecules

Include multiple reference molecules:
utils.py:175
In optimization, similarity ranges (e.g., 0.4-0.9) are used to encourage exploration while maintaining structural relationships.

Prompt Construction in Optimization

The OptimEntry.to_prompt() method builds complete prompts for optimization:
utils.py:197

Custom Properties

Define custom properties for specific optimization tasks:
example_run.py:98

Oracle Score Property

When using rejection sampling (rej-sample-v2 strategy), oracle scores are included:
utils.py:214
This helps the model learn to generate molecules with higher oracle scores.

Example Prompts

Basic Property-Conditioned Generation

Similarity-Guided Generation

Combined Constraints

Optimization with Rejection Sampling

Best Practices

Property Values

Use realistic property value ranges based on your target chemical space

Similarity Scores

Balance exploration (lower similarity) and exploitation (higher similarity)

Multiple References

Include 3-5 similar molecules to guide structural features

Prompt Length

Keep total prompt + generation under 2048 tokens
Always include the EOS token </s> at the start of prompts and the [START_SMILES] tag before generation.

Next Steps

Molecule Generation

Learn how to use prompts for generation

Sampling Strategies

Optimize generation with sampling parameters