Image-Text-to-Text
Transformers
Safetensors
qwen3_5
decision-model
system-one
flide
ocr
pdf
document-understanding
hf_jobs
conversational
Instructions to use davanstrien/ocr-decision-0.8b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use davanstrien/ocr-decision-0.8b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="davanstrien/ocr-decision-0.8b") 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("davanstrien/ocr-decision-0.8b") model = AutoModelForMultimodalLM.from_pretrained("davanstrien/ocr-decision-0.8b", 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 davanstrien/ocr-decision-0.8b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "davanstrien/ocr-decision-0.8b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "davanstrien/ocr-decision-0.8b", "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/davanstrien/ocr-decision-0.8b
- SGLang
How to use davanstrien/ocr-decision-0.8b 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 "davanstrien/ocr-decision-0.8b" \ --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": "davanstrien/ocr-decision-0.8b", "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 "davanstrien/ocr-decision-0.8b" \ --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": "davanstrien/ocr-decision-0.8b", "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 davanstrien/ocr-decision-0.8b with Docker Model Runner:
docker model run hf.co/davanstrien/ocr-decision-0.8b
Add OmniDocBench/historic/paraphrase evals and L4 vs RTX PRO 6000 throughput tables
Browse files
README.md
CHANGED
|
@@ -83,13 +83,50 @@ Evaluated on real embedded `pypdfium2` text layers compared against VLM OCR grou
|
|
| 83 |
| — `missing` text layer vs. clean | 0.679 | **0.998** | — |
|
| 84 |
| — `partial` text layer vs. clean | 0.472 | **0.658** | — |
|
| 85 |
|
| 86 |
-
### 4.
|
| 87 |
|
| 88 |
-
|
| 89 |
|
| 90 |
-
|
| 91 |
-
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
## Usage
|
| 95 |
|
|
@@ -208,7 +245,8 @@ print({"yes": round(probs[0], 4), "no": round(probs[1], 4)})
|
|
| 208 |
## Limitations
|
| 209 |
|
| 210 |
- **Single-page scope:** evaluates one page image (plus optional transcription) at a time; it does not compare across pages or generate transcriptions/bounding boxes.
|
| 211 |
-
- **Partial omissions on dense
|
|
|
|
| 212 |
- **Handwriting & script balance:** historical manuscript training data is weighted toward 19th-century Latin-script archival letters and Ukrainian Cyrillic; `hand` top-1 accuracy on held-out archives is `0.642`, and Greek/Hebrew/Devanagari coverage is thin.
|
| 213 |
- **Calibration for downstream linear heads:** `calibration.json` sets `noul` temperature `T=2.5` so probabilities remain well-spread rather than saturating near 0/1; if you load the weights outside `flide`, apply `T=2.5` to `noul` slot logits when using probabilities as continuous features.
|
| 214 |
|
|
|
|
| 83 |
| — `missing` text layer vs. clean | 0.679 | **0.998** | — |
|
| 84 |
| — `partial` text layer vs. clean | 0.472 | **0.658** | — |
|
| 85 |
|
| 86 |
+
### 4. Modern pre-OCR triage & multilingual OCR (`opendatalab/OmniDocBench`, 240 OOD pages, EN + ZH)
|
| 87 |
|
| 88 |
+
Evaluated zero-shot on unseen modern layout schemas (English & Chinese academic papers, slides, exams, textbooks, reports, magazines, and newspapers):
|
| 89 |
|
| 90 |
+
| Unseen modern triage question | Pos / N | `OneJev1.6-0.8B` (base) AUC / BalAcc | `doc-decision-0.8b` AUC / BalAcc |
|
| 91 |
+
|---|---:|---:|---:|
|
| 92 |
+
| `has_table` | 65 / 240 | 0.992 / 0.961 | **0.996 / 0.959** |
|
| 93 |
+
| `is_chinese` | 133 / 240 | 0.979 / 0.945 | **0.994 / 0.959** |
|
| 94 |
+
| `is_slide` | 30 / 240 | 0.996 / 0.957 | **0.992 / 0.914** |
|
| 95 |
+
| `has_equation` | 40 / 240 | 0.983 / 0.965 | **0.982 / 0.968** |
|
| 96 |
+
| `has_figure` | 105 / 240 | 0.968 / 0.897 | **0.980 / 0.952** |
|
| 97 |
+
| `is_exam_paper` | 30 / 240 | 0.886 / 0.764 | **0.886 / 0.764** |
|
| 98 |
+
| `is_multi_column` | 50 / 240 | 0.748 / 0.682 | **0.852 / 0.781** |
|
| 99 |
+
| `has_footnote` | 46 / 240 | 0.840 / 0.672 | **0.831 / 0.598** |
|
| 100 |
+
|
| 101 |
+
OCR verification on `OmniDocBench` (EN + ZH human-annotated blocks) and harder historic domains (**Chronicling America** dense multi-column newspapers & **BPL Card Catalog** archival cards):
|
| 102 |
+
|
| 103 |
+
| Domain (OOD) | `extra` AUC (base → tuned) | `loop` AUC (base → tuned) | `omission` AUC (base → tuned) |
|
| 104 |
+
|---|---:|---:|---:|
|
| 105 |
+
| `OmniDocBench` — English | 0.290 → **1.000** | 0.957 → **1.000** | 0.519 → **0.837** |
|
| 106 |
+
| `OmniDocBench` — Chinese | 0.452 → **1.000** | 0.978 → **1.000** | 0.568 → **0.816** |
|
| 107 |
+
| BPL Archival Catalogue Cards (57 cards) | 0.163 → **1.000** | 1.000 → **1.000** | 0.438 → **1.000** |
|
| 108 |
+
| Chronicling America Newspapers (48 dense pages) | 0.919 → **1.000** | 0.926 → **1.000** | 0.568 → **0.726** |
|
| 109 |
+
|
| 110 |
+
### 5. Prompt phrasing robustness
|
| 111 |
+
|
| 112 |
+
Tested across 3–4 unseen natural user phrasings per criterion (including flipped-polarity questions) on BHL and 2026 PDFs:
|
| 113 |
+
|
| 114 |
+
- **`extra`:** `0.980–0.989` AUROC on BHL (`Δ = 0.009`), `1.000` across all 4 phrasings on 2026 PDFs.
|
| 115 |
+
- **`loop`:** `1.000` across all 3 phrasings (including flipped polarity).
|
| 116 |
+
- **`omission`:** `0.820–0.838` on BHL and `0.800–0.826` on 2026 PDFs across casual, standard, and flipped-polarity phrasings. Avoid phrasing omission questions around *"readable printed content"* (which dropped AUROC to `0.62–0.67` by partially overlapping with pre-OCR readability).
|
| 117 |
+
|
| 118 |
+
### 6. Throughput & cost
|
| 119 |
+
|
| 120 |
+
Measured via `flide serve` (BF16, `max_side=1024`, pre-encoded real 2026 PDF pages with an average OCR text length of 2,076 characters). `flide`'s `ForkAttention` shares the cached image + `<state>` prefix across all questions on a page — asking 9 triage questions instead of 1 adds only **~2.6 ms** at `c=1` on an RTX PRO 6000:
|
| 121 |
+
|
| 122 |
+
| Workload (`flide serve`, BF16, `1024px`) | NVIDIA L4 (24 GB, ~$0.80/hr) | NVIDIA RTX PRO 6000 (96 GB, ~$2.75/hr) |
|
| 123 |
+
|---|---:|---:|
|
| 124 |
+
| **Pre-OCR triage (1 question)** (`c=1` → peak) | 18.8 → **20.6 p/s** (~$10.80 / 1M pages) | 47.3 → **107.1 p/s** (~$7.10 / 1M pages) |
|
| 125 |
+
| **Pre-OCR triage (9 questions: 8 `noul` + 1 `choice`)** | 14.2 → **15.5 p/s** (`139 dec/s`, ~$14.40 / 1M) | 43.5 → **87.5 p/s** (`787 dec/s`, ~$8.70 / 1M) |
|
| 126 |
+
| **OCR verification (3 questions: `extra` + `omission` + `loop`)** | 12.3 → **12.8 p/s** (`38 dec/s`, ~$17.40 / 1M) | 36.2 → **73.1 p/s** (`219 dec/s`, ~$10.40 / 1M) |
|
| 127 |
+
| **Single-page latency (`c=1` p50)** — 1q / 9q / 3q-OCR | 50.5 / 69.0 / 75.1 ms | 19.6 / 22.2 / 26.8 ms |
|
| 128 |
+
|
| 129 |
+
Default **BF16 is recommended**: `--quantize fp8` adds only ~5–6% on RTX PRO 6000 (`92.8 p/s` 9q triage, `76.9 p/s` 3q OCR) with a slight dip on partial omissions (`0.655 → 0.642`), and is ~25% slower than BF16 on L4 due to quantization overhead at 0.8B scale.
|
| 130 |
|
| 131 |
## Usage
|
| 132 |
|
|
|
|
| 245 |
## Limitations
|
| 246 |
|
| 247 |
- **Single-page scope:** evaluates one page image (plus optional transcription) at a time; it does not compare across pages or generate transcriptions/bounding boxes.
|
| 248 |
+
- **Partial omissions on dense pages:** detects missing text layers (`0.998`) and large dropped blocks reliably across English and Chinese (`0.837` / `0.816`), but subtle 5–15% partial omissions remain harder — especially on dense multi-column historical newspapers (`0.726`), long 19th-century prose pages (`0.823`), and modern tables/spec sheets (`0.658` partial text layers).
|
| 249 |
+
- **Custom `choice` taxonomies vs binary `noul`:** on brand-new document-type taxonomies far from training (e.g. a 6-way modern `OmniDocBench` split), zero-shot `choice` accuracy (`0.600`) lags targeted binary `noul` questions (`0.85–0.996`). For custom modern routing schemas, prefer crisp binary `noul` questions.
|
| 250 |
- **Handwriting & script balance:** historical manuscript training data is weighted toward 19th-century Latin-script archival letters and Ukrainian Cyrillic; `hand` top-1 accuracy on held-out archives is `0.642`, and Greek/Hebrew/Devanagari coverage is thin.
|
| 251 |
- **Calibration for downstream linear heads:** `calibration.json` sets `noul` temperature `T=2.5` so probabilities remain well-spread rather than saturating near 0/1; if you load the weights outside `flide`, apply `T=2.5` to `noul` slot logits when using probabilities as continuous features.
|
| 252 |
|