ERNIE 4.5 模型的先进能力,特别是基于 MoE 的 A47B 和 A3B 系列,得益于以下几项关键技术创新:
多模态异构 MoE 预训练: 我们的模型在文本和视觉两种模态上联合训练,以更好地捕捉多模态信息的细微差异,并提高文本理解与生成、图像理解以及跨模态推理等任务的表现。为了防止一种模态阻碍另一种模态的学习,我们设计了 异构 MoE 结构,引入了 模态隔离路由,并使用了 路由正交损失 和 多模态令牌平衡损失。这些结构选择确保了两种模态的有效表示,从而在训练过程中实现相互强化。
规模效率化基础设施: 我们提出了一种新颖的异构混合并行性和层级负载均衡策略,用于 ERNIE 4.5 模型的效率化训练。通过使用节点内专家并行性、内存效率化管道调度、FP8 混合精度训练和细粒度重计算方法,我们实现了显著的预训练吞吐量。对于推理,我们提出了 多专家并行协作 方法和 卷积代码量化 算法,以实现 4-bit/2-bit 无损量化。此外,我们引入了基于动态角色切换的 PD 解聚合,以有效利用资源,增强 ERNIE 4.5 MoE 模型的推理性能。基于 PaddlePaddle 构建而成,ERNIE 4.5 在广泛的硬件平台上提供高性能推理。
模态特定后训练: 为了满足现实世界应用的多样化需求,我们对预训练模型进行了针对特定模态的微调。我们的 LLMs 优化了一般性语言理解和生成,而 VLMs 则专注于视觉语言理解,并支持思考和和非思考模式。每个模型都采用了一种结合 监督微调 (SFT)、直接偏好优化 (DPO) 或一种名为 统一偏好优化 (UPO) 的修改后的强化学习方法进行后训练。
ERNIE-4.5-300B-A47B 是一个文本 MoE 后训练模型,拥有 300B 总参数和每个标记激活的 47B 参数。以下是模型配置的详细信息:
| 关键字 | 值 |
|---|---|
| 模态 | 文本 |
| 训练阶段 | 预训练 |
| 参数(总/激活) | 300B / 47B |
| 层数 | 54 |
| 头部(Q/KV) | 64 / 8 |
| 文本专家(总/激活) | 64 / 8 |
| 视觉专家(总/激活) | 64 / 8 |
| 上下文长度 | 131072 |
可以使用以下 FastDeploy 命令快速完成服务部署。有关更详细的用法说明,请参考 FastDeploy 仓库。
注意: 若要在每个显存至少 80G 的 4 块 GPU 配置上部署,请指定 --quantization wint4。如果您指定 --quantization wint8,则需要 8 块 GPU 的资源。
python -m fastdeploy.entrypoints.openai.api_server \
--model baidu/ERNIE-4.5-300B-A47B-Paddle \
--port 8180 \
--metrics-port 8181 \
--quantization wint4 \
--tensor-parallel-size 8 \
--engine-worker-queue-port 8182 \
--max-model-len 32768 \
--max-num-seqs 32要使用 FastDeploy 部署 W4A8C8 量化版本,您可以运行以下命令。
python -m fastdeploy.entrypoints.openai.api_server \
--model baidu/ERNIE-4.5-300B-A47B-W4A8C8-TP4-Paddle \
--port 8180 \
--metrics-port 8181 \
--engine-worker-queue-port 8182 \
--tensor-parallel-size 4 \
--max-model-len 32768 \
--max-num-seqs 32要在单个141G GPU上使用FastDeploy部署WINT2量化版本,您可以运行以下命令。
python -m fastdeploy.entrypoints.openai.api_server \
--model "baidu/ERNIE-4.5-300B-A47B-2Bits-Paddle" \
--port 8180 \
--metrics-port 8181 \
--engine-worker-queue-port 8182 \
--tensor-parallel-size 1 \
--max-model-len 32768 \
--max-num-seqs 128以下是一个代码片段,展示了如何使用 ERNIE-4.5-300B-A47B-FP8 根据给定输入生成内容。
from fastdeploy import LLM, SamplingParams
prompts = [
"Hello, my name is",
]
sampling_params = SamplingParams(temperature=0.8, top_p=0.95, max_tokens=128)
model = "baidu/ERNIE-4.5-300B-A47B-FP8-Paddle"
llm = LLM(model=model, tensor_parallel_size=8, max_model_len=8192, num_gpu_blocks_override=1024, engine_worker_queue_port=9981)
outputs = llm.generate(prompts, sampling_params)
for output in outputs:
prompt = output.prompt
generated_text = output.outputs.text
print("generated_text", generated_text)为了达到最佳性能,我们建议使用 Temperature=0.8,TopP=0.8。
对于网络搜索,{references}、{date} 和 {question} 是参数。
对于中文问题,我们使用以下提示:
ernie_search_zh_prompt = \
'''下面你会收到当前时间、多个不同来源的参考文章和一段对话。你的任务是阅读多个参考文章,并根据参考文章中的信息回答对话中的问题。
以下是当前时间和参考文章:
---------
#当前时间
{date}
#参考文章
{references}
---------
请注意:
1. 回答必须结合问题需求和当前时间,对参考文章的可用性进行判断,避免在回答中使用错误或过时的信息。
2. 当参考文章中的信息无法准确地回答问题时,你需要在回答中提供获取相应信息的建议,或承认无法提供相应信息。
3. 你需要优先根据百科、官网、权威机构、专业网站等高权威性来源的信息来回答问题。
4. 回复需要综合参考文章中的相关数字、案例、法律条文、公式等信息,使你的答案更专业。
5. 当问题属于创作类任务时,需注意以下维度:
- 态度鲜明:观点、立场清晰明确,避免模棱两可,语言果断直接
- 文采飞扬:用词精准生动,善用修辞手法,增强感染力
- 有理有据:逻辑严密递进,结合权威数据/事实支撑论点
---------
下面请结合以上信息,回答问题,补全对话
{question}'''对于英文问题,我们采用如下提示语:
ernie_search_en_prompt = \
'''
Below you will be given the current time, multiple references from different sources, and a conversation. Your task is to read the references and use the information in them to answer the question in the conversation.
Here are the current time and the references:
---------
#Current Time
{date}
#References
{references}
---------
Please note:
1. Based on the question’s requirements and the current time, assess the usefulness of the references to avoid using inaccurate or outdated information in the answer.
2. If the references do not provide enough information to accurately answer the question, you should suggest how to obtain the relevant information or acknowledge that you are unable to provide it.
3. Prioritize using information from highly authoritative sources such as encyclopedias, official websites, authoritative institutions, and professional websites when answering questions.
4. Incorporate relevant numbers, cases, legal provisions, formulas, and other details from the references to make your answer more professional.
5. For creative tasks, keep these dimensions in mind:
- Clear attitude: Clear views and positions, avoid ambiguity, and use decisive and direct language
- Brilliant writing: Precise and vivid words, good use of rhetoric, and enhance the appeal
- Well-reasoned: Rigorous logic and progressive, combined with authoritative data/facts to support the argument
---------
Now, using the information above, answer the question and complete the conversation:
{question}'''参数说明:
##参考文章1
标题:周杰伦
文章发布时间:2025-04-20
内容:周杰伦(Jay Chou),1979年1月18日出生于台湾省新北市,祖籍福建省永春县,华语流行乐男歌手、音乐人、演员、导演、编剧,毕业于淡江中学。2000年,发行个人首张音乐专辑《Jay》。...
来源网站网址:baike.baidu.com
来源网站的网站名:百度百科
##参考文章2
...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={}
}当然,我会按照您的要求进行翻译。请您提供需要翻译的英文文本以及期望的中文风格(通俗、专业、优雅或流畅),我将会为您翻译。