Views
No views yet
openbmb/MiniCPM-V-2_6
that turns a document/receipt image into structured line-item JSON
({"menu": [{"nm", "cnt", "price"}], "total": ...}). Built for the
Quillwright project (a small-model agent that
drafts trade estimates) as the document-extraction skill behind its Document Capture path.finetune/eval.py).| Metric | Baseline (un-tuned) | Tuned (this LoRA) | Δ |
|---|---|---|---|
| Item F1 | 0.588 | 0.681 | +0.093 |
| Quantity accuracy | 0.715 | 0.782 | +0.067 |
| Price accuracy | 0.575 | 0.726 | +0.151 |
| Precision | 0.567 | 0.666 | +0.099 |
| Recall | 0.647 | 0.728 | +0.081 |
openbmb/MiniCPM-V-2_6 (8B vision-language model)naver-clova-ix/cord-v2
(CC BY 4.0, © NAVER CLOVA) — 800-receipt train split; held-out 100-receipt test split for evalfinetune.py + CPMTrainer, single GPU (L40S), no DeepSpeed,
bf16 LoRA (not 4-bit). LoRA on the LLM self-attention projections (q/k/v/o) only;
vision tower + resampler frozen (embed_tokens + resampler saved).1from peft import PeftModel
2from transformers import AutoModel, AutoTokenizer
3from PIL import Image
4
5PROMPT = ('Extract the line items from this receipt as JSON with this exact shape: '
6 '{"menu": [{"nm": <item name>, "cnt": <quantity>, "price": <price>}], '
7 '"total": <grand total>}. Output only the JSON.')
8
9base = AutoModel.from_pretrained("openbmb/MiniCPM-V-2_6", trust_remote_code=True,
10 attn_implementation="sdpa")
11model = PeftModel.from_pretrained(base, "Aarya2004/minicpmv-cord-lora",
12 trust_remote_code=True).eval().cuda()
13tok = AutoTokenizer.from_pretrained("openbmb/MiniCPM-V-2_6", trust_remote_code=True)
14
15img = Image.open("receipt.jpg").convert("RGB")
16msgs = [{"role": "user", "content": [img, PROMPT]}]
17print(model.chat(image=None, msgs=msgs, tokenizer=tok, sampling=False))MiniCPM-V-2_6's remote code hard-importsflash_attnat load even with SDPA; if you hit that ImportError, stripflash_attnfromtransformers.dynamic_module_utils.get_imports(seefinetune/flash_patch.pyin the Quillwright repo) — flash-attn is not required.