在过去的三个月中,我们持续提升ERNIE-4.5-21B-A3B的思维能力,改进推理的质量与深度,从而增强ERNIE轻量级模型在复杂推理任务中的竞争力。我们荣幸地推出ERNIE-4.5-21B-A3B-Thinking,其主要增强点如下:
[!NOTE] 注意:此版本的思维长度有所增加。我们强烈推荐将其用于高度复杂的推理任务。

ERNIE-4.5-21B-A3B-Thinking 是一款文本 MoE 后训练模型,总参数为 210 亿,每个 token 的激活参数为 30 亿。以下是模型配置详情:
| 关键项 | 数值 |
|---|---|
| 模态 | 文本 |
| 训练阶段 | 后训练 |
| 参数(总计/激活) | 21B / 3B |
| 层数 | 28 |
| 注意力头数(Q/KV) | 20 / 4 |
| 文本专家数(总计/激活) | 64 / 6 |
| 视觉专家数(总计/激活) | 64 / 6 |
| 共享专家数 | 2 |
| 上下文长度 | 131072 |
[!NOTE] 为与更广泛的社区保持一致,本模型发布 Transformer 风格权重。PyTorch 和 PaddlePaddle 生态工具(如 vLLM、transformers 和 FastDeploy)预计能够加载并运行此模型。
如下所示,使用 FastDeploy 快速部署服务。有关更详细的用法,请参阅 FastDeploy GitHub 仓库。
注意:需要 80GB x 1 GPU 资源。部署此模型需要 FastDeploy 2.2 版本。
python -m fastdeploy.entrypoints.openai.api_server \
--model baidu/ERNIE-4.5-21B-A3B-Thinking \
--port 8180 \
--metrics-port 8181 \
--engine-worker-queue-port 8182 \
--load_choices "default_v1" \
--tensor-parallel-size 1 \
--max-model-len 131072 \
--reasoning-parser ernie_x1 \
--tool-call-parser ernie_x1 \
--max-num-seqs 32ERNIE-4.5-21B-A3B-Thinking模型支持函数调用。
curl -X POST "http://0.0.0.0:8180/v1/chat/completions" \
-H "Content-Type: application/json" \
-d $'{
"messages": [
{
"role": "user",
"content": "How \'s the weather in Beijing today?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Determine weather in my location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"c",
"f"
]
}
},
"additionalProperties": false,
"required": [
"location",
"unit"
]
},
"strict": true
}
}]
}'vllm serve baidu/ERNIE-4.5-21B-A3B-ThinkingvLLM Ernie 的 reasoning-parser 和 tool-call-parser 目前正在开发中。
transformers 库注意:使用此模型需要安装 transformers 库(4.54.0 或更高版本)。
以下代码片段展示了如何使用模型根据给定输入生成内容。
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "baidu/ERNIE-4.5-21B-A3B-Thinking"
# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
device_map="auto",
torch_dtype=torch.bfloat16,
)
# prepare the model input
prompt = "Give me a short introduction to large language model."
messages = [
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], add_special_tokens=False, return_tensors="pt").to(model.device)
# conduct text completion
generated_ids = model.generate(
**model_inputs,
max_new_tokens=1024
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
# decode the generated ids
generate_text = tokenizer.decode(output_ids, skip_special_tokens=True)
print("generate_text:", generate_text)ERNIE 4.5 模型基于 Apache License 2.0 协议提供。本协议允许商业使用,但需遵守其条款和条件。版权所有 (c) 2025 百度公司。保留所有权利。
如果您认为 ERNIE 4.5 模型对您的工作有帮助,或希望在您的项目中使用该模型,请引用我们的技术报告:
@misc{ernie2025technicalreport,
title={ERNIE 4.5 Technical Report},
author={Baidu-ERNIE-Team},
year={2025},
primaryClass={cs.CL},
howpublished={\url{https://ernie.baidu.com/blog/publication/ERNIE_Technical_Report.pdf}}
}