| --- |
| license: apache-2.0 |
| task_categories: |
| - text-generation |
| tags: |
| - dna |
| - genomic |
| - long-context |
| - retrieval |
| - benchmark |
| - niah |
| configs: |
| - config_name: niah_4k |
| data_files: |
| - split: test |
| path: data/niah_4k/test-*.parquet |
| - config_name: niah_8k |
| data_files: |
| - split: test |
| path: data/niah_8k/test-*.parquet |
| - config_name: niah_16k |
| data_files: |
| - split: test |
| path: data/niah_16k/test-*.parquet |
| - config_name: niah_32k |
| data_files: |
| - split: test |
| path: data/niah_32k/test-*.parquet |
| - config_name: niah_64k |
| data_files: |
| - split: test |
| path: data/niah_64k/test-*.parquet |
| - config_name: niah_128k |
| data_files: |
| - split: test |
| path: data/niah_128k/test-*.parquet |
| - config_name: niah_neardup_d4_4k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d4_4k/test-*.parquet |
| - config_name: niah_neardup_d4_8k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d4_8k/test-*.parquet |
| - config_name: niah_neardup_d4_16k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d4_16k/test-*.parquet |
| - config_name: niah_neardup_d4_32k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d4_32k/test-*.parquet |
| - config_name: niah_neardup_d4_64k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d4_64k/test-*.parquet |
| - config_name: niah_neardup_d4_128k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d4_128k/test-*.parquet |
| - config_name: niah_neardup_d2_4k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d2_4k/test-*.parquet |
| - config_name: niah_neardup_d2_8k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d2_8k/test-*.parquet |
| - config_name: niah_neardup_d2_16k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d2_16k/test-*.parquet |
| - config_name: niah_neardup_d2_32k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d2_32k/test-*.parquet |
| - config_name: niah_neardup_d2_64k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d2_64k/test-*.parquet |
| - config_name: niah_neardup_d2_128k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d2_128k/test-*.parquet |
| - config_name: niah_neardup_d1_4k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d1_4k/test-*.parquet |
| - config_name: niah_neardup_d1_8k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d1_8k/test-*.parquet |
| - config_name: niah_neardup_d1_16k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d1_16k/test-*.parquet |
| - config_name: niah_neardup_d1_32k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d1_32k/test-*.parquet |
| - config_name: niah_neardup_d1_64k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d1_64k/test-*.parquet |
| - config_name: niah_neardup_d1_128k |
| data_files: |
| - split: test |
| path: data/niah_neardup_d1_128k/test-*.parquet |
| --- |
| |
| # Genomic-NIAH |
|
|
| **A long-context retrieval benchmark for genomic language models.** |
|
|
| Genomic-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. |
|
|
| 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. |
|
|
| ## Table of contents |
|
|
| 1. [Quick start](#quick-start) |
| 2. [Tasks](#tasks) |
| 3. [Context lengths](#context-lengths) |
| 4. [Sampling design](#sampling-design) |
| 5. [Schema](#schema) |
| 6. [Evaluation metrics](#evaluation-metrics) |
| 7. [Reference results (Carbon-3B)](#reference-results-carbon-3b) |
| 8. [How the benchmark is built](#how-the-benchmark-is-built) |
|
|
| ## Quick start |
|
|
| ```python |
| from datasets import load_dataset |
| |
| # Plain retrieval at 16 k tokens (≈ 98 kbp) |
| ds = load_dataset("hf-carbon/genomic-niah", "niah_16k") |
| |
| # Hardest near-duplicate variant (KEY′ differs by 1 bp) at 64 k tokens (≈ 384 kbp) |
| ds = load_dataset("hf-carbon/genomic-niah", "niah_neardup_d1_64k") |
| ``` |
|
|
| 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). |
|
|
| ## Tasks |
|
|
| | Config prefix | Description | Difficulty | |
| |---|---|---| |
| | `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. | |
| | `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. | |
| | `niah_neardup_d2` | Same as above, distractor distance Δ = 2 bp (92 % key identity). | Hard. Separates extension methods well in our experiments. | |
| | `niah_neardup_d1` | Same, Δ = 1 bp (96 % key identity). | Discrimination test. Used to characterise fine-grained retrieval. | |
|
|
| 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. |
|
|
| ## Context lengths |
|
|
| Six lengths, given in 6-mer tokens (the Carbon convention) and in base pairs (1 token ≈ 6 bp): |
|
|
| | Tokens | bp | Haystack construction | |
| |---:|---:|---| |
| | 4 k | ≈ 24 kbp | Contiguous | |
| | 8 k | ≈ 49 kbp | Contiguous | |
| | 16 k | ≈ 98 kbp | Contiguous | |
| | 32 k | ≈ 197 kbp | Stitched-within-record | |
| | 64 k | ≈ 393 kbp | Stitched-within-record | |
| | 128 k | ≈ 786 kbp | Stitched-within-record | |
|
|
| **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. |
|
|
| ## Sampling design |
|
|
| Each of the 24 configurations contains **n = 500 retrieval examples**, stratified as a 5 × 4 grid: |
|
|
| - **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. |
| - **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. |
|
|
| Total benchmark size: 4 tasks × 6 contexts × 500 examples = **12 000 retrieval examples**. |
|
|
| ## Schema |
|
|
| Each row contains: |
|
|
| | Column | Type | Description | |
| |---|---|---| |
| | `uid` | `string` | Deterministic SHA1 identifier for this row. | |
| | `source` | `string` | Eukaryotic kingdom: `animalia` / `fungi` / `plantae` / `protista`. | |
| | `haystack_mode` | `string` | `real` (contiguous ACGT run) or `real_stitched` (concatenated ACGT runs from one record). | |
| | `context_length_tokens` | `int` | Length of the haystack in 6-mer tokens. | |
| | `context_length_bp` | `int` | Length of `positive_sequence` in base pairs. | |
| | `depth` | `int` | Needle insertion depth as a percentage (10, 25, 50, 75, 90). | |
| | `condition` | `string` | `retrieval` (only condition in this release). | |
| | `key` | `string` | The needle KEY: a random 24 bp DNA string. | |
| | `value` | `string` | The needle VALUE: a random 24 bp DNA string. | |
| | `negative_value` | `string` | `value` with every nucleotide mutated to a different base. Used for `ll_correct`. | |
| | `prompt` | `string` | The model input: `<dna>` + haystack with embedded (KEY, VALUE) + trailing KEY. | |
| | `positive_sequence` | `string` | `prompt + value` (the correct full continuation). | |
| | `negative_sequence` | `string` | `prompt + negative_value` (used for likelihood discrimination). | |
| | `target_insert_start_bp`, `target_insert_end_bp` | `int` | Needle position. Available for `niah` only. | |
| | `distractor_keys`, `distractor_values` | `string` | Comma-separated lists of the 8 near-duplicate distractor pairs. Available for `niah_neardup_*` only. | |
|
|
| ## Evaluation metrics |
|
|
| 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. |
|
|
| Genomic-NIAH supports two metrics, computed per example: |
|
|
| - **`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. |
| - **`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. |
| |
| We treat `gen_exact_match` as the task metric. `ll_correct` is informative but easier to satisfy; it should never be reported in isolation. |
| |
| ## Reference results (Carbon-3B) |
| |
| We report reference Genomic-NIAH results on [Carbon-3B](https://huggingface.co/hf-carbon/Carbon-3B) and [Carbon-8B](https://huggingface.co/hf-carbon/Carbon-8B) to illustrate how the benchmark behaves across difficulties and context lengths. We evaluate two inference settings: Carbon until the native boundary **32k context**, and the same model under **YaRN 4×** (up to 64 k tokens, ≈ 384 kbp and 128k/131k=786kbp). |
| |
| | Native (32 k) | YaRN 4× (up to 64 k) | |
| |:---:|:---:| |
| |  |  | |
| |
| | Native (32 k) | YaRN 4× (up to 131 k) | |
| |:---:|:---:| |
| |  |  | |
| |
| |
| |
| **Reading the heatmaps.** |
| |
| - The `niah_neardup_*` variants are harder than `niah`, and the performance drops with longer contexts. |
| - 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. |
| |
| ## How the benchmark is built |
| |
| - **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). |
| - **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. |
| - **Needles:** KEY and VALUE are independent random 24 bp DNA strings, sampled per-example with a deterministic seed derived from the row index. |
| - **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 Δ. |
| - **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. |
| |
| ## License |
| |
| Apache 2.0. |
| |