Instructions to use bytedance-research/ChatTS-14B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bytedance-research/ChatTS-14B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bytedance-research/ChatTS-14B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("bytedance-research/ChatTS-14B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use bytedance-research/ChatTS-14B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bytedance-research/ChatTS-14B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bytedance-research/ChatTS-14B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/bytedance-research/ChatTS-14B
- SGLang
How to use bytedance-research/ChatTS-14B 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 "bytedance-research/ChatTS-14B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bytedance-research/ChatTS-14B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "bytedance-research/ChatTS-14B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bytedance-research/ChatTS-14B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use bytedance-research/ChatTS-14B with Docker Model Runner:
docker model run hf.co/bytedance-research/ChatTS-14B
Update README.md
#21
by csabakecskemeti - opened
README.md
CHANGED
|
@@ -60,19 +60,21 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, AutoProcessor
|
|
| 60 |
import torch
|
| 61 |
import numpy as np
|
| 62 |
|
|
|
|
| 63 |
# Load the model, tokenizer and processor
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
| 67 |
# Create time series and prompts
|
| 68 |
timeseries = np.sin(np.arange(256) / 10) * 5.0
|
| 69 |
timeseries[100:] -= 10.0
|
| 70 |
prompt = f"I have a time series length of 256: <ts><ts/>. Please analyze the local changes in this time series."
|
| 71 |
# Apply Chat Template
|
| 72 |
-
prompt = f"<|im_start|>system
|
| 73 |
You are a helpful assistant.<|im_end|><|im_start|>user
|
| 74 |
{prompt}<|im_end|><|im_start|>assistant
|
| 75 |
-
"
|
| 76 |
# Convert to tensor
|
| 77 |
inputs = processor(text=[prompt], timeseries=[timeseries], padding=True, return_tensors="pt")
|
| 78 |
# Model Generate
|
|
|
|
| 60 |
import torch
|
| 61 |
import numpy as np
|
| 62 |
|
| 63 |
+
hf_model = "bytedance-research/ChatTS-14B"
|
| 64 |
# Load the model, tokenizer and processor
|
| 65 |
+
# For pre-Ampere GPUs (like V100) use `_attn_implementation='eager'`
|
| 66 |
+
model = AutoModelForCausalLM.from_pretrained(hf_model, trust_remote_code=True, device_map="auto", torch_dtype='float16')
|
| 67 |
+
tokenizer = AutoTokenizer.from_pretrained(hf_model, trust_remote_code=True)
|
| 68 |
+
processor = AutoProcessor.from_pretrained(hf_model, trust_remote_code=True, tokenizer=tokenizer)
|
| 69 |
# Create time series and prompts
|
| 70 |
timeseries = np.sin(np.arange(256) / 10) * 5.0
|
| 71 |
timeseries[100:] -= 10.0
|
| 72 |
prompt = f"I have a time series length of 256: <ts><ts/>. Please analyze the local changes in this time series."
|
| 73 |
# Apply Chat Template
|
| 74 |
+
prompt = f"""<|im_start|>system
|
| 75 |
You are a helpful assistant.<|im_end|><|im_start|>user
|
| 76 |
{prompt}<|im_end|><|im_start|>assistant
|
| 77 |
+
"""
|
| 78 |
# Convert to tensor
|
| 79 |
inputs = processor(text=[prompt], timeseries=[timeseries], padding=True, return_tensors="pt")
|
| 80 |
# Model Generate
|