Text Generation
Transformers
Safetensors
English
Chinese
ernie4_5_moe
ERNIE4.5
conversational
Eval Results
Instructions to use baidu/ERNIE-4.5-21B-A3B-Base-PT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use baidu/ERNIE-4.5-21B-A3B-Base-PT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="baidu/ERNIE-4.5-21B-A3B-Base-PT") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("baidu/ERNIE-4.5-21B-A3B-Base-PT") model = AutoModelForCausalLM.from_pretrained("baidu/ERNIE-4.5-21B-A3B-Base-PT", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use baidu/ERNIE-4.5-21B-A3B-Base-PT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "baidu/ERNIE-4.5-21B-A3B-Base-PT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "baidu/ERNIE-4.5-21B-A3B-Base-PT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/baidu/ERNIE-4.5-21B-A3B-Base-PT
- SGLang
How to use baidu/ERNIE-4.5-21B-A3B-Base-PT 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 "baidu/ERNIE-4.5-21B-A3B-Base-PT" \ --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": "baidu/ERNIE-4.5-21B-A3B-Base-PT", "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 "baidu/ERNIE-4.5-21B-A3B-Base-PT" \ --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": "baidu/ERNIE-4.5-21B-A3B-Base-PT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use baidu/ERNIE-4.5-21B-A3B-Base-PT with Docker Model Runner:
docker model run hf.co/baidu/ERNIE-4.5-21B-A3B-Base-PT
Delete config.json
Browse files- config.json +0 -36
config.json
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"architectures": [
|
| 3 |
-
"Ernie4_5_MoeForCausalLM"
|
| 4 |
-
],
|
| 5 |
-
"bos_token_id": 1,
|
| 6 |
-
"eos_token_id": 2,
|
| 7 |
-
"hidden_act": "silu",
|
| 8 |
-
"hidden_size": 2560,
|
| 9 |
-
"initializer_range": 0.02,
|
| 10 |
-
"intermediate_size": 12288,
|
| 11 |
-
"max_position_embeddings": 131072,
|
| 12 |
-
"model_type": "ernie4_5_moe",
|
| 13 |
-
"moe_intermediate_size": 1536,
|
| 14 |
-
"moe_k": 6,
|
| 15 |
-
"moe_layer_end_index": 27,
|
| 16 |
-
"moe_layer_interval": 1,
|
| 17 |
-
"moe_layer_start_index": 1,
|
| 18 |
-
"moe_norm_min": 1e-12,
|
| 19 |
-
"moe_num_experts": 64,
|
| 20 |
-
"moe_num_shared_experts": 2,
|
| 21 |
-
"num_attention_heads": 20,
|
| 22 |
-
"num_hidden_layers": 28,
|
| 23 |
-
"num_key_value_heads": 4,
|
| 24 |
-
"output_router_logits": false,
|
| 25 |
-
"pad_token_id": 0,
|
| 26 |
-
"rms_norm_eps": 1e-05,
|
| 27 |
-
"rope_scaling": null,
|
| 28 |
-
"rope_theta": 500000.0,
|
| 29 |
-
"router_aux_loss_coef": 0.001,
|
| 30 |
-
"tie_word_embeddings": true,
|
| 31 |
-
"torch_dtype": "bfloat16",
|
| 32 |
-
"transformers_version": "4.54.0.dev0",
|
| 33 |
-
"use_bias": false,
|
| 34 |
-
"use_cache": true,
|
| 35 |
-
"vocab_size": 103424
|
| 36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|