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 modeling_qwen2.py
#7
by xiezhe24 - opened
- modeling_qwen2.py +9 -2
modeling_qwen2.py
CHANGED
|
@@ -1450,6 +1450,9 @@ class Qwen2TSForCausalLM(Qwen2PreTrainedModel):
|
|
| 1450 |
attention_mask=attention_mask
|
| 1451 |
)
|
| 1452 |
|
|
|
|
|
|
|
|
|
|
| 1453 |
def _update_model_kwargs_for_generation(
|
| 1454 |
self,
|
| 1455 |
outputs: ModelOutput,
|
|
@@ -1505,8 +1508,12 @@ class Qwen2TSForCausalLM(Qwen2PreTrainedModel):
|
|
| 1505 |
if past_key_values is not None:
|
| 1506 |
if isinstance(past_key_values, Cache):
|
| 1507 |
cache_length = past_key_values.get_seq_length()
|
| 1508 |
-
past_length
|
| 1509 |
-
max_cache_length =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1510 |
else:
|
| 1511 |
cache_length = past_length = past_key_values[0][0].shape[2]
|
| 1512 |
max_cache_length = None
|
|
|
|
| 1450 |
attention_mask=attention_mask
|
| 1451 |
)
|
| 1452 |
|
| 1453 |
+
def _extract_past_from_model_output(self, outputs: ModelOutput):
|
| 1454 |
+
return "past_key_values", outputs.past_key_values
|
| 1455 |
+
|
| 1456 |
def _update_model_kwargs_for_generation(
|
| 1457 |
self,
|
| 1458 |
outputs: ModelOutput,
|
|
|
|
| 1508 |
if past_key_values is not None:
|
| 1509 |
if isinstance(past_key_values, Cache):
|
| 1510 |
cache_length = past_key_values.get_seq_length()
|
| 1511 |
+
past_length = past_key_values.seen_tokens
|
| 1512 |
+
max_cache_length = (
|
| 1513 |
+
past_key_values.get_max_length()
|
| 1514 |
+
if hasattr(past_key_values, "get_max_length")
|
| 1515 |
+
else past_key_values.get_max_cache_shape()
|
| 1516 |
+
)
|
| 1517 |
else:
|
| 1518 |
cache_length = past_length = past_key_values[0][0].shape[2]
|
| 1519 |
max_cache_length = None
|