Instructions to use WaveMatrix/PaddleOCR-VL-1.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use WaveMatrix/PaddleOCR-VL-1.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="WaveMatrix/PaddleOCR-VL-1.5")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("WaveMatrix/PaddleOCR-VL-1.5", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use WaveMatrix/PaddleOCR-VL-1.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "WaveMatrix/PaddleOCR-VL-1.5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WaveMatrix/PaddleOCR-VL-1.5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/WaveMatrix/PaddleOCR-VL-1.5
- SGLang
How to use WaveMatrix/PaddleOCR-VL-1.5 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 "WaveMatrix/PaddleOCR-VL-1.5" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WaveMatrix/PaddleOCR-VL-1.5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "WaveMatrix/PaddleOCR-VL-1.5" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WaveMatrix/PaddleOCR-VL-1.5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use WaveMatrix/PaddleOCR-VL-1.5 with Docker Model Runner:
docker model run hf.co/WaveMatrix/PaddleOCR-VL-1.5
| from typing import List, Optional, Sequence, Tuple | |
| import numpy as np | |
| def seq_len_from_output(output: np.ndarray) -> Optional[int]: | |
| if output.ndim < 2: | |
| return None | |
| if output.ndim == 2: | |
| return int(output.shape[0]) | |
| return int(output.shape[-2]) | |
| def normalize_vit_output( | |
| output: np.ndarray, | |
| target_hidden_size: int, | |
| expected_tokens: Optional[int] = None, | |
| ) -> np.ndarray: | |
| normalized = output | |
| if expected_tokens is not None: | |
| if normalized.ndim == 3 and normalized.shape[1] == target_hidden_size and normalized.shape[2] == expected_tokens: | |
| normalized = np.transpose(normalized, (0, 2, 1)) | |
| elif normalized.ndim == 2 and normalized.shape[0] == target_hidden_size and normalized.shape[1] == expected_tokens: | |
| normalized = np.transpose(normalized, (1, 0)) | |
| return normalized | |
| def describe_output_shapes(outputs: Sequence[np.ndarray]) -> List[Tuple[int, ...]]: | |
| return [tuple(int(v) for v in output.shape) for output in outputs] | |
| def select_vit_output( | |
| outputs: Sequence[np.ndarray], | |
| target_hidden_size: int, | |
| expected_tokens: Optional[int] = None, | |
| ) -> np.ndarray: | |
| normalized_outputs = [ | |
| normalize_vit_output(output, target_hidden_size, expected_tokens=expected_tokens) for output in outputs | |
| ] | |
| image_embeds = None | |
| if expected_tokens is not None: | |
| for output in normalized_outputs: | |
| if output.ndim >= 2 and seq_len_from_output(output) == expected_tokens and output.shape[-1] == target_hidden_size: | |
| image_embeds = output | |
| break | |
| if image_embeds is None: | |
| for output in normalized_outputs: | |
| if output.ndim >= 2 and seq_len_from_output(output) == expected_tokens: | |
| image_embeds = output | |
| break | |
| if image_embeds is None: | |
| for output in normalized_outputs: | |
| if output.ndim >= 2 and output.shape[-1] == target_hidden_size: | |
| image_embeds = output | |
| break | |
| if image_embeds is None: | |
| image_embeds = normalized_outputs[0] | |
| if image_embeds.ndim == 2: | |
| image_embeds = image_embeds[None, ...] | |
| return image_embeds | |