Text Generation
Transformers
Safetensors
gpt2
Generated from Trainer
grpo
trl
plasmid
biology
dna
text-generation-inference
Instructions to use McClain/PlasmidGPT-RL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use McClain/PlasmidGPT-RL with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="McClain/PlasmidGPT-RL")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("McClain/PlasmidGPT-RL") model = AutoModelForCausalLM.from_pretrained("McClain/PlasmidGPT-RL", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use McClain/PlasmidGPT-RL with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "McClain/PlasmidGPT-RL" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "McClain/PlasmidGPT-RL", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/McClain/PlasmidGPT-RL
- SGLang
How to use McClain/PlasmidGPT-RL 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 "McClain/PlasmidGPT-RL" \ --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": "McClain/PlasmidGPT-RL", "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 "McClain/PlasmidGPT-RL" \ --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": "McClain/PlasmidGPT-RL", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use McClain/PlasmidGPT-RL with Docker Model Runner:
docker model run hf.co/McClain/PlasmidGPT-RL
Remove test_generation.py
Browse files- test_generation.py +0 -51
test_generation.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
-
|
| 4 |
-
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 5 |
-
print(f"Using device: {device}\n")
|
| 6 |
-
|
| 7 |
-
print("Loading RL-optimized PlasmidGPT-GRPO model...")
|
| 8 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 9 |
-
".",
|
| 10 |
-
trust_remote_code=True
|
| 11 |
-
).to(device)
|
| 12 |
-
model.eval()
|
| 13 |
-
|
| 14 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
| 15 |
-
".",
|
| 16 |
-
trust_remote_code=True
|
| 17 |
-
)
|
| 18 |
-
|
| 19 |
-
print("Generating optimized plasmid sequences...\n")
|
| 20 |
-
|
| 21 |
-
start_sequence = 'ATGGCTAGCGAATTCGGCGCGCCT'
|
| 22 |
-
print(f"Start sequence: {start_sequence}\n")
|
| 23 |
-
|
| 24 |
-
input_ids = tokenizer.encode(start_sequence, return_tensors='pt').to(device)
|
| 25 |
-
|
| 26 |
-
outputs = model.generate(
|
| 27 |
-
input_ids,
|
| 28 |
-
max_length=400,
|
| 29 |
-
num_return_sequences=3,
|
| 30 |
-
temperature=0.8,
|
| 31 |
-
do_sample=True,
|
| 32 |
-
top_k=50,
|
| 33 |
-
top_p=0.95,
|
| 34 |
-
pad_token_id=tokenizer.pad_token_id,
|
| 35 |
-
eos_token_id=tokenizer.eos_token_id
|
| 36 |
-
)
|
| 37 |
-
|
| 38 |
-
print("=" * 80)
|
| 39 |
-
for i, output in enumerate(outputs, 1):
|
| 40 |
-
sequence = tokenizer.decode(output, skip_special_tokens=True)
|
| 41 |
-
print(f"\nPlasmid {i}:")
|
| 42 |
-
print(f" Length: {len(sequence)} bp")
|
| 43 |
-
print(f" First 100 bp: {sequence[:100]}")
|
| 44 |
-
print(f" Last 100 bp: {sequence[-100:]}")
|
| 45 |
-
print("\n" + "=" * 80)
|
| 46 |
-
|
| 47 |
-
print("\nNote: These sequences are generated by an RL-optimized model trained to:")
|
| 48 |
-
print(" ✓ Include proper genetic elements (ori, promoters, CDS, markers)")
|
| 49 |
-
print(" ✓ Avoid repeat regions > 50 bp")
|
| 50 |
-
print(" ✓ Generate compact, functional plasmids")
|
| 51 |
-
print(" ✓ Organize genes in proper cassettes (promoter → CDS → terminator)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|