Model Decides How to Tokenize: Adaptive DNA Sequence Tokenization with MxDNA

Lifeng Qiao, Peng Ye, Yuchen Ren, Weiqiang Bai, chaoqi liang, Xinzhu Ma, Nanqing Dong, Wanli Ouyang

Introduction

In the field of genomic foundation models, tokenization remains a critical bottleneck. Unlike Natural Language Processing (NLP), where spaces and punctuation provide natural delimiters, DNA is a continuous sequence of nucleotides without obvious "word" boundaries. Current state-of-the-art models typically rely on rigid, human-defined heuristics borrowed from NLP, such as fixed-length K-mers or frequency-based Byte-Pair Encoding (BPE).

However, these methods are fundamentally ill-suited for the complex "grammar" of biology. Fixed-length segments often bisect meaningful motifs, while BPE is biased toward frequent sequences that may lack functional relevance. Furthermore, biological units are frequently discontinuous or overlapping—properties that standard NLP tokenizers cannot represent. MxDNA introduces a paradigm shift by allowing the model to autonomously learn its own segmentation strategy via gradient descent, moving toward an "ideal" genomic tokenization that is meaningful, discontinuous, and adaptive.

Comparison of standard NLP tokenization approaches versus the ideal requirements for genomic sequences.

Methodology: The Learnt Tokenization Module

The core innovation of MxDNA is the Learnt Tokenization Module, a differentiable neural network that replaces fixed tokenizers. This module is integrated into a Transformer architecture and trained end-to-end using Masked Language Modeling (MLM). The process consists of two primary stages:

1. Basic Units Recognition

The model identifies potential genomic segments of varying lengths (typically 1 to 10 nucleotides). It utilizes a linear gating mechanism, inspired by Mixture of Experts (MoE), to assign confidence scores to these segments. To ensure the selection of the most significant, non-overlapping units, the model applies 1D Non-Maximum Suppression (NMS), a technique adapted from computer vision object detection.

2. Basic Units Assembly

To capture the non-linear nature of DNA, MxDNA employs Deformable Convolutions. Unlike standard convolutions that operate on a fixed grid, deformable convolutions can dynamically adjust their receptive field to group basic units into final tokens. This allows the model to explicitly represent biological features that are discontinuous (separated by gaps), overlapping, or ambiguous.

The MxDNA architecture, featuring the Learnt Tokenization Module integrated between Transformer blocks to enable adaptive sequence segmentation.

Experimental Results

MxDNA was pretrained exclusively on the Human Reference Genome (GRCh38) and evaluated across 26 genomic tasks, including regulatory element classification, histone marker prediction, and splice site detection.

Performance and Efficiency

MxDNA achieved state-of-the-art results, outperforming established models like DNABERT2 and Nucleotide Transformer v2 (NTv2) on 15 out of 26 individual tasks. On the Genomic Benchmarks, it reached an average accuracy of 89.13%, compared to 88.29% for DNABERT2. Notably, MxDNA achieved these results with significantly less pretraining data and shorter training durations, suggesting that adaptive tokenization provides a more efficient "entry point" for the model to learn genomic features.

Emergent Biological Properties

Analysis of the learned tokens revealed that MxDNA discovers a more uniform distribution of token lengths than the bell-curve distribution produced by BPE. Furthermore, t-SNE visualizations showed that tokens naturally cluster according to genomic function (e.g., promoters vs. splice sites) even before supervised finetuning— a property not observed in models using fixed tokenization.

Conclusion and Future Work

MxDNA demonstrates that letting a model "decide" how to segment DNA leads to superior performance and more biologically relevant representations. While the current model uses standard self-attention, which limits its ability to process extremely long sequences due to quadratic complexity, future iterations could combine adaptive tokenization with sub-quadratic architectures like Mamba or Hyena. This would enable the model to tackle long-range genomic dependencies while maintaining its unique ability to recognize complex, overlapping biological motifs.

Summary updated

BibTeX
@inproceedings{qiao2024model,
  author = {Lifeng Qiao and Peng Ye and Yuchen Ren and Weiqiang Bai and chaoqi liang and Xinzhu Ma and Nanqing Dong and Wanli Ouyang},
  title = {{Model Decides How to Tokenize: Adaptive DNA Sequence Tokenization with MxDNA}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=AQ1umQL7dZ},
}
Figure