Safetensors
gpt2
DNA
biology
genomics
lgq12697 commited on
Commit
56f1c7d
1 Parent(s): e0c48ff

Upload 7 files

Browse files
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 OpenAI GPT-2 model with modified 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-dnagpt-singlebase'
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,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "Plant_DNAGPT_singlebase",
3
+ "activation_function": "gelu_new",
4
+ "architectures": [
5
+ "GPT2LMHeadModel"
6
+ ],
7
+ "attn_pdrop": 0.1,
8
+ "bos_token_id": 10,
9
+ "embd_pdrop": 0.1,
10
+ "eos_token_id": 9,
11
+ "initializer_range": 0.02,
12
+ "layer_norm_epsilon": 1e-05,
13
+ "model_type": "gpt2",
14
+ "n_ctx": 512,
15
+ "n_embd": 768,
16
+ "n_head": 12,
17
+ "n_inner": null,
18
+ "n_layer": 12,
19
+ "n_positions": 1024,
20
+ "reorder_and_upcast_attn": false,
21
+ "resid_pdrop": 0.1,
22
+ "scale_attn_by_inverse_layer_idx": false,
23
+ "scale_attn_weights": true,
24
+ "summary_activation": null,
25
+ "summary_first_dropout": 0.1,
26
+ "summary_proj_to_labels": true,
27
+ "summary_type": "cls_index",
28
+ "summary_use_proj": true,
29
+ "task_specific_params": {
30
+ "text-generation": {
31
+ "do_sample": true,
32
+ "max_length": 50
33
+ }
34
+ },
35
+ "torch_dtype": "float32",
36
+ "transformers_version": "4.42.2",
37
+ "use_cache": true,
38
+ "vocab_size": 11
39
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 10,
4
+ "eos_token_id": 9,
5
+ "transformers_version": "4.42.2"
6
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b7f6e2e3021fb13e70fc86fe598d4903f19d1ab65edc8b7902360bb32a30f946
3
+ size 343418496
special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "<cls>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": "<eos>",
10
+ "mask_token": {
11
+ "content": "<mask>",
12
+ "lstrip": false,
13
+ "normalized": false,
14
+ "rstrip": false,
15
+ "single_word": false
16
+ },
17
+ "pad_token": {
18
+ "content": "<pad>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "unk_token": {
25
+ "content": "<unk>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "9": {
36
+ "content": "<eos>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "<cls>",
46
+ "eos_token": "<eos>",
47
+ "mask_token": "<mask>",
48
+ "model_max_length": 512,
49
+ "pad_token": "<pad>",
50
+ "tokenizer_class": "EsmTokenizer",
51
+ "unk_token": "<unk>"
52
+ }
vocab.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <unk>
2
+ <pad>
3
+ <mask>
4
+ <cls>
5
+ A
6
+ T
7
+ C
8
+ G
9
+ N
10
+ <eos>
11
+ <bos>