MegaDNA
A multiscale decoder-only transformer trained on bacteriophage genomes, one token per nucleotide.
Molecules, proteins and genomics · 943 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Parameters
- 145.6M
- Operations
- 943
- Framework
- PyTorch
- Recurrent
- No
- Published
- 2023, Nature Communications
- Cited by
- 67 (as of 28 October 2026)
- Authors
- Bin Shao
- Source
- GitHub: lingxusb/megaDNA
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m18376
- Graph hash
- b88ffabb9592fe0d1a4a1bf56c90b3f5b28ce67656332f6850a6b63358adaff1
- Skeleton hash
- 0c151dbb39674cceb775bcfaad35af1e0cb0e3eb21bb49246af41a5da596d180
- Architecture hash
- 0d9be67fc5ba7cc9a526e8887ac6dfff99f3958a6d81937f24bff18f8a121924
- Diagram SHA-256
- 864f330d37fcb3d777f15381a46ddbb4eaa22e71f65dee0de7e5f5fc2bc0f77b
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
megaDNA is a generative language model for DNA, pre-trained on unannotated bacteriophage genomes with every nucleotide as a separate token. Its starting point is that most genomic language models are trained with masked language modeling, an approach the paper calls not ideal for tasks that require generating new content.
To handle long contexts it uses a multiscale structure of three decoder-only transformer layers, each capturing sequence information at a different resolution. A local layer works within a 16 bp window, a middle layer has a context window of 1024 bp, and a global layer models dependencies across the whole input context of 96 K bp. Each layer has a depth of 8, with dimensions of 196, 256 and 512 from local to global, which is the configuration of this model. The paper gives its size as 145 M parameters in total.
The paper hypothesizes that the model's loss approximates the fitness of a genome sequence, and the loss on the input sequence is what this model returns. Without further fine-tuning, the model is used to predict gene essentiality across a phage genome. It also generates new sequences of up to 96 K base pairs, which the paper describes as containing potential regulatory elements and annotated proteins with phage-related functions.
Key idea. megaDNA is a long-context language model, pre-trained on unannotated bacteriophage genomes at the single-nucleotide level, that both interprets and generates genomic sequences.
- megaDNA
- genomic language model
- DNA language model
- bacteriophage genomes
- phage genome generation
- long-context language model
- multiscale transformer
- genome sequence generation
- gene essentiality prediction
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@article{Shao_2024, title={A long-context language model for deciphering and generating bacteriophage genomes}, volume={15}, ISSN={2041-1723}, url={http://dx.doi.org/10.1038/s41467-024-53759-4}, DOI={10.1038/s41467-024-53759-4}, number={1}, journal={Nature Communications}, publisher={Springer Science and Business Media LLC}, author={Shao, Bin and Yan, Jiawei}, year={2024}, month=Oct }