loubnabnl HF Staff commited on
Commit
3fcb4f5
·
verified ·
1 Parent(s): dbbd50f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +101 -81
README.md CHANGED
@@ -4,6 +4,7 @@ task_categories:
4
  - text-generation
5
  tags:
6
  - dna
 
7
  - long-context
8
  - retrieval
9
  - benchmark
@@ -109,111 +110,130 @@ configs:
109
 
110
  # Genome-NIAH
111
 
112
- A long-context retrieval benchmark for genomic language models, **inspired by
113
- NIAH and RULER**.
114
 
115
- The plain `niah` task is a direct DNA analogue of RULER's `niah_single`:
116
- insert a random (KEY, VALUE) pair into a long real-genome haystack, append
117
- KEY at the end, and ask the model to generate VALUE. This gives a clean
118
- cliff diagnostic — the context length at which a model stops retrieving.
119
 
120
- To stress-test models that already pass plain NIAH, we developed a harder
121
- **near-duplicate** variant. Inspired by RULER's `niah_multikey` (random
122
- distractor pairs), we replace random distractors with **8 (KEY', VALUE')
123
- pairs whose KEY' differs from the target KEY by exactly Δ base pairs**
124
- (Hamming distance Δ = 1, 2, or 4). The model must distinguish the target
125
- key from 8 close-but-not-identical decoys — a fine-grained pattern-matching
126
- test that has biological relevance (DNA contains many similar-but-distinct
127
- motifs) and provides resolution beyond what plain NIAH can detect.
128
 
129
- ## Tasks
130
 
131
- | Task | What it tests |
132
- |---|---|
133
- | `niah` | Plain NIAH: insert (KEY, VALUE) at a depth, query KEY → expect VALUE. The cliff diagnostic. |
134
- | `niah_neardup_d4` | NIAH + 8 distractor (KEY', VALUE') pairs where KEY' differs from KEY by 4 bp (83 % key identity). Easiest harder tier. |
135
- | `niah_neardup_d2` | Same but Δ = 2 bp (92 % key identity). Cleanest separator between extension methods. |
136
- | `niah_neardup_d1` | Same but Δ = 1 bp (96 % key identity) — the discrimination test. |
 
 
137
 
138
- ## Context lengths
139
 
140
- Six lengths in 6-mer-tokens (Carbon convention) → bp:
 
141
 
142
- | ctx (tokens) | ctx (bp) | mode |
143
- |---:|---:|---|
144
- | 4 k | 24 kbp | contiguous (single ACGT run from one OG2 record) |
145
- | 8 k | 49 kbp | contiguous |
146
- | 16 k | 98 kbp | contiguous |
147
- | 32 k | 197 kbp | **stitched-within-record** |
148
- | 64 k | 393 kbp | stitched |
149
- | 128 k | 786 kbp | stitched |
150
 
151
- **Why two modes?** OpenGenome2 records are pre-chunked at 128 KiB max
152
- contiguous ACGT (gaps from N's, soft-masked repeats, and metadata break the
153
- sequence). For ctx ≤ 16 k tokens we use single contiguous runs from one OG2
154
- record. For ctx ≥ 32 k tokens we **stitch all ACGT runs from a single record
155
- together** (gaps removed within the same chromosome) — this matches how DNA
156
- language models are trained and preserves chromosomal locality.
157
 
158
- The `haystack_mode` column distinguishes `"real"` (contiguous) from
159
- `"real_stitched"` (stitched).
160
 
161
- ## Subset structure (24 configs total)
162
 
163
- Each config = one (task, ctx) pair. Layout matches RULER's HF convention:
 
 
 
 
 
164
 
165
- ```
166
- data/<task>_<ctx>/test-00000-of-00001.parquet
167
- ```
168
 
169
- ```python
170
- from datasets import load_dataset
171
- ds = load_dataset("hf-carbon/genome-niah", "niah_16k") # 500 rows, 5 depths × 100/cell
172
- ds = load_dataset("hf-carbon/genome-niah", "niah_neardup_d1_64k")
173
- ```
174
 
175
- ## Sampling design (per config)
176
 
177
- - **n = 500 retrieval rows** per (task, ctx) — matches RULER's per-cell scale
178
- - **5 needle depths** (10 / 25 / 50 / 75 / 90 %), 100 rows each
179
- - **Stratified across 4 species** (animalia / fungi / plantae / protista)
180
- matching Carbon's training distribution; 25 rows per (depth, species)
181
- - Wilson 95 % CI half-widths: ± 9.8 % per-cell, ± 4.4 % per-(task, ctx)
 
 
 
182
 
183
- ## Source
184
 
