ZhiyuanChen commited on
Commit
659bf3b
·
verified ·
1 Parent(s): 59de976

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. README.md +293 -0
  2. config.json +41 -0
  3. model.safetensors +3 -0
  4. tokenizer_config.json +69 -0
  5. vocab.txt +11 -0
README.md ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - Biology
4
+ - DNA
5
+ license: agpl-3.0
6
+ datasets:
7
+ - multimolecule/gencode-human
8
+ library_name: multimolecule
9
+ pipeline_tag: text-generation
10
+ ---
11
+
12
+ # HyenaDNA
13
+
14
+ Pre-trained model on human reference genome using a causal language modeling (CLM) objective with the Hyena operator.
15
+
16
+ ## Disclaimer
17
+
18
+ This is an UNOFFICIAL implementation of the [HyenaDNA: Long-Range Genomic Sequence Modeling at Single Nucleotide Resolution](https://doi.org/10.5555/3666122.3667994) by Eric Nguyen, Michael Poli, Marjan Faizi, et al.
19
+
20
+ The OFFICIAL repository of HyenaDNA is at [HazyResearch/hyena-dna](https://github.com/HazyResearch/hyena-dna).
21
+
22
+ > [!TIP]
23
+ > The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
24
+
25
+ **The team releasing HyenaDNA did not write this model card for this model so this model card has been written by the MultiMolecule team.**
26
+
27
+ ## Model Details
28
+
29
+ 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](#training-details) section for more information on the training process.
30
+
31
+ 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.
32
+
33
+ The Hyena operator uses:
34
+
35
+ - **Implicit filters**: MLP-parameterized convolution kernels with learned positional embeddings
36
+ - **Element-wise gating**: Multiplicative interactions between projected input channels
37
+ - **FFT convolution**: Efficient computation via the Fast Fourier Transform
38
+
39
+ ### Variants
40
+
41
+ - **[multimolecule/hyenadna-large-1m](https://huggingface.co/multimolecule/hyenadna-large-1m)**: The HyenaDNA model with 8 layers, 256 hidden size, and 1,000,000 context length.
42
+ - **[multimolecule/hyenadna-large-450k](https://huggingface.co/multimolecule/hyenadna-large-450k)**: The HyenaDNA model with 8 layers, 256 hidden size, and 450,000 context length.
43
+ - **[multimolecule/hyenadna-large-160k](https://huggingface.co/multimolecule/hyenadna-large-160k)**: The HyenaDNA model with 8 layers, 256 hidden size, and 160,000 context length.
44
+ - **[multimolecule/hyenadna-small-32k](https://huggingface.co/multimolecule/hyenadna-small-32k)**: The HyenaDNA model with 4 layers, 256 hidden size, and 32,768 context length.
45
+ - **[multimolecule/hyenadna-tiny-16k-d128](https://huggingface.co/multimolecule/hyenadna-tiny-16k-d128)**: The HyenaDNA model with 2 layers, 128 hidden size, and 16,384 context length.
46
+ - **[multimolecule/hyenadna-tiny-1k-d256](https://huggingface.co/multimolecule/hyenadna-tiny-1k-d256)**: The HyenaDNA model with 2 layers, 256 hidden size, and 1,024 context length.
47
+ - **[multimolecule/hyenadna-tiny-1k](https://huggingface.co/multimolecule/hyenadna-tiny-1k)**: The HyenaDNA model with 2 layers, 128 hidden size, and 1,024 context length.
48
+
49
+ ### Model Specification
50
+
51
+ <table>
52
+ <thead>
53
+ <tr>
54
+ <th>Variants</th>
55
+ <th>Num Layers</th>
56
+ <th>Hidden Size</th>
57
+ <th>Intermediate Size</th>
58
+ <th>Num Parameters (M)</th>
59
+ <th>FLOPs (G)</th>
60
+ <th>MACs (G)</th>
61
+ <th>Max Num Tokens</th>
62
+ </tr>
63
+ </thead>
64
+ <tbody>
65
+ <tr>
66
+ <td>HyenaDNA-large-1m</td>
67
+ <td rowspan="3">8</td>
68
+ <td rowspan="5">256</td>
69
+ <td rowspan="5">1024</td>
70
+ <td rowspan="3">6.62</td>
71
+ <td rowspan="3">6.69</td>
72
+ <td rowspan="3">3.35</td>
73
+ <td>1,000,002</td>
74
+ </tr>
75
+ <tr>
76
+ <td>HyenaDNA-medium-450k</td>
77
+ <td>450,002</td>
78
+ </tr>
79
+ <tr>
80
+ <td>HyenaDNA-medium-160k</td>
81
+ <td>160,002</td>
82
+ </tr>
83
+ <tr>
84
+ <td>HyenaDNA-small-32k</td>
85
+ <td>4</td>
86
+ <td>3.34</td>
87
+ <td>3.35</td>
88
+ <td>1.67</td>
89
+ <td>32,770</td>
90
+ </tr>
91
+ <tr>
92
+ <td>HyenaDNA-tiny-1k-d256</td>
93
+ <td rowspan="3">2</td>
94
+ <td>1.71</td>
95
+ <td>1.67</td>
96
+ <td>0.84</td>
97
+ <td>1,026</td>
98
+ </tr>
99
+ <tr>
100
+ <td>HyenaDNA-tiny-16k-d128</td>
101
+ <td rowspan="2">128</td>
102
+ <td rowspan="2">512</td>
103
+ <td rowspan="2">0.45</td>
104
+ <td rowspan="2">0.44</td>
105
+ <td rowspan="2">0.22</td>
106
+ <td>16,386</td>
107
+ </tr>
108
+ <tr>
109
+ <td>HyenaDNA-tiny-1k</td>
110
+ <td>1,026</td>
111
+ </tr>
112
+ </tbody>
113
+ </table>
114
+
115
+ ### Links
116
+
117
+ - **Code**: [multimolecule.hyenadna](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/hyenadna)
118
+ - **Data**: [multimolecule/gencode-human](https://huggingface.co/datasets/multimolecule/gencode-human)
119
+ - **Paper**: [HyenaDNA: Long-Range Genomic Sequence Modeling at Single Nucleotide Resolution](https://doi.org/10.5555/3666122.3667994)
120
+ - **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
121
+ - **Model type**: Decoder-only with [Hyena](https://arxiv.org/abs/2302.10866) operator
122
+ - **Original Repository**: [HazyResearch/hyena-dna](https://github.com/HazyResearch/hyena-dna)
123
+
124
+ ## Usage
125
+
126
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
127
+
128
+ ```bash
129
+ pip install multimolecule
130
+ ```
131
+
132
+ ### Direct Use
133
+
134
+ #### Text Generation
135
+
136
+ You can use this model directly with a pipeline for text generation:
137
+
138
+ ```python
139
+ import multimolecule # you must import multimolecule to register models
140
+ from transformers import pipeline
141
+
142
+ generator = pipeline("text-generation", model="multimolecule/hyenadna-large-160k")
143
+ output = generator("ATCGATCGATCG", max_new_tokens=50)
144
+ ```
145
+
146
+ ### Downstream Use
147
+
148
+ #### Extract Features
149
+
150
+ Here is how to use this model to get the features of a given sequence in PyTorch:
151
+
152
+ ```python
153
+ from multimolecule import DnaTokenizer, HyenaDnaModel
154
+
155
+
156
+ tokenizer = DnaTokenizer.from_pretrained("multimolecule/hyenadna-large-160k")
157
+ model = HyenaDnaModel.from_pretrained("multimolecule/hyenadna-large-160k")
158
+
159
+ text = "ATCGATCGATCGATCG"
160
+ input = tokenizer(text, return_tensors="pt")
161
+
162
+ output = model(**input)
163
+ ```
164
+
165
+ #### Sequence Classification / Regression
166
+
167
+ > [!NOTE]
168
+ > 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.
169
+
170
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
171
+
172
+ ```python
173
+ import torch
174
+ from multimolecule import DnaTokenizer, HyenaDnaForSequencePrediction
175
+
176
+
177
+ tokenizer = DnaTokenizer.from_pretrained("multimolecule/hyenadna-large-160k")
178
+ model = HyenaDnaForSequencePrediction.from_pretrained("multimolecule/hyenadna-large-160k")
179
+
180
+ text = "ATCGATCGATCGATCG"
181
+ input = tokenizer(text, return_tensors="pt")
182
+ label = torch.tensor([1])
183
+
184
+ output = model(**input, labels=label)
185
+ ```
186
+
187
+ #### Token Classification / Regression
188
+
189
+ > [!NOTE]
190
+ > 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.
191
+
192
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
193
+
194
+ ```python
195
+ import torch
196
+ from multimolecule import DnaTokenizer, HyenaDnaForTokenPrediction
197
+
198
+
199
+ tokenizer = DnaTokenizer.from_pretrained("multimolecule/hyenadna-large-160k")
200
+ model = HyenaDnaForTokenPrediction.from_pretrained("multimolecule/hyenadna-large-160k")
201
+
202
+ text = "ATCGATCGATCGATCG"
203
+ input = tokenizer(text, return_tensors="pt")
204
+ label = torch.randint(2, (len(text), ))
205
+
206
+ output = model(**input, labels=label)
207
+ ```
208
+
209
+ ## Training Details
210
+
211
+ 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.
212
+
213
+ ### Training Data
214
+
215
+ 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.
216
+
217
+ The dataset is split into training and test sets by chromosome, with held-out chromosomes used for evaluation.
218
+
219
+ ### Training Procedure
220
+
221
+ #### Preprocessing
222
+
223
+ 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.
224
+
225
+ 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).
226
+
227
+ #### Sequence Length Warm-up
228
+
229
+ A key training strategy in HyenaDNA is progressive sequence length warm-up. Training begins with short sequences and gradually increases the context length:
230
+
231
+ 1. Training starts with sequences of length L=64.
232
+ 2. The sequence length is doubled at each warm-up stage (64 → 128 → 256 → ... → target length).
233
+ 3. This strategy enables stable training at very long context lengths that would be difficult to train from scratch.
234
+
235
+ #### Pre-training
236
+
237
+ The model was trained on up to 8 NVIDIA A100 (80GB) GPUs.
238
+
239
+ - Batch size: 64 -- 256
240
+ - Steps: 10,000 -- 20,000
241
+ - Optimizer: AdamW
242
+ - Learning rate: 1.5e-4 -- 6e-4
243
+ - Learning rate scheduler: Cosine
244
+ - Weight decay: 0.1
245
+
246
+ ## Citation
247
+
248
+ ```bibtex
249
+ @inproceedings{NEURIPS2023_86ab6927,
250
+ author = {Nguyen, Eric and Poli, Michael and Faizi, Marjan and Thomas, Armin and Wornow, Michael and Birch-Sykes, Callum and Massaroli, Stefano and Patel, Aman and Rabideau, Clayton and Bengio, Yoshua and Ermon, Stefano and R\'{e}, Christopher and Baccus, Stephen},
251
+ booktitle = {Advances in Neural Information Processing Systems},
252
+ editor = {A. Oh and T. Naumann and A. Globerson and K. Saenko and M. Hardt and S. Levine},
253
+ pages = {43177--43201},
254
+ publisher = {Curran Associates, Inc.},
255
+ title = {HyenaDNA: Long-Range Genomic Sequence Modeling at Single Nucleotide Resolution},
256
+ url = {https://proceedings.neurips.cc/paper_files/paper/2023/file/86ab6927ee4ae9bde4247793c46797c7-Paper-Conference.pdf},
257
+ volume = {36},
258
+ year = {2023}
259
+ }
260
+ ```
261
+
262
+ > [!NOTE]
263
+ > The artifacts distributed in this repository are part of the MultiMolecule project.
264
+ > If you use MultiMolecule in your research, you must cite the MultiMolecule project as follows:
265
+
266
+ ```bibtex
267
+ @software{chen_2024_12638419,
268
+ author = {Chen, Zhiyuan and Zhu, Sophia Y.},
269
+ title = {MultiMolecule},
270
+ doi = {10.5281/zenodo.12638419},
271
+ publisher = {Zenodo},
272
+ url = {https://doi.org/10.5281/zenodo.12638419},
273
+ year = 2024,
274
+ month = may,
275
+ day = 4
276
+ }
277
+ ```
278
+
279
+ ## Contact
280
+
281
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
282
+
283
+ Please contact the authors of the [HyenaDNA paper](https://doi.org/10.5555/3666122.3667994) for questions or comments on the paper/model.
284
+
285
+ ## License
286
+
287
+ This model is licensed under the [GNU Affero General Public License](license.md).
288
+
289
+ For additional terms and clarifications, please refer to our [License FAQ](license-faq.md).
290
+
291
+ ```spdx
292
+ SPDX-License-Identifier: AGPL-3.0-or-later
293
+ ```
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_freq": 10,
3
+ "architectures": [
4
+ "HyenaDnaForCausalLM"
5
+ ],
6
+ "bos_token_id": 1,
7
+ "dtype": "float32",
8
+ "embedding_dropout": 0.1,
9
+ "eos_token_id": 2,
10
+ "filter_dropout": 0.0,
11
+ "filter_emb_dim": 5,
12
+ "filter_order": 64,
13
+ "head": null,
14
+ "hidden_dropout": 0.0,
15
+ "hidden_size": 256,
16
+ "hyena_order": 2,
17
+ "id2label": {
18
+ "0": "LABEL_0"
19
+ },
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 1024,
22
+ "label2id": {
23
+ "LABEL_0": 0
24
+ },
25
+ "layer_norm_eps": 1e-05,
26
+ "mask_token_id": 4,
27
+ "max_position_embeddings": 1000002,
28
+ "model_type": "hyenadna",
29
+ "null_token_id": 5,
30
+ "num_hidden_layers": 8,
31
+ "num_inner_mlps": 2,
32
+ "pad_token_id": 0,
33
+ "pad_vocab_size_multiple": 8,
34
+ "short_filter_order": 3,
35
+ "tie_word_embeddings": true,
36
+ "train_freq": true,
37
+ "transformers_version": "5.2.0",
38
+ "unk_token_id": 3,
39
+ "use_bias": true,
40
+ "vocab_size": 11
41
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7640807967f7e65bb964700ce857994107049f087473566d16d4b46a178c218b
3
+ size 218256456
tokenizer_config.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<pad>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<cls>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "<eos>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "<mask>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "5": {
44
+ "content": "<null>",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ }
51
+ },
52
+ "backend": "custom",
53
+ "bos_token": "<cls>",
54
+ "clean_up_tokenization_spaces": true,
55
+ "cls_token": "<cls>",
56
+ "codon": false,
57
+ "eos_token": "<eos>",
58
+ "extra_special_tokens": [
59
+ "<null>"
60
+ ],
61
+ "mask_token": "<mask>",
62
+ "model_max_length": 1000000000000000019884624838656,
63
+ "nmers": 1,
64
+ "pad_token": "<pad>",
65
+ "replace_U_with_T": true,
66
+ "sep_token": "<eos>",
67
+ "tokenizer_class": "DnaTokenizer",
68
+ "unk_token": "<unk>"
69
+ }
vocab.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <pad>
2
+ <cls>
3
+ <eos>
4
+ <unk>
5
+ <mask>
6
+ <null>
7
+ A
8
+ C
9
+ G
10
+ T
11
+ N