初始化项目,由ModelHub XC社区提供模型

Model: UCL-CSSB/PlasmidGPT
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-07-20 20:37:11 +08:00
commit 4689177c55
9 changed files with 150271 additions and 0 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
model.safetensors filter=lfs diff=lfs merge=lfs -text

40
README.md Normal file
View File

@@ -0,0 +1,40 @@
---
license: mit
library_name: transformers
pipeline_tag: text-generation
tags:
- biology
- plasmid
- dna
- synthetic-biology
- gpt2
---
# PlasmidGPT
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).
## Quick start
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("UCL-CSSB/PlasmidGPT")
tokenizer = AutoTokenizer.from_pretrained("UCL-CSSB/PlasmidGPT")
input_ids = tokenizer("ATG", return_tensors="pt").input_ids
outputs = model.generate(input_ids, max_new_tokens=512, do_sample=True, temperature=1.0)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
## Citation
```bibtex
@article{shao2024plasmidgpt,
title = {{PlasmidGPT}: a generative framework for plasmid design and annotation},
author = {Shao, Bin},
journal = {bioRxiv},
year = {2024},
doi = {10.1101/2024.09.30.615762}
}
```

38
config.json Normal file
View File

@@ -0,0 +1,38 @@
{
"activation_function": "gelu_new",
"architectures": [
"GPT2LMHeadModel"
],
"attn_pdrop": 0.1,
"bos_token_id": 50256,
"embd_pdrop": 0.1,
"eos_token_id": 2,
"initializer_range": 0.02,
"layer_norm_epsilon": 1e-05,
"model_type": "gpt2",
"n_ctx": 2048,
"n_embd": 768,
"n_head": 12,
"n_inner": null,
"n_layer": 12,
"n_positions": 2048,
"reorder_and_upcast_attn": false,
"resid_pdrop": 0.1,
"scale_attn_by_inverse_layer_idx": false,
"scale_attn_weights": true,
"summary_activation": null,
"summary_first_dropout": 0.1,
"summary_proj_to_labels": true,
"summary_type": "cls_index",
"summary_use_proj": true,
"task_specific_params": {
"text-generation": {
"do_sample": true,
"max_length": 50
}
},
"torch_dtype": "float32",
"transformers_version": "4.55.4",
"use_cache": true,
"vocab_size": 30002
}

7
generation_config.json Normal file
View File

@@ -0,0 +1,7 @@
{
"_from_model_config": true,
"bos_token_id": 50256,
"eos_token_id": 2,
"pad_token_id": 3,
"transformers_version": "4.55.4"
}

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:02365cb1aa0e86be0439567e7a8d15b51234dfdc051025ab1b2e4b157923debb
size 438696576

23
special_tokens_map.json Normal file
View File

@@ -0,0 +1,23 @@
{
"bos_token": {
"content": "<s>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"eos_token": {
"content": "[SEP]",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"pad_token": {
"content": "[PAD]",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
}
}

35
test_generation.py Normal file
View File

@@ -0,0 +1,35 @@
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print(f"Using device: {device}")
model = AutoModelForCausalLM.from_pretrained(
"/Users/mcclainthiel/plasmidgpt-addgene-gpt2",
trust_remote_code=True
).to(device)
model.eval()
tokenizer = AutoTokenizer.from_pretrained(
"/Users/mcclainthiel/plasmidgpt-addgene-gpt2",
trust_remote_code=True
)
start_sequence = 'ATGGCTAGCGAATTCGGCGCGCCT'
print(f"Start sequence: {start_sequence}\n")
input_ids = tokenizer.encode(start_sequence, return_tensors='pt').to(device)
outputs = model.generate(
input_ids,
max_length=300,
num_return_sequences=1,
temperature=1.0,
do_sample=True,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id
)
generated_sequence = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(f"Generated sequence:\n{generated_sequence}\n")
print(f"Length: {len(generated_sequence)} bp")

150057
tokenizer.json Normal file

File diff suppressed because one or more lines are too long

67
tokenizer_config.json Normal file
View File

@@ -0,0 +1,67 @@
{
"added_tokens_decoder": {
"0": {
"content": "[UNK]",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"1": {
"content": "[CLS]",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"2": {
"content": "[SEP]",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"3": {
"content": "[PAD]",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"4": {
"content": "[MASK]",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"30000": {
"content": "<s>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"30001": {
"content": "</s>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
}
},
"bos_token": "<s>",
"clean_up_tokenization_spaces": false,
"eos_token": "[SEP]",
"extra_special_tokens": {},
"model_max_length": 1000000000000000019884624838656,
"pad_token": "[PAD]",
"tokenizer_class": "PreTrainedTokenizerFast"
}