﻿# DNABERT-2 BPE features need token-to-nucleotide span mapping

Distinguish DNABERT-2 BPE positions from nucleotide coordinates, preserve token offsets and special-token masks, and label derived per-base feature projections.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-dnabert2-bpe-token-nucleotide-offset-map/
Language: en

## A feature row does not necessarily identify a nucleotide

A genome-annotation experiment may obtain DNABERT-2 hidden states and attach each row to the next nucleotide in the source interval. That correspondence is invalid when the tokenizer groups variable-length substrings. The tensor has a sequence axis, but its positions belong to the tokenized representation.

The [DNABERT-2 paper](https://arxiv.org/abs/2306.15006) motivates BPE in place of fixed k-mer tokenization. Coordinate interpretation must change with that representation choice.

## Variable-length tokens define spans

The [official checkpoint](https://huggingface.co/zhihan1996/DNABERT-2-117M) supplies the tokenizer used with the model. Preserve the mapping from each ordinary token to the covered input substring using the actual tokenizer interface and verified offsets.

Special tokens and padding need separate treatment because they do not denote ordinary genomic spans. A numeric token index should never be added directly to a chromosome start coordinate unless the conversion has explicitly established that relationship.

## Per-base projection is an application operation

An application can choose to distribute a token feature over its covered bases, aggregate several token features, or train an additional prediction head. Those are different downstream definitions. Repeating a vector across a span does not create independently learned predictions at every nucleotide.

Label the resulting artifact as a projection and record the chosen rule. The [span-integrity guide](/journal/data-guide-unicode-normalization-span-integrity/) explains the general need to preserve correspondence between transformed model input and source coordinates.

## Cropping can change token boundaries

The [DNABERT-2 implementation guide](https://raw.githubusercontent.com/MAGICS-LAB/DNABERT_2/main/README.md) identifies BPE as part of the released workflow. Independently tokenizing adjacent genomic windows can produce different boundary segmentation from tokenizing a longer combined interval.

Store window boundaries and tokenizer revision with features. Do not assume that concatenating window feature arrays reconstructs the same token sequence as a full-interval pass. Even equal total coverage does not establish equal model context or equal segmentation.

## Verify a mapping before biological interpretation

Inspect short inputs with several token lengths and confirm that recovered ordinary-token spans cover the intended sequence without treating markers as bases. Then test any annotation join against known source intervals.

The [tensor-axis guide](/journal/tensor-axes-batch-sequence-hidden/) helps keep token and genomic axes separate. A correct coordinate projection establishes computational alignment, not experimental evidence that a highlighted base controls a biological effect or a validated explanation of a model prediction.
