Instructions to use InstaDeepAI/ChatNT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use InstaDeepAI/ChatNT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="InstaDeepAI/ChatNT", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("InstaDeepAI/ChatNT", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use InstaDeepAI/ChatNT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "InstaDeepAI/ChatNT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "InstaDeepAI/ChatNT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/InstaDeepAI/ChatNT
- SGLang
How to use InstaDeepAI/ChatNT 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 "InstaDeepAI/ChatNT" \ --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": "InstaDeepAI/ChatNT", "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 "InstaDeepAI/ChatNT" \ --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": "InstaDeepAI/ChatNT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use InstaDeepAI/ChatNT with Docker Model Runner:
docker model run hf.co/InstaDeepAI/ChatNT
Update text_generation.py
Browse files- text_generation.py +13 -8
text_generation.py
CHANGED
|
@@ -55,19 +55,24 @@ class TextGenerationPipeline(Pipeline):
|
|
| 55 |
truncation=True,
|
| 56 |
max_length=english_tokens_max_length,
|
| 57 |
).input_ids
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
return {"english_tokens": english_tokens, "bio_tokens": bio_tokens}
|
| 67 |
|
| 68 |
def _forward(self, model_inputs: dict, max_num_tokens_to_decode: int = 50) -> dict:
|
| 69 |
english_tokens = model_inputs["english_tokens"].clone()
|
| 70 |
-
bio_tokens = model_inputs["bio_tokens"]
|
|
|
|
|
|
|
| 71 |
projected_bio_embeddings = None
|
| 72 |
|
| 73 |
actual_num_steps = 0
|
|
|
|
| 55 |
truncation=True,
|
| 56 |
max_length=english_tokens_max_length,
|
| 57 |
).input_ids
|
| 58 |
+
if len(dna_sequences) == 0:
|
| 59 |
+
bio_tokens = None
|
| 60 |
+
else:
|
| 61 |
+
bio_tokens = self.bio_tokenizer(
|
| 62 |
+
dna_sequences,
|
| 63 |
+
return_tensors="pt",
|
| 64 |
+
padding="max_length",
|
| 65 |
+
max_length=bio_tokens_max_length,
|
| 66 |
+
truncation=True,
|
| 67 |
+
).input_ids.unsqueeze(0)
|
| 68 |
|
| 69 |
return {"english_tokens": english_tokens, "bio_tokens": bio_tokens}
|
| 70 |
|
| 71 |
def _forward(self, model_inputs: dict, max_num_tokens_to_decode: int = 50) -> dict:
|
| 72 |
english_tokens = model_inputs["english_tokens"].clone()
|
| 73 |
+
bio_tokens = model_inputs["bio_tokens"]
|
| 74 |
+
if bio_tokens is not None:
|
| 75 |
+
bio_tokens = bio_tokens.clone()
|
| 76 |
projected_bio_embeddings = None
|
| 77 |
|
| 78 |
actual_num_steps = 0
|