Hunyuan is Tencent's open-source efficient large language model series, designed for versatile deployment across diverse computational environments. From edge devices to high-concurrency production systems, these models deliver optimal performance with advanced quantization support and ultra-long context capabilities.
We have released a series of Hunyuan dense models, comprising both pre-trained and instruction-tuned variants, with parameter scales of 0.5B, 1.8B, 4B, and 7B. These models adopt training strategies similar to the Hunyuan-A13B, thereby inheriting its robust performance characteristics. This comprehensive model family enables flexible deployment optimization - from resource-constrained edge computing with smaller variants to high-throughput production environments with larger models, all while maintaining strong capabilities across diverse scenarios.
Key Features and Advantages
Hybrid Reasoning Support
: Supports both fast and slow thinking modes, allowing users to flexibly choose according to their needs.
Ultra-Long Context Understanding
: Natively supports a 256K context window, maintaining stable performance on long-text tasks.
Enhanced Agent Capabilities
: Optimized for agent tasks, achieving leading results on benchmarks such as BFCL-v3, τ-Bench and C3-Bench.
Our model defaults to using slow-thinking reasoning, and there are two ways to disable CoT reasoning.
Pass
"enable_thinking=False"
when calling apply_chat_template.
Adding
"/no_think"
before the prompt will force the model not to use perform CoT reasoning. Similarly, adding
"/think"
before the prompt will force the model to perform CoT reasoning.
The following code snippet shows how to use the transformers library to load and apply the model. It also demonstrates how to enable and disable the reasoning mode , and how to parse the reasoning process along with the final output.
we use tencent/Hunyuan-7B-Instruct for example
from transformers import AutoModelForCausalLM, AutoTokenizer
import os
import re
model_name_or_path = "tencent/Hunyuan-7B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, device_map="auto") # You may want to use bfloat16 and/or move to GPU here
messages = [
{"role": "user", "content": "Write a short summary of the benefits of regular exercise"},
]
tokenized_chat = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True,return_tensors="pt",
enable_thinking=True# Toggle thinking mode (default: True)
)
outputs = model.generate(tokenized_chat.to(model.device), max_new_tokens=2048)
output_text = tokenizer.decode(outputs[0])
print("output_text=",output_text)
think_pattern = r'<think>(.*?)</think>'
think_matches = re.findall(think_pattern, output_text, re.DOTALL)
answer_pattern = r'<answer>(.*?)</answer>'
answer_matches = re.findall(answer_pattern, output_text, re.DOTALL)
think_content = [match.strip() formatchin think_matches][0]
answer_content = [match.strip() formatchin answer_matches][0]
print(f"thinking_content:{think_content}\n\n")
print(f"answer_content:{answer_content}\n\n")
We recommend using the following set of parameters for inference. Note that our model does not have the default system_prompt.
If you need to fine-tune our Instruct model, we recommend processing the data into the following format, corresponding to both slow-thinking and fast-thinking scenarios.
Organize your data in
json
format and place it in the
data
directory in
LLaMA-Factory
. The current implementation uses the
sharegpt
dataset format, which requires the following structure:
*Multi-node training
Execute the following command on each node. Configure NNODES, NODE_RANK, MASTER_ADDR, and MASTER_PORT according to your environment:
We used our own
AngleSlim
compression tool to produce FP8 and INT4 quantization models.
AngleSlim
is a toolset dedicated to creating a more user-friendly, comprehensive and efficient model compression solution.
FP8 Quantization
We use FP8-static quantization, FP8 quantization adopts 8-bit floating point format, through a small amount of calibration data (without training) to pre-determine the quantization scale, the model weights and activation values will be converted to FP8 format, to improve the inference efficiency and reduce the deployment threshold. We you can use AngleSlim quantization, you can also directly download our quantization completed open source model to use
LINK
.
Int4 Quantization
We use the GPTQ and AWQ algorithm to achieve W4A16 quantization.
GPTQ processes the model weights layer by layer, uses a small amount of calibration data to minimize the reconfiguration error of the quantized weights, and adjusts the weights layer by layer by the optimization process of approximating the Hessian inverse matrix. The process eliminates the need to retrain the model and requires only a small amount of calibration data to quantize the weights, improving inference efficiency and lowering the deployment threshold.
AWQ using a small amount of calibration data (without the need for training), the amplitude of the activation values is statistically calculated. For each weight channel, a scaling coefficient s is computed to expand the numerical range of important weights, allowing more information to be retained during quantization.
You can use
AngleSlim
quantization, you can also directly download our quantization completed open source model to use
LINK
.
Quantization Benchmark
This subsection describes the Benchmark metrics for the Hunyuan quantitative model.
Bench
Quantization
Hunyuan-0.5B-Instruct
Hunyuan-1.8B-Instruct
Hunyuan-4B-Instruct
Hunyuan-7B-Instruct
DROP
B16
FP8
Int4GPTQ
Int4AWQ
52.8
51.6
50.9
48.9
76.7
75.1
73.0
71.7
78.2
78.3
78.1
78.2
85.9
86.0
85.7
85.9
GPQA-Diamond
B16
FP8
Int4GPTQ
Int4AWQ
23.3
22.5
23.3
23.3
47.2
47.7
44.43
43.62
61.1
60.2
58.1
-
60.1
60.1
60.0
60.1
OlympiadBench
B16
FP8
Int4GPTQ
Int4AWQ
29.6
29.6
26.8
26.3
63.4
62.5
60.9
61.7
73.1
73.1
71.1
71.2
76.5
76.6
76.2
76.4
AIME 2024
B16
FP8
Int4GPTQ
Int4AWQ
17.2
17.2
-
-
56.7
55.17
-
-
78.3
76.6
-
-
81.1
80.9
81.0
80.9
Deployment
For deployment, you can use frameworks such as
TensorRT-LLM
,
vLLM
, or
SGLang
to serve the model and create an OpenAI-compatible API endpoint.
If you would like to leave a message for our R&D and product teams, Welcome to contact our open-source team . You can also contact us via email (
[email protected]
).
Runs of tencent Hunyuan-4B-Instruct on huggingface.co
425
Total runs
0
24-hour runs
0
3-day runs
37
7-day runs
237
30-day runs
More Information About Hunyuan-4B-Instruct huggingface.co Model
Hunyuan-4B-Instruct huggingface.co
Hunyuan-4B-Instruct huggingface.co is an AI model on huggingface.co that provides Hunyuan-4B-Instruct's model effect (), which can be used instantly with this tencent Hunyuan-4B-Instruct model. huggingface.co supports a free trial of the Hunyuan-4B-Instruct model, and also provides paid use of the Hunyuan-4B-Instruct. Support call Hunyuan-4B-Instruct model through api, including Node.js, Python, http.
Hunyuan-4B-Instruct huggingface.co is an online trial and call api platform, which integrates Hunyuan-4B-Instruct's modeling effects, including api services, and provides a free online trial of Hunyuan-4B-Instruct, you can try Hunyuan-4B-Instruct online for free by clicking the link below.
tencent Hunyuan-4B-Instruct online free url in huggingface.co:
Hunyuan-4B-Instruct is an open source model from GitHub that offers a free installation service, and any user can find Hunyuan-4B-Instruct on GitHub to install. At the same time, huggingface.co provides the effect of Hunyuan-4B-Instruct install, users can directly use Hunyuan-4B-Instruct installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
Hunyuan-4B-Instruct install url in huggingface.co: