🚀 ERNIE-4.5-300B-A47B
ERNIE-4.5-300B-A47Bは、高度な技術革新に基づくテキスト生成モデルです。多様なモダリティをサポートし、大規模なパラメータを持つことで、自然言語処理タスクで高い性能を発揮します。
⚠️ 重要な注意事項
「-Paddle」モデルはPaddlePaddleのウェイトを使用し、「-PT」モデルはTransformerスタイルのPyTorchウェイトを使用します。
✨ 主な機能
ERNIE 4.5モデル、特にMoEベースのA47BおよびA3Bシリーズの高度な機能は、いくつかの重要な技術革新に支えられています。
-
マルチモーダル異種MoE事前学習:モデルはテキストとビジュアルの両方のモダリティで共同学習され、マルチモーダル情報のニュアンスをよりよく捉え、テキスト理解と生成、画像理解、クロスモーダル推論などのタスクでの性能を向上させます。これを実現するために、異種MoE構造を設計し、モダリティ分離ルーティングを組み込み、ルータ直交損失とマルチモーダルトークンバランス損失を採用しています。これらのアーキテクチャ選択により、両方のモダリティが効果的に表現され、学習中に相互に強化されます。
-
スケーラビリティに優れたインフラストラクチャ:ERNIE 4.5モデルの効率的な学習のために、新しい異種ハイブリッド並列化と階層的負荷分散戦略を提案しています。ノード内エキスパート並列化、メモリ効率の高いパイプラインスケジューリング、FP8混合精度学習、および細粒度な再計算方法を使用することで、驚くほど高い事前学習スループットを達成しています。推論に関しては、マルチエキスパート並列協調方法と畳み込みコード量子化アルゴリズムを提案し、4ビット/2ビットの損失なし量子化を実現しています。さらに、動的な役割切り替えを伴うPD分散化を導入し、ERNIE 4.5 MoEモデルの推論性能を向上させるための効果的なリソース利用を実現しています。PaddlePaddleをベースに構築されたERNIE 4.5は、幅広いハードウェアプラットフォームで高性能な推論を提供します。
-
モダリティ固有の事後学習:実世界のアプリケーションの多様な要件を満たすために、事前学習モデルのバリアントを特定のモダリティ用に微調整しています。大規模言語モデル(LLM)は汎用的な言語理解と生成に最適化されています。ビジュアル言語モデル(VLM)はビジュアル言語理解に焦点を当て、思考モードと非思考モードの両方をサポートしています。各モデルは、事後学習に教師付き微調整(SFT)、直接嗜好最適化(DPO)、または*統一嗜好最適化(UPO)*と呼ばれる修正強化学習方法を組み合わせて使用しています。
📦 インストール
transformers
ライブラリを使用する場合
注意:モデルを使用する前に、transformers
ライブラリ(バージョン4.50.0以上)がインストールされていることを確認してください。
以下は、与えられた入力に基づいてモデルを使用してコンテンツを生成するコードスニペットです。
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "baidu/ERNIE-4.5-300B-A47B-PT"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
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)
generated_ids = model.generate(
model_inputs.input_ids,
max_new_tokens=1024
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
generate_text = tokenizer.decode(output_ids, skip_special_tokens=True).strip("\n")
print("generate_text:", generate_text)
vLLMを使用する場合
vllmのGitHubライブラリを使用します。Pythonのみのビルドを行います。
vllm serve baidu/ERNIE-4.5-300B-A47B-PT --trust-remote-code
vllm serve baidu/ERNIE-4.5-300B-A47B-PT --trust-remote-code --quantization fp8
📚 ドキュメント
サンプリングパラメータ
最適な性能を得るために、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}'''
パラメータの説明:
- {question}はユーザーの質問です。
- {date}は現在の時間で、推奨フォーマットは「YYYY-MM-DD HH:MM:SS, Day of the Week, Beijing/China」です。
- {references}は参考資料で、推奨フォーマットは以下の通りです。
##参考文章1
标题:周杰伦
文章发布时间:2025-04-20
内容:周杰伦(Jay Chou),1979年1月18日出生于台湾省新北市,祖籍福建省永春县,华语流行乐男歌手、音乐人、演员、导演、编剧,毕业于淡江中学。2000年,发行个人首张音乐专辑《Jay》。...
来源网站网址:baike.baidu.com
来源网站的网站名:百度百科
##参考文章2
...
🔧 技術詳細
ERNIE-4.5-300B-A47Bは、総パラメータ数が3000億、各トークンの活性化パラメータが470億のテキストMoE事後学習モデルです。以下はモデルの構成詳細です。
属性 |
詳細 |
モダリティ |
テキスト |
学習段階 |
事前学習 |
パラメータ(総数 / 活性化数) |
3000億 / 470億 |
レイヤー数 |
54 |
ヘッド数(Q/KV) |
64 / 8 |
テキストエキスパート数(総数 / 活性化数) |
64 / 8 |
ビジュアルエキスパート数(総数 / 活性化数) |
64 / 8 |
コンテキスト長 |
131072 |
📄 ライセンス
ERNIE 4.5モデルは、Apache License 2.0の下で提供されています。このライセンスは、その条件に従って商用利用を許可しています。Copyright (c) 2025 Baidu, Inc. All Rights Reserved.
引用
ERNIE 4.5が役に立った場合、またはあなたのプロジェクトで使用したい場合は、以下の技術レポートを引用してください。
@misc{ernie2025technicalreport,
title={ERNIE 4.5 Technical Report},
author={Baidu ERNIE Team},
year={2025},
eprint={},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={}
}