Introduction
A DNA foundation model has to turn a string over four letters, with no word boundaries, into a sequence of backbone tokens. The information it must recover lives at very different scales, from single bases and short motifs to long regulatory regions and repeats, and the field has not agreed on how to tokenize it. Character-level models keep every nucleotide as a token [1, 2]; DNABERT uses overlapping 6-mers [3]; the Nucleotide Transformer uses non-overlapping 6-mers [4]; DNABERT-2 learns a BPE vocabulary [5]; and a recent line of work learns the segmentation jointly with the model, by adaptive tokenization [6], dynamic chunking [7, 8] or learnable tokenization [9]. The choice and its effect on transfer have also been studied in their own right [10, 11].
The research question here fixes everything except that choice: two backbones (a bidirectional Mamba and a Transformer), the pretraining data and its nucleotide budget, the optimizer, and the downstream protocols. What should the tokenizer, its pretraining objective and its mapping back to nucleotides be, so that the pretrained model transfers best on either backbone?
Two properties of this setup shape our answer. First, every downstream task reads per-nucleotide states, so any merging must be undone, and whatever a merge blurs has to be reconstructed by an upsampler. Second, the budget is set in nucleotides, not tokens: compression saves compute, but it buys no extra data. Merging is therefore a trade the tokenizer is not forced to make. The question becomes what else a tokenizer can contribute if it keeps one token per base.
Method
Our answer, contextualized nucleotide tokens (CNT), keeps full resolution and moves the tokenizer's capacity from segmentation into local context and into the pretraining objective.
A convolutional stem as a continuous k-mer
An overlapping -mer token gives each position a discrete identity for its local window. We replace the discrete vocabulary by a learned function of the window. Each nucleotide is embedded, , with the starter's 16-row table, and the embedding sequence passes through four pre-norm, depthwise-separable convolution blocks with a gated pointwise expansion,
with kernel size 7 and dilations . Each block widens the receptive field by positions, so the stem output sees nucleotides. No position is ever merged with another; the stem only enriches each base with its motif-scale neighbourhood before the backbone sees it.
class ConvBlock(nn.Module):
"""Pre-norm depthwise-separable dilated convolution block with GLU pointwise
expansion: a learned local motif filter bank at nucleotide resolution."""
def __init__(self, d, k=7, dil=1):
super().__init__()
self.norm = RMSNorm(d, eps=1e-5)
self.pw1 = nn.Linear(d, 2 * d)
self.dw = nn.Conv1d(d, d, k, padding=dil * (k // 2), dilation=dil, groups=d)
self.pw2 = nn.Linear(d, d)
def forward(self, x):
a, b = self.pw1(self.norm(x)).chunk(2, dim=-1)
a = self.dw(a.transpose(1, 2)).transpose(1, 2) * F.silu(b)
return x + self.pw2(a)The backbone stays the only global mixer, and the decoder stays off its path
The stem is local by construction, so all long-range mixing is left to the fixed backbone . The per-nucleotide states that every downstream task reads are
The two decoder blocks refine a copy of the stem features, , and are added to the backbone output only at the end. We call this a decoupled decoder: whatever long-range evidence the backbone writes into reaches unchanged, rather than being passed through further local layers. The masked-prediction head is tied to the embedding table, , as in the starter.
def _forward(self, ids, backbone):
h, _ = self._forward_z(ids, backbone)
return h
def _forward_z(self, ids, backbone):
x = self.embed(ids)
for blk in self.stem:
x = blk(x)
z = backbone(x)
y = x
for blk in self.dec:
y = blk(y)
return self.norm_f(z + y), zSpan masking
The starter masks 15% of positions independently. With a 91-nucleotide stem, an isolated masked base can be read off its immediate neighbours, which teaches the model little. We mask contiguous spans instead. For each batch a half-width is drawn, span centres are drawn independently with probability
and each centre is dilated to a span of nucleotides by a max-pool. A
position is then covered by a span with probability away from the window
edges, whatever is. Isolated positions are added with probability 0.03, and N positions are never
masked. Of the masked positions, 80% are replaced by [MASK], half of the rest by a sample from the
generator described next, and the remainder are left unchanged.
def _span_mask(self, nuc):
B, L = nuc.shape
dev = nuc.device
r = int(torch.randint(2, 5, (1,)).item())
q = 1.0 - (1.0 - self.MASK_RATE) ** (1.0 / (2 * r + 1))
seed = (torch.rand(B, 1, L, device=dev) < q).float()
span = F.max_pool1d(seed, kernel_size=2 * r + 1, stride=1, padding=r)[:, 0] > 0
single = torch.rand(B, L, device=dev) < 0.03
return (span | single) & (nuc < 4)Replaced-base detection against a weak local generator
A masked-prediction loss is sparse: it trains on about a fifth of the positions. We add a dense replaced-token detection objective in the style of ELECTRA, which single-nucleotide genomic pretraining has also adopted [12]. The generator is deliberately small: it predicts each base from the 8 nucleotides on its left and the 8 on its right through two one-sided convolutions over a one-hot input, with the centre excluded by construction.
class LocalGen(nn.Module):
"""Tiny generator: predicts each base from its +-8 nucleotide context only
(centre excluded by construction), from a 6-channel one-hot input
(A, C, G, T, N, special/masked). Used to sample locally plausible
replacements for replaced-token detection."""
def __init__(self, hidden=48, ctx=8):
super().__init__()
self.ctx = ctx
self.left = nn.Conv1d(6, hidden, ctx)
self.right = nn.Conv1d(6, hidden, ctx)
self.out = nn.Linear(hidden, 4)
def forward(self, oh):
c = self.ctx
l = self.left(F.pad(oh, (c, 0)))[:, :, :oh.shape[-1]]
r = self.right(F.pad(oh, (0, c)))[:, :, 1:oh.shape[-1] + 1]
return self.out(F.silu(l + r).transpose(1, 2))The generator sees the clean sequence, is trained by its own cross-entropy, and its samples are
drawn from detached probabilities, so it is not trained adversarially. Besides the replacements
among masked positions, 10% of the remaining real bases are replaced by a generator sample. A linear
head on the final states then predicts, at every position that is not [MASK], whether the
input base differs from the original:
A sample that happens to equal the original counts as unreplaced. The point of the weak generator is in what beats it: replacements are plausible given a window of 8 on each side, so detecting them needs evidence from beyond that window.
Deep supervision of the backbone
The objective so far contains a trap, and closing it was the most important step in our development. The stem and the decoder together give the model a short path from the input to the output that bypasses the backbone, and masked prediction of a base from its neighbourhood is largely a local problem. The model can therefore solve much of the loss on the skip path and leave the backbone undertrained as a carrier of base identity. We remove that option by applying the same masked-prediction loss to the backbone output directly, through the same tied head:
Both masked-prediction terms weight each masked position by when the task's pretraining-only repeat annotation marks it as part of a repeat and otherwise, and normalise by , so that capacity goes to the less redundant part of the genome:
When no repeat track is passed, the two terms fall back to a plain mean over masked positions.
def pretrain_loss(self, nuc, extra, backbone):
ids = (nuc + self.OFFSET).clamp(max=15)
# generator sees the clean sequence (pretraining only; never downstream)
gen_logits = self.local(self._onehot6(ids))
gen_probs = torch.softmax(gen_logits.float().detach(), dim=-1)
gen_sample = torch.multinomial(gen_probs.view(-1, 4), 1).view(nuc.shape)
masked = self._span_mask(nuc)
inp = ids.clone()
replaced_tok = (torch.rand(ids.shape, device=ids.device) < 0.8) & masked
inp[replaced_tok] = self.MASK
gen_in_mask = (torch.rand(ids.shape, device=ids.device) < 0.5) & masked & ~replaced_tok
inp[gen_in_mask] = 7 + gen_sample[gen_in_mask]
rtd_sel = (torch.rand(ids.shape, device=ids.device) < self.RTD_RATE) & ~masked & (nuc < 4)
inp[rtd_sel] = 7 + gen_sample[rtd_sel]
h, z = self._forward_z(inp, backbone)
logits = F.linear(h, self.embed.weight).float()
ce = F.cross_entropy(logits[masked], ids[masked], reduction="none")
zlogits = F.linear(z, self.embed.weight).float()
ce_z = F.cross_entropy(zlogits[masked], ids[masked], reduction="none")
rep = extra.get("repeat") if isinstance(extra, dict) else None
if rep is not None:
w = torch.where(rep[masked] > 0, float(self.REPEAT_LOSS_W), 1.0)
mlm = (ce * w).sum() / w.sum().clamp(min=1.0)
mlm_z = (ce_z * w).sum() / w.sum().clamp(min=1.0)
else:
nm = masked.sum().clamp(min=1)
mlm = ce.sum() / nm
mlm_z = ce_z.sum() / nm
loss = mlm + self.DS_W * mlm_z tgt = nuc.clamp(0, 4)
lce = F.cross_entropy(gen_logits.float().view(-1, 4), tgt.view(-1), ignore_index=4,
reduction="none")
n_real = (tgt.view(-1) != 4).sum().clamp(min=1)
local_ce = lce.sum() / n_real
loss = loss + self.LOCAL_W * local_ce
stats["local_ce"] = local_ce.detach()
is_replaced = (inp >= 7) & (inp <= 10) & ((inp - 7) != nuc)
valid = (inp != self.MASK) & (nuc < 4)
rtd_logits = self.rtd_head(h).float()[:, :, 0]
rtd = F.binary_cross_entropy_with_logits(rtd_logits[valid], is_replaced[valid].float(),
reduction="sum") / valid.sum().clamp(min=1)
loss = loss + self.RTD_W * rtd
stats["rtd"] = rtd.detach()
stats["rtd_pos"] = is_replaced[valid].float().mean().detach()
return loss, statsAt downstream time none of this machinery runs: nucleotide_states embeds the clean sequence and
returns . The generator and the detection head are used only in pretraining, fit and
cpu_encode are unchanged no-ops, the token rate is exactly one per nucleotide, and the backbone is
called once per step. Nothing in the method depends on which backbone it is paired with.
Results
| Method | ① | ② | ③ | ④ |
|---|---|---|---|---|
| Benchmark mean score ↑ | Benchmark mean score ↑ | Benchmark mean score ↑ | Benchmark mean score ↑ | |
| Muse Wonder Full | 0.608 | 0.464 | 0.623 | 0.474 |
| 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 BEND-Transf CNT is ahead of every published baseline: 0.474 against 0.468 for the strongest baseline there, Overlapping 6-mers [3], and against 0.454 for the single-nucleotide starter we modified. On BEND-Mamba it reaches 0.464, above the starter's 0.457 but below four baselines, the best of them Overlapping 6-mers [3] at 0.474.
On the other two settings CNT does not improve on the starter. On NT-Mamba it reaches 0.608 against the starter's 0.621, and the strongest baseline, MxDNA [6], reaches 0.650. On NT-Transf it reaches 0.623 against the starter's 0.626 and 0.639 for MxDNA [6]. NT-Mamba is also the setting on which the no-pretraining control (0.623) is above the pretrained single-nucleotide starter, so pretraining as a whole adds little there, and a change to the pretraining objective has little room to show.
Against the compressing tokenizers, CNT is above non-overlapping 6-mers, BPE and dnaHNet on every setting, which is consistent with the premise that, under a nucleotide budget, merging costs more resolution than it saves. It is not above the learned tokenizers everywhere: MxDNA is clearly ahead on NT-Mamba and NT-Transf. We have no estimate of the spread of these means, and several of the gaps, in both directions, are small.
How we got here
We started from the opposite end, with a compressing tokenizer, and arrived at CNT by eliminating alternatives on our own development measurements. Those measurements come from a reduced-scale harness we built to imitate the fixed pretraining protocol, with frozen linear probes and, later, fine-tuning probes of our own; we report them as such.
- A learned soft-warp tokenizer lost to characters. Our first candidate was fully differentiable adaptive resampling: a router predicted a per-nucleotide token density, its cumulative sum warped the nucleotide axis onto a fixed number of backbone tokens (one per four nucleotides), tokens were formed by triangular splat pooling, and per-nucleotide states were recovered by interpolation plus an identity skip. In the shortest runs the router collapsed to a uniform density, which we attributed to weight decay and a uniform-pooling local optimum. After exempting it from weight decay the router became active, but its repeat-based allocation never separated, and in longer runs the tokenizer lost to the character baseline on every probe (mean frozen-probe MCC 0.500 against 0.565 in our development runs). We concluded that the pooling bottleneck does not pay for itself when the budget is counted in nucleotides; by then we had already built a second candidate that removes the bottleneck altogether.
- Full resolution with a stem won on the Mamba backbone, and each part earned its place there. The first full-resolution design (stem, backbone, a joint decoder on their sum, span masking and replaced-base detection) beat characters on the mean frozen probe, 0.574 against 0.565. A decomposition on the same backbone gave 0.552 for the stem alone, 0.566 with span masking, and 0.574 with replaced-base detection added. These numbers predate deep supervision, and we did not repeat the decomposition on the final design.
- More capacity and harder objectives did not help. On the Mamba backbone a larger stem reached 0.540, a 30% mask rate 0.565, and a stronger generator built from the stem's own masked prediction, meant to make replacements harder to detect, reached 0.527: its loss took over the stem. Identity initialisation (zero-initialised output projections, together with an identity bypass) reached 0.548. All were abandoned.
- The Transformer exposed a failure the Mamba runs had hidden. On the Transformer backbone the same design lost to characters overall, and on one fine-tuned development probe it reached 0.518 against the character model's 0.605. A stage-wise diagnostic located the problem: a linear probe on the centre position alone found more of the relevant signal in our states than in the character model's (0.894 against 0.820), but after mean-pooling it fell to 0.144 against 0.290. The local path held the information, and the backbone was no longer spreading it across positions. Single masking instead of span masking, an identity bypass that adds the raw embedding back after the stem, and a pooled auxiliary loss on window-level statistics each helped little or not at all.
- Removing the decoder from the backbone's path was half of the fix. Dropping the decoder helped the Transformer and hurt the Mamba: by our measurements the decoder was worth +0.042 on the Mamba and −0.032 on the Transformer. Moving the decoder onto the stem branch only, so that it never rewrites the backbone stream, kept most of the Transformer's gain (0.517 against 0.522 without a decoder) and became our design at that point.
- At longer training the gap reopened, and only deep supervision closed it. In a longer Transformer run the character model rose to 0.944 on that fine-tuned probe while ours stayed at 0.569, a gap we checked was well outside the probe's own variation (about ±0.05 by our measurement). Mixed masking (0.396), down-scaling the skip branch (0.343), a second pooled auxiliary that predicts masked-span content from unmasked positions (0.484), and a split-channel input (0.452) all failed; the last three were measured only after we had formed the diagnosis below. Our diagnosis was that the backbone stage lost information relative to the stem because the skip path solved masked prediction for it. Applying the masked-prediction loss to the backbone output brought the probe to 0.935 against the character model's 0.944, and 0.953 with a second seed; on the Mamba the same design reached 0.926.
- Deep supervision, not the decoder layout, was the active ingredient. With deep supervision, a joint decoder on the backbone path was also repaired (0.920). We kept the decoupled decoder as a second line of defence. A deep-supervision weight of 1.0 performed like 0.5, and annealing the weight over training gave no benefit, so the shipped weight is a constant 0.5.
- The final design held up in our longest runs. There we measured 0.946 against the character model's 0.963 on the fine-tuned probe on the Transformer, and 0.919 on the Mamba. Separately, the stem's cost proved smaller than a first, contended timing suggested: isolated timing put it at about 20% on top of the backbone.
Limitations
- The method does not beat the starter everywhere. CNT is below the single-nucleotide starter on NT-Mamba (0.608 against 0.621) and on NT-Transf (0.623 against 0.626), and MxDNA leads on both. Its demonstrated gain is on BEND-Mamba and BEND-Transf, and on BEND-Mamba four baselines are still ahead of it.
- Our development evidence is narrow. Every design decision was made on a reduced-scale harness and probes we built ourselves, and in our own longest runs the final design was still below the character model on the fine-tuned probe that drove most decisions on the Transformer. We have no variance estimate for the evaluated means, and some of the differences above are small.
- The parts are not all shown to be necessary. The component decomposition was measured on one backbone and before deep supervision existed; the decoupled decoder was kept after deep supervision had made the joint decoder work as well; and on one of our development probes we found the replaced-base detection itself to be neutral. The final objective has four terms whose weights (0.5, 0.2, 1.0 and the 0.3 repeat weight) were set by hand.
- This is not a tokenizer in the segmentation sense. CNT keeps one token per nucleotide and learns no vocabulary or boundaries. It answers the research question by declining the resolution-length trade rather than by finding a better point on it, and it costs more compute per step than characters.
- The fix is a regulariser against a shortcut our own architecture created. Deep supervision is needed because the stem and decoder give the model a way around the backbone. A design without that shortcut might not need it, and we have not shown that the stem's gains outweigh the supervision it requires on settings where it did not help.
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.
- 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.
- Taewon Kim, Jihwan Shin, Hyomin Kim et al. (2026). DNACHUNKER: Learnable Tokenization for DNA Language Models. 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.