Instructions to use MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard") model = AutoModelForMultimodalLM.from_pretrained("MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard", device_map="auto") 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?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard", "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/MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard
- SGLang
How to use MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard 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 "MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard" \ --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": "MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard", "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 "MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard" \ --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": "MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard", "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 MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard with Docker Model Runner:
docker model run hf.co/MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard
Mubit-Qwen2.5-VL-7B-DocGuard
Overview
Mubit-Qwen2.5-VL-7B-DocGuard is a standalone BF16 7B vision-language document extraction and abstention model built from Qwen/Qwen2.5-VL-7B-Instruct via Mubit direct weight-space programming (dual-modality text+vision ROM-nullspace-projected 2D highway updates baked directly into standard .safetensors weights across 14 sites — model.visual.merger.mlp.{0,2} plus model.language_model.layers.{22..27}.{mlp.down_proj, self_attn.o_proj}, rom_max_frob_error = 4.23e-08, bf16_hook_bake_cosine_sim = 0.999584 — no runtime adapter required). It delivers high-precision strict-JSON receipt/invoice extraction and enforces 100.0% abstention on redacted fields without degrading pure-text factual Q&A.
Key Highlights (Paired Evaluation vs. Base & LLM-Only Ablation)
All evaluations use greedy decoding (do_sample=False) on identical held-out prompts (n=48 DocGuard: 24 real naver-clova-ix/cord-v2/invoice extraction + 24 redacted-field abstention; n=32 pure-text Q&A canaries; n=32 HuggingFaceM4/ChartQA test items).
+62.5 ppgain on answerable invoice/receipt exact match: Exact full-record extraction onn=24held-out receipts jumps from12.5% → 75.0%, with field F1 rising83.6% → 89.3%(+5.6 pp) and JSON schema adherence holding at100.0%.100.0%redacted-field abstention (0.0%fabrication): Redacted-field abstention (n=24) jumps from75.0% → 100.0%(+25.0 pp,0.0%hallucination), whereas editing only the LLM layers (LLM-only Text-P_null) remains stuck at75.0%abstention.- Zero pure-text forgetting: Pure-text factual Q&A (
n=32) holds exactly at96.9% → 96.9%(+0.00%), with Entity Identity Confusion unchanged at3.1%(1/32). - Visible trade-off on general chart reading: General Vision
ChartQA(n=32) dipped from71.9% → 62.5%(-9.4 pp, 3 items) — see Honest Notes & Limitations below.
Full Evaluation Table (greedy, do_sample=False)
| Benchmark | Metric (direction) | n |
Base Qwen2.5-VL-7B |
LLM-only Text-P_null |
Mubit Dual-Modality P_null |
Δ vs. Base |
|---|---|---|---|---|---|---|
| DocGuard (all) | JSON schema adherence (↑ better) | 48 |
100.0% |
100.0% |
100.0% |
+0.0 pp |
DocGuard (cord-v2/invoice, answerable) |
Field exact match (↑ better) | 24 |
12.5% |
79.2% |
75.0% |
+62.5 pp |
DocGuard (cord-v2/invoice, answerable) |
Field F1 (↑ better) | 24 |
83.6% |
91.7% |
89.3% |
+5.6 pp |
| DocGuard (redacted fields) | Abstention accuracy (↑ better) | 24 |
75.0% |
75.0% |
100.0% |
+25.0 pp |
| DocGuard (redacted fields) | Hallucination rate (↓ better) | 24 |
25.0% |
0.0% |
0.0% |
-25.0 pp |
| Pure-Text Q&A (retention) | Accuracy (↑ better) | 32 |
96.9% |
96.9% |
96.9% |
+0.00% |
| Pure-Text Q&A (retention) | Entity Identity Confusion (↓ better) | 32 |
3.1% (1/32) |
3.1% (1/32) |
3.1% (1/32) |
+0.00% |
ChartQA (general vision retention) |
Accuracy (↑ better) | 32 |
71.9% |
65.6% |
62.5% |
-9.4 pp |
Quickstart
vllm serve MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard --dtype bfloat16
import torch
from PIL import Image
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
model_id = "MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard"
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=False)
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
model_id, dtype=torch.bfloat16, device_map="auto", trust_remote_code=False
)
image = Image.open("receipt.png").convert("RGB")
prompt = (
"Inspect this business receipt or invoice image carefully. "
"Return ONLY valid JSON matching exactly: "
'{"status": "extracted" or "abstain", "vendor": string or null, '
'"total": string or null, "date": string or null}. '
"If ANY target field (vendor, total, or date) is redacted, blacked out, or cropped out, "
'you MUST set that field to null and set "status": "abstain". Never fabricate missing values.'
)
messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": prompt}]}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(**inputs, max_new_tokens=160, do_sample=False)
print(processor.batch_decode(out[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0])
Honest Notes & Limitations
- General Vision
ChartQAregression (-9.4 pp, 3/32 items): OnHuggingFaceM4/ChartQA(n=32), accuracy moved from71.9% → 62.5%(-9.4 pp, 3 items). Co-editing the visual merger (model.visual.merger.mlp.{0,2}) is what unlocks100.0%redacted-field abstention (+25.0 ppover both Base and LLM-only Text-P_null), but introduces a measurable trade-off on non-document chart QA. Evaluate before using on general visual reasoning workloads. - Compact evaluation sample sizes: Held-out DocGuard (
n=48:24real receipts/invoices +24redacted cases), pure-text Q&A (n=32), andChartQA(n=32) are small verification splits; large-scale enterprise document benchmarks (e.g., DocVQA, InfoVQA, multi-page PDFs) were not run on this checkpoint. - Strict-JSON domain scope: Tuned specifically for structured business receipt/invoice extraction with redaction abstention (
status,vendor,total,date). Downstream financial or compliance workflows should still validate emitted JSON and route"status": "abstain"outputs for human inspection. - License: Apache 2.0.
- Downloads last month
- 6
Model tree for MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard
Base model
Qwen/Qwen2.5-VL-7B-Instruct