McClain commited on
Commit
843dff7
·
verified ·
1 Parent(s): 67d3233

Camera-ready README: simplified to what-it-is / quick start / citation

Browse files
Files changed (1) hide show
  1. README.md +26 -151
README.md CHANGED
@@ -1,165 +1,40 @@
1
- # PlasmidGPT (Addgene GPT-2 Compatible Version)
 
 
 
 
 
 
 
 
 
 
2
 
3
- This is a **compatibility-enhanced version** of [PlasmidGPT](https://github.com/lingxusb/PlasmidGPT) by Bin Shao (lingxusb), optimized for easier integration with modern transformers libraries and HuggingFace infrastructure.
4
 
5
- ## 🔬 About PlasmidGPT
6
 
7
- PlasmidGPT is a generative language model pretrained on 153,000 engineered plasmid sequences from [Addgene](https://www.addgene.org/). It generates de novo plasmid sequences that share similar characteristics with engineered plasmids while maintaining low sequence identity to training data. The model can generate plasmids in a controlled manner based on input sequences or specific design constraints, and learns informative embeddings for both engineered and natural plasmids.
8
-
9
- **Original work:** [PlasmidGPT: a generative framework for plasmid design and annotation](https://www.biorxiv.org/content/10.1101/2024.09.30.615762v1)
10
- **Original repository:** [github.com/lingxusb/PlasmidGPT](https://github.com/lingxusb/PlasmidGPT)
11
- **Original model:** [huggingface.co/lingxusb/PlasmidGPT](https://huggingface.co/lingxusb/PlasmidGPT)
12
-
13
- ### Key Features
14
-
15
- - **Novel Sequence Generation**: Generates novel plasmid sequences rather than replicating training data
16
- - **Conditional Generation**: Supports generation based on user-specified starting sequences
17
- - **Versatile Predictions**: Predicts sequence-related attributes including lab of origin, species, and vector type
18
- - **Transformer Architecture**: Decoder-only transformer with 12 layers and 110 million parameters
19
-
20
- ## 🆚 Differences from Original
21
-
22
- This version provides:
23
- - ✅ Native HuggingFace `transformers` compatibility (no custom loading required)
24
- - ✅ Standard model format (`model.safetensors` instead of `.pt`)
25
- - ✅ Direct `AutoModel` and `AutoTokenizer` support
26
- - ✅ Simplified installation and usage
27
-
28
- ## 📦 Installation
29
-
30
- ```bash
31
- pip install torch transformers
32
- ```
33
-
34
- ## 🚀 Quick Start
35
-
36
- ### Basic Sequence Generation
37
-
38
- ```python
39
- import torch
40
- from transformers import AutoTokenizer, AutoModelForCausalLM
41
-
42
- device = 'cuda' if torch.cuda.is_available() else 'cpu'
43
-
44
- model = AutoModelForCausalLM.from_pretrained(
45
- "McClain/plasmidgpt-addgene-gpt2",
46
- trust_remote_code=True
47
- ).to(device)
48
- model.eval()
49
-
50
- tokenizer = AutoTokenizer.from_pretrained(
51
- "McClain/plasmidgpt-addgene-gpt2",
52
- trust_remote_code=True
53
- )
54
-
55
- start_sequence = 'ATGGCTAGCGAATTCGGCGCGCCT'
56
- input_ids = tokenizer.encode(start_sequence, return_tensors='pt').to(device)
57
-
58
- outputs = model.generate(
59
- input_ids,
60
- max_length=300,
61
- num_return_sequences=1,
62
- temperature=1.0,
63
- do_sample=True,
64
- pad_token_id=tokenizer.pad_token_id,
65
- eos_token_id=tokenizer.eos_token_id
66
- )
67
-
68
- generated_sequence = tokenizer.decode(outputs[0], skip_special_tokens=True)
69
- print(f"Generated sequence: {generated_sequence}")
70
- ```
71
-
72
- ### Generate Multiple Sequences
73
 
74
  ```python
75
- outputs = model.generate(
76
- input_ids,
77
- max_length=500,
78
- num_return_sequences=5,
79
- temperature=1.2,
80
- do_sample=True,
81
- top_k=50,
82
- top_p=0.95,
83
- pad_token_id=tokenizer.pad_token_id,
84
- eos_token_id=tokenizer.eos_token_id
85
- )
86
-
87
- for i, output in enumerate(outputs):
88
- sequence = tokenizer.decode(output, skip_special_tokens=True)
89
- print(f"Sequence {i+1}: {sequence[:100]}...")
90
- ```
91
 
92
- ### Extract Embeddings
93
-
94
- ```python
95
- model.config.output_hidden_states = True
96
 
97
- with torch.no_grad():
98
- input_ids = tokenizer.encode("ATGCGTACG...", return_tensors='pt').to(device)
99
- outputs = model(input_ids)
100
- hidden_states = outputs.hidden_states[-1]
101
- embedding = hidden_states.mean(dim=1).cpu().numpy()
102
-
103
- print(f"Embedding shape: {embedding.shape}")
104
  ```
105
 
106
- ## 🎯 Use Cases
107
-
108
- - **Plasmid Design**: Generate novel plasmid sequences for synthetic biology applications
109
- - **Sequence Analysis**: Extract meaningful embeddings for downstream ML tasks
110
- - **Feature Prediction**: Predict properties like lab of origin, species, or vector type
111
- - **Conditional Generation**: Create sequences starting from specific promoters or genes
112
-
113
- ## 📊 Model Details
114
-
115
- | Parameter | Value |
116
- |-----------|-------|
117
- | **Architecture** | GPT-2 (Decoder-only Transformer) |
118
- | **Parameters** | 110 million |
119
- | **Layers** | 12 |
120
- | **Hidden Size** | 768 |
121
- | **Attention Heads** | 12 |
122
- | **Context Length** | 2048 tokens |
123
- | **Vocabulary Size** | 30,002 |
124
- | **Training Data** | 153k Addgene plasmid sequences |
125
-
126
- ## 📚 Citation
127
-
128
- If you use this model, please cite the original PlasmidGPT paper:
129
 
130
  ```bibtex
131
  @article{shao2024plasmidgpt,
132
- title={PlasmidGPT: a generative framework for plasmid design and annotation},
133
- author={Shao, Bin and others},
134
- journal={bioRxiv},
135
- year={2024},
136
- doi={10.1101/2024.09.30.615762},
137
- url={https://www.biorxiv.org/content/10.1101/2024.09.30.615762v1}
138
  }
139
  ```
140
-
141
- ## 📄 License
142
-
143
- This model inherits the license from the original PlasmidGPT repository. Please refer to the [original repository](https://github.com/lingxusb/PlasmidGPT) for licensing details.
144
-
145
- ## 🙏 Credits
146
-
147
- **Original Author:** Bin Shao (lingxusb)
148
- **Original Work:** [PlasmidGPT GitHub Repository](https://github.com/lingxusb/PlasmidGPT)
149
- **Paper:** [bioRxiv 2024.09.30.615762](https://www.biorxiv.org/content/10.1101/2024.09.30.615762v1)
150
-
151
- This compatibility version was created to facilitate easier integration with modern ML workflows while preserving all capabilities of the original model.
152
-
153
- ## 🔗 Related Resources
154
-
155
- - [Original PlasmidGPT Repository](https://github.com/lingxusb/PlasmidGPT)
156
- - [Original HuggingFace Model](https://huggingface.co/lingxusb/PlasmidGPT)
157
- - [PlasmidGPT Paper (bioRxiv)](https://www.biorxiv.org/content/10.1101/2024.09.30.615762v1)
158
- - [Addgene Plasmid Repository](https://www.addgene.org/)
159
-
160
- ## ⚠️ Notes
161
-
162
- - The model generates DNA sequences for research purposes
163
- - Generated sequences should be validated before experimental use
164
- - The model was trained on Addgene plasmids and performs best on similar sequence types
165
- - For prediction tasks (lab, species, vector type), refer to the [original repository](https://github.com/lingxusb/PlasmidGPT) for prediction model weights
 
1
+ ---
2
+ license: mit
3
+ library_name: transformers
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - biology
7
+ - plasmid
8
+ - dna
9
+ - synthetic-biology
10
+ - gpt2
11
+ ---
12
 
13
+ # PlasmidGPT
14
 
15
+ A HuggingFace-compatible repackaging of [PlasmidGPT](https://github.com/lingxusb/PlasmidGPT) (Shao, 2024) — a GPT-2-style decoder pretrained on 153k engineered plasmid sequences from Addgene. Loadable with standard `AutoModelForCausalLM` and `AutoTokenizer`. Used as the base for [PlasmidGPT-SFT](https://huggingface.co/UCL-CSSB/PlasmidGPT-SFT) and [PlasmidGPT-GRPO](https://huggingface.co/UCL-CSSB/PlasmidGPT-GRPO).
16
 
17
+ ## Quick start
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  ```python
20
+ from transformers import AutoModelForCausalLM, AutoTokenizer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ model = AutoModelForCausalLM.from_pretrained("UCL-CSSB/PlasmidGPT")
23
+ tokenizer = AutoTokenizer.from_pretrained("UCL-CSSB/PlasmidGPT")
 
 
24
 
25
+ input_ids = tokenizer("ATG", return_tensors="pt").input_ids
26
+ outputs = model.generate(input_ids, max_new_tokens=512, do_sample=True, temperature=1.0)
27
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
 
 
 
 
28
  ```
29
 
30
+ ## Citation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  ```bibtex
33
  @article{shao2024plasmidgpt,
34
+ title = {{PlasmidGPT}: a generative framework for plasmid design and annotation},
35
+ author = {Shao, Bin},
36
+ journal = {bioRxiv},
37
+ year = {2024},
38
+ doi = {10.1101/2024.09.30.615762}
 
39
  }
40
  ```