--- license: mit library_name: pytorch tags: - antimicrobial-peptides - protein-design - variational-autoencoder - cvae - bioinformatics - generative-model --- # Controllable Antimicrobial Peptide Design — CVAE + Judge Trained checkpoints for a conditional VAE that generates antimicrobial peptide (AMP) sequences targeting a user-specified potency (MIC, minimum inhibitory concentration) against *E. coli*, plus an independently trained CNN ("the Judge") that predicts MIC from sequence and is used to evaluate generated candidates. - **Code**: [github.com/Sloudis/controllable-amp-design](https://github.com/Sloudis/controllable-amp-design) - **Dataset**: [Sloudis/controllable-amp-design-dataset](https://huggingface.co/datasets/Sloudis/controllable-amp-design-dataset) - **Full report**: see `report/report.pdf` in the GitHub repo (methodology, training dynamics, evaluation) ## Files | File | Model | Params | Description | |---|---|---|---| | `cvae_best.pt` | CVAE generator | ~3.99M | Bi-GRU encoder / autoregressive-GRU decoder, 32-dim latent | | `judge_best.pt` | Judge predictor | ~329K | Multi-scale residual 1-D CNN (kernel sizes 3/5/7) | ## Architecture **Generator (CVAE)**: a bidirectional, 3-layer GRU encoder (256 hidden units) maps a peptide sequence + a shared learned embedding of the normalized target log10(MIC) to a 32-dimensional diagonal-Gaussian latent. A 3-layer unidirectional GRU decoder (256 hidden units) is re-conditioned on the latent sample and the score embedding at every timestep, generating logits over a 22-symbol vocabulary (20 amino acids + PAD + EOS) autoregressively. Trained with a β-rescaled, free-bits ELBO objective (free bits = 0.1, β annealed over 50 epochs) and 30% word dropout to prevent posterior collapse. **Judge**: parallel 1-D convolutions (kernel sizes 3, 5, 7) extract motifs at different receptive fields, concatenated to 128 channels, expanded to 256, passed through a residual block (with a 1×1-conv shortcut) back down to 128 channels, global-max-pooled, and regressed to a scalar (normalized log10 MIC) through a small MLP head. Trained independently of the CVAE, purely as a post-hoc evaluator — it never sees the conditioning score. ## Usage Requires the model definitions from the [GitHub repo](https://github.com/Sloudis/controllable-amp-design) (`src/models/cvae.py`, `src/models/judge.py`) and its `data/dataset.py` for the vocabulary/encoding utilities. ```python import torch from huggingface_hub import hf_hub_download from models.cvae import CVAE from models.judge import Judge from data.dataset import decode_sequence, normalize_score, denormalize_score cvae_path = hf_hub_download("Sloudis/controllable-amp-design", "cvae_best.pt") judge_path = hf_hub_download("Sloudis/controllable-amp-design", "judge_best.pt") cvae = CVAE() cvae.load_state_dict(torch.load(cvae_path, map_location="cpu")) cvae.eval() judge = Judge() judge.load_state_dict(torch.load(judge_path, map_location="cpu")) judge.eval() # See src/evaluation/generate.py in the GitHub repo for a full generation CLI, # including score normalization against the training set's log_mic mean/std. ``` ## Evaluation Measured on a held-out test set (1,000 sequences): - **Judge**: Spearman ρ = 0.70, Pearson r = 0.73 (MIC prediction from sequence alone) - **Generator**: 99.8% valid, 100% novel (not present in training data) sequences; amino-acid composition matches natural AMPs - **Conditioning accuracy**: strongest in the densely-sampled mid-potency range (~65% hit rate within ±0.5 log10 MIC units), degrading toward the extremes of the potency range where training data is scarce ## Limitations - Conditioning-accuracy numbers are only as good as the Judge itself (ρ=0.70, not a ground-truth oracle) — no generated peptide was synthesized or tested against live bacteria. - Trained and conditioned on *E. coli* MIC only; says nothing about Gram-positive activity, selectivity, hemolysis/cytotoxicity, or synthesizability. - Conditioning reliability degrades toward the extremes of the potency range (see the report, Sec. 6.3). ## Citation ``` Stavros Loudis. "Controllable Antimicrobial Peptide Design via Conditional Variational Autoencoders." Technical University of Crete, 2026. ``` ## License MIT — see [LICENSE](https://github.com/Sloudis/controllable-amp-design/blob/main/LICENSE) in the GitHub repo.