--- pretty_name: OpenGenome2-small license: apache-2.0 task_categories: - text-generation tags: - biology - dna - genomics - metagenomics - language-modeling - evo2 - opengenome2 size_categories: - 1M/.npy kept windows of one OpenGenome2 shard, concatenated (uint8) train//.jsonl one line per window: offset, len, u, tag, rec train//.done per-shard statistics train/selected.json window selection; train/manifest.json composition heldout/, valid/ same layout stats/ statistics (.json), 8-mer counts (_kmer8.npz), baselines (baseline.json) scripts/ build, check and load (below) ``` Sizes: `train` 12 GB, `heldout` 129 MB, `valid` 97 MB; 5.6k files. - **Encoding:** one byte per base. Bits 0–2 hold the base (A=0, C=1, G=2, T=3, N or other IUPAC=4), and bit 7 (0x80) marks a soft-masked (lowercase) base. `codes & 7` gives the base and `codes >> 7` the mask. - **Windows** never cross a record, contig or taxonomy-tag boundary. - **`tag`** is the window's full lineage, e.g. `D__EUKARYOTA;P__CHORDATA;C__MAMMALIA;O__PRIMATES;F__HOMINIDAE;G__HOMO;S__HOMO SAPIENS`, or empty for untagged subsets. ### Scripts | script | purpose | |---|---| | `og2dataloader.py` | PyTorch datasets: `RandomCrops` (training) and `EvalTiles` (evaluation, every target once) | | `og2load.py` | numpy reader: iterate windows, filter by subset or taxon, random crops | | `og2subset.py` | the streaming sampler (`sample`, `finalize`, `report`) | | `build.sh` | exact build recipe | | `og2stats.py` | composition, GC, soft-masking, CpG, k-mer statistics | | `og2baseline.py` | Markov baselines | | `check_rates.py` | realized sampling rate per subset | | `species_overlap.py` | species shared between splits | **Data loader.** Each sample is `ctx + 1` consecutive bases of one window. - Fields: `input_ids` (base ids, N = 4), `labels` (the next base), `loss_mask` and `lowercase`. - With `mask_non_acgt=True` (the default), targets that are not A/C/G/T get label −100 and are excluded from the loss. - `RandomCrops` weights windows by their number of possible crops, so every base is equally likely to be seen. It is reproducible per (seed, worker) and can reverse-complement samples (`rc_prob`). - Both datasets accept `subset=` and `taxon=` filters, e.g. `taxon=r"S__HOMO SAPIENS"` or `taxon=r"D__ARCHAEA"`. ## How it was built 1. **Streaming.** All 902 training shards of OpenGenome2 (`json/*//*_train_*.jsonl.gz`, 2.79 TB) were streamed and decompressed in memory; only the sample was written. 2. **Windows.** Each record is split at taxonomy tags (`|D__…;S__…|`), contig separators (`#`) and window separators (`@`). These characters never enter a sequence. Each segment is tiled into 16,384-bp windows on a fixed grid. 3. **Per-base-uniform sampling.** Each window is kept when a uniform draw `u` is below the rate (0.131%), whatever its length, so every base has the same inclusion probability. `u` is stored: `og2subset.py finalize --target-tokens N` shrinks the sample uniformly. 4. **Held-out species.** A record goes to `heldout` when `blake2b(species name) / 2^64 < 0.01`; untagged records are hashed by record. All records of a species go the same way in every shard and subset. 5. **Determinism.** Seed 0 and a pinned source revision. Each shard's generator is seeded by (seed, shard path), each record's by (shard, record index), so the output does not depend on worker count or order. ### Sampling note `ncbi_eukaryotic_genomes` was sampled in an earlier pass. That pass kept a window of length L with probability rate × L / 16,384, which under-samples short windows. Eukaryotic records are ~20 Mb, so almost all windows are full length, and the realized rate is 0.964 × rate. The deficit falls on segment ends next to tags and contig breaks. All other subsets were re-sampled with the per-base rule; their realized rates are 0.995–1.005 × rate (the three smallest subsets: 0.94–1.09, sampling noise). `build.sh` reproduces both passes exactly, and `check_rates.py` reports the realized rates. ## Reproduce ```bash pip install -r scripts/requirements.txt bash scripts/build.sh # stages: euk rest valid finalize stats baseline ``` About 3–4 hours on 14 CPU cores with ~250 MB/s of bandwidth (CPU-bound). Every stage is resumable. ## Limitations - **Context:** windows are at most 16,384 bp, so context beyond 16 kb is not available. - **Overlaps from the source:** proportions are OpenGenome2's raw ones, including its overlaps. GTDB genomes appear in two subsets (`gtdb_v220_stitched`, `gtdb_v220_imgpr`), and mRNA in two (`mrna`, `mrna_splice_promoter`). There is no deduplication beyond OpenGenome2's own. Evo 2 trained on a phase-dependent mixture, not on these proportions. - **Repeats:** three quarters of the bases are eukaryotic genomes, which are rich in repeats (42% soft-masked). - **Leakage across `heldout`:** untagged records are held out record by record, so related sequences (for example neighbouring metagenome chunks) can fall on both sides of the split. ## Citation Please cite Evo 2, which introduced OpenGenome2: ```bibtex @article{brixi2025evo2, title = {Genome modeling and design across all domains of life with Evo 2}, author = {Brixi, Garyk and Durrant, Matthew G. and Ku, Jerome and others}, journal = {bioRxiv}, year = {2025}, doi = {10.1101/2025.02.18.638918} } ``` ## License Apache 2.0, the license of OpenGenome2, from which every sequence is sampled. The scripts are released under the same license.