SafePro: Generation of Safe and Functional Proteins via Cross-Task Conflict-Aware Alignment

Chongyang Gao, Marco Postiglione, Vs SubrahmanianNeurIPS 2026

TL;DR

Protein language models can dream up brand-new biological machinery at scale, which is fantastic for medicine—until the model accidentally invents a potent toxin. SafePro brings RLHF-style safety alignment directly into protein generation, teaching models to simultaneously optimize for structural stability while steering clear of both cellular toxicity and disease-causing virulence. By dynamically untangling competing biological trade-offs during training, SafePro produces more structurally viable proteins than unaligned models while slashing the rate of dangerous outputs.

What Problem Does This Paper Address?

Just as large language models predict the next word, Protein Language Models (PLMs) predict amino acid sequences to design novel enzymes and therapeutics. However, PLMs are inherently agnostic to whether a functional protein helps a cell or destroys it. Right now, biosecurity relies mostly on downstream screening—generating sequences first and filtering out the dangerous ones later.

Aligning PLMs upstream at the model level using Reinforcement Learning (specifically Proximal Policy Optimization, or PPO) is the logical next step, similar to how we keep chatbots polite. But biology throws two curveballs at standard RL alignment:

  1. Harm isn't a single dial: Protein risk spans multiple distinct axes, notably toxicity (direct cellular damage) and virulence (helping a pathogen cause disease, like host-adherence or immune evasion). Training separate classifiers misses shared biological signals, while mashing them onto one shared neural backbone causes "negative transfer," where class imbalances in one task wreck performance on the other.
  2. Shifting trade-offs in massive parameter spaces: PPO needs a single scalar reward, meaning you have to weight structural foldability against toxicity and virulence. Fixed weights fail because trade-offs shift as the model explores sequence space. Worse, standard multi-objective algorithms (like MGDA) break down on large PLMs because of Gram-matrix dilution: massive, aligned gradients in the model's output layer drown out subtle, localized task conflicts deeper in the network.

Methods

SafePro wraps a standard KL-regularized PPO training loop (plus ESMFold to score 3D structural foldability via pLDDT and a length regularizer to prevent short-sequence gibberish) around two novel components:

Figure 1: Overview of the SAFEPRO framework. CTAF supplies joint toxicity/virulence rewards, ESMFold supplies structural rewards, and TCS-MGDA dynamically calibrates the reward weights during PPO fine-tuning of the PLM policy.
  • Cross-Task Attentive Fusion (CTAF): Instead of choosing between isolated single-task predictors or a rigid shared network, CTAF puts two separate "expert" heads (toxicity and virulence) atop a frozen ESM2 protein backbone. When predicting toxicity, the toxicity expert uses gated cross-attention to peek at token-level representations from the virulence expert (and vice versa). A learned gate decides how much cross-task advice to let in per sequence.
  • Task-Conflict-Saliency MGDA (TCS-MGDA): To dynamically balance the weights of foldability, toxicity, and virulence during PPO without suffering from Gram-matrix dilution, TCS-MGDA filters the parameter space. It centers rewards, normalizes scales, and calculates a saliency score across parameters to find the top 5% where standardized cross-task variation is highest. If the conflict signal in this restricted subspace diverges enough from the full network (measured via a cosine-similarity gap), SafePro calibrates objective weights using only those conflict-heavy parameters.

Datasets

  • Toxicity Benchmark: Sourced from Zhu et al. (derived from UniProt), featuring 5,090 toxic and 12,388 non-toxic sequences split across train/val/test with strict 40% sequence-identity deduplication to prevent data leakage.
  • Curated Virulence Benchmark (New): Because no standardized protein-level virulence benchmark existed, the authors curated 54,166 sequences—pairing 27,083 virulence factors from the Virulence Factor Database (VFDB) with 27,083 length-stratified safe proteins sampled across 21 diverse bacterial proteomes, scrubbed via keyword exclusions and hash-based leakage removal.

Key Insights and Ideas

  • Biological asymmetry shows up in the attention gates: Toxins are biologically a strict subset of virulence factors (all toxins help cause disease, not all virulence factors are toxins). Without being told this, CTAF's learned gates naturally discovered it: the toxicity expert pulls in 20% cross-task signal from virulence, whereas virulence only listens to toxicity 6% of the time.
  • Gradient dilution is dramatic in PLMs: Analyzing ProGen2-medium (~765M parameters), the authors found that nearly 48% of parameters have near-zero gradients on any backward pass, while the output projection block towers over internal blocks by an order of magnitude. Standard multi-objective optimizers get blinded by that output block; filtering for salient parameters restores sensitivity.
