liaojc commited on
Commit
9fc2832
·
verified ·
1 Parent(s): cc9c9c3

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +119 -0
README.md ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ base_model:
6
+ - baidu/ERNIE-4.5-300B-A47B-Base-PT
7
+ ---
8
+ # ERNIE-4.5-300B-A47B-Base
9
+ ## ERNIE 4.5 Highlights
10
+ The advanced capabilities of the ERNIE 4.5 models, particularly the MoE-based A47B and A3B series, are underpinned by several key technical innovations:
11
+ - **Multimodal MoE Pretraining:** Our models are jointly trained on both textual and visual modalities to better capture the nuances of multimodal information and improve performance on tasks involving text generation, image understanding, and cross-modal reasoning. To achieve this without one modality hindering the learning of another, we designed a heterogeneous MoE structure, incorporated three-dimensional rotary embeddings, and employed router orthogonal loss and multimodal token-balanced loss. These architectural choices ensure that both modalities are effectively represented, allowing for mutual reinforcement during training.
12
+ - **Scaling-Efficient Architecture and Infrastructure:** To train the large multimodal MoE models efficiently, we introduce a novel heterogeneous hybrid parallelism and multi-level load balancing strategy for efficient training of ERNIE 4.5 models. By using on-device expert parallelism, memory-efficient pipeline scheduling, and FP8 mixed precision, we achieve ideal pre-training performance. For inference, we propose a quantization method with collaborative parallelism among multiple experts to achieve lossless quantization. Built on PaddlePaddle, ERNIE 4.5 delivers high-performance inference across a wide range of hardware platforms.
13
+ - **Modality-Specific Post-training:** To meet the diverse requirements of real-world applications, we fine-tuned variants of the pretrained model for specific modalities. Our LLMs are optimized for general-purpose language understanding and generation. The VLMs focuses on visual-language understanding and supports both thinking and no-thinking mode. Each model employed a combination of Supervised Fine-tuning (SFT), Direct Preference Optimization (DPO) or a modified reinforcement learning method named Unified Preference Optimization (UPO) for post-training, using targeted datasets aligned with its intended usage scenario.
14
+
15
+ To ensure the stability of multimodal joint training, we adopt a staged training strategy. In the first and second stage, we train only the text-related parameters, enabling the model to develop strong fundamental language understanding as well as long-text processing capabilities. The final multimodal stage extends capabilities to images and videos by introducing additional parameters including a ViT for image feature extraction, an adapter for feature transformation, and visual experts for multimodal understanding. At this stage, text and visual modalities mutually enhance each other. After pretraining trillions tokens, we extracted the text-related parameters and finally obtained ERNIE-4.5-300B-A47B-Base。
16
+
17
+
18
+ ## Model Overview
19
+ ERNIE-4.5-300B-A47B-Base is a text MoE Base model, with 300B total parameters and 47B activated parameters for each token. The following are the model configuration details:
20
+
21
+ | Key | Value |
22
+ | --- | --- |
23
+ | Modality | Text |
24
+ | Training Stage | Pretraining |
25
+ | Params(Total / Activated) | 300B / 47B |
26
+ | Layers | 54 |
27
+ | Heads(Q/KV) | 64 / 8 |
28
+ | Text Experts(Total / Activated) | 64 / 8 |
29
+ | Vision Experts(Total / Activated) | 64 / 8 |
30
+ | Context Length | 131072 |
31
+
32
+
33
+ ## Quickstart
34
+ ### Model Finetuning with ERNIEKit
35
+
36
+ [ERNIEKit](https://github.com/PaddlePaddle/ERNIE) is a training toolkit based on PaddlePaddle, specifically designed for the ERNIE series of open-source large models. It provides comprehensive support for scenarios such as instruction fine-tuning (SFT, LoRA) and alignment training (DPO), ensuring optimal performance.
37
+
38
+ Usage Examples:
39
+ ```bash
40
+ # SFT
41
+ erniekit train --stage SFT --model_name_or_path baidu/ERNIE-4.5-300B-A47B-Base-Paddle --train_dataset_path your_dataset_path
42
+ # DPO
43
+ erniekit train --stage DPO --model_name_or_path baidu/ERNIE-4.5-300B-A47B-Base-Paddle --train_dataset_path your_dataset_path
44
+ ```
45
+ For more detailed examples, including SFT with LoRA, multi-GPU configurations, and advanced scripts, please refer to the examples folder within the [ERNIEKit](https://github.com/PaddlePaddle/ERNIE) repository.
46
+
47
+ ### Using FastDeploy
48
+
49
+ Service deployment can be quickly completed using FastDeploy in the following command. For more detailed usage instructions, please refer to the [FastDeploy Repository](https://github.com/PaddlePaddle/FastDeploy).
50
+
51
+ **Note**: To deploy on a configuration with 4 GPUs each having at least 80G of memory, specify ```--quantization wint4```. If you specify ```--quantization wint8```, then resources for 8 GPUs are required.
52
+
53
+ ```bash
54
+ python -m fastdeploy.entrypoints.openai.api_server \
55
+ --model baidu/ERNIE-4.5-300B-A47B-Base-Paddle \
56
+ --port 8180 \
57
+ --metrics-port 8181 \
58
+ --engine-worker-queue-port 8182 \
59
+ --quantization wint4 \
60
+ --tensor-parallel-size 8 \
61
+ --max-model-len 32768 \ # Maximum supported number of tokens
62
+ --max-num-seqs 32 # Maximum concurrent processing capacity
63
+ ```
64
+
65
+ ### Using `transformers` library
66
+
67
+ The following contains a code snippet illustrating how to use the model generate content based on given inputs.
68
+ ```python
69
+ from transformers import AutoModelForCausalLM, AutoTokenizer
70
+
71
+ model_name = "baidu/ERNIE-4.5-300B-A47B-Base-PT"
72
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
73
+ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", trust_remote_code=True)
74
+
75
+ prompt = "Large language model is"
76
+ model_inputs = tokenizer([prompt], add_special_tokens=False, return_tensors="pt").to(model.device)
77
+
78
+ generated_ids = model.generate(
79
+ model_inputs.input_ids,
80
+ max_new_tokens=1024
81
+ )
82
+ result = tokenizer.decode(generated_ids[0].tolist(), skip_special_tokens=True)
83
+ print("result:", result)
84
+ ```
85
+
86
+
87
+
88
+ ### Using vLLM
89
+ vLLM is currently being adapted, priority can be given to using our fork repository [vllm](https://github.com/CSWYF3634076/vllm/tree/ernie)
90
+ ```bash
91
+ # 80G * 16 GPU
92
+ vllm serve baidu/ERNIE-4.5-300B-A47B-Base-PT --trust-remote-code
93
+ ```
94
+ ```bash
95
+ # FP8 online quantification 80G * 8 GPU
96
+ vllm serve baidu/ERNIE-4.5-300B-A47B-Base-PT --trust-remote-code --quantization fp8
97
+ ```
98
+
99
+
100
+
101
+ ## License
102
+
103
+ The ERNIE 4.5 models are provided under the Apache License 2.0. This license permits commercial use, subject to its terms and conditions. Copyright (c) 2025 Baidu, Inc. All Rights Reserved.
104
+
105
+ ## Citation
106
+
107
+ If you find ERNIE 4.5 useful or wish to use it in your projects, please kindly cite our technical report:
108
+
109
+ ```bibtex
110
+ @misc{ernie2025technicalreport,
111
+ title={ERNIE 4.5 Technical Report},
112
+ author={Baidu ERNIE Team},
113
+ year={2025},
114
+ eprint={},
115
+ archivePrefix={arXiv},
116
+ primaryClass={cs.CL},
117
+ url={}
118
+ }
119
+ ```