Views
No views yet

| Model | Hunyuan-0.5B-Pretrain | Hunyuan-1.8B-Pretrain | Hunyuan-4B-Pretrain | Hunyuan-7B-Pretrain |
|---|---|---|---|---|
| MMLU | 54.02 | 64.62 | 74.01 | 79.82 |
| MMLU-Redux | 54.72 | 64.42 | 73.53 | 79 |
| MMLU-Pro | 31.15 | 38.65 | 51.91 | 57.79 |
| SuperGPQA | 17.23 | 24.98 | 27.28 | 30.47 |
| BBH | 45.92 | 74.32 | 75.17 | 82.95 |
| GPQA | 27.76 | 35.81 | 43.52 | 44.07 |
| GSM8K | 55.64 | 77.26 | 87.49 | 88.25 |
| MATH | 42.95 | 62.85 | 72.25 | 74.85 |
| EvalPlus | 39.71 | 60.67 | 67.76 | 66.96 |
| MultiPL-E | 21.83 | 45.92 | 59.87 | 60.41 |
| MBPP | 43.38 | 66.14 | 76.46 | 76.19 |
| CRUX-O | 30.75 | 36.88 | 56.5 | 60.75 |
| Chinese SimpleQA | 12.51 | 22.31 | 30.53 | 38.86 |
| simpleQA (5shot) | 2.38 | 3.61 | 4.21 | 5.69 |
| Topic | Bench | Hunyuan-0.5B-Instruct | Hunyuan-1.8B-Instruct | Hunyuan-4B-Instruct | Hunyuan-7B-Instruct |
|---|---|---|---|---|---|
| Mathematics | AIME 2024 AIME 2025 MATH | 17.2 20 48.5 | 56.7 53.9 86 | 78.3 66.5 92.6 | 81.1 75.3 93.7 |
| Science | GPQA-Diamond OlympiadBench | 23.3 29.6 | 47.2 63.4 | 61.1 73.1 | 60.1 76.5 |
| Coding | Livecodebench Fullstackbench | 11.1 20.9 | 31.5 42 | 49.4 54.6 | 57 56.3 |
| Reasoning | BBH DROP ZebraLogic | 40.3 52.8 34.5 | 64.6 76.7 74.6 | 83 78.2 83.5 | 87.8 85.9 85.1 |
| Instruction Following | IF-Eval SysBench | 49.7 28.1 | 67.6 55.5 | 76.6 68 | 79.3 72.7 |
| Agent | BFCL v3 τ-Bench ComplexFuncBench C3-Bench | 49.8 14.4 13.9 45.3 | 58.3 18.2 22.3 54.6 | 67.9 30.1 26.3 64.3 | 70.8 35.3 29.2 68.5 |
| Long Context | PenguinScrolls longbench-v2 FRAMES | 53.9 34.7 41.9 | 73.1 33.2 55.6 | 83.1 44.1 79.2 | 82 43 78.6 |
pip install "transformers>=4.56.0"1from transformers import AutoModelForCausalLM, AutoTokenizer
2import os
3import re
4
5model_name_or_path = "tencent/Hunyuan-7B-Instruct"
6
7tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
8model = AutoModelForCausalLM.from_pretrained(model_name_or_path, device_map="auto") # You may want to use bfloat16 and/or move to GPU here
9messages = [
10 {"role": "user", "content": "Write a short summary of the benefits of regular exercise"},
11]
12tokenized_chat = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True,return_tensors="pt",
13 enable_thinking=True # Toggle thinking mode (default: True)
14 )
15
16outputs = model.generate(tokenized_chat.to(model.device), max_new_tokens=2048)
17
18output_text = tokenizer.decode(outputs[0])
19print("output_text=",output_text)
20think_pattern = r'<think>(.*?)</think>'
21think_matches = re.findall(think_pattern, output_text, re.DOTALL)
22
23answer_pattern = r'<answer>(.*?)</answer>'
24answer_matches = re.findall(answer_pattern, output_text, re.DOTALL)
25
26think_content = [match.strip() for match in think_matches][0]
27answer_content = [match.strip() for match in answer_matches][0]
28print(f"thinking_content:{think_content}\n\n")
29print(f"answer_content:{answer_content}\n\n")
30
311
2{
3 "do_sample": true,
4 "top_k": 20,
5 "top_p": 0.8,
6 "repetition_penalty": 1.05,
7 "temperature": 0.7
8}1# think_pattern
2think = ""
3answer = ""
4think_pattern = f"<think>\n{think}\n</think>\n<answer>\n{answer}\n</answer>"
5
6# fast think pattern
7messages = [
8 {"role": "system", "content": "You are a helpful assistant."},
9 {"role": "user", "content": "/no_think海水为什么是咸的" },
10 {"role": "assistant", "content": "<think>\n\n</think>\n<answer>\n海水是咸的主要是因为其中含有许多溶解在水中的盐类和矿物质。这些盐类和矿物质来自于地球表面的岩石和土壤中的化学物质,随着时间的推移,它们被带到了海洋中。当海水蒸发时,水分蒸发掉了,但盐类和矿物质仍然留在水中,导致海水变得更加咸味。因此,海水的咸度是由其中的盐类和矿物质的含量决定的。\n</answer>"}
11]
12
13# slow think pattern
14messages = [
15 {"role": "system", "content": "You are a helpful assistant."},
16 {"role": "user", "content": "1+1=" },
17 {"role": "assistant", "content": "<think>\n嗯,用户问的是1加1等于多少。首先,我需要确认这是一个基本的算术问题。1加1在十进制的数学体系中,通常的结果是2。不过,可能需要考虑是否有其他情况,比如二进制或者其他数制,但用户没有特别说明,所以默认应该是十进制。另外,有时候可能会有脑筋急转弯的情况,比如在某些语境下1+1可能等于1(比如1滴水加1滴水还是1滴水),但通常数学问题中都是2。所以最准确的回答应该是2。</think>\n<answer>\n在十进制的基本算术运算中,1加1的结果是2。这是数学中最基础的加法运算之一,遵循自然数的加法规则。因此,1 + 1 = 2。\n</answer>"}
18]
19
20from transformers import AutoTokenizer
21tokenizer = AutoTokenizer.from_pretrained("your_tokenizer_path", trust_remote_code=True)
22train_ids = tokenizer.apply_chat_template(messages)LLaMA-Factory to fine-tune the Hunyuan model.pip install git+https://github.com/huggingface/transformers@4970b23cedaf745f963779b4eae68da281e8c6cajson format and place it in the data directory in LLaMA-Factory. The current implementation uses the sharegpt dataset format, which requires the following structure:[
{
"messages": [
{
"role": "system",
"content": "System prompt (optional)"
},
{
"role": "user",
"content": "Human instruction"
},
{
"role": "assistant",
"content": "Model response"
}
]
}
]"dataset_name": {
"file_name": "dataset.json",
"formatting": "sharegpt",
"columns": {
"messages": "messages"
},
"tags": {
"role_tag": "role",
"content_tag": "content",
"user_tag": "user",
"assistant_tag": "assistant",
"system_tag": "system"
}
}train/llama_factory_support/example_configs directory to the example/hunyuan directory in LLaMA-Factory.hunyuan_full.yaml. Adjust other configurations as needed:### model
model_name_or_path: [!!!add the model path here!!!]
### dataset
dataset: [!!!add the dataset name here!!!]export DISABLE_VERSION_CHECK=1
llamafactory-cli train examples/hunyuan/hunyuan_full.yamlexport DISABLE_VERSION_CHECK=1
FORCE_TORCHRUN=1 NNODES=${NNODES} NODE_RANK=${NODE_RANK} MASTER_ADDR=${MASTER_ADDR} MASTER_PORT=${MASTER_PORT} \
llamafactory-cli train examples/hunyuan/hunyuan_full.yamlAngleSlim is a toolset dedicated to creating a more user-friendly, comprehensive and efficient model compression solution.| 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 |
docker pull hunyuaninfer/hunyuan-7B:hunyuan-moe-7B-trtllmdocker run --privileged --user root --name hunyuanLLM_infer --rm -it --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 --gpus=all hunyuaninfer/hunyuan-7B:hunyuan-moe-7B-trtllmcat >/path/to/extra-llm-api-config.yml <<EOF
use_cuda_graph: true
cuda_graph_padding_enabled: true
cuda_graph_batch_sizes:
- 1
- 2
- 4
- 8
- 16
- 32
print_iter_log: true
EOFtrtllm-serve \
/path/to/HunYuan-moe-7B \
--host localhost \
--port 8000 \
--backend pytorch \
--max_batch_size 32 \
--max_num_tokens 16384 \
--tp_size 2 \
--kv_cache_free_gpu_memory_fraction 0.6 \
--trust_remote_code \
--extra_llm_api_options /path/to/extra-llm-api-config.ymlmodelscope download --model Tencent-Hunyuan/Hunyuan-7B-Instructexport MODEL_PATH=tencent/Hunyuan-7B-Instructexport MODEL_PATH=/root/.cache/modelscope/hub/models/Tencent-Hunyuan/Hunyuan-7B-Instruct/1python3 -m vllm.entrypoints.openai.api_server \
2 --host 0.0.0.0 \
3 --port 8000 \
4 --trust-remote-code \
5 --model ${MODEL_PATH} \
6 --tensor-parallel-size 1 \
7 --dtype bfloat16 \
8 --quantization experts_int8 \
9 --served-model-name hunyuan \
10 2>&1 | tee log_server.txt1curl http://0.0.0.0:8000/v1/chat/completions -H 'Content-Type: application/json' -d '{
2"model": "hunyuan",
3"messages": [
4 {
5 "role": "system",
6 "content": [{"type": "text", "text": "You are a helpful assistant."}]
7 },
8 {
9 "role": "user",
10 "content": [{"type": "text", "text": "请按面积大小对四大洋进行排序,并给出面积最小的洋是哪一个?直接输出结果。"}]
11 }
12],
13"max_tokens": 2048,
14"temperature":0.7,
15"top_p": 0.6,
16"top_k": 20,
17"repetition_penalty": 1.05,
18"stop_token_ids": [127960]
19}'1python3 -m vllm.entrypoints.openai.api_server \
2 --host 0.0.0.0 \
3 --port 8000 \
4 --trust-remote-code \
5 --model ${MODEL_PATH} \
6 --tensor-parallel-size 1 \
7 --dtype bfloat16 \
8 --served-model-name hunyuan \
9 --quantization experts_int8 \
10 2>&1 | tee log_server.txtexport MODEL_PATH=PATH_TO_INT4_MODEL1python3 -m vllm.entrypoints.openai.api_server \
2 --host 0.0.0.0 \
3 --port 8000 \
4 --trust-remote-code \
5 --model ${MODEL_PATH} \
6 --tensor-parallel-size 1 \
7 --dtype bfloat16 \
8 --served-model-name hunyuan \
9 --quantization gptq_marlin \
10 2>&1 | tee log_server.txt1python3 -m vllm.entrypoints.openai.api_server \
2 --host 0.0.0.0 \
3 --port 8000 \
4 --trust-remote-code \
5 --model ${MODEL_PATH} \
6 --tensor-parallel-size 1 \
7 --dtype bfloat16 \
8 --served-model-name hunyuan \
9 --kv-cache-dtype fp8 \
10 2>&1 | tee log_server.txtdocker pull lmsysorg/sglang:latestdocker run --entrypoint="python3" --gpus all \
--shm-size 32g \
-p 30000:30000 \
--ulimit nproc=10000 \
--privileged \
--ipc=host \
lmsysorg/sglang:latest \
-m sglang.launch_server --model-path hunyuan/huanyuan_7B --tp 4 --trust-remote-code --host 0.0.0.0 --port 30000