Build a CLI tool for drug discovery / small-molecule design that can:
- Train a multimodal model with:
- a molecular graph encoder
- a text encoder
- a shared aligned embedding space
- optional property prediction heads
- Infer / design from:
- a text goal such as
"design a non-toxic kinase inhibitor with good oral ADMET" - an optional similar known drug / seed molecule (SMILES or name)
- a text goal such as
- Return Top-N candidate molecules ranked by:
- goal-text relevance
- similarity / novelty balance
- predicted ADMET / toxicity / synthesizability / docking proxy scores
This should feel closer to image-text generation + retrieval than to a pure property classifier:
- text = design intent / prompt
- reference molecule = analogous to an image prompt or reference image
- output = a ranked set of candidate drug designs
Start with two encoders + alignment loss, similar to CLIP:
- one encoder for the molecular graph
- one encoder for text
- train both to land in a compatible embedding space
- add small property heads and a ranking head
For this product, the main problem is not only prediction. It is:
- matching chemical structures to human design intent
- retrieving and ranking promising candidates
- leveraging known compounds as references
- staying trainable and extensible
A CLIP-style alignment system is the cleanest first step.
Do not start with:
- a pure VAE shared latent model as the center of the system
- RL as the main training method
- fully autoregressive molecule generation from day one
A shared-latent VAE is elegant, but for an initial production-quality tool it is usually harder to stabilize and less directly useful than contrastive alignment plus reranking. VAE / diffusion / flow-based generation make more sense later when generation itself becomes the center of the product. Multimodal molecule-text work such as MoleculeSTM is built around contrastive alignment on structure-text pairs, not a pure VAE-first design. citeturn498535search22turn276799search5
RL is better reserved for later-stage constrained optimization after you already have:
- a strong retriever / scorer
- a calibrated property predictor
- a candidate generator
For early versions, supervised learning + contrastive alignment + reranking is the right default. TDC and mainstream ADMET benchmarks are built around supervised evaluation rather than RL-centric training. citeturn498535search9turn498535search13
goal_text: str
Example:
"Design a liver-safe, low-cardiotoxic, orally available small molecule similar to osimertinib but with lower hERG risk."
reference_molecule: one of- SMILES string
- SDF/MOL file
- known drug name resolved to structure upstream
target_profile: structured JSON or YAML constraintstop_n: integernovelty_weight,similarity_weight,toxicity_weight, etc.
- target protein ID / assay family
- hard filters such as molecular weight, logP, TPSA, HBD/HBA, rotatable bonds
- medicinal chemistry exclusion rules / SMARTS alerts
Return Top-N candidates with:
- canonical SMILES
- 2D depiction path or inline rendering
- similarity to reference compound
- text-goal alignment score
- predicted properties:
- toxicity
- hERG / DILI / BBB / solubility / oral bioavailability proxies
- synthetic accessibility / QED
- novelty score
- final combined rank score
- short textual rationale
Example output object:
{
"goal_text": "Design a low-toxicity oral kinase inhibitor similar to osimertinib",
"reference": "osimertinib",
"top_candidates": [
{
"rank": 1,
"smiles": "CC1=...",
"alignment_score": 0.88,
"similarity_to_reference": 0.71,
"toxicity_score": 0.11,
"herg_risk": 0.09,
"sa_score": 2.9,
"qed": 0.72,
"final_score": 0.81,
"why": "Matches EGFR-inhibitor-like scaffold features while lowering predicted toxicity and maintaining oral-like property profile."
}
]
}This spec is for small-molecule drug discovery.
That means:
- graph nodes = atoms
- graph edges = chemical bonds plus optional geometric / pharmacophore relations
This is a better fit for:
- text-conditioned molecule retrieval
- lead optimization
- ADMET-aware reranking
- similar-drug-guided design
The earlier protein-graph idea still matters as a reusable pattern, but this CLI should center on small molecules because the user flow is “drug design from text + reference compound.”
Use a graph encoder over molecular graphs:
- atom type, valence, aromaticity, formal charge, chirality, ring membership
- bond type, conjugation, stereochemistry
- optional 3D conformer features if available
Use a biomedical / chemistry-capable text encoder over:
- design goal text
- assay descriptions
- mechanism notes
- ADMET constraint descriptions
- scaffold / medicinal chemistry notes
Train so that matched graph-text pairs are close and mismatched pairs are far.
Add:
- property prediction heads
- similarity / novelty scoring
- optional pairwise ranker
At inference:
- Encode
goal_text - Encode
reference_moleculeif provided - Search a candidate pool or generator output set
- Score candidates by:
- text alignment
- reference similarity
- ADMET / toxicity
- synthesizability
- novelty
- Return Top-N
This is analogous to:
- text-to-image retrieval / reranking
- reference-guided generation
- CLIP embedding search
There is no single universally best graph encoder for every medicinal chemistry task, but the strongest practical family is:
Message-passing molecular GNN in PyG, optionally with graph transformer blocks.
Good choices:
- GIN / GINE baseline
- MPNN / AttentiveFP-style baseline
- Graph Transformer / GraphGPS-style upgrade later
For a 0 → 1 CLI product, use:
- GINE / MPNN-level encoder first
- rich atom / bond featurization
- optional 3D branch later
- text alignment as the differentiator
Why:
- easier to train and debug than exotic chemistry foundation models
- straightforward to integrate with PyG
- sufficient to validate the product loop
NVIDIA’s drug-discovery catalog is useful, but mainly as supporting models rather than your core graph encoder. On NVIDIA Build, ESM2-650M is a protein embedding model and OpenFold3 / OpenFold2 / Boltz-2 are structure-prediction models; those are more relevant for protein workflows than for a small-molecule graph backbone. citeturn276799search2
So for this CLI:
- use standard molecular GNNs as the main graph encoder
- use NVIDIA biology models only if you later add protein-side conditioning or target-side modeling
PyTorch Geometric (PyG)
Why:
- strongest flexibility for custom molecular graph encoders
- rich ecosystem for GNN experimentation
- easiest path if you want custom ranking / multimodal heads
RDKit
Why:
- canonical molecular parsing and sanitization
- fingerprints, descriptors, SMARTS filters
- conformer generation
- depiction for CLI outputs
- Transformers for text encoder
- PyTorch Lightning or plain PyTorch for training loops
- scikit-learn for metrics and split utilities
- TDC for benchmark datasets and standard ADMET tasks
- DeepChem for chemistry utilities and baseline models
- FAISS for nearest-neighbor retrieval in embedding space
For this CLI, prefer:
- PyG + RDKit + Transformers + TDC
PyG is the better long-term choice here than TorchDrug because the product is centered on small-molecule graph + text alignment, not protein-native graph abstractions.
There is no single dataset that covers everything. The best setup is two-layered:
Use for:
- molecule-text contrastive pretraining
- text / structure retrieval
- learning the shared graph-text embedding space
Why:
- specifically built for molecule structure + text alignment
- publicly referenced, reproducible, and already used in MoleculeSTM
- suitable for CLIP-style training on chemical structures and textual descriptions. MoleculeSTM reports over 280,000 structure-text pairs in PubChemSTM. citeturn276799search5turn498535search22
Use for:
- larger-scale molecule-text pretraining
- stronger text-conditioned retrieval / ranking
Why:
- much larger recent molecule-text dataset from ChEMBL35
- around 2.5 million molecule-text pairs
- better if you want to train a stronger multimodal foundation model, but newer and less battle-tested than PubChemSTM. citeturn276799academia13
Use for:
- toxicity and ADMET property heads
- standard benchmark splits
- reproducible supervised evaluation
Why:
- TDC provides a broad ecosystem of AI-ready therapeutic datasets and benchmark groupings, including toxicity / ADMET tasks and standard data access through Python. citeturn498535search9turn498535search13
Start with:
- Tox21
- ClinTox
- additional TDC ADMET tasks relevant to your design goals
TDC’s toxicity task overview and ADMET benchmark are appropriate for the supervised property heads in this system. citeturn498535search1turn498535search13turn498535search21
Use:
- ChEMBL as the main public candidate and nearest-neighbor library
- optional PubChem subset for larger retrieval space
Why:
- contains real drug-like molecules and bioactivity-linked chemistry
- natural source for “similar to known drug” retrieval and scaffold seeding
If you want one practical default stack:
- PubChemSTM for graph-text alignment
- TDC ADMET / Tox21 / ClinTox for toxicity and ADMET heads
- ChEMBL subset filtered for drug-like compounds
- replace or augment PubChemSTM with MolTextNet later
- Deduplicate by canonical SMILES / InChIKey
- Split by scaffold, not random rows
- Keep source dataset provenance
- Keep property units / assay metadata
- Remove label conflicts where possible
- Track train / valid / test leakage via near-neighbor similarity
- Keep a frozen external test set
- Mark synthetic text vs human-authored text if mixing datasets
- Bemis–Murcko scaffold split for small molecules
- optional temporal split where available
- external holdout from a different source
This matters a lot because random splits can inflate performance in medicinal chemistry.
Losses:
- InfoNCE / CLIP-style contrastive loss
- optional graph-text matching loss
Inputs:
- molecule graph
- paired text description
Output:
- aligned embedding space
Losses:
- BCE / focal loss for binary toxicity tasks
- regression loss for continuous ADMET endpoints where applicable
Heads:
- toxicity
- hERG proxy
- DILI proxy
- solubility / lipophilicity / permeability / oral-like tasks
Train a scorer over:
- text alignment score
- similarity to reference compound
- property scores
- novelty / synthesizability
Only after the retrieval/scoring stack is working:
- fragment recombination
- scaffold decoration
- diffusion / flow / language-model generation over SMILES or graphs
RL is a phase-2 or phase-3 optimization layer only.
Use RL only if you later want:
- text-conditioned molecular editing
- multi-objective optimization under hard constraints
- active search over generator proposals
The practical roadmap is: alignment + supervised heads → reranker → generator → RL/search
Version 1 does not need to invent molecules from scratch.
Generate candidates from one or more of:
- nearest neighbors in ChEMBL / PubChem embedding space
- scaffold analog expansion from the reference molecule
- medicinal-chemistry transformations / matched molecular pairs
- fragment replacement templates
Then rerank.
This gets you a useful product sooner because:
- outputs are more realistic
- easier to validate
- easier to keep synthesizable
- easier to explain to users
Later add:
- graph diffusion
- SMILES-based generator
- constrained molecular editing
final_score =
w_text * text_alignment
+ w_ref * similarity_to_reference
+ w_prop * property_score
+ w_sa * synthesizability
+ w_qed * drug_likeness
+ w_nov * novelty
- w_tox * predicted_toxicity
- w_alert * structural_alert_penalty
- keep reference similarity in a moderate band, not maximum
- reward novelty only after minimum plausibility is met
- hard-filter obvious toxophores or rule violations before ranking
Example package name:
drugclip
drugclip data download pubchemstm
drugclip data download tdc-tox
drugclip data download chembldrugclip data preprocess --config configs/pretrain_pubchemstm.yamldrugclip train align --config configs/align_pubchemstm.yamldrugclip train property --config configs/property_tdc.yamldrugclip index build --molecules data/chembl/filtered.smi --checkpoint runs/align/best.ckptdrugclip infer \
--goal-text "Design a low-toxicity oral kinase inhibitor similar to osimertinib" \
--reference-smiles "COc1cc..." \
--top-n 20 \
--checkpoint runs/final/model.ckptdrugclip infer-batch --input prompts/design_tasks.jsonl --output outputs/candidates.jsonl- ranked JSON / JSONL
- CSV summary
- optional SDF file with top candidates
- optional PNG depictions
- markdown report
project/
drugclip/
cli.py
config.py
data/
download.py
preprocess.py
chembl.py
pubchemstm.py
tdc_tasks.py
featurizers/
graph.py
text.py
descriptors.py
models/
graph_encoder.py
text_encoder.py
align_model.py
property_heads.py
reranker.py
training/
train_align.py
train_property.py
losses.py
metrics.py
inference/
retrieve.py
generate.py
rank.py
filters.py
explain.py
index/
build_faiss.py
utils/
chemistry.py
io.py
logging.py
configs/
align_pubchemstm.yaml
property_tdc.yaml
infer_default.yaml
tests/
README.md
Per atom:
- atom type
- degree
- formal charge
- aromaticity
- hybridization
- chirality
- ring membership
Per bond:
- bond type
- conjugation
- aromatic bond flag
- stereo
- ring bond flag
Optional global features:
- RDKit descriptors
- Morgan fingerprint
- SA / QED
- raw design goal text
- optional structured prompt template
- optional target / assay / ADMET constraints
- projection MLP for graph embedding
- projection MLP for text embedding
- normalized shared space
- binary / multi-task property heads
- pairwise ranker
Parse text goal into:
- target/mechanism hints
- ADMET constraints
- positive and negative attributes
Resolve reference molecule if given:
- name → SMILES
- sanitize with RDKit
Retrieve initial pool:
- embedding nearest neighbors from ChEMBL
- fingerprint neighbors
- scaffold analogs
Score pool:
- graph-text alignment
- reference similarity
- property heads
- alerts / rule filters
Return Top-N and rationale
Add:
- nearest-neighbor examples from training data
- atom / substructure attribution where possible
- reasons for rejection / filtering
- textual explanation of why the candidate matched the prompt
This matters because medicinal chemistry users will want to know why a candidate was ranked highly.
- text-conditioned molecular editing
- graph diffusion / flow matching candidate generator
- target protein conditioning
- docking-informed reranking
- active learning loop with wet-lab feedback
- RL or search over generator proposals
- multimodal target + ligand + text modeling
- graph encoder + text encoder + CLIP-style alignment
- PyG + RDKit + Transformers + TDC + FAISS
- PubChemSTM for graph-text alignment pretraining
- TDC ADMET / Tox21 / ClinTox for property heads
- ChEMBL as retrieval / candidate library
- MolTextNet as the later scale-up option
- contrastive pretraining
- supervised multitask property fine-tuning
- reranker training
- no RL at the beginning
Input:
- text design goal
- optional similar drug / reference molecule
Output:
- Top-N drug candidates with scores and reasons
That is the most realistic, extensible, and technically grounded starting point.