Image-Text-to-Text
MLX
Safetensors
Japanese
English
Chinese
internvl_chat
document-parsing
ocr
internvl
quantized
custom_code
8-bit precision
Instructions to use tokimoa/hpd-parsing-mlx-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use tokimoa/hpd-parsing-mlx-8bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("tokimoa/hpd-parsing-mlx-8bit") config = load_config("tokimoa/hpd-parsing-mlx-8bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
HPD-Parsing (MLX 8bit, verified)
PaddlePaddleの HPD-Parsing(InternVL3.5-1BベースのHierarchical Parallel Decoding文書パース・1.1B)のMLX変換(8bit量子化・実効10.7bpw)です。
HPDプロトコル(階層並列デコード)のMLX実装を同梱しています(hpd_generate.py)。レイアウト親ブランチが<BLOCK>種別 [座標]<FORK>のスケルトンを生成し、各<FORK>から共有KVキャッシュを継承した子ブランチが中身を埋め、接ぎ合わせて完全なパース結果(レイアウト座標+テキスト+HTMLテーブル)を返します。A4文書1ページ約5秒・ピークメモリ3.6GB。
必要バージョン: mlx-vlm 0.6.8以降(または main)。0.6.7以前のinternvl_chatはQwen3系LMに未対応です。上流のP-MTP(投機デコード)ヘッドは本変換には含みません(HPD自体はMTPなしで動作します)。
使い方
pip install "git+https://github.com/Blaizzy/mlx-vlm.git" timm einops torch
# repoをダウンロードして同梱スクリプトを実行
hf download tokimoa/hpd-parsing-mlx-8bit --local-dir hpd-8bit
python hpd-8bit/hpd_generate.py document.png
出力例(請求書):
<BLOCK>title [63, 45, 187, 77]<CHILD>請求書
<BLOCK>table [64, 185, 937, 350]<CHILD><table><tr><td>品目</td><td>数量</td>...</table>
<BLOCK>text [533, 440, 727, 464]<CHILD>合計: 880,000円
タスクプロンプトは訓練時の正規形document parsing with fork.固定です(自由QAには非対応の特化モデルです)。
変換品質の検証(tokimoa)
- transformers公式実装の
generate_hpd(greedy・同一入力)との比較で、請求書1ページのパース結果が741文字中740文字一致(唯一の差は両実装とも誤読している小文字セルのbf16ゆらぎ) - 日本語ビジネス文書5種・正解既知59項目の含有率: 47/59でbf16と一致・ミス項目まで完全同一(量子化劣化なし)(ミスの方向は参照実装と同一=変換起因でなく1.1Bの小文字読み取り能力の範囲。表構造・数値・座標は高精度)
- 不確信セルの文字列に軽微なゆれはあるがGT項目レベルの結果はbf16と同一
実測速度(M4 Max 36GB)
- レイアウト+子ブランチ合計で約5秒/ページ(13タイル・プロンプト約3,400トークン・生成約500トークン)
- ピークメモリ: 3.6GB(重み1.3GB)
変換情報
- 変換元:
PaddlePaddle/HPD-Parsing(公式BF16。P-MTPヘッドは除外) - 変換: mlx-vlm main(internvl_chat Qwen3対応)
convert -q --q-bits 8 - HPDプロトコル実装・前処理は同梱(
hpd_generate.py・conversation.py・image_preprocess.py) - 兄弟repo: bf16(参照一致検証の基準)/ 4bit(1.0GB)
- 変換者: tokimoa
ライセンス
Apache-2.0(元モデルに準拠)
- Downloads last month
- 22
Model size
0.5B params
Tensor type
BF16
·
U32 ·
Hardware compatibility
Log In to add your hardware
8-bit
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support
Model tree for tokimoa/hpd-parsing-mlx-8bit
Base model
OpenGVLab/InternVL3_5-1B-Pretrained Finetuned
OpenGVLab/InternVL3_5-1B-Instruct Finetuned
OpenGVLab/InternVL3_5-1B-MPO Finetuned
OpenGVLab/InternVL3_5-1B Finetuned
PaddlePaddle/HPD-Parsing