Text Generation
Transformers
Safetensors
gpt2
biology
plasmid
dna
synthetic-biology
grpo
reinforcement-learning
Eval Results (legacy)
text-generation-inference
Run this model with HF Jobs
Run UCL-CSSB/PlasmidGPT-GRPO on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/UCL-CSSB/PlasmidGPT-GRPO. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/UCL-CSSB/PlasmidGPT-GRPO on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/UCL-CSSB/PlasmidGPT-GRPO. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/UCL-CSSB/PlasmidGPT-GRPO. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
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")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("UCL-CSSB/PlasmidGPT-GRPO") model = AutoModelForCausalLM.from_pretrained("UCL-CSSB/PlasmidGPT-GRPO", device_map="auto") - 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
Refresh weights and simplify README; add W&B link (#2)
Browse files- Refresh weights and simplify README; add W&B link (1e95a81160aba55b4ac82ad9a9ec156bc5f68318)
Files changed (2)
- README.md+34-247
- model.safetensors+1-1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258# PlasmidGPT-GRPO: Reinforcement Learning Fine-tuned Plasmid Generator[](https://wandb.ai/ucl-cssb/PlasmidRL/runs/u3wt9c50)**A biologically-constrained plasmid design model trained with reinforcement learning to generate functional DNA sequences.**This model is a fine-tuned version of [McClain/plasmidgpt-addgene-gpt2](https://huggingface.co/McClain/plasmidgpt-addgene-gpt2) (itself based on the original [PlasmidGPT](https://github.com/lingxusb/PlasmidGPT) by Bin Shao), optimized using **Group Relative Policy Optimization (GRPO)** to generate plasmids that satisfy biological constraints.## π― Key Improvements Over Base ModelThis RL-fine-tuned model has been trained to generate plasmids that:- β Contain **correct numbers** of essential genetic elements (ori, promoters, terminators, markers, CDS)- β Avoid **repeat regions** (>50 bp repeats penalized)- β Generate **shorter, more efficient** sequences (rewarded for compactness)- β Maintain **proper gene cassette organization** (promoter β CDS β terminator)- β Achieve up to **1.0 reward score** for optimal plasmid design### Reward StructureThe model was trained using a custom bioinformatics reward function that scores sequences based on:| Component | Min | Max | Weight | Description ||-----------|-----|-----|--------|-------------|| **Origin of Replication (ori)** | 1 | 1 | 1.5Γ | Essential for plasmid replication || **Promoters** | 1 | 1 | 1.0Γ | Drive gene expression || **Terminators** | 0 | 2 | 0.5Γ | Stop transcription || **Selectable Markers** | 1 | 2 | 1.0Γ | Antibiotic resistance || **Coding Sequences (CDS)** | 1 | 5 | 1.0Γ | Functional genes |**Additional Scoring:**- **Repeat Penalty**: -0.1 per repeat region β₯50 bp (including reverse complements)- **Length Bonus**: Rewards for shorter, more compact sequences (up to +0.5)- **Location Awareness**: Bonuses for correct gene cassette ordering and proximity**Maximum reward:** 1.0 (perfect plasmid with all constraints satisfied)## π Quick Start### Basic Sequence Generation```pythonimport torchfrom transformers import AutoTokenizer, AutoModelForCausalLMdevice = 'cuda' if torch.cuda.is_available() else 'cpu'model = AutoModelForCausalLM.from_pretrained("McClain/plasmidgpt-grpo-rl",trust_remote_code=True).to(device)model.eval()tokenizer = AutoTokenizer.from_pretrained("McClain/plasmidgpt-grpo-rl",trust_remote_code=True)# Generate optimized plasmid sequencestart_sequence = 'ATGGCTAGCGAATTC'input_ids = tokenizer.encode(start_sequence, return_tensors='pt').to(device)outputs = model.generate(input_ids,max_length=400,num_return_sequences=5,temperature=0.8,do_sample=True,top_k=50,top_p=0.95,pad_token_id=tokenizer.pad_token_id,eos_token_id=tokenizer.eos_token_id)for i, output in enumerate(outputs):sequence = tokenizer.decode(output, skip_special_tokens=True)print(f"Plasmid {i+1}: {len(sequence)} bp")```### Scoring Generated PlasmidsTo evaluate plasmids using the same reward function from training:```python# Install plasmidkit for annotation# pip install plasmidkitfrom plasmidrl.rewards import Scorer, RewardConfig# Use the same config as trainingreward_config = RewardConfig(punish_mode=True,length_reward_mode=False,repeat_penalty_enabled=True,repeat_min_length=50,repeat_penalty_per_region=0.1,ori_min=1, ori_max=1, ori_weight=1.5,promoter_min=1, promoter_max=1, promoter_weight=1.0,terminator_min=0, terminator_max=2, terminator_weight=0.5,marker_min=1, marker_max=2, marker_weight=1.0,cds_min=1, cds_max=5, cds_weight=1.0,location_aware=True)scorer = Scorer(reward_config)score, components = scorer.score(generated_sequence)print(f"Reward Score: {score:.3f}")print(f"Components: {components}")```## π Training Details### Training Configuration- **Base Model**: [McClain/plasmidgpt-addgene-gpt2](https://huggingface.co/McClain/plasmidgpt-addgene-gpt2)- **RL Algorithm**: GRPO (Group Relative Policy Optimization)- **Training Steps**: 2,500 steps- **Training Repository**: [PlasmidRL](https://github.com/McClain-Thiel/PlasmidRL)- **W&B Run**: [u3wt9c50](https://wandb.ai/ucl-cssb/PlasmidRL/runs/u3wt9c50)### Model Architecture| Parameter | Value ||-----------|-------|| **Architecture** | GPT-2 (Decoder-only Transformer) || **Parameters** | 110 million || **Layers** | 12 || **Hidden Size** | 768 || **Attention Heads** | 12 || **Context Length** | 2048 tokens || **Vocabulary Size** | 30,002 |### Framework Versions- **TRL**: 0.23.1- **Transformers**: 4.57.0- **PyTorch**: 2.8.0- **Datasets**: 4.1.1- **Tokenizers**: 0.22.1## 𧬠Use Cases1. **Optimized Plasmid Design**: Generate plasmids that satisfy specific biological constraints2. **Synthetic Biology**: Create novel genetic constructs for molecular cloning3. **Gene Cassette Engineering**: Design properly organized promoter-CDS-terminator cassettes4. **Compact Plasmid Construction**: Generate shorter plasmids while maintaining functionality5. **Repeat-Free Sequences**: Avoid problematic repeat regions in plasmid design## π Related Resources### Original PlasmidGPTThis model builds upon the original PlasmidGPT work:- **Paper**: [PlasmidGPT: a generative framework for plasmid design and annotation](https://www.biorxiv.org/content/10.1101/2024.09.30.615762v1) (bioRxiv 2024.09.30.615762)- **Author**: Bin Shao (lingxusb)- **Original Repository**: [github.com/lingxusb/PlasmidGPT](https://github.com/lingxusb/PlasmidGPT)- **Original Model**: [huggingface.co/lingxusb/PlasmidGPT](https://huggingface.co/lingxusb/PlasmidGPT)### Training Infrastructure- **Training Code**: [github.com/McClain-Thiel/PlasmidRL](https://github.com/McClain-Thiel/PlasmidRL)- **W&B Project**: [ucl-cssb/PlasmidRL](https://wandb.ai/ucl-cssb/PlasmidRL)- **Base Model**: [McClain/plasmidgpt-addgene-gpt2](https://huggingface.co/McClain/plasmidgpt-addgene-gpt2)## π CitationsIf you use this model, please cite:### This RL Model```bibtex@misc{thiel2024plasmidgpt_grpo,title={PlasmidGPT-GRPO: Reinforcement Learning for Functional Plasmid Design},author={Thiel, McClain},year={2024},howpublished={\url{https://github.com/McClain-Thiel/PlasmidRL}},note={Training run: https://wandb.ai/ucl-cssb/PlasmidRL/runs/u3wt9c50}}```### Original PlasmidGPT```bibtex@article{shao2024plasmidgpt,title={PlasmidGPT: a generative framework for plasmid design and annotation},author={Shao, Bin and others},journal={bioRxiv},year={2024},doi={10.1101/2024.09.30.615762},url={https://www.biorxiv.org/content/10.1101/2024.09.30.615762v1}}```### GRPO Algorithm```bibtex@article{shao2024deepseekmath,title={{DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models}},author={Zhihong Shao and Peiyi Wang and Qihao Zhu and Runxin Xu and Junxiao Song and Mingchuan Zhang and Y. K. Li and Y. Wu and Daya Guo},journal={arXiv preprint arXiv:2402.03300},year={2024}}```### TRL Library```bibtex@misc{vonwerra2022trl,title={{TRL: Transformer Reinforcement Learning}},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},year={2020},publisher={GitHub},howpublished={\url{https://github.com/huggingface/trl}}}```## βοΈ Technical Details### Reward Function ComponentsThe bioinformatics reward function (`src/rewards/bioinformatics/scorer.py`) includes:1. **Feature Counting**: Uses [PlasmidKit](https://github.com/jbloomlab/plasmidkit) for automated annotation2. **Overlap Merging**: Intelligently merges overlapping features (80% threshold)3. **CDS Filtering**: Removes CDS annotations overlapping with ori/promoter/terminator/marker4. **Strand Awareness**: Considers strand orientation for gene cassette scoring5. **Repeat Detection**: Finds direct and reverse complement repeats using k-mer indexing6. **Proximity Scoring**: Rewards features within 300 bp for proper cassette formation### Training HyperparametersView complete hyperparameters and metrics on [W&B](https://wandb.ai/ucl-cssb/PlasmidRL/runs/u3wt9c50).## β οΈ Important Notes- **Research Use Only**: Generated plasmids should be validated before experimental use- **Annotation Dependency**: Scoring requires `plasmidkit` for feature annotation- **Compute Requirements**: GPU recommended for generation (CPU fallback available)- **Sequence Validation**: Always verify generated sequences contain expected features## π LicenseThis model inherits licensing from the original PlasmidGPT repository. Please refer to the [original repository](https://github.com/lingxusb/PlasmidGPT) for details.## π Acknowledgments- **Bin Shao (lingxusb)** for the original PlasmidGPT model and architecture- **Addgene** for providing the training data (153k plasmid sequences)- **HuggingFace TRL team** for the GRPO implementation- **UCL CSSB** for computational resources---**Model Version**: grpo-production-20251110_132247**Training Date**: November 10, 2025**Last Updated**: November 13, 2025123456789101112131415161718192021222324252627282930313233343536373839404142434445# PlasmidGPT-GRPOPlasmidGPT-GRPO is a GRPO-trained causal language model for plasmid/DNA sequence generation.This update refreshes the weights (model.safetensors) and streamlines the documentation.## Weights- `model.safetensors` (updated)- All tokenizer/config files remain unchanged.## Training Run- Weights and metrics: https://wandb.ai/ucl-cssb/PlasmidRL/runs/ty13u43j/overview## UsageInstall:```pip install torch transformers safetensors```Load and generate:```from transformers import AutoModelForCausalLM, AutoTokenizermodel_id = "UCL-CSSB/PlasmidGPT-GRPO"tok = AutoTokenizer.from_pretrained(model_id)if tok.pad_token is None:tok.pad_token = tok.eos_tokenmodel = AutoModelForCausalLM.from_pretrained(model_id)inputs = tok(["ATG"], return_tensors="pt")out = model.generate(**inputs,max_new_tokens=128,do_sample=True,temperature=0.7,top_p=0.9,pad_token_id=tok.eos_token_id,eos_token_id=tok.eos_token_id,)print(tok.decode(out[0], skip_special_tokens=True))```Notes:- Use sampling (temperature/top_p) for diverse sequences; disable for deterministic output.- Runs on CPU, CUDA, or Apple MPS depending on your PyTorch install.
123version https://git-lfs.github.com/spec/v1oid sha256:ba508e7a9d4bfb9c095f95c11fe0e7a1131f6a9076e89852bdd22f67ca00c324size 438696576123version https://git-lfs.github.com/spec/v1oid sha256:353de867743e69096257539c5ae44131947d9e41ef8a9a0ffdd863b3cff9eee6size 438696576
README.md+34-247
model.safetensors+1-1