Instructions to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
Use Docker
docker model run hf.co/XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
- SGLang
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with Ollama:
ollama run hf.co/XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
- Unsloth Studio
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF to start chatting
- Pi
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with Docker Model Runner:
docker model run hf.co/XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
- Lemonade
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.ERNIE-4.5-21B-A3B-Thinking-GGUF-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "XythicK/ERNIE-4.5-21B-A3B-Thinking-GGUF:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
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 |
+

|
| 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 |
+
|