Instructions to use zhangtaolab/plant-dnamamba-BPE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zhangtaolab/plant-dnamamba-BPE with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zhangtaolab/plant-dnamamba-BPE", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zhangtaolab/plant-dnamamba-BPE", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("zhangtaolab/plant-dnamamba-BPE", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zhangtaolab/plant-dnamamba-BPE with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zhangtaolab/plant-dnamamba-BPE" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zhangtaolab/plant-dnamamba-BPE", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/zhangtaolab/plant-dnamamba-BPE
- SGLang
How to use zhangtaolab/plant-dnamamba-BPE 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 "zhangtaolab/plant-dnamamba-BPE" \ --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": "zhangtaolab/plant-dnamamba-BPE", "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 "zhangtaolab/plant-dnamamba-BPE" \ --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": "zhangtaolab/plant-dnamamba-BPE", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use zhangtaolab/plant-dnamamba-BPE with Docker Model Runner:
docker model run hf.co/zhangtaolab/plant-dnamamba-BPE
Plant foundation DNA large language models
The plant DNA large language models (LLMs) contain a series of foundation models based on different model architectures, which are pre-trained on various plant reference genomes.
All the models have a comparable model size between 90 MB and 150 MB, BPE tokenizer is used for tokenization and 8000 tokens are included in the vocabulary.
Developed by: zhangtaolab
Model Sources
- Repository: Plant DNA LLMs
- Manuscript: PDLLMs: A group of tailored DNA large language models for analyzing plant genomes
Architecture
The model is trained based on the State-Space Mamba-130m model with modified tokenizer specific for DNA sequence.
How to use
Install the runtime library first:
pip install transformers
Here is a simple code for inference (Note that Mamba model requires NVIDIA GPU for inference):
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_name = 'plant-dnamamba-BPE'
# load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(f'zhangtaolab/{model_name}', trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(f'zhangtaolab/{model_name}', trust_remote_code=True)
# example sequence and tokenization
sequences = ['ATATACGGCCGNC','GGGTATCGCTTCCGAC']
tokens = tokenizer(sequences,padding="longest")['input_ids']
print(f"Tokenzied sequence: {tokenizer.batch_decode(tokens)}")
# inference
device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
model.to(device)
inputs = tokenizer(sequences, truncation=True, padding='max_length', max_length=512,
return_tensors="pt")
inputs = {k: v.to(device) for k, v in inputs.items()}
outs = model(
**inputs,
output_hidden_states=True
)
# get the final layer embeddings and prediction logits
embeddings = outs['hidden_states'][-1].detach().numpy()
logits = outs['logits'].detach().numpy()
Training data
We use CausalLM method to pre-train the model, the tokenized sequence have a maximum length of 512.
Detailed training procedure can be found in our manuscript.
Hardware
Model was pre-trained on a NVIDIA RTX4090 GPU (24 GB).
- Downloads last month
- 176