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")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("naniltx/codonGPT") model = AutoModelForCausalLM.from_pretrained("naniltx/codonGPT") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- 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
Update synonymous_logit_processor.py
Browse files
synonymous_logit_processor.py
CHANGED
|
@@ -45,14 +45,18 @@ def generate_candidate_codons_with_generate(initial_codons, temperature=1.0, top
|
|
| 45 |
"""
|
| 46 |
# Use global variables if not provided as parameters
|
| 47 |
if model is None:
|
| 48 |
-
import
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
if model is None:
|
| 51 |
raise ValueError("Model not provided and no global 'model' variable found")
|
| 52 |
|
| 53 |
if tokenizer is None:
|
| 54 |
-
import
|
| 55 |
-
|
|
|
|
|
|
|
| 56 |
if tokenizer is None:
|
| 57 |
raise ValueError("Tokenizer not provided and no global 'tokenizer' variable found")
|
| 58 |
|
|
|
|
| 45 |
"""
|
| 46 |
# Use global variables if not provided as parameters
|
| 47 |
if model is None:
|
| 48 |
+
import inspect
|
| 49 |
+
# Check calling frame's globals and locals
|
| 50 |
+
frame = inspect.currentframe().f_back
|
| 51 |
+
model = frame.f_locals.get('model') or frame.f_globals.get('model')
|
| 52 |
if model is None:
|
| 53 |
raise ValueError("Model not provided and no global 'model' variable found")
|
| 54 |
|
| 55 |
if tokenizer is None:
|
| 56 |
+
import inspect
|
| 57 |
+
# Check calling frame's globals and locals
|
| 58 |
+
frame = inspect.currentframe().f_back
|
| 59 |
+
tokenizer = frame.f_locals.get('tokenizer') or frame.f_globals.get('tokenizer')
|
| 60 |
if tokenizer is None:
|
| 61 |
raise ValueError("Tokenizer not provided and no global 'tokenizer' variable found")
|
| 62 |
|