Figure 2: Mean gradient magnitude across N=32 samples. For each block, we plot 1
  • Without length guardrails, models cheat: If you penalize a PLM for making toxins without a length regularizer, it eventually discovers a lazy loophole: generating tiny, single-digit amino acid fragments that technically aren't toxic, collapsing sequence length from ~480 down to single digits by iteration 900.

Key Results

  • Superior Reward Modeling: On held-out test sets, CTAF strictly beats both single-task classifiers and shared-trunk baselines on every metric, boosting toxic F1 by +0.0584 (to 0.8619) and virulence F1 by +0.0268 (to 0.9426) over independent models.
  • End-to-End Alignment Wins: On progen2-medium, SafePro achieves a composite alignment score of 66.86, beating standard MGDA (+6.41), the best fixed-weight PPO baseline (+5.21), and preference-optimization baselines like DB-DPO (+4.14). It slashes predicted toxicity from $0.0564 \to 0.0139$ and virulence from $0.6443 \to 0.5407$ while nudging structural quality (pLDDT) up to 56.04. Gains also transfer cleanly to ProtGPT2.
  • Safer and More Designable: When filtering 1,000 generated sequences for true 3D structural viability (self-consistency RMSD $< 2$,\AA), SafePro yields 62 designable proteins—more than double the base model (27). Within those viable designs, the fraction flagged as harmful drops from 89% (fixed-weight PPO) and 100% (base model) down to 34%. External tools not used in training (ToxDL2, VirulentHunter, and VFDB homology search) independently confirm fewer offensive hits (e.g., an 80% drop in effector-delivery matches).

Limitations and Future Work

  • In silico proxies vs. wet-lab reality: All safety and structural metrics rely on computational predictors (CTAF, external classifiers, ESMFold confidence, and sequence homology) rather than wet-lab experimental validation of biological function or safety.
  • Optimization diagnostics: Using a restricted parameter subspace in TCS-MGDA serves as an effective weight-calibration heuristic, not a mathematical guarantee of full-parameter Pareto stationarity.
  • Dual-use sensitivity: Because the exact same reward-alignment machinery could theoretically be inverted (flipping signs to maximize toxicity and virulence), the authors withhold open public weights and instead release code, models, and the new virulence dataset strictly upon request. (Further limitations and release policies are deferred to Appendix A, which is beyond the main text provided.)

Summary updated

Abstract

Protein language models (PLMs) enable scalable protein design but lack intrinsic safety constraints. We introduce SAFEPRO, a reinforcement-learning framework jointly optimizing structural foldability, toxicity avoidance, and virulence avoidance. SAFEPRO features two novel components: (1) Cross-Task Attentive Fusion (CTAF), a joint reward model that employs gated cross-attention between toxicity and virulence experts to capture shared biological signals through selective cross-task sharing, and (2) Task-Conflict-Saliency MGDA (TCS-MGDA), an adaptive weight-calibration procedure for Proximal Policy Optimization (PPO). TCS-MGDA targets gradient Gram-matrix dilution via parameter-space saliency filtering. On ProGen2, SAFEPRO improves composite alignment scores by $+5.21$ over the strongest fixed-weight baseline, significantly reducing toxicity ($0.0564 \to 0.0139$) and virulence ($0.6443 \to 0.5407$) while maintaining structural quality. External classifiers and homology screening also show reductions in selected toxicity and virulence proxies relative to the base policy. Among structurally designable outputs (scRMSD $< 2$\,\AA), SAFEPRO reduces the CTAF-flagged harmful fraction from $89\%$ under fixed-weight PPO to $34\%$ while producing more than twice as many designable sequences as the base model. We also curate a virulence dataset of $54{,}166$ sequences from VFDB, available on request.
BibTeX
@inproceedings{gao2026safepro,
  author = {Chongyang Gao and Marco Postiglione and VS Subrahmanian},
  title = {{SafePro: Generation of Safe and Functional Proteins via Cross-Task Conflict-Aware Alignment}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=dEUkSqPWuL},
}
Figure