Text Generation
Transformers
Safetensors
hy_v4
hunyuan
hy4
Mixture of Experts
conversational
Eval Results
Instructions to use tencent/Hy4-preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tencent/Hy4-preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tencent/Hy4-preview") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("tencent/Hy4-preview", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tencent/Hy4-preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tencent/Hy4-preview" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tencent/Hy4-preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tencent/Hy4-preview
- SGLang
How to use tencent/Hy4-preview 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 "tencent/Hy4-preview" \ --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": "tencent/Hy4-preview", "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 "tencent/Hy4-preview" \ --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": "tencent/Hy4-preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tencent/Hy4-preview with Docker Model Runner:
docker model run hf.co/tencent/Hy4-preview
Update vLLM recipe
#4
by jeeejeee - opened
- README.md +1 -25
- README_CN.md +1 -27
README.md
CHANGED
|
@@ -167,31 +167,7 @@ For production serving, we recommend using [vLLM](https://github.com/vllm-projec
|
|
| 167 |
|
| 168 |
### vLLM
|
| 169 |
|
| 170 |
-
|
| 171 |
-
```bash
|
| 172 |
-
uv venv --python 3.12 --seed --managed-python
|
| 173 |
-
source .venv/bin/activate
|
| 174 |
-
git clone https://github.com/vllm-project/vllm.git
|
| 175 |
-
cd vllm
|
| 176 |
-
uv pip install --editable . --torch-backend=auto
|
| 177 |
-
```
|
| 178 |
-
|
| 179 |
-
Start the vLLM server with MTP enabled:
|
| 180 |
-
|
| 181 |
-
```bash
|
| 182 |
-
vllm serve tencent/Hy4-preview-FP8 \
|
| 183 |
-
--tensor-parallel-size 8 \
|
| 184 |
-
--speculative-config.method mtp \
|
| 185 |
-
--speculative-config.num_speculative_tokens 3 \
|
| 186 |
-
--attention-backend FLASHMLA_SPARSE \
|
| 187 |
-
--tool-call-parser hy_v4 \
|
| 188 |
-
--reasoning-parser hy_v4 \
|
| 189 |
-
--enable-auto-tool-choice \
|
| 190 |
-
--port 8000 \
|
| 191 |
-
--served-model-name hy4-preview
|
| 192 |
-
```
|
| 193 |
-
|
| 194 |
-
Or use official prebuilt image `vllm/vllm-openai:hy4-preview`:
|
| 195 |
|
| 196 |
```bash
|
| 197 |
docker run --gpus all \
|
|
|
|
| 167 |
|
| 168 |
### vLLM
|
| 169 |
|
| 170 |
+
Use official prebuilt image `vllm/vllm-openai:hy4-preview`:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
```bash
|
| 173 |
docker run --gpus all \
|
README_CN.md
CHANGED
|
@@ -158,33 +158,7 @@ print(response.choices[0].message.content)
|
|
| 158 |
|
| 159 |
### vLLM
|
| 160 |
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
```bash
|
| 164 |
-
uv venv --python 3.12 --seed --managed-python
|
| 165 |
-
source .venv/bin/activate
|
| 166 |
-
git clone https://github.com/vllm-project/vllm.git
|
| 167 |
-
cd vllm
|
| 168 |
-
uv pip install --editable . --torch-backend=auto
|
| 169 |
-
```
|
| 170 |
-
|
| 171 |
-
启动 vLLM 服务,开启 MTP:
|
| 172 |
-
|
| 173 |
-
```bash
|
| 174 |
-
vllm serve tencent/Hy4-preview-FP8 \
|
| 175 |
-
--tensor-parallel-size 8 \
|
| 176 |
-
--speculative-config.method mtp \
|
| 177 |
-
--speculative-config.num_speculative_tokens 3 \
|
| 178 |
-
--attention-backend FLASHMLA_SPARSE \
|
| 179 |
-
--tool-call-parser hy_v4 \
|
| 180 |
-
--reasoning-parser hy_v4 \
|
| 181 |
-
--enable-auto-tool-choice \
|
| 182 |
-
--port 8000 \
|
| 183 |
-
--served-model-name hy4-preview
|
| 184 |
-
```
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
或者使用社区官方镜像部署:`vllm/vllm-openai:hy4-preview`:
|
| 188 |
|
| 189 |
```bash
|
| 190 |
docker run --gpus all \
|
|
|
|
| 158 |
|
| 159 |
### vLLM
|
| 160 |
|
| 161 |
+
使用社区官方镜像部署:`vllm/vllm-openai:hy4-preview`:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
```bash
|
| 164 |
docker run --gpus all \
|