KeeeeepGoing
commited on
Commit
•
8a18b3d
1
Parent(s):
f4f7c37
Upload 8 files
Browse files- README.md +74 -3
- config.json +40 -0
- generation_config.json +7 -0
- model.safetensors +3 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +30 -0
- tokenizer_config.json +44 -0
- vocab.txt +27 -0
README.md
CHANGED
@@ -1,3 +1,74 @@
|
|
1 |
-
---
|
2 |
-
license: cc-by-nc-sa-4.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: cc-by-nc-sa-4.0
|
3 |
+
widget:
|
4 |
+
- text: AAAAGCGACATGACCAAACTGCCCCTCACCCGCCGCACTGATGACCGA
|
5 |
+
tags:
|
6 |
+
- DNA
|
7 |
+
- biology
|
8 |
+
- genomics
|
9 |
+
datasets:
|
10 |
+
- zhangtaolab/plant_reference_genomes
|
11 |
+
---
|
12 |
+
# Plant foundation DNA large language models
|
13 |
+
|
14 |
+
The plant DNA large language models (LLMs) contain a series of foundation models based on different model architectures, which are pre-trained on various plant reference genomes.
|
15 |
+
All the models have a comparable model size between 90 MB and 150 MB, BPE tokenizer is used for tokenization and 8000 tokens are included in the vocabulary.
|
16 |
+
|
17 |
+
|
18 |
+
**Developed by:** zhangtaolab
|
19 |
+
|
20 |
+
### Model Sources
|
21 |
+
|
22 |
+
- **Repository:** [Plant DNA LLMs](https://github.com/zhangtaolab/plant_DNA_LLMs)
|
23 |
+
- **Manuscript:** [Versatile applications of foundation DNA language models in plant genomes]()
|
24 |
+
|
25 |
+
### Architecture
|
26 |
+
|
27 |
+
The model is trained based on the Google Gemma model with modified config and tokenizer specific for DNA sequence.
|
28 |
+
|
29 |
+
### How to use
|
30 |
+
|
31 |
+
Install the runtime library first:
|
32 |
+
```bash
|
33 |
+
pip install transformers
|
34 |
+
```
|
35 |
+
|
36 |
+
Here is a simple code for inference:
|
37 |
+
```python
|
38 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
39 |
+
import torch
|
40 |
+
|
41 |
+
model_name = 'plant-dnabert-2mer'
|
42 |
+
# load model and tokenizer
|
43 |
+
model = AutoModelForCausalLM.from_pretrained(f'zhangtaolab/{model_name}', trust_remote_code=True)
|
44 |
+
tokenizer = AutoTokenizer.from_pretrained(f'zhangtaolab/{model_name}', trust_remote_code=True)
|
45 |
+
|
46 |
+
# example sequence and tokenization
|
47 |
+
sequences = ['ATATACGGCCGNC','GGGTATCGCTTCCGAC']
|
48 |
+
tokens = tokenizer(sequences,padding="longest")['input_ids']
|
49 |
+
print(f"Tokenzied sequence: {tokenizer.batch_decode(tokens)}")
|
50 |
+
|
51 |
+
# inference
|
52 |
+
device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
|
53 |
+
model.to(device)
|
54 |
+
inputs = tokenizer(sequences, truncation=True, padding='max_length', max_length=512,
|
55 |
+
return_tensors="pt")
|
56 |
+
inputs = {k: v.to(device) for k, v in inputs.items()}
|
57 |
+
outs = model(
|
58 |
+
**inputs,
|
59 |
+
output_hidden_states=True
|
60 |
+
)
|
61 |
+
|
62 |
+
# get the final layer embeddings and prediction logits
|
63 |
+
embeddings = outs['hidden_states'][-1].detach().numpy()
|
64 |
+
logits = outs['logits'].detach().numpy()
|
65 |
+
```
|
66 |
+
|
67 |
+
|
68 |
+
### Training data
|
69 |
+
We use CausalLM method to pre-train the model, the tokenized sequence have a maximum length of 512.
|
70 |
+
Detailed training procedure can be found in our manuscript.
|
71 |
+
|
72 |
+
|
73 |
+
#### Hardware
|
74 |
+
Model was pre-trained on a NVIDIA RTX4090 GPU (24 GB).
|
config.json
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "../model/PlantDna_Mamba_2mer",
|
3 |
+
"architectures": [
|
4 |
+
"MambaForCausalLM"
|
5 |
+
],
|
6 |
+
"bos_token_id": 0,
|
7 |
+
"conv_kernel": 4,
|
8 |
+
"d_inner": 1536,
|
9 |
+
"d_model": 768,
|
10 |
+
"eos_token_id": 0,
|
11 |
+
"expand": 2,
|
12 |
+
"fused_add_norm": true,
|
13 |
+
"hidden_act": "silu",
|
14 |
+
"hidden_size": 768,
|
15 |
+
"initializer_range": 0.1,
|
16 |
+
"intermediate_size": 1536,
|
17 |
+
"layer_norm_epsilon": 1e-05,
|
18 |
+
"model_type": "mamba",
|
19 |
+
"n_layer": 24,
|
20 |
+
"num_hidden_layers": 24,
|
21 |
+
"pad_token_id": 0,
|
22 |
+
"pad_vocab_size_multiple": 8,
|
23 |
+
"rescale_prenorm_residual": false,
|
24 |
+
"residual_in_fp32": true,
|
25 |
+
"rms_norm": true,
|
26 |
+
"ssm_cfg": {},
|
27 |
+
"state_size": 16,
|
28 |
+
"time_step_floor": 0.0001,
|
29 |
+
"time_step_init_scheme": "random",
|
30 |
+
"time_step_max": 0.1,
|
31 |
+
"time_step_min": 0.001,
|
32 |
+
"time_step_rank": 48,
|
33 |
+
"time_step_scale": 1.0,
|
34 |
+
"torch_dtype": "float32",
|
35 |
+
"transformers_version": "4.42.4",
|
36 |
+
"use_bias": false,
|
37 |
+
"use_cache": true,
|
38 |
+
"use_conv_bias": true,
|
39 |
+
"vocab_size": 27
|
40 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 0,
|
4 |
+
"eos_token_id": 0,
|
5 |
+
"pad_token_id": 0,
|
6 |
+
"transformers_version": "4.42.4"
|
7 |
+
}
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d57afc076da0bdb53da5fecc8a42413945c4e7c2ced0bb6fd35a11faf22c8d49
|
3 |
+
size 362190176
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:91c24a7b5c1a46b51f795a16865f8179aa1211d7c699fa3d955e33c9e423c66d
|
3 |
+
size 362241426
|
special_tokens_map.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cls_token": {
|
3 |
+
"content": "<cls>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"mask_token": {
|
10 |
+
"content": "<mask>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": {
|
17 |
+
"content": "<pad>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"unk_token": {
|
24 |
+
"content": "<unk>",
|
25 |
+
"lstrip": false,
|
26 |
+
"normalized": false,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
}
|
30 |
+
}
|
tokenizer_config.json
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"added_tokens_decoder": {
|
3 |
+
"0": {
|
4 |
+
"content": "<unk>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false,
|
9 |
+
"special": true
|
10 |
+
},
|
11 |
+
"1": {
|
12 |
+
"content": "<pad>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": false,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false,
|
17 |
+
"special": true
|
18 |
+
},
|
19 |
+
"2": {
|
20 |
+
"content": "<mask>",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": false,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false,
|
25 |
+
"special": true
|
26 |
+
},
|
27 |
+
"3": {
|
28 |
+
"content": "<cls>",
|
29 |
+
"lstrip": false,
|
30 |
+
"normalized": false,
|
31 |
+
"rstrip": false,
|
32 |
+
"single_word": false,
|
33 |
+
"special": true
|
34 |
+
}
|
35 |
+
},
|
36 |
+
"clean_up_tokenization_spaces": true,
|
37 |
+
"cls_token": "<cls>",
|
38 |
+
"eos_token": null,
|
39 |
+
"mask_token": "<mask>",
|
40 |
+
"model_max_length": 512,
|
41 |
+
"pad_token": "<pad>",
|
42 |
+
"tokenizer_class": "EsmTokenizer",
|
43 |
+
"unk_token": "<unk>"
|
44 |
+
}
|
vocab.txt
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<unk>
|
2 |
+
<pad>
|
3 |
+
<mask>
|
4 |
+
<cls>
|
5 |
+
AA
|
6 |
+
AT
|
7 |
+
AC
|
8 |
+
AG
|
9 |
+
TA
|
10 |
+
TT
|
11 |
+
TC
|
12 |
+
TG
|
13 |
+
CA
|
14 |
+
CT
|
15 |
+
CC
|
16 |
+
CG
|
17 |
+
GA
|
18 |
+
GT
|
19 |
+
GC
|
20 |
+
GG
|
21 |
+
A
|
22 |
+
T
|
23 |
+
C
|
24 |
+
G
|
25 |
+
N
|
26 |
+
<eos>
|
27 |
+
<bos>
|