BIO-Distiller is a framework for tuning and distilling supervised learning baselines on RNA sequence based tasks by leveraging knowledge distillation from large biological foundation models (FMs). This repository provides scripts, utilities, and benchmarks for distillation workflows and downstream evaluation.
- Install the requirements in
requirements.txt.pip install -r requirements.txt
Download the BEACON RNA benchmark dataset and select from the following sequence classification tasks:
- ncRNA
- MRL
- APA
- PRS ON
- PRS OFF
- PRS ON-OFF
biod- Scripts for training simple CNNs and their distilled variantsfms- Code for fine-tuning biological foundation models
Install the package with pip install -e ..
Create a .env file with the following variables included:
DATASETS_DIR="/path/to/datasets/"
TUNE_STORAGE_PATH="/path/to/ray/output/dir"
# Optional
WANDB_API_KEY="your_wandb_api_key"
WANDB_DIR="/path/to/local/wandb/output/dir"
A job can be runned with the command below, where model refers to a simple CNN models with file in config/model, and task refer to a task in config/task.
The following command runs the simple baselines for the specified task
python runner.py model=gbench_cnn task={task}
To distill using feature KD losses, run the following command specifying the task, agg (loss aggregation method: sum or convex), kd_loss (fitnet or eucosine), ft (finetuning of FMs: true or false), and fm (list of FMs to distill from)
python runner.py model=gbench_cnn task={task} +distill={agg} distill.kd_loss_name={kd_loss} distill.fm_is_ft={ft} distill.fm_name=[{fm}]
For response based KD, run the following command
python runner.py model=gbench_cnn task={task} +distill=${agg} distill.kd_loss_name=${kd_loss} distill.fm_is_ft=${ft} distill.fm_name=[{fm}] distill.kd_type=logits
The fms/ directory contains scripts and utilities for fine-tuning and generating predictions for biological foundation models (FMs) used in the BIO-Distiller pipeline.
To finetune the foundation models, enter the respective [rna/dna/protein] directory and run the following command
python finetune.py --fm {fm_name} --task {task_name}
Once the model is trained, you can obtain the predictions [hidden representations + logits] from either the finetuned or non-finetuned variants by running the following command
python preds.py --fm {fm_name} --task {task_name} --finetuned {true/false} --ds_set {train/test/val}
- List of available FMs: [RNA: RNA-FM, RNA-MSM, UTRLM-TE+EL, UTRLM-MRL] [DNA: HyenaDNA-tiny1k] [Protein: ESM2 t6-8m]