Image-Text-to-Text
Transformers
Safetensors
English
Chinese
ernie4_5_moe_vl
ERNIE4.5
conversational
custom_code
Instructions to use baidu/ERNIE-4.5-VL-28B-A3B-PT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use baidu/ERNIE-4.5-VL-28B-A3B-PT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="baidu/ERNIE-4.5-VL-28B-A3B-PT", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoModelForMultimodalLM model = AutoModelForMultimodalLM.from_pretrained("baidu/ERNIE-4.5-VL-28B-A3B-PT", trust_remote_code=True, device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use baidu/ERNIE-4.5-VL-28B-A3B-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-VL-28B-A3B-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-VL-28B-A3B-PT", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/baidu/ERNIE-4.5-VL-28B-A3B-PT
- SGLang
How to use baidu/ERNIE-4.5-VL-28B-A3B-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-VL-28B-A3B-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-VL-28B-A3B-PT", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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-VL-28B-A3B-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-VL-28B-A3B-PT", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use baidu/ERNIE-4.5-VL-28B-A3B-PT with Docker Model Runner:
docker model run hf.co/baidu/ERNIE-4.5-VL-28B-A3B-PT
Update configuration_ernie4_5_vl.py (#13)
Browse files- Update configuration_ernie4_5_vl.py (f3fad3f0e4a3658a1847f5d46b6d409e591ba79c)
Co-authored-by: Harry Mellor <hmellor@users.noreply.huggingface.co>
configuration_ernie4_5_vl.py
CHANGED
|
@@ -429,14 +429,12 @@ class Ernie4_5_MoEConfig(Ernie4_5_Config):
|
|
| 429 |
Note:
|
| 430 |
When use_recompute_moe is True, recompute_granularity will be changed to full_attn.
|
| 431 |
"""
|
| 432 |
-
|
| 433 |
if use_recompute_moe:
|
| 434 |
logger.warning(
|
| 435 |
"set `use_recompute_moe`=True, disabling `recompute_granularity=full`, change to full_attn."
|
| 436 |
)
|
| 437 |
if kwargs["recompute"] and kwargs["recompute_granularity"] == "full":
|
| 438 |
kwargs["recompute_granularity"] = "full_attn"
|
| 439 |
-
super().__init__(**kwargs)
|
| 440 |
|
| 441 |
self.moe_num_experts = moe_num_experts
|
| 442 |
self.use_recompute_moe = use_recompute_moe
|
|
@@ -476,6 +474,7 @@ class Ernie4_5_MoEConfig(Ernie4_5_Config):
|
|
| 476 |
)
|
| 477 |
self.moe_use_hard_gate = moe_use_hard_gate
|
| 478 |
self.moe_dense_experts_token_type_id = moe_dense_experts_token_type_id
|
|
|
|
| 479 |
|
| 480 |
@property
|
| 481 |
def multimodel_experts(self) -> bool:
|
|
@@ -581,7 +580,6 @@ class Ernie4_5_VLMoEConfig(Ernie4_5_MoEConfig):
|
|
| 581 |
tensor_parallel_degree=1,
|
| 582 |
**kwargs,
|
| 583 |
):
|
| 584 |
-
super().__init__(**kwargs)
|
| 585 |
if isinstance(vision_config, dict):
|
| 586 |
self.vision_config = DFNRopeVisionTransformerConfig(**vision_config)
|
| 587 |
else:
|
|
@@ -612,6 +610,7 @@ class Ernie4_5_VLMoEConfig(Ernie4_5_MoEConfig):
|
|
| 612 |
self.moe_layer_feed_fake_token = moe_layer_feed_fake_token
|
| 613 |
|
| 614 |
self.tensor_parallel_degree = tensor_parallel_degree
|
|
|
|
| 615 |
|
| 616 |
@property
|
| 617 |
def multimodel_experts(self) -> bool:
|
|
|
|
| 429 |
Note:
|
| 430 |
When use_recompute_moe is True, recompute_granularity will be changed to full_attn.
|
| 431 |
"""
|
|
|
|
| 432 |
if use_recompute_moe:
|
| 433 |
logger.warning(
|
| 434 |
"set `use_recompute_moe`=True, disabling `recompute_granularity=full`, change to full_attn."
|
| 435 |
)
|
| 436 |
if kwargs["recompute"] and kwargs["recompute_granularity"] == "full":
|
| 437 |
kwargs["recompute_granularity"] = "full_attn"
|
|
|
|
| 438 |
|
| 439 |
self.moe_num_experts = moe_num_experts
|
| 440 |
self.use_recompute_moe = use_recompute_moe
|
|
|
|
| 474 |
)
|
| 475 |
self.moe_use_hard_gate = moe_use_hard_gate
|
| 476 |
self.moe_dense_experts_token_type_id = moe_dense_experts_token_type_id
|
| 477 |
+
super().__init__(**kwargs)
|
| 478 |
|
| 479 |
@property
|
| 480 |
def multimodel_experts(self) -> bool:
|
|
|
|
| 580 |
tensor_parallel_degree=1,
|
| 581 |
**kwargs,
|
| 582 |
):
|
|
|
|
| 583 |
if isinstance(vision_config, dict):
|
| 584 |
self.vision_config = DFNRopeVisionTransformerConfig(**vision_config)
|
| 585 |
else:
|
|
|
|
| 610 |
self.moe_layer_feed_fake_token = moe_layer_feed_fake_token
|
| 611 |
|
| 612 |
self.tensor_parallel_degree = tensor_parallel_degree
|
| 613 |
+
super().__init__(**kwargs)
|
| 614 |
|
| 615 |
@property
|
| 616 |
def multimodel_experts(self) -> bool:
|