Views
No views yet
[!NOTE] Note: This version has an increased thinking length. We strongly recommend its use in highly complex reasoning tasks.

| Key | Value |
|---|---|
| Modality | Text |
| Training Stage | Posttraining |
| Params(Total / Activated) | 21B / 3B |
| Layers | 28 |
| Heads(Q/KV) | 20 / 4 |
| Text Experts(Total / Activated) | 64 / 6 |
| Vision Experts(Total / Activated) | 64 / 6 |
| Shared Experts | 2 |
| Context Length | 131072 |
[!NOTE] 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.
1python -m fastdeploy.entrypoints.openai.api_server \
2 --model baidu/ERNIE-4.5-21B-A3B-Thinking \
3 --port 8180 \
4 --metrics-port 8181 \
5 --engine-worker-queue-port 8182 \
6 --load_choices "default_v1" \
7 --tensor-parallel-size 1 \
8 --max-model-len 131072 \
9 --reasoning-parser ernie_x1 \
10 --tool-call-parser ernie_x1 \
11 --max-num-seqs 321curl -X POST "http://0.0.0.0:8180/v1/chat/completions" \
2-H "Content-Type: application/json" \
3-d $'{
4 "messages": [
5 {
6 "role": "user",
7 "content": "How \'s the weather in Beijing today?"
8 }
9 ],
10 "tools": [
11 {
12 "type": "function",
13 "function": {
14 "name": "get_weather",
15 "description": "Determine weather in my location",
16 "parameters": {
17 "type": "object",
18 "properties": {
19 "location": {
20 "type": "string",
21 "description": "The city and state e.g. San Francisco, CA"
22 },
23 "unit": {
24 "type": "string",
25 "enum": [
26 "c",
27 "f"
28 ]
29 }
30 },
31 "additionalProperties": false,
32 "required": [
33 "location",
34 "unit"
35 ]
36 },
37 "strict": true
38 }
39 }]
40}'vllm serve baidu/ERNIE-4.5-21B-A3B-Thinkingreasoning-parser and tool-call-parser for vLLM Ernie are currently under development.transformers librarytransformerslibrary (version 4.54.0 or newer) installed to use this model.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_name = "baidu/ERNIE-4.5-21B-A3B-Thinking"
5
6# load the tokenizer and the model
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8model = AutoModelForCausalLM.from_pretrained(
9 model_name,
10 device_map="auto",
11 torch_dtype=torch.bfloat16,
12)
13
14# prepare the model input
15prompt = "Give me a short introduction to large language model."
16messages = [
17 {"role": "user", "content": prompt}
18]
19text = tokenizer.apply_chat_template(
20 messages,
21 tokenize=False,
22 add_generation_prompt=True
23)
24model_inputs = tokenizer([text], add_special_tokens=False, return_tensors="pt").to(model.device)
25
26# conduct text completion
27generated_ids = model.generate(
28 **model_inputs,
29 max_new_tokens=1024
30)
31output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
32
33# decode the generated ids
34generate_text = tokenizer.decode(output_ids, skip_special_tokens=True)
35print("generate_text:", generate_text)1@misc{ernie2025technicalreport,
2 title={ERNIE 4.5 Technical Report},
3 author={Baidu-ERNIE-Team},
4 year={2025},
5 primaryClass={cs.CL},
6 howpublished={\url{https://ernie.baidu.com/blog/publication/ERNIE_Technical_Report.pdf}}
7}