Datasets:
File size: 12,548 Bytes
6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 6f32cc3 d708c47 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | ---
pretty_name: OpenGenome2-small
license: apache-2.0
task_categories:
- text-generation
tags:
- biology
- dna
- genomics
- metagenomics
- language-modeling
- evo2
- opengenome2
size_categories:
- 1M<n<10M
viewer: false
---
# OpenGenome2-small (og2_small)
**An 11.8B-token, per-base-uniform sample of [OpenGenome2](https://huggingface.co/datasets/arcinstitute/opengenome2)**,
the ~8.8T-token DNA corpus used to train Evo 2, with the same mix of eukaryotic genomes, prokaryotic genomes,
metagenomes, transcripts, viruses and regulatory sequence, plus a validation set of species never seen in training.
| | |
|---|---|
| **Train** | 11.78B bases in 1.54M windows (≤ 16,384 bp), ~39.3k species, 226 phyla |
| **Held-out species** | 124M bases, 367 species absent from train (1% of species) |
| **Evo 2 valid** | 99M bases from OpenGenome2's own validation split |
| **Baseline** | 1.940 bits/base on held-out species (order-7 Markov model) |
| **Source** | `arcinstitute/opengenome2`, revision [`84d2a7e`](https://huggingface.co/datasets/arcinstitute/opengenome2/tree/84d2a7e690c8bb395d1f4868822dfa031ea561c6), sampling rate 0.131% |
| **License** | Apache 2.0 (as OpenGenome2) |
## Quick start
```bash
hf download AutomatedScientist/og2_small --repo-type dataset --local-dir og2_small
cd og2_small && pip install -r scripts/requirements.txt torch
```
```python
import sys; sys.path.insert(0, "scripts")
import torch.nn.functional as F
from og2dataloader import RandomCrops, EvalTiles, make_loader
train = make_loader(RandomCrops(".", "train", ctx=4096, seed=0, rc_prob=0.5), batch_size=16, num_workers=4)
heldout = make_loader(EvalTiles(".", "heldout", ctx=4096), batch_size=16)
batch = next(iter(train)) # input_ids, labels, loss_mask, lowercase: each [16, 4096]
loss = F.cross_entropy(logits.flatten(0, 1), batch["labels"].flatten(), ignore_index=-100)
```
The data are numpy arrays with JSONL indexes (one byte per base), read with the scripts in `scripts/`; there is no
Parquet copy, so `datasets.load_dataset` and the dataset viewer do not apply.
## Splits
| split | bases | windows | species | what it measures |
|---|---|---|---|---|
| `train` | 11.78B | 1,539,679 | ~39.3k | training |
| `heldout` | 124M | 15,940 | 367 | generalization to unseen species |
| `valid` | 99M | 7,811 | 59 | Evo 2's validation split (comparability) |
- **`heldout`** is drawn from the same source shards as `train`: every record of ~1% of species (chosen by a hash of
the species name) and ~1% of untagged records, sampled at the same rate. It shares **no species** with `train` and
has the same subset mix, so it is the split to report.
- **`valid`** samples OpenGenome2's own `valid` shards. Evo 2 held those out by genomic region, not by species: 31 of
its 59 species (80% of its tagged bases) also occur in `train`, and 91% of it is eukaryotic genomes.
- Species are distinct `S__` taxonomy tags. Only eukaryotic genomes and GTDB carry tags; metagenomes, transcripts and
viruses add diversity that is not counted as species.
## Composition
Every base of OpenGenome2's training shards had the same chance (0.131%) of being kept, so subset shares match the
full corpus:
| subset | train bases | share | share in OpenGenome2 | species | heldout bases |
|---|---|---|---|---|---|
| ncbi_eukaryotic_genomes | 8.69B | 73.8% | 74.5% | 12,058 | 93.8M |
| metagenomes | 1.11B | 9.42% | 9.15% | – | 11.0M |
| eukaryotic_genic_windows | 545M | 4.62% | 4.50% | – | 5.8M |
| gtdb_v220_stitched | 463M | 3.93% | 3.83% | 27,259 | 4.1M |
| gtdb_v220_imgpr | 461M | 3.91% | 3.83% | – | 4.5M |
| mrna_splice_promoter | 257M | 2.18% | 2.11% | – | 2.7M |
| mrna | 151M | 1.28% | 1.24% | – | 1.5M |
| imgvr_untagged | 46.9M | 0.40% | 0.39% | – | 0.5M |
| ncrna | 42.7M | 0.36% | 0.35% | – | 0.4M |
| imgpr | 8.0M | 0.07% | 0.06% | – | 0.1M |
| organelle | 7.9M | 0.07% | 0.06% | – | 0.1M |
| promoters | 0.3M | <0.01% | <0.01% | – | <0.1M |
"–" = the subset carries no species tags. Eukaryotic genomes are slightly under-represented (73.8% vs 74.5%); see
[Sampling note](#sampling-note).
**Domains** (share of train bases): Eukaryota 73.8% · untagged 22.3% · Bacteria 3.8% · Archaea 0.12%.
**Largest phyla:**
| phylum | share | | phylum | share |
|---|---|---|---|---|
| Chordata | 33.0% | | Bacteroidota | 0.54% |
| Streptophyta | 18.8% | | Actinomycetota | 0.53% |
| Arthropoda | 15.6% | | Cnidaria | 0.50% |
| Mollusca | 2.48% | | Basidiomycota | 0.47% |
| Pseudomonadota | 1.11% | | Annelida | 0.43% |
| Ascomycota | 0.99% | | Echinodermata | 0.41% |
## Statistics
| split | A | C | G | T | N | GC | soft-masked | CpG o/e |
|---|---|---|---|---|---|---|---|---|
| `train` | 28.9% | 21.1% | 21.1% | 28.9% | 0.005% | 42.2% | 32.5% | 0.75 |
| `heldout` | 28.8% | 21.2% | 21.2% | 28.8% | 0.006% | 42.5% | 34.8% | 0.76 |
| `valid` | 27.8% | 22.2% | 22.3% | 27.8% | 0.001% | 44.5% | 25.3% | 0.94 |
| group (train) | bases | GC | soft-masked | CpG o/e |
|---|---|---|---|---|
| Eukaryota | 8.69B | 39.5% | 42.1% | 0.56 |
| untagged (metagenomes, transcripts, viruses, ...) | 2.63B | 49.1% | 6.6% | 1.02 |
| Bacteria | 449M | 54.2% | – | 1.17 |
| Archaea | 13.9M | 47.3% | – | 1.09 |
- The corpus is AT-rich (GC 42%) because eukaryotic genomes dominate; prokaryotes and metagenomes sit at 50–57% GC.
- CpG is depleted in eukaryotes (observed/expected 0.56, methylation-driven) but not in bacteria (1.17).
- Soft-masking (lowercase = repeat-masked) exists only in eukaryotic data: 42% of eukaryotic bases.
- Strand symmetry holds (Chargaff's second rule): 4-mer and reverse-complement frequencies differ by 0.02% on
average in `train`.
- Most frequent 8-mers: `AAAAAAAA`/`TTTTTTTT` (0.075% each), then `ATATATAT`/`TATATATA` and `(CA)n`/`(TG)n` repeats.
Per-subset and per-domain statistics and the full 8-mer counts are in `stats/`.
## Baselines
Order-k Markov models fitted on `train` (8-mer counts, add-½ smoothing), in bits per base:
| split | k=0 | k=1 | k=3 | k=5 | k=7 |
|---|---|---|---|---|---|
| `heldout` | 1.984 | 1.973 | 1.961 | 1.952 | **1.940** |
| `valid` | 1.993 | 1.988 | 1.976 | 1.969 | **1.959** |
| `train` (in sample) | 1.982 | 1.971 | 1.960 | 1.953 | 1.942 |
Per subset on `heldout`, best order (k=7 unless noted):
| subset | bits/base | | subset | bits/base |
|---|---|---|---|---|
| ncbi_eukaryotic_genomes | 1.930 | | mrna_splice_promoter | 1.950 |
| eukaryotic_genic_windows | 1.931 | | mrna | 1.967 |
| gtdb_v220_stitched | 1.982 | | ncrna | 1.973 |
| metagenomes | 1.984 | | imgvr_untagged | 1.980 |
| gtdb_v220_imgpr | 1.986 | | organelle | 1.963 (k=1) |
- Scored positions are those whose target and 7 preceding bases are all A/C/G/T, identical for every order.
- One model is fitted on the pooled (eukaryote-dominated) composition. GC-rich subsets therefore score near 2 bits,
and above 2 at low orders.
- Compare a trained model's masked bits/base on `heldout` with 1.940.
## Format
```
README.md
plan_train_eukaryotic.json, plan_train_rest.json, plan_valid.json sampling parameters of each pass
train/<subset>/<shard>.npy kept windows of one OpenGenome2 shard, concatenated (uint8)
train/<subset>/<shard>.jsonl one line per window: offset, len, u, tag, rec
train/<subset>/<shard>.done per-shard statistics
train/selected.json window selection; train/manifest.json composition
heldout/, valid/ same layout
stats/ statistics (<split>.json), 8-mer counts (<split>_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/*/<subset>/*_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.
|