🚀 EXAONE-4.0-32B GGUF模型
EXAONE-4.0-32B GGUF模型结合了先进的量化技术与高效的模型架构,在文本生成任务中具备出色的推理和非推理能力,支持多语言,适用于多种自然语言处理场景。
🚀 快速开始
你需要安装从原始版本分叉而来的transformers库,该库可在我们的PR中获取。一旦此PR合并并发布,我们将更新此部分内容。
你可以通过以下命令安装支持EXAONE 4.0的最新版本的transformers库:
pip install git+https://github.com/lgai-exaone/transformers@add-exaone4
✨ 主要特性
- 双模式运行:集成了非推理模式和推理模式,兼具EXAONE 3.5的出色可用性和EXAONE Deep的高级推理能力。
- 多语言支持:语言支持包括英语、韩语和西班牙语,拓展了模型的应用范围。
- 混合注意力机制:32B模型采用混合注意力方案,将局部注意力(滑动窗口注意力)与全局注意力(全注意力)按3:1的比例结合,且在全局注意力中不使用RoPE(旋转位置嵌入),以更好地理解全局上下文。
- QK重排序归一化:重新调整了LayerNorm的位置,直接将其应用于注意力和MLP输出,并在Q和K投影后添加RMS归一化,尽管计算量增加,但能在下游任务中产生更好的性能。
- 智能工具调用:具备工具调用能力,可作为智能代理使用,通过提供工具模式实现有效的工具调用。
📦 安装指南
安装transformers库
pip install git+https://github.com/lgai-exaone/transformers@add-exaone4
TensorRT-LLM部署
TensorRT-LLM在最新提交中正式支持EXAONE 4.0模型。在其发布之前,你需要克隆TensorRT-LLM仓库并从源代码进行构建。
git clone https://github.com/NVIDIA/TensorRT-LLM.git
克隆仓库后,你需要构建源代码以进行安装。请参考官方文档来构建TensorRT-LLM环境。
你可以按照以下步骤运行TensorRT-LLM服务器:
- 编写额外的配置YAML文件
kv_cache_config:
enable_block_reuse: false
- 使用配置运行服务器
trtllm-serve serve [MODEL_PATH] --backend pytorch --extra_llm_api_options extra_llm_api_config.yaml
更多详细信息,请参考TensorRT-LLM中EXAONE的文档。
⚠️ 重要提示
其他推理引擎(如vllm
和sglang
)目前尚未正式支持EXAONE 4.0。我们将在这些库更新后尽快进行更新。
💻 使用示例
基础用法
非推理模式
对于一般使用场景,你可以使用以下示例代码来使用EXAONE 4.0模型:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "LGAI-EXAONE/EXAONE-4.0-32B"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="bfloat16",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "Explain how wonderful you are"
prompt = "Explica lo increíble que eres"
prompt = "너가 얼마나 대단한지 설명해 봐"
messages = [
{"role": "user", "content": prompt}
]
input_ids = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
)
output = model.generate(
input_ids.to(model.device),
max_new_tokens=128,
do_sample=False,
)
print(tokenizer.decode(output[0]))
推理模式
EXAONE 4.0模型具备处理复杂问题的推理能力。你可以通过在分词器中使用enable_thinking=True
参数来激活推理模式,该参数会打开一个以<think>
标签开头的推理块,但不会关闭它。
messages = [
{"role": "user", "content": "Which one is bigger, 3.12 vs 3.9?"}
]
input_ids = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
enable_thinking=True,
)
output = model.generate(
input_ids.to(model.device),
max_new_tokens=128,
do_sample=True,
temperature=0.6,
top_p=0.95
)
print(tokenizer.decode(output[0]))
⚠️ 重要提示
推理模式下的模型生成会受到采样参数的敏感影响,请参考使用指南以获得更好的质量。
智能工具调用
EXAONE 4.0模型可以作为智能代理使用,具备工具调用能力。你可以向模型提供工具模式以实现有效的工具调用。
import random
def roll_dice(max_num: int):
return random.randint(1, max_num)
tools = [
{
"type": "function",
"function": {
"name": "roll_dice",
"description": "Roll a dice with the number 1 to N. User can select the number N.",
"parameters": {
"type": "object",
"required": ["max_num"],
"properties": {
"max_num": {
"type": "int",
"description": "Max number of the dice"
}
}
}
}
}
]
messages = [
{"role": "user", "content": "Roll D6 dice twice!"}
]
input_ids = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
tools=tools,
)
output = model.generate(
input_ids.to(model.device),
max_new_tokens=1024,
do_sample=True,
temperature=0.6,
top_p=0.95,
)
print(tokenizer.decode(output[0]))
📚 详细文档
模型生成细节
此模型使用llama.cpp在提交版本bf9087f5
时生成。
超越IMatrix的量化
我一直在尝试一种新的量化方法,该方法有选择地提高关键层的精度,超越了默认IMatrix配置所提供的精度。
在我的测试中,标准IMatrix量化在较低比特深度下表现不佳,尤其是在专家混合(MoE)模型中。为了解决这个问题,我在llama.cpp
中使用--tensor-type
选项手动将重要层的精度提升。你可以在以下链接查看实现代码:
👉 使用llama.cpp进行层精度提升
虽然这会增加模型文件的大小,但它显著提高了给定量化级别的精度。
选择合适的GGUF模型格式
点击此处获取选择合适GGUF模型格式的信息。
模型配置
属性 |
详情 |
模型类型 |
EXAONE-4.0-32B |
参数数量(不包括嵌入层) |
309.5亿 |
层数 |
64 |
注意力头数量 |
GQA,40个头和8个KV头 |
词汇表大小 |
102,400 |
上下文长度 |
131,072个标记 |
🔧 技术细节
在EXAONE 4.0架构中,与之前的EXAONE模型相比,我们进行了以下新的架构更改:
- 混合注意力:对于32B模型,我们采用混合注意力方案,将*局部注意力(滑动窗口注意力)与全局注意力(全注意力)*按3:1的比例结合。为了更好地理解全局上下文,我们在全局注意力中不使用RoPE(旋转位置嵌入)。
- QK重排序归一化:我们从传统的Pre-LN方案中重新调整了LayerNorm的位置,直接将其应用于注意力和MLP输出,并在Q和K投影后添加RMS归一化。尽管这会消耗更多的计算资源,但有助于在下游任务中产生更好的性能。
更多详细信息,请参考我们的技术报告、HuggingFace论文、博客和GitHub。
📊 性能表现
以下表格展示了每个模型在推理和非推理模式下的评估结果。评估细节可在技术报告中找到。
32B推理模式
|
EXAONE 4.0 32B |
Phi 4 reasoning - plus |
Magistral Small - 2506 |
Qwen 3 32B |
Qwen 3 235B |
DeepSeek R1 - 0528 |
模型大小 |
320亿 |
147亿 |
236亿 |
328亿 |
2350亿 |
6710亿 |
混合推理 |
✅ |
|
|
✅ |
✅ |
|
世界知识 |
|
|
|
|
|
|
MMLU - Redux |
92.3 |
90.8 |
86.8 |
90.9 |
92.7 |
93.4 |
MMLU - Pro |
81.8 |
76.0 |
73.4 |
80.0 |
83.0 |
85.0 |
GPQA - Diamond |
75.4 |
68.9 |
68.2 |
68.4 |
71.1 |
81.0 |
数学/编码 |
|
|
|
|
|
|
AIME 2025 |
85.3 |
78.0 |
62.8 |
72.9 |
81.5 |
87.5 |
HMMT Feb 2025 |
72.9 |
53.6 |
43.5 |
50.4 |
62.5 |
79.4 |
LiveCodeBench v5 |
72.6 |
51.7 |
55.8 |
65.7 |
70.7 |
75.2 |
LiveCodeBench v6 |
66.7 |
47.1 |
47.4 |
60.1 |
58.9 |
70.3 |
指令跟随 |
|
|
|
|
|
|
IFEval |
83.7 |
84.9 |
37.9 |
85.0 |
83.4 |
80.8 |
Multi - IF (EN) |
73.5 |
56.1 |
27.4 |
73.4 |
73.4 |
72.0 |
智能工具调用 |
|
|
|
|
|
|
BFCL - v3 |
63.9 |
N/A |
40.4 |
70.3 |
70.8 |
64.7 |
Tau - bench (Airline) |
51.5 |
N/A |
38.5 |
34.5 |
37.5 |
53.5 |
Tau - bench (Retail) |
62.8 |
N/A |
10.2 |
55.2 |
58.3 |
63.9 |
多语言能力 |
|
|
|
|
|
|
KMMLU - Pro |
67.7 |
55.8 |
51.5 |
61.4 |
68.1 |
71.7 |
KMMLU - Redux |
72.7 |
62.7 |
54.6 |
67.5 |
74.5 |
77.0 |
KSM |
87.6 |
79.8 |
71.9 |
82.8 |
86.2 |
86.7 |
MMMLU (ES) |
85.6 |
84.3 |
68.9 |
82.8 |
86.7 |
88.2 |
MATH500 (ES) |
95.8 |
94.2 |
83.5 |
94.3 |
95.1 |
96.0 |
32B非推理模式
|
EXAONE 4.0 32B |
Phi 4 |
Mistral - Small - 2506 |
Gemma 3 27B |
Qwen3 32B |
Qwen3 235B |
Llama - 4 - Maverick |
DeepSeek V3 - 0324 |
模型大小 |
320亿 |
147亿 |
240亿 |
274亿 |
328亿 |
2350亿 |
4020亿 |
6710亿 |
混合推理 |
✅ |
|
|
|
✅ |
✅ |
|
|
世界知识 |
|
|
|
|
|
|
|
|
MMLU - Redux |
89.8 |
88.3 |
85.9 |
85.0 |
85.7 |
89.2 |
92.3 |
92.3 |
MMLU - Pro |
77.6 |
70.4 |
69.1 |
67.5 |
74.4 |
77.4 |
80.5 |
81.2 |
GPQA - Diamond |
63.7 |
56.1 |
46.1 |
42.4 |
54.6 |
62.9 |
69.8 |
68.4 |
数学/编码 |
|
|
|
|
|
|
|
|
AIME 2025 |
35.9 |
17.8 |
30.2 |
23.8 |
20.2 |
24.7 |
18.0 |
50.0 |
HMMT Feb 2025 |
21.8 |
4.0 |
16.9 |
10.3 |
9.8 |
11.9 |
7.3 |
29.2 |
LiveCodeBench v5 |
43.3 |
24.6 |
25.8 |
27.5 |
31.3 |
35.3 |
43.4 |
46.7 |
LiveCodeBench v6 |
43.1 |
27.4 |
26.9 |
29.7 |
28.0 |
31.4 |
32.7 |
44.0 |
指令跟随 |
|
|
|
|
|
|
|
|
IFEval |
84.8 |
63.0 |
77.8 |
82.6 |
83.2 |
83.2 |
85.4 |
81.2 |
Multi - IF (EN) |
71.6 |
47.7 |
63.2 |
72.1 |
71.9 |
72.5 |
77.9 |
68.3 |
长上下文处理 |
|
|
|
|
|
|
|
|
HELMET |
58.3 |
N/A |
61.9 |
58.3 |
54.5 |
63.3 |
13.7 |
N/A |
RULER |
88.2 |
N/A |
|
|
|
|
|
|
📄 许可证
本项目采用其他许可证,许可证名称为exaone,具体许可证信息请参考LICENSE。