mirror of
https://github.com/hanzoai/ml.git
synced 2026-11-20 23:08:29 +00:00
Three-way per file through the rename: base 39355c6c91, theirs the upstream
merge of main with 35d7ae7c (via 7ef6a694d), ours origin/main.
Lands the barrier thread pool, runtime CPU feature dispatch, aarch64 and x86
repacked quantized kernels (indexed_gemv, gemv_fused_shared_lhs), quantized
embedding on CPU/Metal/CUDA, paged flash-attn kernels, cutile fused MoE, the
in-place op aliasing API, parking_lot storage locks, Metal buffer builders and
debug labels, safetensors 0.8, hf-hub 1.0, tokenizers 0.23.
Ours keeps ROCm, Vulkan, wgpu, the IQ/MXFP4/NVFP4/TQ dtypes, and the i-quant
weight/activation block split in matmul. Our backends ride InplaceOpN and the
quantized embedding; Metal get_rows gains the IQ kernels. ug leaves, as upstream.
Co-authored-by: Hanzo Dev <[email protected]>
PaddleOCR-VL
PaddleOCR-VL is a state-of-the-art vision-language model for document parsing, developed by PaddlePaddle. With only 0.9B parameters, it achieves competitive performance against much larger models (72B+) while maintaining fast inference speeds.
Features
- Multilingual: Supports 109 languages including Chinese, English, Japanese, Korean, Arabic, and more
- Multi-element Recognition: Handles text, tables, formulas, and charts
- Dynamic Resolution: NaViT-style encoder processes images at variable resolutions without distortion
- Multi-Image Processing: Process multiple images (e.g., multi-page documents) in a single prompt
- Video Support: Extract and process video frames with temporal position encoding
- Efficient: Compact 0.9B parameters with grouped query attention (GQA)
- Position Embedding Caching: LFU cache for interpolated position embeddings improves performance
Command Line Options
| Option | Description | Default |
|---|---|---|
--image |
Path to document image (can be specified multiple times) | (required*) |
--video |
Path to video file | (required*) |
--fps |
Frames per second to extract from video | 1.0 |
--max-frames |
Maximum frames to extract from video | 16 |
--task |
Task type: ocr, table, formula, chart |
ocr |
--model-id |
HuggingFace model ID | PaddlePaddle/PaddleOCR-VL |
--revision |
Model revision | main |
--max-length |
Maximum generation length | 1024 |
--cpu |
Run on CPU | false |
--bf16 |
Use bfloat16 precision | false |
--seed |
Random seed | 299792458 |
* Either --image or --video is required (mutually exclusive).
Examples
Basic Recognition
cargo run --example paddleocr-vl --release -- \
--image hanzo-ml-examples/examples/paddleocr-vl/test_ocr.png \
--task ocr
Table Recognition
cargo run --example paddleocr-vl --release -- \
--image hanzo-ml-examples/examples/paddleocr-vl/test_table.png \
--task table
Formula Recognition
cargo run --example paddleocr-vl --release -- \
--image hanzo-ml-examples/examples/paddleocr-vl/test_formula.png \
--task formula
Chart Recognition
cargo run --example paddleocr-vl --release -- \
--image hanzo-ml-examples/examples/paddleocr-vl/test_chart.png \
--task chart
Multi-Image (combined output)
Multi-Image OCR works with any task and uses --task ocr by default.
# Process multiple images with combined output
cargo run --example paddleocr-vl --release -- \
--image hanzo-ml-examples/examples/paddleocr-vl/test_ocr.png \
--image hanzo-ml-examples/examples/paddleocr-vl/test_ocr_page2.png
Mutli-Image (batch)
# Process chosen images sequentially with distinct output
cargo run --example paddleocr-vl --release -- \
--batch hanzo-ml-examples/examples/paddleocr-vl/test_ocr.png hanzo-ml-examples/examples/paddleocr-vl/test_ocr_page2.png
# With shell glob expansion
cargo run --example paddleocr-vl --release -- \
--batch hanzo-ml-examples/examples/paddleocr-vl/test_ocr*.png
Video OCR
cargo run --example paddleocr-vl --release -- \
--video hanzo-ml-examples/examples/paddleocr-vl/test_video.mp4 \
--task video \
--fps 0.6 \
--max-frames 64 \
--max-length 2048