yurakuratov
commited on
Commit
•
7192f11
1
Parent(s):
da975ed
update readme
Browse files
README.md
CHANGED
@@ -4,52 +4,94 @@ tags:
|
|
4 |
- human_genome
|
5 |
---
|
6 |
|
7 |
-
#
|
8 |
|
9 |
-
|
10 |
|
11 |
-
|
12 |
|
13 |
-
|
14 |
|
15 |
-
Differences between GENA-LM and DNABERT:
|
16 |
- BPE tokenization instead of k-mers;
|
17 |
-
- input sequence size is about
|
18 |
- pre-training on T2T vs. GRCh38.p13 human genome assembly.
|
19 |
|
20 |
Source code and data: https://github.com/AIRI-Institute/GENA_LM
|
21 |
|
22 |
-
|
23 |
-
### How to load the model to fine-tune it on classification task
|
24 |
-
```python
|
25 |
-
from src.gena_lm.modeling_bert import BertForSequenceClassification
|
26 |
-
from transformers import AutoTokenizer
|
27 |
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
```
|
31 |
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
36 |
-
- 12 Layers, 12 Attention heads
|
37 |
-
- 768 Hidden size
|
38 |
-
- 32k Vocabulary size
|
39 |
|
40 |
-
|
|
|
|
|
41 |
|
42 |
-
|
43 |
-
|
|
|
44 |
|
45 |
-
### Fine-tuning GENA-LM on our data and scoring
|
46 |
-
After fine-tuning gena-lm-bert-base on promoter prediction dataset, following results were achieved:
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
53 |
|
54 |
-
|
|
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
- human_genome
|
5 |
---
|
6 |
|
7 |
+
# GENA-LM (gena-lm-bigbird-base-sparse-t2t)
|
8 |
|
9 |
+
GENA-LM is a Family of Open-Source Foundational Models for Long DNA Sequences.
|
10 |
|
11 |
+
GENA-LM models are transformer masked language models trained on human DNA sequence.
|
12 |
|
13 |
+
`gena-lm-bigbird-base-sparse-t2t` follows the BigBird architecture and uses sparse attention from DeepSpeed.
|
14 |
|
15 |
+
Differences between GENA-LM (`gena-lm-bigbird-base-sparse-t2t`) and DNABERT:
|
16 |
- BPE tokenization instead of k-mers;
|
17 |
+
- input sequence size is about 36000 nucleotides (4096 BPE tokens) compared to 512 nucleotides of DNABERT;
|
18 |
- pre-training on T2T vs. GRCh38.p13 human genome assembly.
|
19 |
|
20 |
Source code and data: https://github.com/AIRI-Institute/GENA_LM
|
21 |
|
22 |
+
Paper: https://www.biorxiv.org/content/10.1101/2023.06.12.544594v1
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
## Installation
|
25 |
+
`gena-lm-bigbird-base-sparse-t2t` sparse ops require DeepSpeed.
|
26 |
+
|
27 |
+
### DeepSpeed
|
28 |
+
DeepSpeed installation is needed to work with SparseAttention versions of language models. DeepSpeed Sparse attention supports only GPUs with compute compatibility >= 7 (V100, T4, A100).
|
29 |
+
```bash
|
30 |
+
pip install triton==1.0.0
|
31 |
+
DS_BUILD_SPARSE_ATTN=1 pip install deepspeed==0.6.0 --global-option="build_ext" --global-option="-j8" --no-cache
|
32 |
+
```
|
33 |
+
and check installation with
|
34 |
+
```bash
|
35 |
+
ds_report
|
36 |
```
|
37 |
|
38 |
+
### APEX for FP16
|
39 |
+
Install APEX https://github.com/NVIDIA/apex#quick-start
|
40 |
+
```
|
41 |
+
git clone https://github.com/NVIDIA/apex
|
42 |
+
cd apex
|
43 |
+
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
|
44 |
+
```
|
45 |
|
46 |
+
## Examples
|
|
|
|
|
|
|
47 |
|
48 |
+
### Load pre-trained model
|
49 |
+
```python
|
50 |
+
from transformers import AutoTokenizer, BigBirdForMaskedLM
|
51 |
|
52 |
+
tokenizer = AutoTokenizer.from_pretrained('AIRI-Institute/gena-lm-bigbird-base-sparse-t2t')
|
53 |
+
model = BigBirdForMaskedLM.from_pretrained('AIRI-Institute/gena-lm-bigbird-base-sparse-t2t')
|
54 |
+
```
|
55 |
|
|
|
|
|
56 |
|
57 |
+
### How to load the model to fine-tune it on classification task
|
58 |
+
```python
|
59 |
+
from transformers import AutoTokenizer, BigBirdForSequenceClassification
|
60 |
+
|
61 |
+
tokenizer = AutoTokenizer.from_pretrained('AIRI-Institute/gena-lm-bigbird-base-sparse-t2t')
|
62 |
+
model = BigBirdForSequenceClassification.from_pretrained('AIRI-Institute/gena-lm-bigbird-base-sparse-t2t')
|
63 |
+
```
|
64 |
|
65 |
+
## Model description
|
66 |
+
GENA-LM (`gena-lm-bigbird-base-sparse-t2t`) model is trained in a masked language model (MLM) fashion, following the methods proposed in the BigBird paper by masking 15% of tokens. Model config for `gena-lm-bigbird-base-sparse-t2t` is similar to the `google/bigbird-roberta-base`:
|
67 |
|
68 |
+
- 4096 Maximum sequence length
|
69 |
+
- 12 Layers, 12 Attention heads
|
70 |
+
- 768 Hidden size
|
71 |
+
- sparse config:
|
72 |
+
- block size: 64
|
73 |
+
- random blocks: 3
|
74 |
+
- global blocks: 2
|
75 |
+
- sliding window blocks: 3
|
76 |
+
- Rotary positional embeddings
|
77 |
+
- 32k Vocabulary size, tokenizer trained on DNA data.
|
78 |
+
|
79 |
+
We pre-trained `gena-lm-bigbird-base-sparse-t2t` using the latest T2T human genome assembly (https://www.ncbi.nlm.nih.gov/assembly/GCA_009914755.3/). The data was augmented by sampling mutations from 1000-genome SNPs (gnomAD dataset). Pre-training was performed for 800,000 iterations with batch size 256. We modified Transformer with [Pre-Layer normalization](https://arxiv.org/abs/2002.04745).
|
80 |
+
|
81 |
+
## Evaluation
|
82 |
+
For evaluation results, see our paper: https://www.biorxiv.org/content/10.1101/2023.06.12.544594v1
|
83 |
+
|
84 |
+
## Citation
|
85 |
+
```bibtex
|
86 |
+
@article{GENA_LM,
|
87 |
+
author = {Veniamin Fishman and Yuri Kuratov and Maxim Petrov and Aleksei Shmelev and Denis Shepelin and Nikolay Chekanov and Olga Kardymon and Mikhail Burtsev},
|
88 |
+
title = {GENA-LM: A Family of Open-Source Foundational Models for Long DNA Sequences},
|
89 |
+
elocation-id = {2023.06.12.544594},
|
90 |
+
year = {2023},
|
91 |
+
doi = {10.1101/2023.06.12.544594},
|
92 |
+
publisher = {Cold Spring Harbor Laboratory},
|
93 |
+
URL = {https://www.biorxiv.org/content/early/2023/06/13/2023.06.12.544594},
|
94 |
+
eprint = {https://www.biorxiv.org/content/early/2023/06/13/2023.06.12.544594.full.pdf},
|
95 |
+
journal = {bioRxiv}
|
96 |
+
}
|
97 |
+
```
|