185
- OpenGenome2 NCBI eukaryotic test + valid splits across all 8 batches:
186
- [arcinstitute/opengenome2 → midtraining_specific/ncbi_eukaryotic_genomes/](https://huggingface.co/datasets/arcinstitute/opengenome2/tree/main/json/midtraining_specific/ncbi_eukaryotic_genomes).
187
- Chromista is dropped (not in Carbon's training mix; also has the worst
188
- fragmentation under the [ACGT]+ filter).
 
 
 
 
189
 
190
  ## Schema
191
 
192
- | column | dtype | description |
 
 
193
  |---|---|---|
194
- | `uid` | string | deterministic SHA1 row id |
195
- | `haystack_mode` | string | `real` (contiguous) or `real_stitched` |
196
- | `source` | string | `animalia` / `fungi` / `plantae` / `protista` |
197
- | `context_length_tokens` | int | 6-mer tokens 6 = bp) |
198
- | `context_length_bp` | int | length of `positive_sequence` |
199
- | `depth` | int | needle insertion depth as percentage |
200
- | `condition` | string | `retrieval` (only no `no_memory` in this release) |
201
- | `key`, `value` | string | random 24 bp DNA strings |
202
- | `negative_value` | string | `value` with all 24 bp mutated to a different base |
203
- | `prompt` | string | `<dna>` + haystack with embedded (KEY, VALUE) + trailing KEY |
204
- | `positive_sequence` | string | `prompt` + `value` |
205
- | `negative_sequence` | string | `prompt` + `negative_value` |
206
- | `target_insert_start_bp` / `target_insert_end_bp` | int | needle position (`niah` only) |
207
- | `distractor_keys`, `distractor_values` | string | comma-separated lists (`niah_neardup_*` only) |
 
208
 
209
  ## Evaluation metrics
210
 
211
- - `gen_exact_match` strict: greedy decode (DNA-token-restricted) matches `value` char-for-char.
212
- - `ll_correct` — lenient: `LL(value | prompt) > LL(negative_value | prompt)`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
 
214
- ## Citation
 
 
 
 
215
 
216
- If you use this benchmark, please cite the Carbon DNA model project (Hugging Face).
217
 
218
- Built with the `build_dna_long_context_retrieval.py` /
219
- `build_dna_lcr_harder.py` pipelines in the carbon-long-context repo.
 
4
  - text-generation
5
  tags:
6
  - dna
7
+ - genomic
8
  - long-context
9
  - retrieval
10
  - benchmark
 
110
 
111
  # Genome-NIAH
112
 
113
+ **A long-context retrieval benchmark for genomic language models.**
 
114
 
