Instructions to use goodarzilab/decodon-200M-euk with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use goodarzilab/decodon-200M-euk with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="goodarzilab/decodon-200M-euk", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("goodarzilab/decodon-200M-euk", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use goodarzilab/decodon-200M-euk with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "goodarzilab/decodon-200M-euk" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "goodarzilab/decodon-200M-euk", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/goodarzilab/decodon-200M-euk
- SGLang
How to use goodarzilab/decodon-200M-euk 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 "goodarzilab/decodon-200M-euk" \ --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": "goodarzilab/decodon-200M-euk", "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 "goodarzilab/decodon-200M-euk" \ --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": "goodarzilab/decodon-200M-euk", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use goodarzilab/decodon-200M-euk with Docker Model Runner:
docker model run hf.co/goodarzilab/decodon-200M-euk
Get started π
Installation
From source
Currently, this is the only way to install the package but will push a pip installable version soon. To install the package from source, run the following command:
pip install git+https://github.com/goodarzilab/cdsFM.git
Applications
Now that you have cdsFM installed, you can use AutoEnCodon and AutoDeCodon classes which serve as wrappers around the pre-trained models. Here are some examples on how to use them:
Sequence Embedding Extraction with EnCodon
Following is an example of how to use the EnCodon model to extract sequence embeddings:
from cdsFM import AutoEnCodon
# Load your dataframe containing sequences
seqs = ...
# Load a pre-trained EnCodon model
model = AutoEnCodon.from_pretrained("goodarzilab/encodon-620M")
# Extract embeddings
embeddings = model.get_embeddings(seqs, batch_size=32)
Sequence Generation with DeCodon
You can generate organism-specific coding sequences with DeCodon simply by:
from cdsFM import AutoDeCodon
# Load a pre-trained DeCodon model
model = AutoDeCodon.from_pretrained("goodarzilab/DeCodon-200M")
# Generate!
gen_seqs = model.generate(
taxid=9606, # NCBI Taxonomy ID for Homo sapiens
num_return_sequences=32, # Number of sequences to return
max_length=1024, # Maximum length of the generated sequence
batch_size=8, # Batch size for generation
)
Tokenization
EnCodon and DeCodon are pre-trained on coding sequences of length up to 2048 codons (i.e. 6144 nucleotides), including the <CLS> token prepended automatically to the beginning of the sequence and the <SEP> token appended at the end. The tokenizer's vocabulary consists of 64 codons and 5 special tokens namely <CLS>, <SEP>, <PAD>, <MASK> and <UNK>.
HuggingFace π€
A collection of pre-trained checkpoints of EnCodon & DeCodon models are available on HuggingFace π€. Following table contains the list of available models:
| Model | name | num. params | description | weights |
|---|---|---|---|---|
| EnCodon | encodon-80M | 80M | Pre-trained checkpoint | π€ |
| EnCodon | encodon-80M-euk | 80M | Eukaryotic-expert | π€ |
| EnCodon | encodon-620M | 620M | Pre-trained checkpoint | π€ |
| EnCodon | encodon-620M-euk | 620M | Eukaryotic-expert | π€ |
| DeCodon | decodon-200M | 200M | Pre-trained checkpoint | π€ |
| DeCodon | decodon-200M-euk | 200M | Eukaryotic-expert | π€ |
Citation
@article{Naghipourfar2024,
title = {A Suite of Foundation Models Captures the Contextual Interplay Between Codons},
url = {http://dx.doi.org/10.1101/2024.10.10.617568},
DOI = {10.1101/2024.10.10.617568},
publisher = {Cold Spring Harbor Laboratory},
author = {Naghipourfar, Mohsen and Chen, Siyu and Howard, Mathew and Macdonald, Christian and Saberi, Ali and Hagen, Timo and Mofrad, Mohammad and Coyote-Maestas, Willow and Goodarzi, Hani},
year = {2024},
month = oct
}
- Downloads last month
- 9
docker model run hf.co/goodarzilab/decodon-200M-euk