XythicK commited on
Commit
c9ecd28
·
verified ·
1 Parent(s): 133e52b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +188 -0
README.md ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ - zh
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - ERNIE4.5
9
+ library_name: transformers
10
+ base_model: baidu/ERNIE-4.5-21B-A3B-Thinking
11
+ ---
12
+ <div align="center" style="line-height: 1;">
13
+ <a href="https://ernie.baidu.com/" target="_blank" style="margin: 2px;">
14
+ <img alt="Chat" src="https://img.shields.io/badge/🤖_Chat-ERNIE_Bot-blue" style="display: inline-block; vertical-align: middle;"/>
15
+ </a>
16
+ <a href="https://huggingface.co/baidu" target="_blank" style="margin: 2px;">
17
+ <img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Baidu-ffc107?color=ffc107&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
18
+ </a>
19
+ <a href="https://github.com/PaddlePaddle/ERNIE" target="_blank" style="margin: 2px;">
20
+ <img alt="Github" src="https://img.shields.io/badge/GitHub-ERNIE-000?logo=github&color=0000FF" style="display: inline-block; vertical-align: middle;"/>
21
+ </a>
22
+ <a href="https://ernie.baidu.com/blog/ernie4.5" target="_blank" style="margin: 2px;">
23
+ <img alt="Blog" src="https://img.shields.io/badge/🖖_Blog-ERNIE4.5-A020A0" style="display: inline-block; vertical-align: middle;"/>
24
+ </a>
25
+ <a href="https://discord.gg/JPmZXDsEEK" target="_blank" style="margin: 2px;">
26
+ <img alt="Discord" src="https://img.shields.io/badge/Discord-ERNIE-5865F2?logo=discord&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
27
+ </a>
28
+ <a href="https://x.com/PaddlePaddle" target="_blank" style="margin: 2px;">
29
+ <img alt="X" src="https://img.shields.io/badge/X-PaddlePaddle-6080F0"?logo=x&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
30
+ </a>
31
+ </div>
32
+ <div align="center" style="line-height: 1;">
33
+ <a href="#license" style="margin: 2px;">
34
+ <img alt="License" src="https://img.shields.io/badge/License-Apache2.0-A5de54" style="display: inline-block; vertical-align: middle;"/>
35
+ </a>
36
+ </div>
37
+ # ERNIE-4.5-21B-A3B-Thinking
38
+
39
+ ## Model Highlights
40
+
41
+ Over the past three months, we have continued to scale the **thinking capability** of ERNIE-4.5-21B-A3B, improving both the **quality and depth** of reasoning, thereby advancing the competitiveness of ERNIE **lightweight models** in complex reasoning tasks. We are pleased to introduce **ERNIE-4.5-21B-A3B-Thinking**, featuring the following key enhancements:
42
+
43
+ * **Significantly improved performance** on reasoning tasks, including logical reasoning, mathematics, science, coding, text generation, and academic benchmarks that typically require human expertise.
44
+ * **Efficient tool usage** capabilities.
45
+ * **Enhanced 128K long-context understanding** capabilities.
46
+
47
+ > [!NOTE]
48
+ > Note: This version has an increased thinking length. We strongly recommend its use in highly complex reasoning tasks.
49
+
50
+ ![benchmark](./benchmark.png)
51
+
52
+ ## Model Overview
53
+
54
+ ERNIE-4.5-21B-A3B-Thinking is a text MoE post-trained model, with 21B total parameters and 3B activated parameters for each token. The following are the model configuration details:
55
+
56
+ |Key|Value|
57
+ |-|-|
58
+ |Modality|Text|
59
+ |Training Stage|Posttraining|
60
+ |Params(Total / Activated)|21B / 3B|
61
+ |Layers|28|
62
+ |Heads(Q/KV)|20 / 4|
63
+ |Text Experts(Total / Activated)|64 / 6|
64
+ |Vision Experts(Total / Activated)|64 / 6|
65
+ |Shared Experts|2|
66
+ |Context Length|131072|
67
+
68
+ ## Quickstart
69
+
70
+ > [!NOTE]
71
+ > To align with the wider community, this model releases Transformer-style weights. Both PyTorch and PaddlePaddle ecosystem tools, such as vLLM, transformers, and FastDeploy, are expected to be able to load and run this model.
72
+
73
+ ### FastDeploy Inference
74
+
75
+ Quickly deploy services using FastDeploy as shown below. For more detailed usage, refer to the [FastDeploy GitHub Repository](https://github.com/PaddlePaddle/FastDeploy).
76
+
77
+ **Note**: 80GB x 1 GPU resources are required. Deploying this model requires FastDeploy version 2.2.
78
+
79
+ ```bash
80
+ python -m fastdeploy.entrypoints.openai.api_server \
81
+ --model baidu/ERNIE-4.5-21B-A3B-Thinking \
82
+ --port 8180 \
83
+ --metrics-port 8181 \
84
+ --engine-worker-queue-port 8182 \
85
+ --load_choices "default_v1" \
86
+ --tensor-parallel-size 1 \
87
+ --max-model-len 131072 \
88
+ --reasoning-parser ernie_x1 \
89
+ --tool-call-parser ernie_x1 \
90
+ --max-num-seqs 32
91
+ ```
92
+
93
+ The ERNIE-4.5-21B-A3B-Thinking model supports function call.
94
+
95
+ ```bash
96
+ curl -X POST "http://0.0.0.0:8180/v1/chat/completions" \
97
+ -H "Content-Type: application/json" \
98
+ -d $'{
99
+ "messages": [
100
+ {
101
+ "role": "user",
102
+ "content": "How \'s the weather in Beijing today?"
103
+ }
104
+ ],
105
+ "tools": [
106
+ {
107
+ "type": "function",
108
+ "function": {
109
+ "name": "get_weather",
110
+ "description": "Determine weather in my location",
111
+ "parameters": {
112
+ "type": "object",
113
+ "properties": {
114
+ "location": {
115
+ "type": "string",
116
+ "description": "The city and state e.g. San Francisco, CA"
117
+ },
118
+ "unit": {
119
+ "type": "string",
120
+ "enum": [
121
+ "c",
122
+ "f"
123
+ ]
124
+ }
125
+ },
126
+ "additionalProperties": false,
127
+ "required": [
128
+ "location",
129
+ "unit"
130
+ ]
131
+ },
132
+ "strict": true
133
+ }
134
+ }]
135
+ }'
136
+ ```
137
+
138
+ ### vLLM inference
139
+
140
+ ```bash
141
+ vllm serve baidu/ERNIE-4.5-21B-A3B-Thinking
142
+ ```
143
+
144
+ The `reasoning-parser` and `tool-call-parser` for vLLM Ernie are currently under development.
145
+
146
+ ### Using `transformers` library
147
+
148
+ **Note**: You'll need the`transformers`library (version 4.54.0 or newer) installed to use this model.
149
+
150
+ The following contains a code snippet illustrating how to use the model generate content based on given inputs.
151
+
152
+ ```python
153
+ import torch
154
+ from transformers import AutoModelForCausalLM, AutoTokenizer
155
+ model_name = "baidu/ERNIE-4.5-21B-A3B-Thinking"
156
+ # load the tokenizer and the model
157
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
158
+ model = AutoModelForCausalLM.from_pretrained(
159
+ model_name,
160
+ device_map="auto",
161
+ torch_dtype=torch.bfloat16,
162
+ )
163
+ # prepare the model input
164
+ prompt = "Give me a short introduction to large language model."
165
+ messages = [
166
+ {"role": "user", "content": prompt}
167
+ ]
168
+ text = tokenizer.apply_chat_template(
169
+ messages,
170
+ tokenize=False,
171
+ add_generation_prompt=True
172
+ )
173
+ model_inputs = tokenizer([text], add_special_tokens=False, return_tensors="pt").to(model.device)
174
+ # conduct text completion
175
+ generated_ids = model.generate(
176
+ **model_inputs,
177
+ max_new_tokens=1024
178
+ )
179
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
180
+ # decode the generated ids
181
+ generate_text = tokenizer.decode(output_ids, skip_special_tokens=True)
182
+ print("generate_text:", generate_text)
183
+ ```
184
+
185
+ ## License
186
+
187
+ 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.
188
+