FOCUS: Near-Lossless Model Compression Enables Longer Context Inference in DNA Large Language Models
This project focus on the evaluation utilities for the summary-token (FOCUS) adapter trained on Evo-2 7B. Summary tokens (sometimes called FOCUS tokens): they are the compact, trainable markers inserted every k bases to retain long-range context.
Citation
Zhu, R., Zhou, X., Tang, H., Scherer, S. W., & Ohno-Machado, L. (2025). Near-Lossless Model Compression Enables Longer Context Inference in DNA Large Language Models, pp. 2025–11.
-
Docker image (BioNeMo)
export BIONEMO_IMAGE_PATH="nvcr.io/nvidia/clara/bionemo-framework:2.6.1" docker pull "$BIONEMO_IMAGE_PATH" # ~8 GB
Launch the container with GPU access, mounting this FOCUS directory and your checkpoint/output folders.
-
Repository layout
Inside the container, assume/workspace/FOCUSis the mount point for this folder and/workspace/bionemo-frameworkhosts the full BioNeMo stack (required for thebeacon.*Python modules). Set:export PYTHONPATH=/workspace/bionemo-framework/workspace/vendor:\ /workspace/bionemo-framework/workspace/vendor/bionemo/sub-packages/bionemo-core/src:\ /workspace/bionemo-framework/workspace/vendor/bionemo/sub-packages/bionemo-llm/src:\ /workspace/bionemo-framework/workspace/vendor/bionemo/sub-packages/bionemo-evo2/src:\ /workspace/bionemo-framework/workspace/vendor/bionemo/3rdparty/NeMo:\ /workspace/bionemo-framework/workspace/vendor/bionemo/3rdparty/Megatron-LM:\ /workspace/FOCUS:$PYTHONPATH
-
Model checkpoints
- Base Evo-2 7B flattened weights: place under
checkpoints/evo2_7b_nemo_flattened(or adjust paths when running scripts). - Summary adapter weights: copy your
beacon_adapter.ptintooutput/focus_runs/chr1/checkpoints/. Only the configuration (configs/summary_config.generated.yaml) is shipped here—the actual.ptfile must come from your internal training run.
- Base Evo-2 7B flattened weights: place under
For reproducibility, data/ includes short placeholder files (e.g., data/GRCh38/chr2_sample.fasta, data/Virus/virus_val_sample.csv, and an OpenGenome2 tarball). Replace them with full datasets for real experiments—the samples merely keep the project runnable in CI or documentation builds.
All scripts live in scripts/ and default to the structure under output/focus_runs/chr1. Pass --help to view full arguments.
python scripts/eval_summary_metrics.py \
--run-dir output/focus_runs/chr1 \
--base-model checkpoints/evo2_7b_nemo_flattened \
--chroms 2,3 \
--segment-length 1024 \
--num-seqs 10 \
--sample random \
--batch-size 4 \
--output output/focus_runs/chr1/outputs/GRCh38/summary.tsvThis compares next-token distributions between the summary adapter and the frozen base model on GRCh38 chromosome slices, writing both per-chromosome CSVs and a TSV summary. Summary tokens and base tokens are evaluated with the same tokenizer; only the adapter’s internal attention differs.
Important fields:
-
insert_every_n = 100: place one summary token after every 100 DNA bases. -
beacons_per_block = 1: one summary token per block; each token summarizes exactly one$k$ -mer. -
condense_ratio = 100: expected key/value compression factor (keep ~1% of KV entries). -
block_len = 1024: streaming chunk size (also used byeval_memory.py). -
special_tokens.beacon_token = '~': the actual summary token symbol and ID (126). We keep the key name for compatibility, but treat it as the “FOCUS token” throughout the documentation.
Train/eval hyperparameters (learning rate, warm-up, dataset paths, etc.) are identical to the chr1 experiment and can be tweaked in this YAML before re-running training.
-
Pull the BioNeMo container (
docker pull "$BIONEMO_IMAGE_PATH"). -
Run the container with GPUs and mount:
docker run --gpus all -it \ -v ./FOCUS:/workspace/FOCUS \ -v ./checkpoints:/workspace/checkpoints \ -v ./output:/workspace/output \ "$BIONEMO_IMAGE_PATH" bash -
Set
PYTHONPATHto include the BioNeMo vendor subpackages (see Section 1.2). -
Copy checkpoints: put
beacon_adapter.ptintooutput/focus_runs/chr1/checkpoints/and the Evo-2 weights intocheckpoints/evo2_7b_nemo_flattened/. -
(Optional) Replace sample data under
data/with the full GRCh38/OpenGenome2/Virus datasets. - Run evaluations using the commands in Section 3 (GRCh38, OpenGenome2, Virus) or profile memory via Section 3.4.
-
Inspect outputs in
output/focus_runs/chr1/outputs/*—each script writes TSV summaries plus per-dataset CSVs.
This completes the streamlined FOCUS project setup. The scripts, minimal data, and configuration files here are enough to document or regression-test the summary-token adapter; swap in your full datasets and trained checkpoints for production-scale experiments.
