HyenaDNA¶
HyenaDNA¶
Pre-trained model on human reference genome using a causal language modeling (CLM) objective with the Hyena operator.
Disclaimer¶
This is an UNOFFICIAL implementation of the HyenaDNA: Long-Range Genomic Sequence Modeling at Single Nucleotide Resolution by Eric Nguyen, Michael Poli, Marjan Faizi, et al.
The OFFICIAL repository of HyenaDNA is at HazyResearch/hyena-dna.
Tip
The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
The team releasing HyenaDNA did not write this model card for this model so this model card has been written by the MultiMolecule team.
Model Details¶
HyenaDNA is a decoder-only model pre-trained on the human reference genome with single nucleotide tokenization in a self-supervised fashion. This means that the model was trained on the raw nucleotides of DNA sequences only, with an automatic process to generate inputs and labels from those sequences. Please refer to the Training Details section for more information on the training process.
HyenaDNA replaces the attention mechanism with the Hyena operator — a subquadratic sequence mixer based on implicit long convolutions. This enables O(L log L) complexity for sequence modeling, allowing the model to handle context lengths up to 1 million base pairs at single nucleotide resolution.
The Hyena operator uses:
- Implicit filters: MLP-parameterized convolution kernels with learned positional embeddings
- Element-wise gating: Multiplicative interactions between projected input channels
- FFT convolution: Efficient computation via the Fast Fourier Transform
Variants¶
HyenaDNA was pretrained across 5 architectures (Table A.1 in the paper), of which 4 have released checkpoints. We provide one converted checkpoint per architecture, using the longest available context length:
- multimolecule/hyenadna-large: The HyenaDNA large model with 8 layers, 256 hidden size, and 1,000,000 context length.
- multimolecule/hyenadna-medium: The HyenaDNA medium model with 4 layers, 256 hidden size, and 32,768 context length.
- multimolecule/hyenadna-small: The HyenaDNA small model with 2 layers, 256 hidden size, and 1,024 context length.
- multimolecule/hyenadna-tiny: The HyenaDNA tiny model with 2 layers, 128 hidden size, and 16,384 context length.
Note
The original repository releases 7 checkpoints with inconsistent naming (e.g., “large” and “medium” share the same architecture, and multiple “tiny” variants are identical except for context length). We retain only the best (longest context) checkpoint per architecture and use a consistent size-based naming scheme. The mapping from original to MultiMolecule names is:
| Original Checkpoint | MultiMolecule Name | Architecture |
|---|---|---|
hyenadna-large-1m-seqlen-hf |
hyenadna-large |
8 layers, 256 dim |
hyenadna-small-32k-seqlen-hf |
hyenadna-medium |
4 layers, 256 dim |
hyenadna-tiny-1k-seqlen-d256-hf |
hyenadna-small |
2 layers, 256 dim |
hyenadna-tiny-16k-seqlen-d128-hf |
hyenadna-tiny |
2 layers, 128 dim |
The (4, 128) architecture from the paper has no released checkpoint. The remaining 3 original checkpoints (hyenadna-medium-450k-seqlen-hf, hyenadna-medium-160k-seqlen-hf, hyenadna-tiny-1k-seqlen-hf) share the same architecture as one of the above but with shorter context lengths, and are not provided.
Model Specification¶
| Variants | Num Layers | Hidden Size | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
|---|---|---|---|---|---|---|---|
| HyenaDNA-large | 8 | 256 | 1024 | 6.62 | 6.69 | 3.35 | 1,000,002 |
| HyenaDNA-medium | 4 | 3.34 | 3.35 | 1.67 | 32,770 | ||
| HyenaDNA-small | 2 | 1.71 | 1.67 | 0.84 | 1,026 | ||
| HyenaDNA-tiny | 128 | 512 | 0.45 | 0.44 | 0.22 | 16,386 |
Links¶
- Code: multimolecule.hyenadna
- Data: multimolecule/gencode-human
- Paper: HyenaDNA: Long-Range Genomic Sequence Modeling at Single Nucleotide Resolution
- Developed by: Eric Nguyen, Michael Poli, Marjan Faizi, Armin W. Thomas, Callum Birch-Sykes, Michael Wornow, Aman Patel, Clayton Rabideau, Stefano Massaroli, Yoshua Bengio, Stefano Ermon, Christopher Ré, Stephen A. Baccus
- Model type: Decoder-only with Hyena operator
- Original Repository: HazyResearch/hyena-dna
Usage¶
The model file depends on the multimolecule library. You can install it using pip:
| Bash | |
|---|---|
Direct Use¶
Text Generation¶
You can use this model directly with a pipeline for text generation:
| Python | |
|---|---|
Downstream Use¶
Extract Features¶
Here is how to use this model to get the features of a given sequence in PyTorch:
| Python | |
|---|---|
Sequence Classification / Regression¶
Note
This model is not fine-tuned for any specific task. You will need to fine-tune the model on a downstream task to use it for sequence classification or regression.
Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
Token Classification / Regression¶
Note
This model is not fine-tuned for any specific task. You will need to fine-tune the model on a downstream task to use it for token classification or regression.
Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
Training Details¶
HyenaDNA used Causal Language Modeling (CLM) as the pre-training objective: given a DNA sequence, the model is trained to predict the next nucleotide token autoregressively.
Training Data¶
The HyenaDNA model was pre-trained on the human reference genome (GRCh38). The training data consists of single nucleotide-level DNA sequences from all human chromosomes. Sequences are tokenized at the individual character level (A, C, G, T, N) without k-mer encoding.
The dataset is split into training and test sets by chromosome, with held-out chromosomes used for evaluation.
Training Procedure¶
Preprocessing¶
HyenaDNA used causal language modeling (CLM) as the pre-training objective: given a DNA sequence of length L, the model predicts the next nucleotide at each position, i.e., predicting token x_{t+1} given x_1, …, x_t.
Single nucleotide tokenization is used with a vocabulary of 12 tokens: A, C, G, T, N, and special tokens (CLS, SEP, BOS, MASK, PAD, RESERVED, UNK).
Sequence Length Warm-up¶
A key training strategy in HyenaDNA is progressive sequence length warm-up. Training begins with short sequences and gradually increases the context length:
- Training starts with sequences of length L=64.
- The sequence length is doubled at each warm-up stage (64 → 128 → 256 → … → target length).
- This strategy enables stable training at very long context lengths that would be difficult to train from scratch.
Pre-training¶
The model was trained on up to 8 NVIDIA A100 (80GB) GPUs.
- Batch size: 64 – 256
- Steps: 10,000 – 20,000
- Optimizer: AdamW
- Learning rate: 1.5e-4 – 6e-4
- Learning rate scheduler: Cosine
- Weight decay: 0.1
Citation¶
Note
The artifacts distributed in this repository are part of the MultiMolecule project. If you use MultiMolecule in your research, you must cite the MultiMolecule project as follows:
| BibTeX | |
|---|---|
Contact¶
Please use GitHub issues of MultiMolecule for any questions or comments on the model card.
Please contact the authors of the HyenaDNA paper for questions or comments on the paper/model.
License¶
This model implementation is licensed under the GNU Affero General Public License.
For additional terms and clarifications, please refer to our License FAQ.
| Text Only | |
|---|---|
multimolecule.models.hyenadna
¶
DnaTokenizer
¶
Bases: Tokenizer
Tokenizer for DNA sequences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Alphabet | str | List[str] | None
|
alphabet to use for tokenization.
|
None
|
|
int
|
Size of kmer to tokenize. |
1
|
|
bool
|
Whether to tokenize into codons. |
False
|
|
bool
|
Whether to replace U with T. |
True
|
|
bool
|
Whether to convert input to uppercase. |
True
|
Examples:
Source code in multimolecule/tokenisers/dna/tokenization_dna.py
HyenaDnaConfig
¶
Bases: PreTrainedConfig
This is the configuration class to store the configuration of a
HyenaDnaModel. It is used to instantiate a HyenaDNA model according
to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will
yield a similar configuration to that of the HyenaDNA
LongSafari/hyenadna-medium-160k-seqlen-hf
architecture.
Configuration objects inherit from PreTrainedConfig and can be used to
control the model outputs. Read the documentation from PreTrainedConfig
for more information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
Vocabulary size of the HyenaDNA model. Defines the number of different tokens that can be represented by
the |
11
|
|
int
|
Dimensionality of the model layers. |
256
|
|
int
|
Number of hidden layers (Hyena blocks) in the model. |
8
|
|
int | None
|
Dimensionality of the feed-forward layer. If |
None
|
|
float
|
The dropout probability for the embedding layer. |
0.1
|
|
float
|
The dropout probability within the Hyena operator. |
0.0
|
|
int
|
The maximum sequence length that this model might ever be used with. |
160002
|
|
float
|
The standard deviation of the truncated_normal_initializer for initializing all weight matrices. |
0.02
|
|
float
|
The epsilon used by the layer normalization layers. |
1e-05
|
|
int
|
Order of the Hyena recurrence. Controls the number of element-wise gating steps. |
2
|
|
int
|
Width of the implicit filter MLP (number of hidden units). |
64
|
|
int
|
Kernel size of the short depthwise convolution applied before the Hyena recurrence. |
3
|
|
int
|
Dimensionality of the positional embedding fed to the implicit filter MLP.
Must be odd and >= 3. Computed as |
5
|
|
int
|
Number of inner linear layers inside the implicit filter MLP. |
2
|
|
int
|
Frequency multiplier for the Sin activation function in the implicit filter. |
10
|
|
float
|
The dropout probability for the implicit filter. |
0.0
|
|
bool
|
Whether to use bias in the implicit filter. |
True
|
|
bool
|
Whether the Sin activation frequencies are learnable parameters. |
True
|
|
int
|
Pad the vocabulary size to be a multiple of this value (for GPU performance). |
8
|
|
HeadConfig | None
|
The configuration of the head. |
None
|
Examples:
Source code in multimolecule/models/hyenadna/configuration_hyenadna.py
| Python | |
|---|---|
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
HyenaDnaForCausalLM
¶
Bases: HyenaDnaPreTrainedModel, GenerationMixin
Examples:
| Python Console Session | |
|---|---|
Source code in multimolecule/models/hyenadna/modeling_hyenadna.py
HyenaDnaForSequencePrediction
¶
Bases: HyenaDnaPreTrainedModel
Examples:
| Python Console Session | |
|---|---|
Source code in multimolecule/models/hyenadna/modeling_hyenadna.py
HyenaDnaForTokenPrediction
¶
Bases: HyenaDnaPreTrainedModel
Examples:
| Python Console Session | |
|---|---|
Source code in multimolecule/models/hyenadna/modeling_hyenadna.py
HyenaDnaModel
¶
Bases: HyenaDnaPreTrainedModel
Examples:
| Python Console Session | |
|---|---|
Source code in multimolecule/models/hyenadna/modeling_hyenadna.py
| Python | |
|---|---|
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |