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
SGLang: use the prebuilt multi-arch image instead of building from source
#1
by JustinTong - opened
README.md
CHANGED
|
@@ -191,29 +191,22 @@ vllm serve tencent/Hy4-preview-FP8 \
|
|
| 191 |
|
| 192 |
### SGLang
|
| 193 |
|
| 194 |
-
|
| 195 |
-
```bash
|
| 196 |
-
git clone https://github.com/sgl-project/sglang
|
| 197 |
-
cd sglang
|
| 198 |
-
pip3 install pip --upgrade
|
| 199 |
-
pip3 install "transformers>=5.6.0"
|
| 200 |
-
pip3 install -e "python"
|
| 201 |
-
```
|
| 202 |
-
|
| 203 |
-
Launch SGLang server with MTP enabled:
|
| 204 |
|
| 205 |
```bash
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
| 217 |
```
|
| 218 |
|
| 219 |
## Finetuning
|
|
|
|
| 191 |
|
| 192 |
### SGLang
|
| 193 |
|
| 194 |
+
Use the prebuilt image `lmsysorg/sglang:hy4-preview` (multi-arch, x86 and Arm):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
```bash
|
| 197 |
+
docker pull lmsysorg/sglang:hy4-preview
|
| 198 |
+
|
| 199 |
+
docker run --gpus all --ipc=host -p 8000:8000 lmsysorg/sglang:hy4-preview \
|
| 200 |
+
python3 -m sglang.launch_server \
|
| 201 |
+
--model tencent/Hy4-preview \
|
| 202 |
+
--tp-size 8 \
|
| 203 |
+
--reasoning-parser auto --tool-call-parser auto \
|
| 204 |
+
--speculative-algorithm NEXTN \
|
| 205 |
+
--speculative-num-steps 3 \
|
| 206 |
+
--speculative-eagle-topk 1 \
|
| 207 |
+
--speculative-num-draft-tokens 4 \
|
| 208 |
+
--served-model-name hy4-preview \
|
| 209 |
+
--port 8000
|
| 210 |
```
|
| 211 |
|
| 212 |
## Finetuning
|