ERNIE 4.5 系列模型(尤其是基于 MoE 架构的 A47B 和 A3B 版本)的卓越能力源于多项关键技术突破:
多模态异构混合专家预训练:模型通过联合训练文本与视觉模态,深度捕捉跨模态信息关联,显著提升文本理解生成、图像解析及跨模态推理能力。为避免模态间学习干扰,我们创新设计了异构MoE结构,采用模态隔离路由机制,并引入路由器正交损失与多模态令牌均衡损失,确保双模态表征既独立又互补,实现协同优化。
高效可扩展的基础架构:我们提出异构混合并行与分层负载均衡策略,结合节点内专家并行、内存优化流水线调度、FP8混合精度训练及细粒度重计算技术,大幅提升预训练吞吐量。推理阶段采用多专家并行协作方法与卷积编码量化算法,实现4比特/2比特无损量化。此外,通过动态角色切换的PD解耦技术,显著提升MoE模型推理效率。基于PaddlePaddle框架,ERNIE 4.5 可在多样化硬件平台上实现高性能推理。
模态定向微调优化:为满足实际场景需求,我们对预训练模型进行模态专项微调。通用大语言模型(LLM)专注于文本理解与生成;视觉语言模型(VLM)强化图文交互能力,支持思维链与非思维链双模式。采用监督微调(SFT)、*直接偏好优化(DPO)及改进的强化学习方法统一偏好优化(UPO)*进行模型对齐。
在视觉语言模型微调阶段,图文深度融合对复杂任务(如理解、推理、生成)的性能起决定性作用。我们围绕图像理解、任务适配微调和多模态思维链推理三大核心能力,系统构建训练数据并优化策略。进一步通过可验证奖励的强化学习(RLVR)提升对齐质量。经SFT与RL阶段优化后,最终获得ERNIE-4.5-VL-28B-A3B模型。
ERNIE-4.5-VL-28B-A3B 是一款多模态混合专家对话模型,总参数量280亿,单token激活参数量30亿。关键配置如下:
| 参数项 | 值 |
|---|---|
| 模态支持 | 文本 & 视觉 |
| 训练阶段 | 微调阶段 |
| 参数量(总量/激活量) | 280亿/30亿 |
| 网络层数 | 28 |
| 注意力头数(Q/KV) | 20 / 4 |
| 文本专家数(总量/激活量) | 64 / 6 |
| 视觉专家数(总量/激活量) | 64 / 6 |
| 共享专家数 | 2 |
| 上下文长度 | 131072 |
使用FastDeploy快速部署服务,示例如下。完整用法请参考FastDeploy GitHub仓库。
注意:单卡部署需至少80GB显存。
python -m fastdeploy.entrypoints.openai.api_server \
--model baidu/ERNIE-4.5-VL-28B-A3B-Paddle \
--port 8180 \
--metrics-port 8181 \
--engine-worker-queue-port 8182 \
--max-model-len 32768 \
--enable-mm \
--reasoning-parser ernie-45-vl \
--max-num-seqs 32ERNIE-4.5-VL 模型支持通过请求参数开启或关闭思考模式。
curl -X POST "http://0.0.0.0:8180/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://paddlenlp.bj.bcebos.com/datasets/paddlemix/demo_images/example2.jpg"}},
{"type": "text", "text": "Descript this image"}
]}
],
"metadata": {"enable_thinking": true}
}'curl -X POST "http://0.0.0.0:8180/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://paddlenlp.bj.bcebos.com/datasets/paddlemix/demo_images/example2.jpg"}},
{"type": "text", "text": "Descript this image"}
]}
],
"metadata": {"enable_thinking": false}
}'transformers 库以下是一个利用 transformers 库进行推理的示例:
import torch
from transformers import AutoProcessor, AutoTokenizer, AutoModelForCausalLM
model_path = 'baidu/ERNIE-4.5-VL-28B-A3B-PT'
model = AutoModelForCausalLM.from_pretrained(
model_path,
device_map="auto",
torch_dtype=torch.bfloat16,
trust_remote_code=True
)
processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)
processor.eval()
model.add_image_preprocess(processor)
messages = [
{
"role": "user",
"content": [
{"type": "text", "text": "Describe the image."},
{"type": "image_url", "image_url": {"url": "https://paddlenlp.bj.bcebos.com/datasets/paddlemix/demo_images/example1.jpg"}},
]
},
]
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True, enable_thinking=False
)
image_inputs, video_inputs = processor.process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
device = next(model.parameters()).device
inputs = inputs.to(device)
generated_ids = model.generate(
inputs=inputs['input_ids'].to(device),
**inputs,
max_new_tokens=128
)
output_text = processor.decode(generated_ids[0])
print(output_text)我们正与社区合作,全面适配ERNIE4.5模型,敬请期待。
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},
eprint={},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={}
}