115
+ Genome-NIAH measures whether a DNA model actually *uses* its long context. Each example plants a random (KEY, VALUE) DNA pair inside a real-genome haystack and asks the model to recover VALUE given the haystack followed by KEY. Because both KEY and VALUE are uncorrelated with the surrounding sequence, the only way to succeed is to retrieve the planted pair at long range — turning the abstract question "does the model use distal context" into a concrete generative task with a per-example accuracy. This benchmark is inspired from [NIAH](https://github.com/gkamradt/LLMTest_NeedleInAHaystack) and [RULER](https://arxiv.org/abs/2404.06654), popular long context benchmarks for natural language.
 
 
 
116
 
117
+ The benchmark provides 4 tasks of varying difficulty, and 24 sub-configurations on a **4 × 6 grid** of task difficulty (plain retrieval and three near-duplicate variants) × context length (from 4k to 128k 6-mer tokens ≈ 24,000 DNA base pairs – 786,000 DNA base pairs). Each sub-configuration contains 500 examples, stratified across five needle depths and four eukaryotic kingdoms.
 
 
 
 
 
 
 
118
 
119
+ ## Table of contents
120
 
121
+ 1. [Quick start](#quick-start)
122
+ 2. [Tasks](#tasks)
123
+ 3. [Context lengths](#context-lengths)
124
+ 4. [Sampling design](#sampling-design)
125
+ 5. [Schema](#schema)
126
+ 6. [Evaluation metrics](#evaluation-metrics)
127
+ 7. [Reference results (Carbon-3B)](#reference-results-carbon-3b)
128
+ 8. [How the benchmark is built](#how-the-benchmark-is-built)
129
 
130
+ ## Quick start
131
 
132
+ ```python
133
+ from datasets import load_dataset
134
 
135
+ # Plain retrieval at 16 k tokens (≈ 98 kbp)
136
+ ds = load_dataset("hf-carbon/genome-niah", "niah_16k")
 
 
 
 
 
 
137
 
138
+ # Hardest near-duplicate variant (KEY′ differs by 1 bp) at 64 k tokens (≈ 384 kbp)
139
+ ds = load_dataset("hf-carbon/genome-niah", "niah_neardup_d1_64k")
140
+ ```
 
 
 
141
 
142
+ For each example, the `prompt` field already contains the full input to feed the model. The expected response is in `value` (for `gen_exact_match`) or can be discriminated against `negative_value` (for `ll_correct`). See [Evaluation metrics](#evaluation-metrics).
 
143
 
144
+ ## Tasks
145
 
146
+ | Config prefix | Description | Difficulty |
147
+ |---|---|---|
148
+ | `niah` | Insert a single (KEY, VALUE) pair into the haystack, query KEY → expect VALUE. The plain retrieval cliff diagnostic. | Easy once the model handles the relevant context length. |
149
+ | `niah_neardup_d4` | Plain retrieval + **eight near-duplicate distractor pairs**. Each distractor key differs from the target KEY by 4 bp (83 % key identity). | Moderate. Stresses long-range exact matching. |
150
+ | `niah_neardup_d2` | Same as above, distractor distance Δ = 2 bp (92 % key identity). | Hard. Separates extension methods well in our experiments. |
151
+ | `niah_neardup_d1` | Same, Δ = 1 bp (96 % key identity). | Discrimination test. Used to characterise fine-grained retrieval. |
152
 
153
+ The near-duplicate variants are inspired by RULER's multi-key task, but they use *near-duplicate* rather than fully random distractors. This is the relevant regime for DNA: real genomes contain many similar-but-not-identical motifs, so a useful long-context DNA model must be able to discriminate sequences that differ at only a few positions.
 
 
154
 
155
+ ## Context lengths
 
 
 
 
156
 
157
+ Six lengths, given in 6-mer tokens (the Carbon convention) and in base pairs (1 token ≈ 6 bp):
158
 
159
+ | Tokens | bp | Haystack construction |
160
+ |---:|---:|---|
161
+ | 4 k | 24 kbp | Contiguous |
162
+ | 8 k | 49 kbp | Contiguous |
163
+ | 16 k | 98 kbp | Contiguous |
164
+ | 32 k | ≈ 197 kbp | Stitched-within-record |
165
+ | 64 k | ≈ 393 kbp | Stitched-within-record |
166
+ | 128 k | ≈ 786 kbp | Stitched-within-record |
167
 
168
+ **Why two haystack modes.** OpenGenome2 records are pre-chunked at 128 KiB of contiguous ACGT, with breaks introduced by `N`s, soft-masked repeats, and metadata. For context lengths ≤ 16 k tokens, single contiguous ACGT runs of one OG2 record are sufficient; the `haystack_mode` field is `"real"`. For 32 k tokens and above, contiguous runs are rarely long enough, so we stitch together all ACGT runs from a single record into one sequence (ambiguity-coded and soft-masked positions removed); `haystack_mode` is `"real_stitched"`. This matches how DNA language models are trained, preserves chromosomal locality, and ensures the haystack remains real genomic sequence even at the longest evaluated contexts. **The benchmark never falls back to random A/C/G/T padding** — real haystacks are essential to its diagnostic value.
169
 
170
+ ## Sampling design
171
+
172
+ Each of the 24 configurations contains **n = 500 retrieval examples**, stratified as a 5 × 4 grid:
173
+
174
+ - **Five needle depths.** The (KEY, VALUE) needle is inserted at one of five depths within the haystack: 10 %, 25 %, 50 %, 75 %, or 90 % of haystack length. 100 examples per depth. This exposes asymmetric attention patterns — for instance, models that retrieve well from the end but poorly from the middle.
175
+ - **Four eukaryotic kingdoms.** Examples are stratified across `animalia`, `fungi`, `plantae`, and `protista` (25 examples per depth-kingdom cell). The kingdom split matches the multi-kingdom composition of typical DNA-model training corpora. Chromista is excluded because it is not in the CARBON-0 training mixture and has the highest fragmentation rate under the ACGT filter.
176
+
177
+ Total benchmark size: 4 tasks × 6 contexts × 500 examples = **12 000 retrieval examples**.
178
 
179
  ## Schema
180
 
181
+ Each row contains:
182
+
183
+ | Column | Type | Description |
184
  |---|---|---|
185
+ | `uid` | `string` | Deterministic SHA1 identifier for this row. |
186
+ | `source` | `string` | Eukaryotic kingdom: `animalia` / `fungi` / `plantae` / `protista`. |
187
+ | `haystack_mode` | `string` | `real` (contiguous ACGT run) or `real_stitched` (concatenated ACGT runs from one record). |
188
+ | `context_length_tokens` | `int` | Length of the haystack in 6-mer tokens. |
189
+ | `context_length_bp` | `int` | Length of `positive_sequence` in base pairs. |
190
+ | `depth` | `int` | Needle insertion depth as a percentage (10, 25, 50, 75, 90). |
191
+ | `condition` | `string` | `retrieval` (only condition in this release). |
192
+ | `key` | `string` | The needle KEY: a random 24 bp DNA string. |
193
+ | `value` | `string` | The needle VALUE: a random 24 bp DNA string. |
194
+ | `negative_value` | `string` | `value` with every nucleotide mutated to a different base. Used for `ll_correct`. |
195
+ | `prompt` | `string` | The model input: `<dna>` + haystack with embedded (KEY, VALUE) + trailing KEY. |
196
+ | `positive_sequence` | `string` | `prompt + value` (the correct full continuation). |
197
+ | `negative_sequence` | `string` | `prompt + negative_value` (used for likelihood discrimination). |
198
+ | `target_insert_start_bp`, `target_insert_end_bp` | `int` | Needle position. Available for `niah` only. |
199
+ | `distractor_keys`, `distractor_values` | `string` | Comma-separated lists of the 8 near-duplicate distractor pairs. Available for `niah_neardup_*` only. |
200
 
201
  ## Evaluation metrics
202
 
203
+ The official evaluation script lives in the Carbon repository. See [`evaluation/genome_niah_eval.py`](https://github.com/huggingface/carbon/tree/main/evaluation#5-genome-niah-long-context-retrieval) for the command-line interface, supported backends, and reproducible run instructions.
204
+
205
+ Genome-NIAH supports two metrics, computed per example:
206
+
207
+ - **`gen_exact_match` (recommended headline metric).** Greedy decoding with the next-token logit space restricted to DNA tokens. The decoded VALUE must match the ground-truth `value` exactly. This is the strict, fully-generative retrieval accuracy.
208
+ - **`ll_correct` (complementary).** The log-likelihood of `positive_sequence` (`prompt + value`) is higher than the log-likelihood of `negative_sequence` (`prompt + negative_value`). This is a softer probe: the model only needs to prefer the correct VALUE over a fully-mutated alternative, not to generate it. Useful for diagnosing whether retrieval failures are decoding failures or attention failures.
209
+
210
+ We treat `gen_exact_match` as the task metric. `ll_correct` is informative but easier to satisfy; it should never be reported in isolation.
211
+
212
+ ## Reference results (Carbon-3B)
213
+
214
+ We report reference Genome-NIAH results on [Carbon-3B](https://huggingface.co/hf-carbon/Carbon-3B) to illustrate how the benchmark behaves across difficulties and context lengths. We evaluate two inference settings: Carbon-3B until the native boundary **32k context**, and the same model under **YaRN 4×** (up to 64 k tokens, ≈ 384 kbp).
215
+
216
+ ### Native (32 k)
217
+
218
+ ![Carbon-3B native, 32 k context, gen_exact_match across the 4×6 grid](assets/modelcard_carbon3b_native.png)
219
+
220
+ ### YaRN 4× (up to 64 k)
221
+
222
+ ![Carbon-3B YaRN 4×, up to 64 k context, gen_exact_match across the 4×6 grid](assets/modelcard_carbon3b_yarn4x.png)
223
+
224
+ **Reading the heatmaps.**
225
+
226
+ - The `niah_neardup_*` variants are harder than `niah`, and the performance drops with longer contexts.
227
+ - Carbon-3B retrieves reliably up to its 32k native boundary. **YaRN 4×** recovers most of the loss at the 32 k → 64 k boundary and extends the usable retrieval range from ≈ 197 kbp to ≈ 384 kbp; beyond 64 k tokens (i.e., at 128 k), retrieval degrades sharply.
228
+
229
+ ## How the benchmark is built
230
 
231
+ - **Haystacks** are drawn from the OpenGenome2 NCBI-eukaryotic *test* and *valid* splits across all eight batches: [`arcinstitute/opengenome2 → midtraining_specific/ncbi_eukaryotic_genomes/`](https://huggingface.co/datasets/arcinstitute/opengenome2/tree/main/json/midtraining_specific/ncbi_eukaryotic_genomes).
232
+ - **ACGT filter:** ambiguity-coded and soft-masked positions are removed. For ctx ≤ 16 k tokens we use the longest contiguous ACGT run of a single record; for ctx ≥ 32 k tokens we stitch all ACGT runs from one record into a single sequence, preserving record-level (chromosome-level) locality.
233
+ - **Needles:** KEY and VALUE are independent random 24 bp DNA strings, sampled per-example with a deterministic seed derived from the row index.
234
+ - **Distractor keys** (near-duplicate variants only): obtained by substituting exactly Δ randomly chosen positions of KEY to a different base, for $\Delta \in \{1, 2, 4\}$. Each example has 8 distractor pairs with the same Δ.
235
+ - **Insertion:** the (KEY, VALUE) pair (and each distractor pair, if any) is inserted as a literal substring at the configured depth. The pairs are placed at distinct positions; for near-duplicate variants, distractors are placed before and after the target proportionally so that no depth bias is introduced by distractor placement.
236
 
237
+ ## License
238
 
239
+ Apache 2.0.