Instructions to use PaddlePaddle/HPD-Parsing with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PaddlePaddle/HPD-Parsing with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="PaddlePaddle/HPD-Parsing", 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 AutoModel model = AutoModel.from_pretrained("PaddlePaddle/HPD-Parsing", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use PaddlePaddle/HPD-Parsing with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "PaddlePaddle/HPD-Parsing" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PaddlePaddle/HPD-Parsing", "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/PaddlePaddle/HPD-Parsing
- SGLang
How to use PaddlePaddle/HPD-Parsing 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 "PaddlePaddle/HPD-Parsing" \ --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": "PaddlePaddle/HPD-Parsing", "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 "PaddlePaddle/HPD-Parsing" \ --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": "PaddlePaddle/HPD-Parsing", "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 PaddlePaddle/HPD-Parsing with Docker Model Runner:
docker model run hf.co/PaddlePaddle/HPD-Parsing
HPD-Parsing Evaluation & Benchmark
Scripts to reproduce the HPD-Parsing throughput (TPS) numbers and the OmniDocBench v1.6 accuracy, using the customized vLLM build (<FORK>/<CHILD> hierarchical parallel decoding + P-MTP speculative decoding).
eval/
βββ benchmark_tps.py # vLLM batch inference: measures TPS and dumps raw predictions
βββ hpd_to_markdown.py # converts <BLOCK>...<CHILD>... predictions to per-page markdown
The pipeline is decoupled into three steps: infer β convert β evaluate. A single inference run produces both the speed metrics and the prediction file that feeds the accuracy evaluation.
Prerequisites
- The customized vLLM build that supports
<FORK>/<CHILD>decoding andRepetitionDetectionParams(see the main README install section). - The model weights
PaddlePaddle/HPD-Parsing(including theP-MTP/speculative head). - The OmniDocBench evaluation dataset (
OmniDocBench.json+images/) and its evaluation suite (for step 3).
Step 1 β Throughput benchmark + dump predictions
benchmark_tps.py runs batched inference over an image folder, times the whole batch loop with time.perf_counter(), and reports TPS metrics. It also writes the raw predictions used by the accuracy evaluation, so you only run the model once.
MAX_PATCHES_WITH_RESIZE=true python eval/benchmark_tps.py
Edit the variables at the top of __main__ to match your setup:
model_path/model_path_medusaβ model dir and itsP-MTP/head (defaultPaddlePaddle/HPD-Parsing/).rootβ image folder (defaultOmniDocBench_1_6/images/).promptβdocument parsing with fork.enables hierarchical parallel decoding; usedocument parsing.for standard full-page parsing.batch_size(default512),max_model_len,max_num_seqs, and thespeculative_config(num_speculative_tokens=6for P-MTP). To measure the autoregressive baseline, removespeculative_config.
Outputs:
- Predictions ->
batch_512_pred_HPD-Parsing.json(a list of{index, img_path, pred}), consumed by step 2. - Metrics ->
records/<ckpt>.txt: Total Time, Throughput (Requests/s), Input/Output/Total Tokens/s, and average tokens per request.
Step 2 β Convert predictions to markdown
hpd_to_markdown.py parses each <BLOCK> <type> [bbox] <CHILD> <content> prediction into a reading-order markdown file named after the source image (<image_stem>.md), which is the input format OmniDocBench's end2end evaluation expects.
python eval/hpd_to_markdown.py \
--input batch_512_pred_HPD-Parsing.json \
--out-md pred_md/HPD-Parsing/
Step 3 β Run OmniDocBench end2end evaluation
Use the official OmniDocBench suite. Point its end2end config at the markdown folder from step 2 and the ground-truth OmniDocBench.json, then run its evaluator to get the overall score and per-metric breakdown (text / formula / table / reading order).
git clone https://github.com/opendatalab/OmniDocBench.git
# set the prediction folder to pred_md/HPD-Parsing/ and gt to OmniDocBench.json
# in the end2end config, then run the OmniDocBench evaluation entry point
The OmniDocBench evaluation code is a separate project with its own license and is intentionally not vendored here.