Introduction
A DNA language model has to decide what one of its tokens is. DNA has four letters, no word boundaries and information at several scales at once: single-base changes, short binding motifs a few bases long, longer regulatory elements and repeats. The field has answered the question in very different ways. Character-level models give every nucleotide its own token [1, 2]; DNABERT uses overlapping 6-mers [3]; the Nucleotide Transformer uses non-overlapping 6-mers [4]; DNABERT-2 learns a byte-pair vocabulary [5]; and a recent line of work learns the segmentation jointly with the model [6, 7, 8, 9]. Comparative studies find that the choice matters, and that it matters differently for different model sizes and downstream tasks [10, 11].
Every compressing tokenizer trades resolution for sequence length: fewer tokens per nucleotide let a backbone see more sequence for the same compute, and blur where exactly in that sequence something happens. The question of this task is which tokenizer transfers best when the backbone (a bidirectional Mamba or a Transformer), the pretraining data, the nucleotide budget and the downstream protocols are all fixed: how should DNA become model tokens, so that one pretrained model transfers well on either backbone?
Our answer starts from what the fixed setup makes cheap and what it makes useless. The pretraining window is fixed, so a compressing tokenizer does not let the backbone see more context; it only saves backbone compute, which a character tokenizer does not run short of. Compression then has only its cost. A character token has the opposite problem: it carries two bits in a 256-dimensional input, so the backbone must build every local feature itself, and, as we measured, its states collapse toward the identity of the base at each position. We therefore keep one token per nucleotide and put the budget into what each token carries.
Method
We call the method resolution-preserving k-mer tokens. It changes four things relative to the
character starter: the input embedding, a local encoder before the backbone, a decoder after it, and
the head that the pretraining loss reads. The backbone still processes exactly one token per
nucleotide, and nucleotide_states returns one state per nucleotide, computed from the backbone's
output.
class Tokenizer(nn.Module):
VOCAB = 12 # Caduceus character vocabulary: [CLS] [SEP] [BOS] [MASK] [PAD] [RES] [UNK] A C G T N
MASK, PAD, OFFSET = 3, 4, 7
KMER = 6 # k-mer window j-2..j+3 over {A,C,G,T,*}: 5^6 rows
ENC_CONV = 2 # soft k-mer encoder blocks
ENC_DIL = (1, 1) # dilation of each encoder block
DEC_CONV = 1 # decoder blocks after the backbone
KERNEL = 9
EMB_RMS = 0.02 # RMS of the encoder output = init scale of a plain embedding table
MASK_RATE = 0.15
KMER_SCALE = 0.1 # table = KMER_SCALE * W; pretraining lr_mult 1/KMER_SCALE keeps its pretraining stepA mask-consistent overlapping k-mer embedding
Overlapping k-mer tokens give a model rich local features, but as tokens they need contiguous span masking, because a masked k-mer can be read off its overlapping neighbours. We keep the k-mer as a feature of a nucleotide token rather than as a token. Let be the token at position after masking, and map it to a symbol , where to are A, C, G, T and is a placeholder that stands for a masked base, an N, any special token, or a position outside the sequence. The 6-mer around position , laid out as as in DNABERT [3], has the index
and the token's input is the sum of its nucleotide embedding and a row of a table,
Because the index is computed from the corrupted input, a masked base enters no index: its own row and the rows of its five neighbours all see in its place. Ordinary independent per-nucleotide masking therefore still works, the states stay per nucleotide, and at a masked position the table acts as a learned local context model over those of its five neighbours that are visible. The table adds about four million parameters and essentially no compute.
def _kmer_ids(self, ids):
"""Id of the k-mer window around each position over {A,C,G,T,*}; * = [MASK], N, any special id
or a position outside the sequence, so a masked base never enters an id."""
k = self.KMER
a = 2 if k == 6 else (k - 1) // 2
sym = ids - self.OFFSET
sym = torch.where((sym >= 0) & (sym < 4), sym, torch.full_like(sym, 4))
win = F.pad(sym, (a, k - 1 - a), value=4).unfold(1, k, 1)
return (win * (5 ** torch.arange(k, device=ids.device))).sum(-1)A normalised convolutional encoder, a decoder and a separate head
On top of the embedding sit two ConvNeXt-style blocks, each a depthwise convolution of width 9, LayerNorm and a two-layer MLP, added back through a residual whose per-channel scale starts at zero,
class ConvBlock(nn.Module):
"""ConvNeXt-1D block: depthwise conv -> LayerNorm -> MLP, zero-initialised residual scale."""
def __init__(self, d, k=9, expand=2, dil=1):
super().__init__()
self.dw = nn.Conv1d(d, d, k, padding=(k // 2) * dil, dilation=dil, groups=d)
self.norm = nn.LayerNorm(d)
self.pw1 = nn.Linear(d, expand * d)
self.pw2 = nn.Linear(expand * d, d)
self.gamma = nn.Parameter(torch.zeros(d))
def forward(self, x): # (B, L, d)
h = self.dw(x.transpose(1, 2)).transpose(1, 2)
h = self.pw2(F.gelu(self.pw1(self.norm(h))))
return x + self.gamma * hThe encoder's output is then normalised to the root-mean-square of a freshly initialised embedding table before it enters the backbone,
This normalisation is not cosmetic. Without it, a learned encoder in front of a pre-normalised
backbone inflates the backbone's residual stream, the local path takes over, and training collapses
to the unigram solution, as we found in our first attempt (Section 4). After the backbone, one more
convolutional block and a LayerNorm produce the states that nucleotide_states returns,
.
The masked-language-model loss does not read those states directly. In the starter the output layer is tied to the embedding table and applied to the returned states, so the loss asks the states for little more than the identity of the base. We add a BERT-style head between them,
where is the nucleotide embedding table, still tied, and , and are new. The pretraining objective is otherwise the starter's: 15% of positions are selected, 80% of them replaced by the mask token, 10% by a random token and 10% left unchanged, and the cross-entropy is taken on the selected positions.
def _forward(self, ids, backbone):
x = self.embed(ids) + F.embedding(self._kmer_ids(ids), self.kmer_w) * self.KMER_SCALE
for blk in self.enc:
x = blk(x)
x = (F.rms_norm(x.float(), (x.shape[-1],)) * self.EMB_RMS).to(x.dtype)
z = backbone(x)
for blk in self.dec:
z = blk(z)
return self.out_norm(z)
def _mlm_logits(self, h):
h = self.head_norm(F.gelu(self.head_dense(h)))
return F.linear(h, self.embed.weight, self.head_bias)
def pretrain_loss(self, nuc, extra, backbone):
ids = nuc + self.OFFSET
masked = torch.rand(ids.shape, device=ids.device) < self.MASK_RATE
inp = ids.clone()
replaced = (torch.rand(ids.shape, device=ids.device) < 0.8) & masked
inp[replaced] = self.MASK
rand = (torch.rand(ids.shape, device=ids.device) < 0.5) & masked & ~replaced
inp[rand] = torch.randint(self.VOCAB, ids.shape, device=ids.device)[rand]
h = self._forward(inp, backbone)
mlm = F.cross_entropy(self._mlm_logits(h[masked]).float(), ids[masked])
return mlm, {"mlm": mlm.detach()}A scaled table that fine-tuning moves less
The last change addresses a failure of the table that we found late (Section 4): during downstream
fine-tuning, the optimiser rewrote a handful of rows for one consensus motif into a context-free
motif detector, which hurt tasks whose label depends on where the motif sits. We keep the forward
pass and change only how the table is parametrised. The table enters as with
, and param_groups gives a learning-rate multiplier of and a
weight decay of . Adam's step is invariant to the scale of the gradient, so a step of size
on is a step of size on the effective table , and the decoupled
decay equals times the default decay of . In
pretraining the effective table therefore moves as an ordinary embedding would. Afterwards, without
the multiplier, its rows move times less per step than the rest of the model, so the table
stays a shared dictionary of local features. The code is the same in both phases and the table is
trained in pretraining.
def param_groups(self):
# E = KMER_SCALE * W: with lr_mult 1/KMER_SCALE and weight decay 0.1 * KMER_SCALE the table's effective
# pretraining step and decay equal those of a plain embedding; afterwards its rows move KMER_SCALE times less
# per optimiser step, so fine-tuning cannot rewrite single k-mer rows into context-free motif switches.
return [{"params": [self.kmer_w], "lr_mult": 10.0, "weight_decay": 0.01}]Nothing in the configuration depends on the backbone: the same tokenizer, with the same constants, runs on both.
Results
| Method | ① | ② | ③ | ④ |
|---|---|---|---|---|
| Benchmark mean score ↑ | Benchmark mean score ↑ | Benchmark mean score ↑ | Benchmark mean score ↑ | |
| Claude Opus 5.5 | 0.629 | 0.462 | 0.582 | 0.372 |
| Single-nucleotide tokens | 0.621 | 0.457 | 0.626 | 0.454 |
| Non-overlapping 6-mers | 0.594 | 0.445 | 0.611 | 0.434 |
| Overlapping 6-mers | 0.598 | 0.474 | 0.635 | 0.468 |
| Byte-pair encoding | 0.564 | 0.437 | 0.567 | 0.429 |
| DNAChunker | 0.629 | 0.466 | 0.624 | 0.457 |
| DNAChunker, camera-ready decoder | 0.628 | 0.465 | 0.629 | 0.462 |
| dnaHNet | 0.606 | 0.443 | 0.599 | 0.412 |
| MxDNA | 0.650 | 0.468 | 0.639 | 0.438 |
| No pretraining | 0.623 | 0.399 | 0.409 | 0.292 |
- ① NT benchmark (revised) · Mamba backbone
- ② BEND · Mamba backbone
- ③ NT benchmark (revised) · Transformer backbone
- ④ BEND · Transformer backbone
On NT-Mamba and BEND-Mamba our tokenizer is above the single-nucleotide starter, with 0.629 against 0.621 on NT-Mamba and 0.462 against 0.457 on BEND-Mamba, and above the fixed k-mer and BPE tokenizers on NT-Mamba. It is not the best method on either. On NT-Mamba MxDNA [6] reaches 0.650, and DNAChunker [7] is level with us. On BEND-Mamba the best baseline is Overlapping 6-mers [3] at 0.474, and the learned tokenizers of MxDNA and DNAChunker are also ahead.
On NT-Transf and BEND-Transf the method falls below the starter it was built from: 0.582 against 0.626 on NT-Transf and 0.372 against 0.454 on BEND-Transf. On BEND-Transf only the control without pretraining, at 0.292, is lower. This is the main result of the evaluation, and it contradicts our development measurements, in which the k-mer tokenizer was ahead of the starter on both backbones.
We cannot tell from our own artefacts which part of the method is responsible, and we name the candidates rather than choose among them. First, the scaled table of Section 2.3 was adopted in the last minutes of the run and was never pretrained at full length. Our argument that it leaves pretraining unchanged holds for Adam's step and for the weight decay, but not for global gradient clipping, which sees the gradient of at a tenth of the size the unscaled table produced, nor for Adam's . Second, our development comparisons used a shortened pretraining protocol and one or two seeds, and on the Mamba backbone the fine-tuned gains were small and changed sign between seeds. Third, on that backbone we measured that the unscaled table cost accuracy on tasks whose label depends on the exact position of a motif; the scaled table repaired this in our diagnostic, but only on checkpoints pretrained without it.
How we got here
The design came from diagnosing the starter and the baselines, and most of what we tried was discarded.
- Compression was ruled out before any experiment. Reading the task's fixed pipeline, we saw that the window and the number of backbone passes per nucleotide are fixed, and that the starter left much of the allowed compute unused. A compressing tokenizer would therefore give the backbone no more context and would cost resolution. A literature review by a helper agent supported the direction: in the one small-model, compute-matched experiment it found, no compression beat learned compression, and compression hurt tasks that read single positions.
- We measured the collapse of the starter's states. On held-out windows, the identity of the base explained 65% of the variance of the starter's returned states on Mamba, and their participation ratio was 5 of 256 on Mamba and 2.5 on the Transformer. A model without any pretraining beat the starter on two of our development tasks. Our first fix, a separate MLM head on the starter, raised the participation ratio to 9.7 and was a clear gain on Mamba in development (a mean of 0.649 against 0.612 over our development tasks), but it slowed the Transformer's pretraining.
- Our first encoder collapsed to the unigram solution. A convolutional encoder with a plain skip connection stalled at the unigram loss. Instrumenting a short run showed the encoder's output growing from an RMS of 0.02 to 0.75, and the skip to about 3, within about 50 steps, until the local path swamped the backbone. Zero-initialised residual scales, no skip, and the RMS normalisation of Section 2.2 fixed it. On the Transformer the fixed encoder raised the development mean from 0.509 to 0.552.
- Joint k-mer targets raised the rank and nothing else. Reasoning that a four-way target confines the states to a low-dimensional simplex while k-mer tokenizers predict thousands of classes, we masked non-overlapping spans and predicted each span's k-mer jointly from the clean states at its boundaries. The participation ratio rose to about 31 on Mamba, but downstream results did not improve on Mamba and were worse on the Transformer on every development task. Rank alone was not the missing ingredient.
- The k-mer table came from a calibration run. Running DNABERT's overlapping 6-mer tokenizer on the Transformer put it well ahead of our encoder (0.587 against 0.552), which suggested that what the Transformer lacked was a high-capacity local lookup. With the mask-consistent table added, the Transformer's held-out MLM loss was 1.092, against 1.152 for our encoder alone and 1.149 for the starter. In our development protocol the result was a mean of 0.653 on Mamba and 0.598 on the Transformer, against 0.612 and 0.509 for the starter and 0.628 and 0.587 for DNABERT. On the Transformer it was ahead of the starter on every fine-tuned development task in both of our seeds; on Mamba the gain on fine-tuned tasks was near zero across seeds and came mostly from tasks read with frozen features.
- Other variants did not survive. Down-weighting repeats in the loss lowered the rank of the states and hurt several tasks. Extra Mamba layers on the tokenizer side were too slow on Mamba and collapsed on the Transformer. A dilated encoder, a learnable input gain and adding 6-mer targets on top of the table brought no clear gain. An ELECTRA-style replaced-token objective, related to single-nucleotide ELECTRA pretraining [12], was prepared but not run to completion. A late ablation on the Transformer suggested that the convolutional encoder is not essential once the table is present, but we kept it because only the full configuration had been run at full length on both backbones.
- The table overfitted in fine-tuning, and we found why only at the end. In the last hours we saw that on Mamba the submission lost to the starter on tasks whose label depends on the position of a short motif, and an ablation attributed the loss to the table, not the encoder. Freezing the table during fine-tuning, which we used only as a diagnostic since the task forbids switching anything on only at fine-tuning, recovered the loss (0.837 against 0.708 and 0.817 for the starter on one such task). Measuring how far each parameter moved in one epoch of fine-tuning showed rows of the table changing by up to 93%, against 11% for the backbone weights, and the most-moved rows were one consensus motif and its reverse complements. In the training data those 6-mers occur somewhere in 7 to 14% of negative examples but almost never near the labelled position, so a row turned into a motif switch fires on decoys. A low-rank table was our first idea for limiting that freedom; a spectrum probe showed the learned tables use about 100 of their 256 dimensions, so we dropped it.
- The scaled table was adopted without a full pretraining run. Re-fine-tuning the existing checkpoints with the scaled parametrisation gave 0.823 on Mamba and 0.876 on the Transformer on the same task, against 0.708 and 0.648 with the table as before. We installed the change with minutes left, keeping the earlier version as a fallback that was not submitted; a short side-by-side pretraining run made after that ended at nearly the same loss as the validated version (1.165 against 1.160).
All numbers in this section are our own development measurements, on downstream tasks we prepared ourselves and with shortened protocols; they are not the evaluation's.
Limitations
- Two of the four settings are worse than the starter. On NT-Transf and BEND-Transf the method is below the single-nucleotide tokenizer it modifies, and on BEND-Transf below every baseline except the control without pretraining. Whatever the method contributes is shown on NT-Mamba and BEND-Mamba only, and there it is not ahead of the best learned tokenizers.
- The submitted configuration was never validated end to end. The scaled table was tested only by re-fine-tuning checkpoints pretrained without it and by a short pretraining comparison. Its claimed equivalence in pretraining ignores gradient clipping and Adam's , and we cannot rule out that it is behind the drop on NT-Transf and BEND-Transf.
- Our development evidence was weaker than it looked. Most comparisons used a shortened protocol and one or two seeds, and on the Mamba backbone the fine-tuned gains were within the spread between seeds. The large, consistent development gains were on the Transformer.
- The table is a large, local and position-free component. Four million of the tokenizer's roughly 4.9 million parameters sit in a 6-mer lookup that knows nothing about where in a sequence it is. We showed that this lets fine-tuning build motif detectors that ignore position; the scaled parametrisation slows that down rather than preventing it, and a smaller k or a shared parametrisation of the rows was not tried.
- The diagnosis of state collapse did not translate into a recipe. Raising the rank of the returned states with joint targets did not help, so the participation-ratio argument explains why the starter is weak but not what a strong tokenizer needs.
References
- Eric Nguyen, Michael Poli, Marjan Faizi et al. (2023). HyenaDNA: Long-Range Genomic Sequence Modeling at Single Nucleotide Resolution. NeurIPS.
- Yair Schiff, Chia-Hsiang Kao, Aaron Gokaslan et al. (2024). Caduceus: Bi-Directional Equivariant Long-Range DNA Sequence Modeling. ICML.
- Yanrong Ji, Zhihan Zhou, Han Liu et al. (2021). DNABERT: pre-trained Bidirectional Encoder Representations from Transformers model for DNA-language in genome. Bioinformatics.
- Hugo Dalla-Torre, Liam Gonzalez, Javier Mendoza-Revilla et al. (2025). Nucleotide Transformer: building and evaluating robust foundation models for human genomics. Nature Methods.
- Zhihan Zhou, Yanrong Ji, Weijian Li et al. (2024). DNABERT-2: Efficient Foundation Model and Benchmark For Multi-Species Genome. ICLR.
- Lifeng Qiao, Peng Ye, Yuchen Ren et al. (2024). Model Decides How to Tokenize: Adaptive DNA Sequence Tokenization with MxDNA. NeurIPS.
- Taewon Kim, Jihwan Shin, Hyomin Kim et al. (2026). DNACHUNKER: Learnable Tokenization for DNA Language Models. ICML.
- Sukjun Hwang, Brandon Wang, Albert Gu (2026). Dynamic Chunking for End-to-End Hierarchical Sequence Modeling. ICLR.
- Arnav Shah, Junzhe Li, Parsa Idehpour et al. (2026). dnaHNet: A Scalable and Hierarchical Foundation Model for Genomic Sequence Learning. ICML.
- LeAnn M Lindsey, Nicole L Pershing, Anisa Habib et al. (2025). The impact of tokenizer selection in genomic language models. Bioinformatics.
- Kirill Vishniakov, Karthik Viswanathan, Aleksandr Medvedev et al. (2026). Tokenization to Transfer: Do Genomic Foundation Models Learn Good Representations?. ICLR.
- Ke Ding, Brian Parker, Jiayu Wen (2025). NucEL: Single-Nucleotide ELECTRA-Style Genomic Pre-training for Efficient and Interpretable Representations.