lgq12697 commited on
Commit
f79a9ce
1 Parent(s): 4261a94

Add Plant DNAMamba model

Browse files
README.md CHANGED
@@ -1,3 +1,75 @@
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
+ inference: false
6
+ tags:
7
+ - DNA
8
+ - biology
9
+ - genomics
10
+ datasets:
11
+ - zhangtaolab/plant_reference_genomes
12
+ ---
13
+ # Plant foundation DNA large language models
14
+
15
+ 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.
16
+ 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.
17
+
18
+
19
+ **Developed by:** zhangtaolab
20
+
21
+ ### Model Sources
22
+
23
+ - **Repository:** [Plant DNA LLMs](https://github.com/zhangtaolab/plant_DNA_LLMs)
24
+ - **Manuscript:** [Versatile applications of foundation DNA language models in plant genomes]()
25
+
26
+ ### Architecture
27
+
28
+ The model is trained based on the State-Space Mamba-130m model with modified tokenizer specific for DNA sequence.
29
+
30
+ ### How to use
31
+
32
+ Install the runtime library first:
33
+ ```bash
34
+ pip install transformers
35
+ ```
36
+
37
+ Here is a simple code for inference (Note that Mamba model requires NVIDIA GPU for inference):
38
+ ```python
39
+ from transformers import AutoModelForCausalLM, AutoTokenizer
40
+ import torch
41
+
42
+ model_name = 'plant-dnamamba'
43
+ # load model and tokenizer
44
+ model = AutoModelForCausalLM.from_pretrained(f'zhangtaolab/{model_name}', trust_remote_code=True)
45
+ tokenizer = AutoTokenizer.from_pretrained(f'zhangtaolab/{model_name}', trust_remote_code=True)
46
+
47
+ # example sequence and tokenization
48
+ sequences = ['ATATACGGCCGNC','GGGTATCGCTTCCGAC']
49
+ tokens = tokenizer(sequences,padding="longest")['input_ids']
50
+ print(f"Tokenzied sequence: {tokenizer.batch_decode(tokens)}")
51
+
52
+ # inference
53
+ device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
54
+ model.to(device)
55
+ inputs = tokenizer(sequences, truncation=True, padding='max_length', max_length=512,
56
+ return_tensors="pt")
57
+ inputs = {k: v.to(device) for k, v in inputs.items()}
58
+ outs = model(
59
+ **inputs,
60
+ output_hidden_states=True
61
+ )
62
+
63
+ # get the final layer embeddings and prediction logits
64
+ embeddings = outs['hidden_states'][-1].detach().numpy()
65
+ logits = outs['logits'].detach().numpy()
66
+ ```
67
+
68
+
69
+ ### Training data
70
+ We use CausalLM method to pre-train the model, the tokenized sequence have a maximum length of 512.
71
+ Detailed training procedure can be found in our manuscript.
72
+
73
+
74
+ #### Hardware
75
+ Model was pre-trained on a NVIDIA RTX4090 GPU (24 GB).
config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "Plant_DNAMamba",
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.39.1",
36
+ "use_bias": false,
37
+ "use_cache": true,
38
+ "use_conv_bias": true,
39
+ "vocab_size": 8000
40
+ }
config.json.bak ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "d_model": 768,
3
+ "n_layer": 24,
4
+ "vocab_size": 8000,
5
+ "ssm_cfg": {},
6
+ "rms_norm": true,
7
+ "residual_in_fp32": true,
8
+ "fused_add_norm": true,
9
+ "pad_vocab_size_multiple": 8
10
+ }
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.39.1"
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e9aa13208d5f709cba91b5e2bbb3ceac274c826ce321507de982d7b3bd9d695
3
+ size 386683304
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a3bc7a5023da7b7b1320df7fb304fbb7e1c88a835d7770567b18c207a1b6f7e
3
+ size 386734482
special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<|endoftext|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<|endoftext|>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<|padding|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ }
20
+ },
21
+ "bos_token": "<|endoftext|>",
22
+ "clean_up_tokenization_spaces": true,
23
+ "eos_token": "<|endoftext|>",
24
+ "max_length": 1024,
25
+ "model_max_length": 1000000000000000019884624838656,
26
+ "pad_token": "<|endoftext|>",
27
+ "stride": 0,
28
+ "tokenizer_class": "GPTNeoXTokenizer",
29
+ "truncation_side": "right",
30
+ "truncation_strategy": "longest_first",
31
+ "unk_token": "<|endoftext|>"
32
+ }