yiqichen01 commited on
Commit
0aa562b
·
verified ·
1 Parent(s): 79c3855

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +238 -0
  2. README_CN.md +232 -0
README.md CHANGED
@@ -1,3 +1,241 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - hunyuan
7
+ - hy4
8
+ - moe
9
+ - text-generation
10
  ---
11
+ <p align="left">
12
+ <a href="https://huggingface.co/tencent/Hy4-preview/blob/main/README_CN.md">中文</a>&nbsp;|&nbsp;English
13
+ </p>
14
+ <br>
15
+
16
+ <p align="center">
17
+ <img src="assets/logo-en.png" width="400"/> <br>
18
+ </p>
19
+
20
+ <div align="center" style="line-height: 1;">
21
+
22
+
23
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue)](#license)
24
+ &nbsp;&nbsp;
25
+ [![HuggingFace](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Tencent%20Hy-ffc107?color=ffc107&logoColor=white)](https://huggingface.co/tencent/Hy4-preview)
26
+ &nbsp;&nbsp;
27
+ [![ModelScope](https://img.shields.io/badge/ModelScope-Tencent%20Hy-624aff)](https://modelscope.cn/models/Tencent-Hunyuan/Hy4-preview)
28
+ &nbsp;&nbsp;
29
+ [![cnb.cool](https://img.shields.io/badge/cnb.cool-Tencent%20Hy-blue?logoColor=white)](https://cnb.cool/ai-models/tencent/Hy4-preview)
30
+ &nbsp;&nbsp;
31
+ [![GitCode](https://img.shields.io/badge/GitCode-Tencent%20Hy-red?logoColor=white)](https://ai.gitcode.com/tencent_hunyuan/Hy4-preview)
32
+
33
+ </div>
34
+
35
+ <p align="center">
36
+ 🖥️&nbsp;<a href="https://aistudio.tencent.com/"><b>Official Website</b></a>&nbsp;&nbsp;|&nbsp;&nbsp;
37
+ 💬&nbsp;<a href="https://github.com/Tencent-Hunyuan/Hy4-preview"><b>GitHub</b></a></p>
38
+
39
+ ---
40
+
41
+ ## Table of Contents
42
+
43
+ - [Model Introduction](#model-introduction)
44
+ - [A New Flagship Generation](#a-new-flagship-generation)
45
+ - [Built for Real-World Productivity](#built-for-real-world-productivity)
46
+ - [Benchmark Appendix](#benchmark-appendix)
47
+ - [Known Limitations](#known-limitations)
48
+ - [News](#news)
49
+ - [Model Links](#model-links)
50
+ - [Quickstart](#quickstart)
51
+ - [Deployment](#deployment)
52
+ - [vLLM](#vllm)
53
+ - [SGLang](#sglang)
54
+ - [Finetuning](#finetuning)
55
+ - [Quantization](#quantization)
56
+ - [License](#license)
57
+ - [Contact Us](#contact-us)
58
+
59
+ ---
60
+
61
+ ## Model Introduction
62
+
63
+ **Hy4 preview** is a new-generation Mixture-of-Experts (MoE) flagship model developed by the Tencent Hy Team. The model comprises 770B total parameters, of which 49B are activated per token. The backbone consists of 78 layers, where the first layer uses a standard dense FFN and the remaining 77 layers replace it with MoE, each containing 256 routed experts and 1 shared expert; every token activates the top-8 routed experts along with the shared expert. In addition to the backbone, 1 native MTP layer (10B total parameters, 0.7B activated) is built in for speculative decoding.
64
+
65
+ On the architecture side, inspired by DeepSeek and GLM, the attention module employs Gated [DeepSeek Sparse Attention](https://arxiv.org/abs/2512.02556) (Gated DSA) with [IndexCache](https://arxiv.org/abs/2603.12201) for cross-layer sparse index reuse. The residual pathway uses [iHC (identity Hyper-Connections)](https://zhuanlan.zhihu.com/p/2010852389670908320) to expand inter-layer information flow.
66
+
67
+ ### Model Specifications
68
+
69
+ > The table below lists backbone parameters only, excluding the MTP layer.
70
+
71
+ | Property | Value |
72
+ |:---|:---|
73
+ | Architecture | Mixture-of-Experts (MoE) |
74
+ | Total Parameters | 770B |
75
+ | Activated Parameters | 49B |
76
+ | Layers | 78 |
77
+ | Hidden Size | 6144 |
78
+ | Attention Type | Gated DSA |
79
+ | Attention Heads | 64 |
80
+ | Query Compression Dimension | 2048 |
81
+ | Key-Value Compression Dimension | 512 |
82
+ | Indexer Heads / Head Dimension | 32 / 128 |
83
+ | Indexer top-k | 2048 |
84
+ | Residual Streams | 4 |
85
+ | Routed Experts | 256 |
86
+ | Shared Experts | 1 |
87
+ | Activated Routed Experts per Token | 8 |
88
+ | MoE Intermediate Size | 2048 |
89
+ | FFN Intermediate Size | 18432 |
90
+ | Context Length | 1M |
91
+ | Vocabulary Size | 120832 |
92
+
93
+ ## A New Flagship Generation
94
+
95
+ We scaled Hy4 preview on three fronts: model size, context length, and training data. Stronger pre-training and a substantially larger post-training run compound into another step change in capability — the largest generation-over-generation gain we've measured, and enough to put Hy4 preview at the open-source frontier.
96
+
97
+ <p align="center">
98
+ <img src="assets/benchmark.jpg" width="100%"/>
99
+ </p>
100
+
101
+ ## Built for Real-World Productivity
102
+
103
+ We partnered with top experts inside Tencent — such as software engineers, game developers, finance analysts, and security experts — and built training data around the work they ship. The result is a model that gets meaningfully further on the tasks these teams run every day:
104
+
105
+ **Software engineering**: Better at understanding, planning, debugging, and verifying long-horizon development tasks, with further gains in the visual taste and interaction quality of front-end work.
106
+
107
+ **Office and analysis**: Takes messy context spread across many files and converts it into shareable artifacts — documents, spreadsheets, and presentations — handling data analysis, equations, and financial models with greater precision.
108
+
109
+ **Game development**: Turns a single prompt into a playable prototype and works fluently with game engines, so developers can keep refining complex projects over multiple turns.
110
+
111
+ **Scientific research**: Stronger understanding, reasoning, and problem-solving on hard research questions, with solid progress across AI research, molecular dynamics, condensed matter physics, and pure mathematics.
112
+
113
+ We also continue to co-design Hy4 preview with Tencent products like CodeBuddy and WorkBuddy, so that gains in the model show up in the work people actually do with it. To check that, we ran a blind side-by-side evaluation: 163 internal experts rated model outputs on 203 engineering tasks. Hy4 preview came out slightly ahead of both GLM 5.3 (2.99 vs. 2.92 average, 46.8% wins / 12.8% ties / 40.4% losses) and Kimi K3 (2.99 vs. 2.94, 51.2% wins / 7.9% ties / 40.9% losses).
114
+
115
+ ## Benchmark Appendix
116
+
117
+ <p align="center">
118
+ <img src="assets/benchmark-appendix.jpg" width="100%"/>
119
+ </p>
120
+
121
+ ## Known Limitations
122
+
123
+ This is an early version of Hy4. There is real headroom left in both pre-training and post-training, and we are shipping with known issues — among them, spending longer than necessary reasoning through complex tasks, and a tendency to over-verify its own work. As with Hy3 preview, we would rather ship early and hear what breaks — that's what made Hy3 substantially better, and it's how we will get Hy4 right. We will also keep collaborating closely with Tencent's products and in-house experts to push the boundaries of model intelligence while making it more abundant and affordable.
124
+
125
+ ## News
126
+
127
+ * 🔥 We open-source **Hy4 preview** and **Hy4 preview-FP8** model weights on [Hugging Face](https://huggingface.co/tencent/Hy4-preview), [ModelScope](https://modelscope.cn/models/Tencent-Hunyuan/Hy4-preview), [GitCode](https://ai.gitcode.com/tencent_hunyuan/Hy4-preview), and [CNB](https://cnb.cool/ai-models/tencent/Hy4-preview).
128
+
129
+ ## Model Links
130
+
131
+ | Model Name | Description | Hugging Face | ModelScope | GitCode | CNB |
132
+ |:---|:---|:---:|:---:|:---:|:---:|
133
+ | Hy4 preview | Instruct model | 🤗 [Model](https://huggingface.co/tencent/Hy4-preview) | [Model](https://modelscope.cn/models/Tencent-Hunyuan/Hy4-preview) | [Model](https://ai.gitcode.com/tencent_hunyuan/Hy4-preview) | [Model](https://cnb.cool/ai-models/tencent/Hy4-preview) |
134
+ | Hy4 preview-FP8 | FP8 quantized instruct model | 🤗 [Model](https://huggingface.co/tencent/Hy4-preview-FP8) | [Model](https://modelscope.cn/models/Tencent-Hunyuan/Hy4-preview-FP8) | [Model](https://ai.gitcode.com/tencent_hunyuan/Hy4-preview-FP8) | [Model](https://cnb.cool/ai-models/tencent/Hy4-preview-FP8) |
135
+
136
+ ## Quickstart
137
+
138
+ Deploy Hy4 preview with [vLLM](#vllm) or [SGLang](#sglang) first, then call the OpenAI-compatible API:
139
+
140
+ ```python
141
+ from openai import OpenAI
142
+
143
+ client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="EMPTY")
144
+
145
+ response = client.chat.completions.create(
146
+ model="hy4-preview",
147
+ messages=[
148
+ {"role": "user", "content": "Hello! Can you briefly introduce yourself?"},
149
+ ],
150
+ temperature=0.9,
151
+ top_p=1.0,
152
+ )
153
+ print(response.choices[0].message.content)
154
+ ```
155
+
156
+ > **Recommended parameters**: `temperature=0.9`, `top_p=1.0`.
157
+ >
158
+ > **Reasoning mode**: Defaults to `"high"` (deep chain-of-thought), which suits complex tasks such as math, coding, and reasoning. For direct responses, pass `extra_body={"chat_template_kwargs": {"reasoning_effort": "no_think"}}`.
159
+
160
+ See the [Deployment](#deployment) section below for how to start the API server.
161
+
162
+ ## Deployment
163
+
164
+ For production serving, we recommend using [vLLM](https://github.com/vllm-project/vllm) or [SGLang](https://docs.sglang.io/).
165
+
166
+ ### vLLM
167
+
168
+ Build vLLM from source:
169
+ ```bash
170
+ uv venv --python 3.12 --seed --managed-python
171
+ source .venv/bin/activate
172
+ git clone https://github.com/vllm-project/vllm.git
173
+ cd vllm
174
+ uv pip install --editable . --torch-backend=auto
175
+ ```
176
+
177
+ Start the vLLM server with MTP enabled:
178
+
179
+ ```bash
180
+ vllm serve tencent/Hy4-preview-FP8 \
181
+ --tensor-parallel-size 8 \
182
+ --speculative-config.method mtp \
183
+ --speculative-config.num_speculative_tokens 3 \
184
+ --attention-backend FLASHMLA_SPARSE \
185
+ --tool-call-parser hy_v4 \
186
+ --reasoning-parser hy_v4 \
187
+ --enable-auto-tool-choice \
188
+ --port 8000 \
189
+ --served-model-name hy4-preview
190
+ ```
191
+
192
+ ### SGLang
193
+
194
+ Build SGLang from source:
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
+ python3 -m sglang.launch_server \
207
+ --model tencent/Hy4-preview-FP8 \
208
+ --tp-size 8 \
209
+ --tool-call-parser hy_v4 \
210
+ --reasoning-parser hy_v4 \
211
+ --speculative-num-steps 2 \
212
+ --speculative-eagle-topk 1 \
213
+ --speculative-num-draft-tokens 3 \
214
+ --speculative-algorithm EAGLE \
215
+ --port 8000 \
216
+ --served-model-name hy4-preview
217
+ ```
218
+
219
+ ## Finetuning
220
+
221
+ Hy4 preview provides a complete model finetuning pipeline. For detailed documentation, please refer to: [Finetuning Guide](https://huggingface.co/tencent/Hy4-preview/blob/main/finetune/README.md)
222
+
223
+ ## Quantization
224
+
225
+ We provide [AngelSlim](https://github.com/tencent/AngelSlim), a more accessible, comprehensive, and efficient toolkit for large model compression. AngelSlim supports a comprehensive suite of compression tools for large-scale multimodal models, including common quantization algorithms, low-bit quantization, and speculative sampling.
226
+
227
+ ## License
228
+
229
+ Hy4 preview is released under the **Apache License 2.0**. See [LICENSE](https://huggingface.co/tencent/Hy4-preview/blob/main/LICENSE) for details.
230
+
231
+ ## Contact Us
232
+
233
+ If you have any questions or suggestions, feel free to reach out to our R&D and product teams via email:
234
+
235
+ 📧 **hunyuan_opensource@tencent.com**
236
+
237
+ ---
238
+
239
+ <p align="center">
240
+ <i>Hy4 preview is developed by the Tencent Hy Team.</i>
241
+ </p>
README_CN.md ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="left">
2
+ <a href="https://huggingface.co/tencent/Hy4-preview">English</a>&nbsp;|&nbsp;中文
3
+ </p>
4
+ <br>
5
+
6
+ <p align="center">
7
+ <img src="assets/logo-zh.png" width="400"/> <br>
8
+ </p>
9
+
10
+ <div align="center" style="line-height: 1;">
11
+
12
+
13
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue)](#许可证)
14
+ &nbsp;&nbsp;
15
+ [![HuggingFace](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Tencent%20Hy-ffc107?color=ffc107&logoColor=white)](https://huggingface.co/tencent/Hy4-preview)
16
+ &nbsp;&nbsp;
17
+ [![ModelScope](https://img.shields.io/badge/ModelScope-Tencent%20Hy-624aff)](https://modelscope.cn/models/Tencent-Hunyuan/Hy4-preview)
18
+ &nbsp;&nbsp;
19
+ [![cnb.cool](https://img.shields.io/badge/cnb.cool-Tencent%20Hy-blue?logoColor=white)](https://cnb.cool/ai-models/tencent/Hy4-preview)
20
+ &nbsp;&nbsp;
21
+ [![GitCode](https://img.shields.io/badge/GitCode-Tencent%20Hy-red?logoColor=white)](https://ai.gitcode.com/tencent_hunyuan/Hy4-preview)
22
+
23
+ </div>
24
+
25
+ <p align="center">
26
+ 🖥️&nbsp;<a href="https://aistudio.tencent.com/"><b>官方网站</b></a>&nbsp;&nbsp;|&nbsp;&nbsp;
27
+ 💬&nbsp;<a href="https://github.com/Tencent-Hunyuan/Hy4-preview"><b>GitHub</b></a></p>
28
+
29
+ ---
30
+
31
+ ## 目录
32
+
33
+ - [模型介绍](#模型介绍)
34
+ - [新一代旗舰模型](#新一代旗舰模型)
35
+ - [为真实生产力而生](#为真实生产力而生)
36
+ - [Benchmark 附录](#benchmark-附录)
37
+ - [已知局限](#已知局限)
38
+ - [新闻](#新闻)
39
+ - [模型链接](#模型链接)
40
+ - [快速开始](#快速开始)
41
+ - [推理和部署](#推理和部署)
42
+ - [vLLM](#vllm)
43
+ - [SGLang](#sglang)
44
+ - [模型微调](#模型微调)
45
+ - [量化工具](#量化工具)
46
+ - [许可证](#许可证)
47
+ - [联系我们](#联系我们)
48
+
49
+ ---
50
+
51
+ ## 模型介绍
52
+
53
+ **Hy4 preview** 是由腾讯混元团队研发的新一代混合专家(MoE)旗舰模型。模型总参数量 770B,每个 token 激活 49B,主干共包含78层,第一层采用标准 FFN,其余 77 层均为 MoE 结构,每层包含 256 个路由专家与 1 个共享专家,每个 token 激活 top-8 路由专家及共享专家。主干之外原生内置 1 层 MTP(总参数量 10B,激活 0.7B)以支持投机解码。
54
+
55
+ 在架构层面,受到 DeepSeek 和 GLM 的启发,注意力侧采用 Gated [DeepSeek Sparse Attention](https://arxiv.org/abs/2512.02556)(Gated DSA),并引入 [IndexCache](https://arxiv.org/abs/2603.12201) 跨层复用稀疏索引,残差侧采用 [iHC (identity Hyper-Connections)](https://zhuanlan.zhihu.com/p/2010852389670908320) 扩展层间信息通路。
56
+
57
+ ### 模型规格
58
+
59
+ > 下表仅列出主干网络参数,不含MTP层
60
+
61
+ | 属性 | 值 |
62
+ |:---|:---|
63
+ | 架构 | 混合专家(MoE) |
64
+ | 总参数 | 770B |
65
+ | 激活参数量 | 49B |
66
+ | 层数 | 78 |
67
+ | 隐藏层维度 | 6144 |
68
+ | 注意力类型 | Gated DSA |
69
+ | 注意力头数 | 64 |
70
+ | Query 压缩维度 | 2048 |
71
+ | Key-Value 压缩维度 | 512 |
72
+ | Indexer 头数 / 头维度 | 32 / 128 |
73
+ | Indexer top-k | 2048 |
74
+ | 残差流数 | 4 |
75
+ | 路由专家数 | 256 |
76
+ | 共享专家数 | 1 |
77
+ | 单 token 激活路由专家数 | 8 |
78
+ | MoE中间层维度 | 2048 |
79
+ | FFN中间层维度 | 18432 |
80
+ | 上下文长度 | 1M |
81
+ | 词表大小 | 120832 |
82
+
83
+ ## 新一代旗舰模型
84
+
85
+ Hy4 preview 在模型尺寸、上下文长度、数据规模上都进行了显著的扩展,预训练和后训练的共同进步带来了智能水平的又一次巨大提升,稳居开源模型第一梯队。
86
+
87
+ <p align="center">
88
+ <img src="assets/benchmark.jpg" width="100%"/>
89
+ </p>
90
+
91
+ ## 为真实生产力而生
92
+
93
+ 通过与腾讯内部软件工程师、游戏开发者、金融分析师、安全专家等各领域顶尖专家的高质量数据共建,Hy4 preview 在各类真实生产力任务上取得显著进步:
94
+
95
+ **软件工程**:增强长程开发任务的理解、规划、调试与验证能力,进一步提升前端开发的视觉审美和交互质量。
96
+
97
+ **办公分析**:显著提升复杂办公环境理解和金融分析能力,着重优化数据分析、跨文件协作,完成从信息处理到文档、表格与演示文稿交付的完整流程。
98
+
99
+ **游戏开发**:增强一句需求直接生成可玩原型的能力,并能熟练使用游戏引擎,开发者可以通过多轮交互持续完善复杂游戏项目。
100
+
101
+ **科学研究**:显著提升复杂科研问题的理解、推理与求解能力,模型在 AI 研发、分子动力学模拟、凝聚态物理、基础数学等各类场景中均有长足进步。
102
+
103
+ 同时,Hy4 preview 持续与 CodeBuddy / WorkBuddy 等产品深度协同,优化生产力场景的真实用户体验。为验证这一点,我们组织了 163 位内部专家基于 203 个真实工程任务进行模型盲测:Hy4 preview(均分 2.99 / 4)略优于 GLM 5.3(均分 2.92 / 4;胜 46.8% / 平 12.8% / 负 40.4%)和 Kimi K3(均分 2.94 / 4;胜 51.2% / 平 7.9% / 负 40.9%)。
104
+
105
+ ## Benchmark 附录
106
+
107
+ <p align="center">
108
+ <img src="assets/benchmark-appendix.jpg" width="100%"/>
109
+ </p>
110
+
111
+ ## 已知局限
112
+
113
+ Hy4 preview 是 Hy4 迭代��一个早期版本,预训练和后训练均仍有较大的提升空间,也有一些已知问题,如复杂任务上的长思考和过度自我验证倾向。如同 Hy3 preview,我们希望通过 Hy4 preview 的尽快发布获得广泛的真实反馈,从而显著提升 Hy4 正式版。同时,我们将坚持发挥与腾讯产品和专家深度合作的独特优势,持续提升生产力的普惠性和上限。
114
+
115
+ ## 新闻
116
+
117
+ * 🔥 我们在 [Hugging Face](https://huggingface.co/tencent/Hy4-preview)、[ModelScope](https://modelscope.cn/models/Tencent-Hunyuan/Hy4-preview)、[GitCode](https://ai.gitcode.com/tencent_hunyuan/Hy4-preview) 和 [CNB](https://cnb.cool/ai-models/tencent/Hy4-preview) 开源了 **Hy4 preview** 和 **Hy4 preview-FP8** 模型权重。
118
+
119
+ ## 模型链接
120
+
121
+ | 模型名 | 简介 | Hugging Face | ModelScope | GitCode | CNB |
122
+ |:---|:---|:---:|:---:|:---:|:---:|
123
+ | Hy4 preview | Instruct 模型 | 🤗 [Model](https://huggingface.co/tencent/Hy4-preview) | [Model](https://modelscope.cn/models/Tencent-Hunyuan/Hy4-preview) | [Model](https://ai.gitcode.com/tencent_hunyuan/Hy4-preview) | [Model](https://cnb.cool/ai-models/tencent/Hy4-preview) |
124
+ | Hy4 preview-FP8 | FP8 量化 Instruct 模型 | 🤗 [Model](https://huggingface.co/tencent/Hy4-preview-FP8) | [Model](https://modelscope.cn/models/Tencent-Hunyuan/Hy4-preview-FP8) | [Model](https://ai.gitcode.com/tencent_hunyuan/Hy4-preview-FP8) | [Model](https://cnb.cool/ai-models/tencent/Hy4-preview-FP8) |
125
+
126
+ ## 快速开始
127
+
128
+ 建议先通过 [vLLM](#vllm) 或 [SGLang](#sglang) 部署服务,然后通过 OpenAI 兼容 API 调用:
129
+
130
+ ```python
131
+ from openai import OpenAI
132
+
133
+ client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="EMPTY")
134
+
135
+ response = client.chat.completions.create(
136
+ model="hy4-preview",
137
+ messages=[
138
+ {"role": "user", "content": "你好!请简单介绍一下你自己。"},
139
+ ],
140
+ temperature=0.9,
141
+ top_p=1.0,
142
+ )
143
+ print(response.choices[0].message.content)
144
+ ```
145
+
146
+ > **推荐参数**:`temperature=0.9`,`top_p=1.0`。
147
+ >
148
+ > **推理模式**:默认为 `"high"`(深度思维链),适合数学、编程、推理等复杂任务;日常对话如需直接回复,可传入 `extra_body={"chat_template_kwargs": {"reasoning_effort": "no_think"}}`。
149
+
150
+ 具体部署方式请参考下方[推理和部署](#推理和部署)章节。
151
+
152
+ ## 推理和部署
153
+
154
+ 对于生产环境部署,我们建议使用 [vLLM](https://github.com/vllm-project/vllm) 或 [SGLang](https://docs.sglang.io/)。
155
+
156
+ ### vLLM
157
+
158
+ 从源码构建 vLLM:
159
+
160
+ ```bash
161
+ uv venv --python 3.12 --seed --managed-python
162
+ source .venv/bin/activate
163
+ git clone https://github.com/vllm-project/vllm.git
164
+ cd vllm
165
+ uv pip install --editable . --torch-backend=auto
166
+ ```
167
+
168
+ 启动 vLLM 服务,开启 MTP:
169
+
170
+ ```bash
171
+ vllm serve tencent/Hy4-preview-FP8 \
172
+ --tensor-parallel-size 8 \
173
+ --speculative-config.method mtp \
174
+ --speculative-config.num_speculative_tokens 3 \
175
+ --attention-backend FLASHMLA_SPARSE \
176
+ --tool-call-parser hy_v4 \
177
+ --reasoning-parser hy_v4 \
178
+ --enable-auto-tool-choice \
179
+ --port 8000 \
180
+ --served-model-name hy4-preview
181
+ ```
182
+
183
+ ### SGLang
184
+
185
+ 从源码构建 SGLang:
186
+
187
+ ```bash
188
+ git clone https://github.com/sgl-project/sglang
189
+ cd sglang
190
+ pip3 install pip --upgrade
191
+ pip3 install "transformers>=5.6.0"
192
+ pip3 install -e "python"
193
+ ```
194
+
195
+ 启动 SGLang 服务,开启 MTP:
196
+ ```bash
197
+ python3 -m sglang.launch_server \
198
+ --model tencent/Hy4-preview-FP8 \
199
+ --tp-size 8 \
200
+ --tool-call-parser hy_v4 \
201
+ --reasoning-parser hy_v4 \
202
+ --speculative-num-steps 2 \
203
+ --speculative-eagle-topk 1 \
204
+ --speculative-num-draft-tokens 3 \
205
+ --speculative-algorithm EAGLE \
206
+ --port 8000 \
207
+ --served-model-name hy4-preview
208
+ ```
209
+
210
+ ## 模型微调
211
+
212
+ Hy4 preview 提供了完整的模型微调流程,详细的微调文档请参考:[模型微调指南](https://huggingface.co/tencent/Hy4-preview/blob/main/finetune/README_CN.md)
213
+
214
+ ## 量化工具
215
+
216
+ 我们提供了 [AngelSlim](https://github.com/tencent/AngelSlim)——一套易用、全面、高效的大模型压缩工具包,涵盖常用量化算法、低比特量化和投机采样等能力。
217
+
218
+ ## 许可证
219
+
220
+ Hy4 preview 基于 **Apache 2.0 许可证** 发布。详情请参阅 [LICENSE](https://huggingface.co/tencent/Hy4-preview/blob/main/LICENSE)。
221
+
222
+ ## 联系我们
223
+
224
+ 如有问题或建议,欢迎通过邮件联系我们的研发和产品团队:
225
+
226
+ 📧 **hunyuan_opensource@tencent.com**
227
+
228
+ ---
229
+
230
+ <p align="center">
231
+ <i>Hy4 preview 由腾讯混元团队研发。</i>
232
+ </p>