Code for AncestorGFN: Evolutionary Sequence Design with GFlowNets (ICLR 2026 Workshop on Generative Models for Genomics).
We train GFlowNets to generate RNA sequences proportional to reward, targeting LET-7 miRNA family members across species. The codebase supports TB, DB, and FL-DB objectives with GPU-accelerated batch training.

Learned GFlowNet flow network over RNA sequence trajectories, with target, novel, and intermediate states.
pip install -r requirements.txtfrom gfn import train, TrainingConfig
from gfn.reward import TargetMatchReward
targets = [['A', 'U', 'G', 'C'], ['C', 'C', 'U', 'A'], ['G', 'G', 'G', 'G']]
result = train(TargetMatchReward(targets, r_min=0.1), TrainingConfig(n_episodes=20_000))For the full LET-7 22bp training run:
python train_LET7_22bp.pyrun_training.ipynb— toy example (4bp), compares TB vs DB vs FL-DBrun_training_gpu.ipynb— GPU training on 10bp targetsrun_training_gpu_long_LET7.ipynb— LET-7 22bp, the main experimentrun_training_gpu_long_LET7_10bp.ipynb— LET-7 10bp substring variantrun_analysis.ipynb— hit trajectories, phylogenetic coveragerun_analysis_sequence_design.ipynb— greedy/stochastic/beam search generation
gfn/
├── env.py # state space and transitions
├── model.py # TB and DB networks
├── losses.py # loss functions
├── reward.py # reward schemes (Hamming, entropy-weighted, conservation)
├── training.py # episode-based training loop
├── training_fast.py # GPU batch training
├── visualization.py # plotting
└── utils.py # helpers
data/
├── LET7_22bp_targets.json # 22bp targets filtered from miRBase
├── LET7_10bp_targets.json # 10bp substrings (positions 10–19)
└── LET7_family_mature_ALLspecies.fa
phylogeny/
├── phylogeny_analysis.ipynb
└── phylogeny_pipeline.sh