Instructions to use naniltx/codonGPT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use naniltx/codonGPT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="naniltx/codonGPT")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("naniltx/codonGPT") model = AutoModelForCausalLM.from_pretrained("naniltx/codonGPT", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use naniltx/codonGPT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "naniltx/codonGPT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "naniltx/codonGPT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/naniltx/codonGPT
- SGLang
How to use naniltx/codonGPT 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 "naniltx/codonGPT" \ --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": "naniltx/codonGPT", "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 "naniltx/codonGPT" \ --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": "naniltx/codonGPT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use naniltx/codonGPT with Docker Model Runner:
docker model run hf.co/naniltx/codonGPT
File size: 1,572 Bytes
ee7017c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/usr/bin/env python3
"""
Test that existing notebook code still works with updated HF files
"""
from Bio.Seq import Seq
from transformers import GPT2LMHeadModel, GPT2Tokenizer, LogitsProcessor
import torch
print("Testing notebook compatibility...")
try:
# Import the custom components (they should be downloaded already)
from tokenizer import CodonTokenizer
from synonymous_logit_processor import generate_candidate_codons_with_generate
# Load model and tokenizer (notebook style)
print("Loading model and tokenizer...")
model = GPT2LMHeadModel.from_pretrained("naniltx/codonGPT")
tokenizer = CodonTokenizer()
print("✓ Model and tokenizer loaded successfully")
# Test the exact notebook usage pattern
print("\nTesting notebook usage pattern...")
# Example usage (from your notebook):
initial_codons = ["GCT", "TGT", "GAT"]
initial_codons = ['ATG', 'GAA', 'CTT', 'GTC'] # This overwrites the previous line
print("The initial prompt codons are:", " ".join(initial_codons))
# This should work with global model/tokenizer variables
generated_codons_generate = generate_candidate_codons_with_generate(initial_codons, temperature=0.7, top_k=5)
print("Generated with model.generate():", " ".join(generated_codons_generate))
print("\n✅ Notebook compatibility test passed!")
print("Your existing notebook code will continue to work unchanged.")
except Exception as e:
print(f"\n❌ Compatibility test failed: {e}")
import traceback
traceback.print_exc() |