Text Generation
Transformers
Safetensors
English
Chinese
ernie4_5_moe
ERNIE4.5
conversational
Eval Results
Instructions to use baidu/ERNIE-4.5-300B-A47B-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-300B-A47B-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-300B-A47B-Base-PT") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("baidu/ERNIE-4.5-300B-A47B-Base-PT") model = AutoModelForCausalLM.from_pretrained("baidu/ERNIE-4.5-300B-A47B-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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use baidu/ERNIE-4.5-300B-A47B-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-300B-A47B-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-300B-A47B-Base-PT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/baidu/ERNIE-4.5-300B-A47B-Base-PT
- SGLang
How to use baidu/ERNIE-4.5-300B-A47B-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-300B-A47B-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-300B-A47B-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-300B-A47B-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-300B-A47B-Base-PT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use baidu/ERNIE-4.5-300B-A47B-Base-PT with Docker Model Runner:
docker model run hf.co/baidu/ERNIE-4.5-300B-A47B-Base-PT
Update README.md (#2)
Browse files- Update README.md (9bf6dd7e43f9cba4fae872caa3157b74f2da378c)
Co-authored-by: Suen.ZK <sunzhongkai588@users.noreply.huggingface.co>
README.md
CHANGED
|
@@ -32,6 +32,9 @@ library_name: transformers
|
|
| 32 |
|
| 33 |
# ERNIE-4.5-300B-A47B-Base
|
| 34 |
|
|
|
|
|
|
|
|
|
|
| 35 |
## ERNIE 4.5 Highlights
|
| 36 |
|
| 37 |
The advanced capabilities of the ERNIE 4.5 models, particularly the MoE-based A47B and A3B series, are underpinned by several key technical innovations:
|
|
@@ -61,41 +64,6 @@ ERNIE-4.5-300B-A47B-Base is a text MoE Base model, with 300B total parameters an
|
|
| 61 |
|
| 62 |
## Quickstart
|
| 63 |
|
| 64 |
-
### Model Finetuning with ERNIEKit
|
| 65 |
-
|
| 66 |
-
[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.
|
| 67 |
-
|
| 68 |
-
Usage Examples:
|
| 69 |
-
|
| 70 |
-
```bash
|
| 71 |
-
# Download model
|
| 72 |
-
huggingface-cli download baidu/ERNIE-4.5-300B-A47B-Base-Paddle --local-dir baidu/ERNIE-4.5-300B-A47B-Base-Paddle
|
| 73 |
-
# SFT
|
| 74 |
-
erniekit train examples/configs/ERNIE-4.5-300B-A47B/sft/run_sft_wint8mix_lora_8k.yaml model_name_or_path=baidu/ERNIE-4.5-300B-A47B-Base-Paddle
|
| 75 |
-
# DPO
|
| 76 |
-
erniekit train examples/configs/ERNIE-4.5-300B-A47B/dpo/run_dpo_wint8mix_lora_8k.yaml model_name_or_path=baidu/ERNIE-4.5-300B-A47B-Base-Paddle
|
| 77 |
-
```
|
| 78 |
-
|
| 79 |
-
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.
|
| 80 |
-
|
| 81 |
-
### Using FastDeploy
|
| 82 |
-
|
| 83 |
-
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).
|
| 84 |
-
|
| 85 |
-
**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.
|
| 86 |
-
|
| 87 |
-
```bash
|
| 88 |
-
python -m fastdeploy.entrypoints.openai.api_server \
|
| 89 |
-
--model baidu/ERNIE-4.5-300B-A47B-Base-Paddle \
|
| 90 |
-
--port 8180 \
|
| 91 |
-
--metrics-port 8181 \
|
| 92 |
-
--engine-worker-queue-port 8182 \
|
| 93 |
-
--quantization wint4 \
|
| 94 |
-
--tensor-parallel-size 8 \
|
| 95 |
-
--max-model-len 32768 \
|
| 96 |
-
--max-num-seqs 32
|
| 97 |
-
```
|
| 98 |
-
|
| 99 |
### Using `transformers` library
|
| 100 |
|
| 101 |
**Note**: Before using the model, please ensure you have the `transformers` library installed (version 4.50.0 or higher)
|
|
|
|
| 32 |
|
| 33 |
# ERNIE-4.5-300B-A47B-Base
|
| 34 |
|
| 35 |
+
> [!NOTE]
|
| 36 |
+
> Note: "**-Paddle**" models use [PaddlePaddle](https://github.com/PaddlePaddle/Paddle) weights, while "**-PT**" models use Transformer-style PyTorch weights.
|
| 37 |
+
|
| 38 |
## ERNIE 4.5 Highlights
|
| 39 |
|
| 40 |
The advanced capabilities of the ERNIE 4.5 models, particularly the MoE-based A47B and A3B series, are underpinned by several key technical innovations:
|
|
|
|
| 64 |
|
| 65 |
## Quickstart
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
### Using `transformers` library
|
| 68 |
|
| 69 |
**Note**: Before using the model, please ensure you have the `transformers` library installed (version 4.50.0 or higher)
|