Text Generation
Transformers
Safetensors
gpt2
biology
plasmid
dna
synthetic-biology
grpo
reinforcement-learning
text-generation-inference
Instructions to use UCL-CSSB/PlasmidGPT-GRPO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use UCL-CSSB/PlasmidGPT-GRPO with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="UCL-CSSB/PlasmidGPT-GRPO")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("UCL-CSSB/PlasmidGPT-GRPO") model = AutoModelForCausalLM.from_pretrained("UCL-CSSB/PlasmidGPT-GRPO") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use UCL-CSSB/PlasmidGPT-GRPO with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "UCL-CSSB/PlasmidGPT-GRPO" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "UCL-CSSB/PlasmidGPT-GRPO", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/UCL-CSSB/PlasmidGPT-GRPO
- SGLang
How to use UCL-CSSB/PlasmidGPT-GRPO with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "UCL-CSSB/PlasmidGPT-GRPO" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "UCL-CSSB/PlasmidGPT-GRPO", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "UCL-CSSB/PlasmidGPT-GRPO" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "UCL-CSSB/PlasmidGPT-GRPO", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use UCL-CSSB/PlasmidGPT-GRPO with Docker Model Runner:
docker model run hf.co/UCL-CSSB/PlasmidGPT-GRPO
Camera-ready README: simplified to what-it-is / quick start / citation
Browse files
README.md
CHANGED
|
@@ -1,39 +1,23 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
library_name: transformers
|
| 4 |
-
|
|
|
|
| 5 |
tags:
|
| 6 |
-
- generated_from_trainer
|
| 7 |
-
- grpo
|
| 8 |
-
- trl
|
| 9 |
- biology
|
| 10 |
- plasmid
|
| 11 |
- dna
|
| 12 |
- synthetic-biology
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
-
|
| 16 |
-
pipeline_tag: text-generation
|
| 17 |
---
|
| 18 |
|
| 19 |
# PlasmidGPT-GRPO
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
##
|
| 24 |
-
|
| 25 |
-
This model is a fine-tuned version of [PlasmidGPT](https://huggingface.co/McClain/plasmidgpt-addgene-gpt2) optimized using GRPO to generate valid, functional plasmid sequences with:
|
| 26 |
-
- **Origin of replication (ORI)** - Required for plasmid maintenance
|
| 27 |
-
- **Antibiotic resistance marker (AMR)** - Required for selection
|
| 28 |
-
|
| 29 |
-
### Performance
|
| 30 |
-
|
| 31 |
-
At temperature 1.3, this model achieves:
|
| 32 |
-
- **90% QC pass rate** (valid ORI + AMR)
|
| 33 |
-
- **3 unique ORI types** (ColE1, Col(pHAD28), Col440I)
|
| 34 |
-
- **100% unique sequences** (no duplicates)
|
| 35 |
-
|
| 36 |
-
## Quick Start
|
| 37 |
|
| 38 |
```python
|
| 39 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
@@ -41,66 +25,20 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
| 41 |
model = AutoModelForCausalLM.from_pretrained("UCL-CSSB/PlasmidGPT-GRPO")
|
| 42 |
tokenizer = AutoTokenizer.from_pretrained("UCL-CSSB/PlasmidGPT-GRPO")
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
outputs = model.generate(
|
| 49 |
-
**inputs,
|
| 50 |
-
max_new_tokens=2000,
|
| 51 |
-
temperature=1.3,
|
| 52 |
-
do_sample=True,
|
| 53 |
-
pad_token_id=tokenizer.eos_token_id
|
| 54 |
-
)
|
| 55 |
-
|
| 56 |
-
sequence = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 57 |
-
print(sequence)
|
| 58 |
```
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
[<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="150" height="24"/>](https://wandb.ai/ucl-cssb/PlasmidRL/runs/u3wt9c50)
|
| 63 |
-
|
| 64 |
-
This model was trained with GRPO (Group Relative Policy Optimization), a method introduced in [DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models](https://huggingface.co/papers/2402.03300).
|
| 65 |
-
|
| 66 |
-
The reward function optimizes for:
|
| 67 |
-
1. Presence of a valid origin of replication (ORI)
|
| 68 |
-
2. Presence of a valid antibiotic resistance marker (AMR)
|
| 69 |
-
3. Absence of long repetitive sequences
|
| 70 |
-
|
| 71 |
-
### Framework Versions
|
| 72 |
-
|
| 73 |
-
- TRL: 0.23.1
|
| 74 |
-
- Transformers: 4.57.0
|
| 75 |
-
- PyTorch: 2.8.0
|
| 76 |
-
- Datasets: 4.1.1
|
| 77 |
-
- Tokenizers: 0.22.1
|
| 78 |
-
|
| 79 |
-
## Recommended Sampling Parameters
|
| 80 |
-
|
| 81 |
-
| Temperature | Pass Rate | ORI Diversity | Notes |
|
| 82 |
-
|-------------|-----------|---------------|-------|
|
| 83 |
-
| 0.8 | 37% | 1 type | Collapsed - avoid |
|
| 84 |
-
| 0.95 | 63% | 2 types | Conservative |
|
| 85 |
-
| 1.15 | 76% | 2 types | Balanced |
|
| 86 |
-
| **1.3** | **90%** | **3 types** | **Recommended** |
|
| 87 |
|
| 88 |
## Citation
|
| 89 |
|
| 90 |
```bibtex
|
| 91 |
-
@
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
}
|
| 97 |
-
|
| 98 |
-
@misc{vonwerra2022trl,
|
| 99 |
-
title={{TRL: Transformer Reinforcement Learning}},
|
| 100 |
-
author={Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
|
| 101 |
-
year=2020,
|
| 102 |
-
journal={GitHub repository},
|
| 103 |
-
publisher={GitHub},
|
| 104 |
-
howpublished={\url{https://github.com/huggingface/trl}}
|
| 105 |
}
|
| 106 |
```
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
library_name: transformers
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
base_model: UCL-CSSB/PlasmidGPT
|
| 6 |
tags:
|
|
|
|
|
|
|
|
|
|
| 7 |
- biology
|
| 8 |
- plasmid
|
| 9 |
- dna
|
| 10 |
- synthetic-biology
|
| 11 |
+
- gpt2
|
| 12 |
+
- grpo
|
| 13 |
+
- reinforcement-learning
|
|
|
|
| 14 |
---
|
| 15 |
|
| 16 |
# PlasmidGPT-GRPO
|
| 17 |
|
| 18 |
+
GRPO reinforcement-learning fine-tune of [PlasmidGPT](https://huggingface.co/UCL-CSSB/PlasmidGPT), trained against a multi-component biological reward (functional annotations, length prior, repeat penalty, cassette ordering). Camera-ready model for the ICML 2026 paper *Effects of Structural Reward Shaping on Biophysical Properties in RL-Trained Plasmid Generators*.
|
| 19 |
|
| 20 |
+
## Quick start
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
```python
|
| 23 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 25 |
model = AutoModelForCausalLM.from_pretrained("UCL-CSSB/PlasmidGPT-GRPO")
|
| 26 |
tokenizer = AutoTokenizer.from_pretrained("UCL-CSSB/PlasmidGPT-GRPO")
|
| 27 |
|
| 28 |
+
input_ids = tokenizer("ATG", return_tensors="pt").input_ids
|
| 29 |
+
outputs = model.generate(input_ids, max_new_tokens=512, do_sample=True, temperature=1.0)
|
| 30 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
```
|
| 32 |
|
| 33 |
+
Recommended sampling: T=1.0 for direct generation, T=1.15 for rejection sampling (per the paper).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
## Citation
|
| 36 |
|
| 37 |
```bibtex
|
| 38 |
+
@inproceedings{thiel2026plasmidrl,
|
| 39 |
+
title = {Effects of Structural Reward Shaping on Biophysical Properties in {RL}-Trained Plasmid Generators},
|
| 40 |
+
author = {Thiel, McClain and Cunningham, Angus G. and Barnes, Chris P.},
|
| 41 |
+
booktitle = {Proceedings of the 43rd International Conference on Machine Learning},
|
| 42 |
+
year = {2026}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
```
|