GeneFormer: Learned Gene Compression using Transformer-Based Context Modeling

Zhanbei Cui, Tongda Xu, Jia Wang, Yu Liao, Yan Wang

Abstract

GeneFormer is a novel neural gene compressor that adapts the Transformer-XL architecture to the unique challenges of DNA sequencing data. By combining a modified attention mechanism with a "multi-level-grouping" strategy, it achieves state-of-the-art compression ratios—outperforming traditional tools like G-zip by orders of magnitude—while significantly reducing the high latency typically associated with deep learning-based compressors.

Introduction

The world is facing a genomic data explosion. Since 2007, the amount of DNA sequencing data has doubled every 12 to 18 months, a pace that outstrips Moore’s Law. Efficiently storing this data is no longer a luxury; it’s a necessity. Traditional general-purpose compressors (like G-zip or 7zip) don't exploit the specific internal correlations of DNA—sequences composed of just four bases (A, G, C, T) with frequent repeats. While recent research has turned to deep learning (specifically LSTMs) to model these patterns, these models often struggle with long-range dependencies or suffer from extreme compression latency. GeneFormer aims to bridge this gap by providing high-density compression with a much faster decoding speed.

Methodology

GeneFormer treats DNA compression as a context-modeling problem. The architecture consists of several key components designed to optimize both compression ratio and processing speed.

System Architecture

The core pipeline involves a CNN-based Feature Generator that extracts local features from DNA fragments, followed by a modified Transformer-XL encoder. Unlike standard Transformers, this model uses a segment-level recurrence mechanism with a Latent Array to store information from past segments. A "Segment Cut" is implemented to limit recurrence length, as biological correlation is strongest among immediate neighbors.

The overall architecture of the GeneFormer model, illustrating the flow from DNA sequence input through the Feature Generator and GeneFormer Encoders to the final loss calculation.

Multi-level Grouping

To address the latency bottleneck of serial decoding, the authors introduced a multi-level grouping strategy. This includes fixed-length grouping for parallel processing, N-gram grouping to shorten sequence length (analogous to biological codons), and byte-grouping. Byte-grouping reshapes 1D data into 2D tensors, allowing the neural network to find structural correlations that are not obvious in a linear string.

The multi-level grouping process, showing how DNA sequences are transformed via N-gram and byte grouping before being processed by GeneFormer and arithmetic encoding.

Experimental Results

The model was evaluated on human and fish mitochondrial sequences. GeneFormer sets a new benchmark for DNA compression performance:

  • Compression Ratio: On the human dataset, GeneFormer achieved 0.0010 bits per base (bpb), significantly outperforming G-zip (1.4232 bpb) and the previous state-of-the-art AI model, DNA-BiLSTM (0.0145 bpb).
  • Speed: The multi-level grouping strategy allowed the model to compress the human dataset in approximately 11 minutes, compared to over 84 minutes for previous AI methods.
  • Efficiency: The model maintains a relatively small parameter count (~4.8M), ensuring it remains comparable in size to less efficient predecessors.

Discussion and Conclusion

GeneFormer demonstrates that Transformer architectures, when modified for biological context and parallelized via grouping, can revolutionize genomic data storage. Key insights include the importance of local context over extreme long-range dependencies for DNA and the surprising effectiveness of 2D data reshaping.

While GeneFormer is significantly faster than previous deep learning models, it remains slower than traditional hand-crafted compressors. Future work will focus on further latency reduction, exploring more complex structural data-shaping strategies, and scaling the model to full human nuclear genomes.

Summary updated

BibTeX
@inproceedings{cui2022geneformer,
  author = {Zhanbei Cui and Tongda Xu and Jia Wang and Yu Liao and Yan Wang},
  title = {{GeneFormer: Learned Gene Compression using Transformer-Based Context Modeling}},
  booktitle = {IEEE International Conference on Acoustics, Speech and Signal Processing},
  year = {2022},
}
Figure